From eb0b0508cd4e3b308d3d7168c00be0dfcf3d6ca1 Mon Sep 17 00:00:00 2001 From: chshkhr Date: Mon, 28 Nov 2022 17:24:00 +0200 Subject: [PATCH] Restarting due to too long AP inactivity --- esp32-cam-webserver.ino | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/esp32-cam-webserver.ino b/esp32-cam-webserver.ino index 64d6483..9100f45 100644 --- a/esp32-cam-webserver.ino +++ b/esp32-cam-webserver.ino @@ -443,6 +443,9 @@ void StartCamera() { // We now have camera with default init } + +unsigned long accesspoint_start = 0; + void WifiSetup() { // Feedback that we are now attempting to connect flashLED(300); @@ -625,6 +628,7 @@ void WifiSetup() { dnsServer.start(DNS_PORT, "*", ip); captivePortal = true; } + accesspoint_start = millis(); } } @@ -814,6 +818,10 @@ void loop() { handleSerial(); if (captivePortal) dnsServer.processNextRequest(); } + if (accesspoint_start > 0 && millis() - accesspoint_start > 20 * WIFI_WATCHDOG && !streamsServed) { + Serial.println("Restarting due to too long AP inactivity..."); + ESP.restart(); + } } else { // client mode can fail; so reconnect as appropriate static bool warned = false;