Skip to content

Commit

Permalink
fixup! cpu/esp_common: stop WiFi interface before reboot
Browse files Browse the repository at this point in the history
  • Loading branch information
gschorcht committed Mar 22, 2020
1 parent 04bbca3 commit f744cb0
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions cpu/esp_common/esp-wifi/esp_wifi_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f744cb0

Please sign in to comment.