diff options
| author | Jeff Epler <jepler@gmail.com> | 2020-11-19 11:36:02 -0600 |
|---|---|---|
| committer | Jeff Epler <jepler@gmail.com> | 2020-11-19 11:36:02 -0600 |
| commit | dd108b755dc2bb886df14c9fcfcd4f09be61f2d4 (patch) | |
| tree | fc037d2a3265fc13d08a106b412e20f4c38b627f | |
| parent | 83d790ad8f7838d70269d0f0add6de1199198227 (diff) | |
esp32s2: initialize event loop ane netif only once
deinitting these seems to cause problems.
| -rw-r--r-- | ports/esp32s2/common-hal/wifi/__init__.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/ports/esp32s2/common-hal/wifi/__init__.c b/ports/esp32s2/common-hal/wifi/__init__.c index 1b244dd2f..f53e68fc2 100644 --- a/ports/esp32s2/common-hal/wifi/__init__.c +++ b/ports/esp32s2/common-hal/wifi/__init__.c @@ -88,14 +88,17 @@ static void event_handler(void* arg, esp_event_base_t event_base, } } -static bool wifi_inited; +static bool wifi_inited, wifi_ever_inited; void common_hal_wifi_init(void) { wifi_inited = true; common_hal_wifi_radio_obj.base.type = &wifi_radio_type; - ESP_ERROR_CHECK(esp_netif_init()); - ESP_ERROR_CHECK(esp_event_loop_create_default()); + if (!wifi_ever_inited) { + ESP_ERROR_CHECK(esp_netif_init()); + ESP_ERROR_CHECK(esp_event_loop_create_default()); + } + wifi_ever_inited = true; wifi_radio_obj_t* self = &common_hal_wifi_radio_obj; self->netif = esp_netif_create_default_wifi_sta(); |
