From e8ec1ac950bdcfd7c832a41860e0940d4b954e16 Mon Sep 17 00:00:00 2001 From: Joe Tretter Date: Fri, 17 Jun 2022 23:11:49 -0500 Subject: [PATCH] Add WiFi recovery via reboot --- src/main.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 543e6fb..259d791 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -144,11 +144,17 @@ void setup(void) { WiFi.begin(ssid, password); Serial.println(""); - // Wait for connection + // Wait for connection or reboot if it doesn't connect for too long + uint32_t wifiConnAttements = 0; while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); + if (wifiConnAttements++ > 120) { + Serial.println(""); + ESP.restart(); + } } + Serial.println(""); Serial.print("Connected to "); Serial.println(ssid);