From 33fca6e8c3bd8f8fe5c0dac4c04648c80c6a7723 Mon Sep 17 00:00:00 2001 From: Timm Bogner <64260873+timmbogner@users.noreply.github.com> Date: Sun, 2 Jun 2024 21:04:02 -0500 Subject: [PATCH] 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(). --- src/fdrs_gateway_wifi.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/fdrs_gateway_wifi.h b/src/fdrs_gateway_wifi.h index 8081ea7..a493930 100644 --- a/src/fdrs_gateway_wifi.h +++ b/src/fdrs_gateway_wifi.h @@ -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 }