Fix 8266 WiFi

WiFi for 8266 devices wasn't working. WiFi.reconnect() shouldn't be called every time it checks the connection. I made it so it doesn't restart anymore, but that can be added back in if called for. It now waits 10 seconds for a connection, then calls WiFi.reconnect().
This commit is contained in:
Timm Bogner 2024-06-02 21:04:02 -05:00
parent 6b7134fb51
commit 33fca6e8c3

View File

@ -175,18 +175,16 @@ void begin_wifi()
WiFi.config(hostIpAddress, gatewayAddress, subnetAddress, dns1Address, dns2Address);
#endif
WiFi.begin(ssid, password);
int connectTries = 0;
DBG("Connecting to WiFi SSID: " + String(FDRS_WIFI_SSID));
int connectTries = 0;
while (WiFi.status() != WL_CONNECTED)
{
connectTries++;
DBG("Connecting to WiFi SSID: " + String(FDRS_WIFI_SSID) + " try number " + String(connectTries));
delay(1000);
WiFi.reconnect();
if(connectTries >= 15) {
DBG("Restarting ESP32: WiFi issues\n");
delay(5000);
ESP.restart();
}
if(connectTries >= 10) {
DBG("Couldn't connect! Retrying...");
WiFi.reconnect();
}
}
#endif // USE_ETHERNET
}