From d542007b70cbe8bd8e5e48439f3e543eb2942c34 Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Tue, 21 Mar 2023 22:00:20 +0100 Subject: [PATCH 1/2] Variable _WifiAP_active dazu (Aufruf webinterface) --- WiFiManager.cpp | 13 +++++++++++++ WiFiManager.h | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index d2802856a..f48bda3ee 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -280,6 +280,8 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { DEBUG_WM(F("AutoConnect")); #endif + _WifiAP_active = false; + // bool wifiIsSaved = getWiFiIsSaved(); #ifdef ESP32 @@ -574,6 +576,13 @@ void WiFiManager::stopWebPortal() { shutdownConfigPortal(); } +bool WiFiManager::WifiAP_active(int max_uptime_minutes){ + if((millis()-_startconn) < (max_uptime_minutes * 60000)){ + return (_WifiAP_active); + } + return false; +} + boolean WiFiManager::configPortalHasTimeout(){ if(!configPortalActive) return false; uint16_t logintvl = 30000; // how often to emit timeing out counter logging @@ -1329,6 +1338,8 @@ void WiFiManager::handleRoot() { #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_VERBOSE,F("<- HTTP Root")); #endif + + _WifiAP_active = true; if (captivePortal()) return; // If captive portal redirect instead of displaying the page handleRequest(); String page = getHTTPHead(_title); // @token options @todo replace options with title @@ -2312,6 +2323,7 @@ void WiFiManager::handleExit() { #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_VERBOSE,F("<- HTTP Exit")); #endif + _WifiAP_active = false; handleRequest(); String page = getHTTPHead(FPSTR(S_titleexit)); // @token titleexit page += FPSTR(S_exiting); // @token exiting @@ -2440,6 +2452,7 @@ void WiFiManager::stopCaptivePortal(){ // HTTPD CALLBACK, handle close, stop captive portal, if not enabled undefined void WiFiManager::handleClose(){ DEBUG_WM(DEBUG_VERBOSE,F("Disabling Captive Portal")); + _WifiAP_active = false; stopCaptivePortal(); #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_VERBOSE,F("<- HTTP close")); diff --git a/WiFiManager.h b/WiFiManager.h index 8c415888b..cef420695 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -487,6 +487,9 @@ class WiFiManager // get hostname helper String getWiFiHostname(); + // indicate if AP is currently in use + bool WifiAP_active(int max_uptime_minutes); + std::unique_ptr dnsServer; @@ -553,6 +556,7 @@ class WiFiManager // on some conn failure modes will add delays and many retries to work around esp and ap bugs, ie, anti de-auth protections // https://github.com/tzapu/WiFiManager/issues/1067 bool _allowExit = true; // allow exit in nonblocking, else user exit/abort calls will be ignored including cptimeout + bool _WifiAP_active = false; #ifdef ESP32 wifi_event_id_t wm_event_id = 0; From b60e19bf41454586d198a07e24bfd5adc30d1e2c Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Tue, 18 Apr 2023 14:02:32 +0200 Subject: [PATCH 2/2] Set _WifiAP_active = true in startAP() --- WiFiManager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index f48bda3ee..b6999d228 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -463,6 +463,7 @@ bool WiFiManager::setupHostname(bool restart){ // CONFIG PORTAL bool WiFiManager::startAP(){ + _WifiAP_active = true; bool ret = true; #ifdef WM_DEBUG_LEVEL DEBUG_WM(F("StartAP with SSID: "),_apName);