@@ -141,7 +141,12 @@ static bool wifi_ever_inited;
141
141
static bool wifi_user_initiated ;
142
142
143
143
void common_hal_wifi_init (bool user_initiated ) {
144
+ wifi_radio_obj_t * self = & common_hal_wifi_radio_obj ;
145
+
144
146
if (wifi_inited ) {
147
+ if (user_initiated && !wifi_user_initiated ) {
148
+ common_hal_wifi_radio_set_enabled (self , true);
149
+ }
145
150
return ;
146
151
}
147
152
wifi_inited = true;
@@ -154,7 +159,6 @@ void common_hal_wifi_init(bool user_initiated) {
154
159
}
155
160
wifi_ever_inited = true;
156
161
157
- wifi_radio_obj_t * self = & common_hal_wifi_radio_obj ;
158
162
self -> netif = esp_netif_create_default_wifi_sta ();
159
163
self -> ap_netif = esp_netif_create_default_wifi_ap ();
160
164
self -> started = false;
@@ -204,6 +208,7 @@ void common_hal_wifi_init(bool user_initiated) {
204
208
void wifi_user_reset (void ) {
205
209
if (wifi_user_initiated ) {
206
210
wifi_reset ();
211
+ wifi_user_initiated = false;
207
212
}
208
213
}
209
214
@@ -214,6 +219,7 @@ void wifi_reset(void) {
214
219
common_hal_wifi_monitor_deinit (MP_STATE_VM (wifi_monitor_singleton ));
215
220
wifi_radio_obj_t * radio = & common_hal_wifi_radio_obj ;
216
221
common_hal_wifi_radio_set_enabled (radio , false);
222
+ #ifndef CONFIG_IDF_TARGET_ESP32
217
223
ESP_ERROR_CHECK (esp_event_handler_instance_unregister (WIFI_EVENT ,
218
224
ESP_EVENT_ANY_ID ,
219
225
radio -> handler_instance_all_wifi ));
@@ -226,6 +232,7 @@ void wifi_reset(void) {
226
232
esp_netif_destroy (radio -> ap_netif );
227
233
radio -> ap_netif = NULL ;
228
234
wifi_inited = false;
235
+ #endif
229
236
supervisor_workflow_request_background ();
230
237
}
231
238
0 commit comments