Merge pull request #6600 from jepler/esp32-soft-reset-wifi
esp32: don't fully reset the wifi device
This commit is contained in:
commit
02c804c2d8
|
@ -141,7 +141,12 @@ static bool wifi_ever_inited;
|
||||||
static bool wifi_user_initiated;
|
static bool wifi_user_initiated;
|
||||||
|
|
||||||
void common_hal_wifi_init(bool user_initiated) {
|
void common_hal_wifi_init(bool user_initiated) {
|
||||||
|
wifi_radio_obj_t *self = &common_hal_wifi_radio_obj;
|
||||||
|
|
||||||
if (wifi_inited) {
|
if (wifi_inited) {
|
||||||
|
if (user_initiated && !wifi_user_initiated) {
|
||||||
|
common_hal_wifi_radio_set_enabled(self, true);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wifi_inited = true;
|
wifi_inited = true;
|
||||||
|
@ -154,7 +159,6 @@ void common_hal_wifi_init(bool user_initiated) {
|
||||||
}
|
}
|
||||||
wifi_ever_inited = true;
|
wifi_ever_inited = true;
|
||||||
|
|
||||||
wifi_radio_obj_t *self = &common_hal_wifi_radio_obj;
|
|
||||||
self->netif = esp_netif_create_default_wifi_sta();
|
self->netif = esp_netif_create_default_wifi_sta();
|
||||||
self->ap_netif = esp_netif_create_default_wifi_ap();
|
self->ap_netif = esp_netif_create_default_wifi_ap();
|
||||||
self->started = false;
|
self->started = false;
|
||||||
|
@ -204,6 +208,7 @@ void common_hal_wifi_init(bool user_initiated) {
|
||||||
void wifi_user_reset(void) {
|
void wifi_user_reset(void) {
|
||||||
if (wifi_user_initiated) {
|
if (wifi_user_initiated) {
|
||||||
wifi_reset();
|
wifi_reset();
|
||||||
|
wifi_user_initiated = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,6 +219,7 @@ void wifi_reset(void) {
|
||||||
common_hal_wifi_monitor_deinit(MP_STATE_VM(wifi_monitor_singleton));
|
common_hal_wifi_monitor_deinit(MP_STATE_VM(wifi_monitor_singleton));
|
||||||
wifi_radio_obj_t *radio = &common_hal_wifi_radio_obj;
|
wifi_radio_obj_t *radio = &common_hal_wifi_radio_obj;
|
||||||
common_hal_wifi_radio_set_enabled(radio, false);
|
common_hal_wifi_radio_set_enabled(radio, false);
|
||||||
|
#ifndef CONFIG_IDF_TARGET_ESP32
|
||||||
ESP_ERROR_CHECK(esp_event_handler_instance_unregister(WIFI_EVENT,
|
ESP_ERROR_CHECK(esp_event_handler_instance_unregister(WIFI_EVENT,
|
||||||
ESP_EVENT_ANY_ID,
|
ESP_EVENT_ANY_ID,
|
||||||
radio->handler_instance_all_wifi));
|
radio->handler_instance_all_wifi));
|
||||||
|
@ -226,6 +232,7 @@ void wifi_reset(void) {
|
||||||
esp_netif_destroy(radio->ap_netif);
|
esp_netif_destroy(radio->ap_netif);
|
||||||
radio->ap_netif = NULL;
|
radio->ap_netif = NULL;
|
||||||
wifi_inited = false;
|
wifi_inited = false;
|
||||||
|
#endif
|
||||||
supervisor_workflow_request_background();
|
supervisor_workflow_request_background();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue