Add WiFi recovery via reboot

This commit is contained in:
Joe Tretter
2022-06-17 23:11:49 -05:00
parent 2ce6c5d012
commit e8ec1ac950

View File

@@ -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("<Wifi not connecting after 120 attmepts (1 min.) - rebooting>");
ESP.restart();
}
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);