Skip to content

Commit 2f14609

Browse files
authored
Merge pull request adafruit#3716 from jepler/keep-event-loop
esp32s2: don't delete the event loop
2 parents 60c608b + dd108b7 commit 2f14609

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,17 @@ static void event_handler(void* arg, esp_event_base_t event_base,
8888
}
8989
}
9090

91-
static bool wifi_inited;
91+
static bool wifi_inited, wifi_ever_inited;
9292

9393
void common_hal_wifi_init(void) {
9494
wifi_inited = true;
9595
common_hal_wifi_radio_obj.base.type = &wifi_radio_type;
9696

97-
ESP_ERROR_CHECK(esp_netif_init());
98-
ESP_ERROR_CHECK(esp_event_loop_create_default());
97+
if (!wifi_ever_inited) {
98+
ESP_ERROR_CHECK(esp_netif_init());
99+
ESP_ERROR_CHECK(esp_event_loop_create_default());
100+
}
101+
wifi_ever_inited = true;
99102

100103
wifi_radio_obj_t* self = &common_hal_wifi_radio_obj;
101104
self->netif = esp_netif_create_default_wifi_sta();
@@ -143,7 +146,6 @@ void wifi_reset(void) {
143146
radio->handler_instance_got_ip));
144147
ESP_ERROR_CHECK(esp_wifi_deinit());
145148
esp_netif_destroy(radio->netif);
146-
ESP_ERROR_CHECK(esp_event_loop_delete_default());
147149
radio->netif = NULL;
148150
}
149151

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy