From 24de319c7ecd618bacb65206a85cf678939c2cca Mon Sep 17 00:00:00 2001 From: Shawn A Date: Thu, 19 Jul 2018 16:54:38 -0500 Subject: [PATCH] issues with captive portals and preloadscan hammering --- WiFiManager.cpp | 10 +++++++--- extras/WiFiManager.template.html | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 39cea64..c051ef0 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -856,7 +856,10 @@ void WiFiManager::handleRoot() { server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); server->send(200, FPSTR(HTTP_HEAD_CT), page); // server->close(); // testing reliability fix for content length mismatches during mutiple flood hits WiFi_scanNetworks(); // preload wifiscan - if(_preloadwifiscan) WiFi_scanNetworks((unsigned)10000); // preload wifiscan throttled + if(_preloadwifiscan) WiFi_scanNetworks((unsigned)20000); // preload wifiscan throttled + // @todo buggy, captive portals make a query on every page load, causing this to run every time in addition to the real page load + // I dont understand why, when you are already in the captive portal, I guess they want to know that its still up and not done or gone + // if we can detect these and ignore them that would be great, since they come from the captive portal redirect maybe there is a refferer } /** @@ -945,11 +948,12 @@ bool WiFiManager::WiFi_scanNetworks(bool force){ // DEBUG_WM("scanNetworks force:",force == true); // DEBUG_WM(_numNetworks,(millis()-_lastscan )); if(force || _numNetworks == 0 || (millis()-_lastscan > 60000)){ + unsigned int _scanstart = millis(); _numNetworks = WiFi.scanNetworks(); _lastscan = millis(); - DEBUG_WM(DEBUG_VERBOSE,F("WiFi Scan done")); + DEBUG_WM(DEBUG_VERBOSE,F("WiFi Scan done"), "in "+(String)(_lastscan - _scanstart)+"ms"); return true; - } else DEBUG_WM(DEBUG_VERBOSE,"Scan is cached"); + } else DEBUG_WM(DEBUG_VERBOSE,"Scan is cached",(String)(millis()-_lastscan )+"ago"); return false; } diff --git a/extras/WiFiManager.template.html b/extras/WiFiManager.template.html index ecb09de..9a0b082 100644 --- a/extras/WiFiManager.template.html +++ b/extras/WiFiManager.template.html @@ -19,6 +19,7 @@ body.invert .msg{ border-top: 1px solid #555; border-right: 1px solid #555; border-bottom: 1px solid #555; + color:#fff; } body.invert .q[role=img] { -webkit-filter: invert(1);