Restart if after 10 minutes no connection

This commit is contained in:
Djuri 2023-11-26 00:51:54 +01:00
parent 5f971cfee3
commit 8ed4bb8aa6
10 changed files with 215 additions and 30 deletions

View file

@ -4,10 +4,11 @@
#include "ESPAsyncWebServer.h"
#include "lib/config.hpp"
#define USE_QR
//char ptrTaskList[400];
uint wifiLostConnection;
extern "C" void app_main()
{
initArduino();
@ -27,7 +28,21 @@ extern "C" void app_main()
xTaskNotifyGive(eventSourceTaskHandle);
if (!WiFi.isConnected()) {
if (!wifiLostConnection) {
wifiLostConnection = esp_timer_get_time() / 1000000;
Serial.println("Lost WiFi connection, trying to reconnect...");
}
if (((esp_timer_get_time() / 1000000) - wifiLostConnection) > 600) {
Serial.println("Still no connection after 10 minutes, restarting...");
delay(2000);
ESP.restart();
}
WiFi.begin();
} else if (wifiLostConnection) {
wifiLostConnection = 0;
Serial.println("Connection restored, reset timer.");
}
vTaskDelay(pdMS_TO_TICKS(5000));