File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
ports/espressif/common-hal/wifi Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 1616#include "py/gc.h"
1717#include "py/mpstate.h"
1818#include "py/runtime.h"
19+ #include "py/objstr.h"
20+ #include "py/objint.h"
1921
2022#include "components/esp_wifi/include/esp_wifi.h"
2123
@@ -197,6 +199,19 @@ void common_hal_wifi_init(bool user_initiated) {
197199 ESP_LOGE (TAG , "WiFi error code: %x" , result );
198200 return ;
199201 }
202+ // set the default lwip_local_hostname
203+ //
204+ // What happens if someone uses wifi.radio.hostname and then the
205+ // interface is reset, I don't know if an interface reset is a thing
206+ // but there is logic here to check for re-entry into the common_hal_wifi_init
207+ // module. I would think we would want to carry the exising hostname across
208+ // subsequent interface resets.
209+ char cpy_default_hostname [80 ];
210+ uint8_t mac [6 ];
211+ esp_wifi_get_mac (ESP_IF_WIFI_STA , mac );
212+ sprintf (cpy_default_hostname , "cpy_%s_%x" , CIRCUITPY_BOARD_ID , (unsigned int )mac );
213+ const char * default_lwip_local_hostname = cpy_default_hostname ;
214+ ESP_ERROR_CHECK (esp_netif_set_hostname (self -> netif ,default_lwip_local_hostname ));
200215 // set station mode to avoid the default SoftAP
201216 common_hal_wifi_radio_start_station (self );
202217 // start wifi
You can’t perform that action at this time.
0 commit comments