-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove CONFIG_LWIP_LOCAL_HOSTNAME from Espressif boards #9656
Conversation
For completeness: I checked an S2 board with an empty |
I submitted this not really knowing as much as I should have about core Circuitpython WiFi. It seems to me if the variable is used somewhere that is visible via Circuitpython we should probably leave it alone. Feel free to re-open if there's a reason to pursue this. I made these changes using a script so it would be relatively painless, if for some reason we wanted to expand to other chips or make a different change to the files/default values. |
I didn't mean to shut this down, only highlight what the new hostname would be. We haven't been consistent with having |
I do want to get rid of these settings so that our IDF builds are more uniform across boards. I think we should set it to the board id by default though. That's basically what folks use this setting for anyway. |
Perhaps we should unify this with the MDNS name too. It could be |
Any pointers as to where the initialization should take place. It looks like common_hal_wifi_init happens when wifi is imported which sounds too late to me. |
I would think |
I worked a while on trying to get |
I was concerned that if someone set the hostname using wifi.radio.hostname that this default code would replace it when the interface was reset. I haven't figured out if there is a way to reset the network interface in code yet, but I did some quick testing and it seems that wifi.radio.hostname survives a ctrl-d reset without being set back to this new default value. I haven't seen the host name set by wifi.radio.hostname show up on my router yet, but I'm thinking there's some sort of dhcp timeout that has to happen first. |
I'm not sure what level of reset or deinit would clear the hostname, or if CircuitPython has such a path invokable by the user. If there is a way to reset the interface, thereby ordinarily clearing or reverting the hostname, I can see pros and cons to preserving the custom hostname vs. letting it be lost. A user may want a clean interface and would expect to set a new hostname. OTOH, it's only one line to set a new hostname if the previous custom hostname survives. If it survives and isn't re-set by the user, anything expecting the previous custom hostname isn't disrupted. So I don't think it's a big issue either way. I do see the
|
Neither In 9.1.4, `supervisor.reload()` will clear the custom hostname back to `CONFIG_LWIP_LOCAL_HOSTNAME`...import wifi
import time
import supervisor
print(wifi.radio.hostname)
wifi.radio.hostname = "blahblah"
print(wifi.radio.hostname)
time.sleep(5)
supervisor.reload() Adafruit CircuitPython 9.1.4 on 2024-09-17; Adafruit QT Py ESP32-S3 4MB Flash 2MB PSRAM with ESP32S3
>>> import microcontroller ; microcontroller.on_next_reset(microcontroller.RunMode.NORMAL) ; microcontroller.reset()
[11:25:41.279] Disconnected
[11:25:42.282] Warning: Could not open tty device (No such file or directory)
[11:25:42.282] Waiting for tty device..
[11:25:44.311] Connected
Code done running.
soft reboot
Auto-reload is off.
code.py output:
espressif-esp32s3
blahblah
Code done running.
soft reboot
Auto-reload is off.
code.py output:
espressif-esp32s3
blahblah |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you!
I didn't really think this was ready, it does work but the following code segment isn't optimized for Micropython/Circuitpython in terms of variable/memory use: char cpy_default_hostname[80];
uint8_t mac[6];
esp_wifi_get_mac(ESP_IF_WIFI_STA, mac);
sprintf(cpy_default_hostname, "cpy_%s_%x", CIRCUITPY_BOARD_ID, (unsigned int)mac);
const char *default_lwip_local_hostname = cpy_default_hostname;
ESP_ERROR_CHECK(esp_netif_set_hostname(self->netif, default_lwip_local_hostname)); |
Not-ready code should be in a draft PR then. I think that's fine because |
Sorry, I should have drafted it.... I'll see if there's anything I can do to optimize it and if so, submit another PR. |
As discussed in #9583 this removes the CONFIG_LWIP_LOCAL_HOSTNAME parameter from the sdkconfig files of all ESP32-S3 boards.
I actually just commented out the configuration setting but can easily update this to completely remove the lines if that is preferred.