From f744cb063f6907b93def85469dc3eceb8cd51dce Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Sun, 22 Mar 2020 23:51:04 +0100 Subject: [PATCH] fixup! cpu/esp_common: stop WiFi interface before reboot --- cpu/esp_common/esp-wifi/esp_wifi_netdev.c | 33 +++++++++++------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/cpu/esp_common/esp-wifi/esp_wifi_netdev.c b/cpu/esp_common/esp-wifi/esp_wifi_netdev.c index 98442e3b87bad..f88e1586ebe44 100644 --- a/cpu/esp_common/esp-wifi/esp_wifi_netdev.c +++ b/cpu/esp_common/esp-wifi/esp_wifi_netdev.c @@ -425,12 +425,7 @@ static esp_err_t IRAM_ATTR _esp_system_event_handler(void *ctx, system_event_t * case SYSTEM_EVENT_STA_STOP: _esp_wifi_started = 0; - ESP_WIFI_DEBUG("WiFi stoped"); - result = esp_wifi_connect(); - if (result != ESP_OK) { - ESP_WIFI_LOG_ERROR("esp_wifi_connect failed with return " - "value %d", result); - } + ESP_WIFI_DEBUG("WiFi stopped"); break; case SYSTEM_EVENT_SCAN_DONE: @@ -470,18 +465,20 @@ static esp_err_t IRAM_ATTR _esp_system_event_handler(void *ctx, system_event_t * _esp_wifi_dev.event_disc++; netdev_trigger_event_isr(&_esp_wifi_dev.netdev); - /* call disconnect to reset internal state */ - result = esp_wifi_disconnect(); - if (result != ESP_OK) { - ESP_WIFI_LOG_ERROR("esp_wifi_disconnect failed with " - "return value %d", result); - return result; - } - - /* try to reconnect */ - if (_esp_wifi_started && ((result = esp_wifi_connect()) != ESP_OK)) { - ESP_WIFI_LOG_ERROR("esp_wifi_connect failed with " - "return value %d", result); + if (reason != WIFI_REASON_ASSOC_LEAVE) { + /* call disconnect to reset internal state */ + result = esp_wifi_disconnect(); + if (result != ESP_OK) { + ESP_WIFI_LOG_ERROR("esp_wifi_disconnect failed with " + "return value %d", result); + return result; + } + + /* try to reconnect */ + if (_esp_wifi_started && ((result = esp_wifi_connect()) != ESP_OK)) { + ESP_WIFI_LOG_ERROR("esp_wifi_connect failed with " + "return value %d", result); + } } break;