From ee3350ed1d1f198d4b540a7b4aeb7d33936d46ce Mon Sep 17 00:00:00 2001 From: chenwen Date: Tue, 25 May 2021 17:48:09 +0800 Subject: [PATCH] risc-v/esp32c3: Disable Wi-Fi reconnect by default --- arch/risc-v/src/esp32c3/Kconfig | 6 ++++++ arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/risc-v/src/esp32c3/Kconfig b/arch/risc-v/src/esp32c3/Kconfig index adda87b8e0..30e92dd257 100644 --- a/arch/risc-v/src/esp32c3/Kconfig +++ b/arch/risc-v/src/esp32c3/Kconfig @@ -751,6 +751,12 @@ choice EXAMPLE_POWER_SAVE_MODE bool "maximum modem" endchoice +config ESP32C3_WIFI_RECONNECT + bool "Enable Wi-Fi to reconnect" + default n + ---help--- + Select this option to enable Wi-Fi to reconnect for station when disconnected. + endmenu # ESP32C3_WIRELESS menu "SPI Flash configuration" diff --git a/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c b/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c index 97be493ae3..d15a271371 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c +++ b/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c @@ -2056,6 +2056,7 @@ static void esp_evt_work_cb(FAR void *arg) irqstate_t flags; struct evt_adpt *evt_adpt; struct wifi_notify *notify; + wifi_event_sta_disconnected_t *disconnected; while (1) { @@ -2092,8 +2093,11 @@ static void esp_evt_work_cb(FAR void *arg) break; case WIFI_ADPT_EVT_STA_DISCONNECT: - wlinfo("INFO: Wi-Fi sta disconnect\n"); + disconnected = (wifi_event_sta_disconnected_t *)evt_adpt->buf; + wlinfo("INFO: Wi-Fi sta disconnect, reason code: %d\n", + disconnected->reason); g_sta_connected = false; +#ifdef CONFIG_ESP32C3_WIFI_RECONNECT if (g_sta_reconnect) { ret = esp_wifi_connect(); @@ -2102,6 +2106,7 @@ static void esp_evt_work_cb(FAR void *arg) wlerr("ERROR: Failed to connect AP error=%d\n", ret); } } +#endif break; case WIFI_ADPT_EVT_STA_STOP: