From 8e3b500307b8166e812d9689076dc0eb2139f00c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 23 Nov 2022 23:47:50 +0100 Subject: [PATCH] ---EXPERIMENTAL--- reboot the board if the NO_AP_FOUND error comes back. --- src/mesh/http/WiFiAPClient.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/mesh/http/WiFiAPClient.cpp b/src/mesh/http/WiFiAPClient.cpp index 4e6019e4c..bb4542468 100644 --- a/src/mesh/http/WiFiAPClient.cpp +++ b/src/mesh/http/WiFiAPClient.cpp @@ -56,9 +56,24 @@ static int32_t reconnectWiFi() // Make sure we clear old connection credentials WiFi.disconnect(false, true); - DEBUG_MSG("... Reconnecting to WiFi access point\n"); - WiFi.mode(WIFI_MODE_STA); - WiFi.begin(wifiName, wifiPsw); + DEBUG_MSG("... Reconnecting to WiFi access point %s\n",wifiName); + + int n = WiFi.scanNetworks(); + + if (n > 0) { + for (int i = 0; i < n; ++i) { + DEBUG_MSG("Found WiFi network %s, signal strength %d\n", WiFi.SSID(i).c_str(), WiFi.RSSI(i)); + yield(); + } + WiFi.mode(WIFI_MODE_STA); + WiFi.begin(wifiName, wifiPsw); + } else { + DEBUG_MSG("No networks found during site survey. Rebooting MCU...\n"); + screen->startRebootScreen(); + rebootAtMsec = millis() + 5000; + } + + } #ifndef DISABLE_NTP