mirror of
https://github.com/timmbogner/Farm-Data-Relay-System
synced 2024-11-08 13:10:29 +00:00
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:
parent
6b7134fb51
commit
33fca6e8c3
@ -175,17 +175,15 @@ void begin_wifi()
|
|||||||
WiFi.config(hostIpAddress, gatewayAddress, subnetAddress, dns1Address, dns2Address);
|
WiFi.config(hostIpAddress, gatewayAddress, subnetAddress, dns1Address, dns2Address);
|
||||||
#endif
|
#endif
|
||||||
WiFi.begin(ssid, password);
|
WiFi.begin(ssid, password);
|
||||||
|
DBG("Connecting to WiFi SSID: " + String(FDRS_WIFI_SSID));
|
||||||
int connectTries = 0;
|
int connectTries = 0;
|
||||||
while (WiFi.status() != WL_CONNECTED)
|
while (WiFi.status() != WL_CONNECTED)
|
||||||
{
|
{
|
||||||
connectTries++;
|
connectTries++;
|
||||||
DBG("Connecting to WiFi SSID: " + String(FDRS_WIFI_SSID) + " try number " + String(connectTries));
|
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
if(connectTries >= 10) {
|
||||||
|
DBG("Couldn't connect! Retrying...");
|
||||||
WiFi.reconnect();
|
WiFi.reconnect();
|
||||||
if(connectTries >= 15) {
|
|
||||||
DBG("Restarting ESP32: WiFi issues\n");
|
|
||||||
delay(5000);
|
|
||||||
ESP.restart();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // USE_ETHERNET
|
#endif // USE_ETHERNET
|
||||||
|
Loading…
Reference in New Issue
Block a user