From b5df3075f6c58bafb0b807a3b74404f36edb398d Mon Sep 17 00:00:00 2001 From: Marius Strom Date: Wed, 17 Jan 2024 21:56:17 -0800 Subject: [PATCH] Update wifi-manager.h Update wifi connection to be stubborn and not proceed until connected as well as change power setting based on linked documentation. --- src/wifi-manager.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/wifi-manager.h b/src/wifi-manager.h index 2e67622..d7aaeca 100644 --- a/src/wifi-manager.h +++ b/src/wifi-manager.h @@ -10,7 +10,6 @@ bool shouldSaveConfig = true; int connectionAttempts = 0; -const int maxConnectionAttempts = 10; void restartprocess(){ deleteFileSystem(); @@ -33,7 +32,7 @@ bool setupWifi(){ return false; } - while (connectionAttempts < maxConnectionAttempts) { + while (true) { // stay in this loop until wifi connects if (WiFi.status() == WL_CONNECTED) break; @@ -41,10 +40,13 @@ bool setupWifi(){ WiFi.begin(globalVariables.SSID, globalVariables.APPW); delay(1000); - Serial.print(F("Connecting to WIFI.. ")); - Serial.println(globalVariables.SSID); + Serial.print(F("Connecting to WIFI.. Attempt #")); + Serial.print(connectionAttempts); + Serial.print(F(" SSID: ")); + Serial.print(globalVariables.SSID); + Serial.print(F(" APPW: ")) Serial.println(globalVariables.APPW); - delay(8000); // can probably be lower? + delay(10000); // can probably be lower? connectionAttempts++; } @@ -70,6 +72,10 @@ bool setupWifi(){ WiFi.setTxPower(WIFI_POWER_19_5dBm); // https://github.com/G6EJD/ESP32-8266-Adjust-WiFi-RF-Power-Output/blob/main/README.md #endif + #ifdef ESP32 + WiFi.setTxPower(WIFI_POWER_19_5dBm); // https://github.com/G6EJD/ESP32-8266-Adjust-WiFi-RF-Power-Output/blob/main/README.md + #endif + return true; }