detect and recover from wifi disconnect

This commit is contained in:
Cedric Girard 2019-09-13 13:42:47 +02:00
parent c0924a52ef
commit 8a740d4f19
Signed by: X-dark
GPG Key ID: E7D0E125DB9519E4
1 changed files with 20 additions and 0 deletions

View File

@ -295,8 +295,28 @@ void setup() {
}
void loop() {
//detect connection lost and reconnect
if (WiFi.status() != WL_CONNECTED) {
u8g2log.print("WiFi lost connection.\n");
delay(500);
WiFi.begin(ssid, password);
u8g2log.print("Reconnecting to:\n");
u8g2log.print(ssid);
u8g2log.print("\n");
u8g2log.print("\n");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
u8g2log.print(".");
}
};
server.handleClient();
}