Skip to content

Commit 02c804c

Browse files
authored
Merge pull request #6600 from jepler/esp32-soft-reset-wifi
esp32: don't fully reset the wifi device
2 parents 19fad09 + dcc27a8 commit 02c804c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ports/espressif/common-hal/wifi/__init__.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,12 @@ static bool wifi_ever_inited;
141141
static bool wifi_user_initiated;
142142

143143
void common_hal_wifi_init(bool user_initiated) {
144+
wifi_radio_obj_t *self = &common_hal_wifi_radio_obj;
145+
144146
if (wifi_inited) {
147+
if (user_initiated && !wifi_user_initiated) {
148+
common_hal_wifi_radio_set_enabled(self, true);
149+
}
145150
return;
146151
}
147152
wifi_inited = true;
@@ -154,7 +159,6 @@ void common_hal_wifi_init(bool user_initiated) {
154159
}
155160
wifi_ever_inited = true;
156161

157-
wifi_radio_obj_t *self = &common_hal_wifi_radio_obj;
158162
self->netif = esp_netif_create_default_wifi_sta();
159163
self->ap_netif = esp_netif_create_default_wifi_ap();
160164
self->started = false;
@@ -204,6 +208,7 @@ void common_hal_wifi_init(bool user_initiated) {
204208
void wifi_user_reset(void) {
205209
if (wifi_user_initiated) {
206210
wifi_reset();
211+
wifi_user_initiated = false;
207212
}
208213
}
209214

@@ -214,6 +219,7 @@ void wifi_reset(void) {
214219
common_hal_wifi_monitor_deinit(MP_STATE_VM(wifi_monitor_singleton));
215220
wifi_radio_obj_t *radio = &common_hal_wifi_radio_obj;
216221
common_hal_wifi_radio_set_enabled(radio, false);
222+
#ifndef CONFIG_IDF_TARGET_ESP32
217223
ESP_ERROR_CHECK(esp_event_handler_instance_unregister(WIFI_EVENT,
218224
ESP_EVENT_ANY_ID,
219225
radio->handler_instance_all_wifi));
@@ -226,6 +232,7 @@ void wifi_reset(void) {
226232
esp_netif_destroy(radio->ap_netif);
227233
radio->ap_netif = NULL;
228234
wifi_inited = false;
235+
#endif
229236
supervisor_workflow_request_background();
230237
}
231238

0 commit comments

Comments
 (0)