From d2322083aae54641cfdf5bece831a646c6655150 Mon Sep 17 00:00:00 2001 From: mcurtiss1992 <69280569+mcurtiss1992@users.noreply.github.com> Date: Thu, 7 Mar 2024 14:43:14 -0600 Subject: [PATCH] Fixes WiFi stability issue WiFi sometimes fails and cannot reconnect without a sleep cycle. To fix this, we can fully disconnect from the WiFi connection before our reconnection attempt --- Platformio/src/hardware/mqtt.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Platformio/src/hardware/mqtt.cpp b/Platformio/src/hardware/mqtt.cpp index 3c80c19..028801f 100644 --- a/Platformio/src/hardware/mqtt.cpp +++ b/Platformio/src/hardware/mqtt.cpp @@ -27,6 +27,7 @@ void WiFiEvent(WiFiEvent_t event){ if (WifiLabel != NULL) {lv_label_set_text(WifiLabel, "");} // automatically try to reconnect Serial.printf("WiFi got disconnected. Will try to reconnect.\r\n"); + WiFi.disconnect(); WiFi.begin(WIFI_SSID, WIFI_PASSWORD); } else {