From bdd87e73996e7809ba74a669d5d1ea9c658a3f98 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sun, 31 Jul 2022 08:47:58 +0200 Subject: [PATCH] wifi 2nd try kludge --- WifiESP32.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/WifiESP32.cpp b/WifiESP32.cpp index 9d2af6d..4599c64 100644 --- a/WifiESP32.cpp +++ b/WifiESP32.cpp @@ -21,6 +21,7 @@ #include #include "defines.h" #include +#include "esp_wifi.h" #include "WifiESP32.h" #include "DIAG.h" #include "RingStream.h" @@ -110,6 +111,21 @@ bool WifiESP::setup(const char *SSid, wifiUp = true; } else { DIAG(F("Could not connect to Wifi SSID %s"),SSid); + DIAG(F("Forcing one more Wifi restart")); + esp_wifi_start(); + esp_wifi_connect(); + tries=40; + while (WiFi.status() != WL_CONNECTED && tries) { + Serial.print('.'); + tries--; + delay(500); + } + if (WiFi.status() == WL_CONNECTED) { + DIAG(F("Wifi STA IP 2nd try %s"),WiFi.localIP().toString().c_str()); + wifiUp = true; + } else { + DIAG(F("Fail 2nd try")); + } } } if (!haveSSID) {