From 7043bd6b0f2671295eee32667e95a6f89b2cb2f1 Mon Sep 17 00:00:00 2001 From: Francesco Carnielli Date: Wed, 8 May 2024 14:33:10 +0200 Subject: [PATCH 1/2] add a Delay between the WiFi reconnections --- code/components/jomjol_wlan/connect_wlan.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/components/jomjol_wlan/connect_wlan.cpp b/code/components/jomjol_wlan/connect_wlan.cpp index 603751265..7262b1372 100644 --- a/code/components/jomjol_wlan/connect_wlan.cpp +++ b/code/components/jomjol_wlan/connect_wlan.cpp @@ -478,6 +478,7 @@ static void event_handler(void* arg, esp_event_base_t event_base, int32_t event_ } if (WIFIReconnectCnt >= 10) { + vTaskDelay(5000 / portTICK_PERIOD_MS); // Delay between the reconnections WIFIReconnectCnt = 0; LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Disconnected, multiple reconnect attempts failed (" + std::to_string(disconn->reason) + "), still retrying..."); From f4dbd8e759d7f43c73da1d8453ae0ade306df6ec Mon Sep 17 00:00:00 2001 From: Francesco Carnielli Date: Thu, 20 Jun 2024 11:28:26 +0200 Subject: [PATCH 2/2] log the delay between the WiFi reconnections move the delay after the log --- code/components/jomjol_wlan/connect_wlan.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/components/jomjol_wlan/connect_wlan.cpp b/code/components/jomjol_wlan/connect_wlan.cpp index 7262b1372..03a4cd756 100644 --- a/code/components/jomjol_wlan/connect_wlan.cpp +++ b/code/components/jomjol_wlan/connect_wlan.cpp @@ -478,10 +478,10 @@ static void event_handler(void* arg, esp_event_base_t event_base, int32_t event_ } if (WIFIReconnectCnt >= 10) { - vTaskDelay(5000 / portTICK_PERIOD_MS); // Delay between the reconnections WIFIReconnectCnt = 0; LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Disconnected, multiple reconnect attempts failed (" + - std::to_string(disconn->reason) + "), still retrying..."); + std::to_string(disconn->reason) + "), retrying after 5s"); + vTaskDelay(5000 / portTICK_PERIOD_MS); // Delay between the reconnections } } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_CONNECTED)