From c987ee93c8b405958c9be540361e5ddb417eb038 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Wed, 23 Feb 2022 16:36:52 -0600 Subject: [PATCH 001/100] abstract httpsend --- WiFiManager.cpp | 30 +++++++++++++++++------------- WiFiManager.h | 1 + 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 818d614d..e4b71c26 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -1212,6 +1212,10 @@ String WiFiManager::getHTTPHead(String title){ return page; } +void WiFiManager::HTTPSend(String content){ + server->send(200, FPSTR(HTTP_HEAD_CT), content); +} + /** * HTTPD handler for page requests */ @@ -1260,7 +1264,7 @@ void WiFiManager::handleRoot() { // server->setContentLength(page.length()); // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); - server->send(200, FPSTR(HTTP_HEAD_CT), page); + HTTPSend(page); // server->close(); // testing reliability fix for content length mismatches during mutiple flood hits WiFi_scanNetworks(); // preload wifiscan if(_preloadwifiscan) WiFi_scanNetworks(_scancachetime,true); // preload wifiscan throttled, async // @todo buggy, captive portals make a query on every page load, causing this to run every time in addition to the real page load @@ -1318,7 +1322,7 @@ void WiFiManager::handleWifi(boolean scan) { page += FPSTR(HTTP_END); // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); - server->send(200, FPSTR(HTTP_HEAD_CT), page); + HTTPSend(page); // server->close(); // testing reliability fix for content length mismatches during mutiple flood hits #ifdef WM_DEBUG_LEVEL @@ -1349,7 +1353,7 @@ void WiFiManager::handleParam(){ page += FPSTR(HTTP_END); // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); - server->send(200, FPSTR(HTTP_HEAD_CT), page); + HTTPSend(page); #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_DEV,F("Sent param page")); @@ -1706,7 +1710,7 @@ void WiFiManager::handleWiFiStatus(){ page = FPSTR(HTTP_JS); #endif // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); - server->send(200, FPSTR(HTTP_HEAD_CT), page); + HTTPSend(page); } /** @@ -1774,7 +1778,7 @@ void WiFiManager::handleWifiSave() { // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); server->sendHeader(FPSTR(HTTP_HEAD_CORS), FPSTR(HTTP_HEAD_CORS_ALLOW_ALL)); - server->send(200, FPSTR(HTTP_HEAD_CT), page); + HTTPSend(page); #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_DEV,F("Sent wifi save page")); @@ -1800,7 +1804,7 @@ void WiFiManager::handleParamSave() { page += FPSTR(HTTP_END); // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); - server->send(200, FPSTR(HTTP_HEAD_CT), page); + HTTPSend(page); #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_DEV,F("Sent param save page")); @@ -1951,7 +1955,7 @@ void WiFiManager::handleInfo() { page += FPSTR(HTTP_END); // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); - server->send(200, FPSTR(HTTP_HEAD_CT), page); + HTTPSend(page); #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_DEV,F("Sent info page")); @@ -2174,7 +2178,7 @@ void WiFiManager::handleExit() { server->sendHeader(F("Cache-Control"), F("no-cache, no-store, must-revalidate")); // ('Logout', 401, {'WWW-Authenticate': 'Basic realm="Login required"'}) // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); - server->send(200, FPSTR(HTTP_HEAD_CT), page); + HTTPSend(page); delay(2000); abort = true; } @@ -2192,7 +2196,7 @@ void WiFiManager::handleReset() { page += FPSTR(HTTP_END); // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); - server->send(200, FPSTR(HTTP_HEAD_CT), page); + HTTPSend(page); #ifdef WM_DEBUG_LEVEL DEBUG_WM(F("RESETTING ESP")); @@ -2227,7 +2231,7 @@ void WiFiManager::handleErase(boolean opt) { page += FPSTR(HTTP_END); // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); - server->send(200, FPSTR(HTTP_HEAD_CT), page); + HTTPSend(page); if(ret){ delay(2000); @@ -2308,7 +2312,7 @@ void WiFiManager::handleClose(){ String page = getHTTPHead(FPSTR(S_titleclose)); // @token titleclose page += FPSTR(S_closing); // @token closing // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); - server->send(200, FPSTR(HTTP_HEAD_CT), page); + HTTPSend(page); } void WiFiManager::reportStatus(String &page){ @@ -3653,7 +3657,7 @@ void WiFiManager::handleUpdate() { page += FPSTR(HTTP_END); // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); - server->send(200, FPSTR(HTTP_HEAD_CT), page); + HTTPSend(page); } @@ -3770,7 +3774,7 @@ void WiFiManager::handleUpdateDone() { page += FPSTR(HTTP_END); // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); - server->send(200, FPSTR(HTTP_HEAD_CT), page); + HTTPSend(page); delay(1000); // send page if (!Update.hasError()) { diff --git a/WiFiManager.h b/WiFiManager.h index 1588bad5..d5bd1299 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -556,6 +556,7 @@ class WiFiManager void updateConxResult(uint8_t status); // webserver handlers + void HTTPSend(String content); void handleRoot(); void handleWifi(boolean scan); void handleWifiSave(); From e9d0012ccea08dc8045e433d40af18ce943ece64 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Wed, 23 Feb 2022 16:46:24 -0600 Subject: [PATCH 002/100] abstract httpserver setup --- WiFiManager.cpp | 47 +++++++++++++++++++++++++---------------------- WiFiManager.h | 1 + 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index e4b71c26..52a92971 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -574,40 +574,21 @@ boolean WiFiManager::configPortalHasTimeout(){ return false; } -void WiFiManager::setupDNSD(){ - dnsServer.reset(new DNSServer()); - - /* Setup the DNS server redirecting all the domains to the apIP */ - dnsServer->setErrorReplyCode(DNSReplyCode::NoError); - #ifdef WM_DEBUG_LEVEL - // DEBUG_WM("dns server started port: ",DNS_PORT); - DEBUG_WM(DEBUG_DEV,F("dns server started with ip: "),WiFi.softAPIP()); // @todo not showing ip - #endif - dnsServer->start(DNS_PORT, F("*"), WiFi.softAPIP()); -} - -void WiFiManager::setupConfigPortal() { +void WiFiManager::setupHTTPServer(){ #ifdef WM_DEBUG_LEVEL DEBUG_WM(F("Starting Web Portal")); #endif - // setup dns and web servers - server.reset(new WM_WebServer(_httpPort)); - if(_httpPort != 80) { #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_VERBOSE,F("http server started with custom port: "),_httpPort); // @todo not showing ip #endif - } - - if ( _webservercallback != NULL) { - _webservercallback(); } - // @todo add a new callback maybe, after webserver started, callback cannot override handlers, but can grab them first - /* Setup httpd callbacks, web pages: root, wifi config pages, SO captive portal detectors and not found. */ + server.reset(new WM_WebServer(_httpPort)); + /* Setup httpd callbacks, web pages: root, wifi config pages, SO captive portal detectors and not found. */ server->on(String(FPSTR(R_root)).c_str(), std::bind(&WiFiManager::handleRoot, this)); server->on(String(FPSTR(R_wifi)).c_str(), std::bind(&WiFiManager::handleWifi, this, true)); server->on(String(FPSTR(R_wifinoscan)).c_str(), std::bind(&WiFiManager::handleWifi, this, false)); @@ -629,6 +610,28 @@ void WiFiManager::setupConfigPortal() { #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_VERBOSE,F("HTTP server started")); #endif +} + +void WiFiManager::setupDNSD(){ + dnsServer.reset(new DNSServer()); + + /* Setup the DNS server redirecting all the domains to the apIP */ + dnsServer->setErrorReplyCode(DNSReplyCode::NoError); + #ifdef WM_DEBUG_LEVEL + // DEBUG_WM("dns server started port: ",DNS_PORT); + DEBUG_WM(DEBUG_DEV,F("dns server started with ip: "),WiFi.softAPIP()); // @todo not showing ip + #endif + dnsServer->start(DNS_PORT, F("*"), WiFi.softAPIP()); +} + +void WiFiManager::setupConfigPortal() { + + if ( _webservercallback != NULL) { + _webservercallback(); + } + // @todo add a new callback maybe, after webserver started, callback cannot override handlers, but can grab them first + + setupHTTPServer(); if(_preloadwifiscan) WiFi_scanNetworks(true,true); // preload wifiscan , async } diff --git a/WiFiManager.h b/WiFiManager.h index d5bd1299..5c135110 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -545,6 +545,7 @@ class WiFiManager bool startAP(); void setupDNSD(); + void setupHTTPServer(); uint8_t connectWifi(String ssid, String pass, bool connect = true); bool setSTAConfig(); From 8ecf0575a15160dde10bdc4e17a783ba53fb1b76 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Thu, 24 Feb 2022 10:45:06 -0600 Subject: [PATCH 003/100] remove old content length headers --- WiFiManager.cpp | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 52a92971..cd58a171 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -1265,10 +1265,7 @@ void WiFiManager::handleRoot() { reportStatus(page); page += FPSTR(HTTP_END); - // server->setContentLength(page.length()); - // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); HTTPSend(page); - // server->close(); // testing reliability fix for content length mismatches during mutiple flood hits WiFi_scanNetworks(); // preload wifiscan if(_preloadwifiscan) WiFi_scanNetworks(_scancachetime,true); // preload wifiscan throttled, async // @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 @@ -1324,9 +1321,7 @@ void WiFiManager::handleWifi(boolean scan) { reportStatus(page); page += FPSTR(HTTP_END); - // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); HTTPSend(page); - // server->close(); // testing reliability fix for content length mismatches during mutiple flood hits #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_DEV,F("Sent config page")); @@ -1355,7 +1350,6 @@ void WiFiManager::handleParam(){ reportStatus(page); page += FPSTR(HTTP_END); - // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); HTTPSend(page); #ifdef WM_DEBUG_LEVEL @@ -1712,7 +1706,6 @@ void WiFiManager::handleWiFiStatus(){ #ifdef WM_JSTEST page = FPSTR(HTTP_JS); #endif - // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); HTTPSend(page); } @@ -1779,8 +1772,7 @@ void WiFiManager::handleWifiSave() { } page += FPSTR(HTTP_END); - // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); - server->sendHeader(FPSTR(HTTP_HEAD_CORS), FPSTR(HTTP_HEAD_CORS_ALLOW_ALL)); + server->sendHeader(FPSTR(HTTP_HEAD_CORS), FPSTR(HTTP_HEAD_CORS_ALLOW_ALL)); // @HTTPHEAD send cors HTTPSend(page); #ifdef WM_DEBUG_LEVEL @@ -1806,7 +1798,6 @@ void WiFiManager::handleParamSave() { page += FPSTR(HTTP_PARAMSAVED); page += FPSTR(HTTP_END); - // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); HTTPSend(page); #ifdef WM_DEBUG_LEVEL @@ -1957,7 +1948,6 @@ void WiFiManager::handleInfo() { page += FPSTR(HTTP_HELP); page += FPSTR(HTTP_END); - // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); HTTPSend(page); #ifdef WM_DEBUG_LEVEL @@ -2178,9 +2168,8 @@ void WiFiManager::handleExit() { handleRequest(); String page = getHTTPHead(FPSTR(S_titleexit)); // @token titleexit page += FPSTR(S_exiting); // @token exiting - server->sendHeader(F("Cache-Control"), F("no-cache, no-store, must-revalidate")); // ('Logout', 401, {'WWW-Authenticate': 'Basic realm="Login required"'}) - // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); + server->sendHeader(F("Cache-Control"), F("no-cache, no-store, must-revalidate")); // @HTTPHEAD send cache HTTPSend(page); delay(2000); abort = true; @@ -2198,7 +2187,6 @@ void WiFiManager::handleReset() { page += FPSTR(S_resetting); //@token resetting page += FPSTR(HTTP_END); - // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); HTTPSend(page); #ifdef WM_DEBUG_LEVEL @@ -2233,7 +2221,6 @@ void WiFiManager::handleErase(boolean opt) { } page += FPSTR(HTTP_END); - // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); HTTPSend(page); if(ret){ @@ -2263,10 +2250,9 @@ void WiFiManager::handleNotFound() { for ( uint8_t i = 0; i < server->args(); i++ ) { message += " " + server->argName ( i ) + ": " + server->arg ( i ) + "\n"; } - server->sendHeader(F("Cache-Control"), F("no-cache, no-store, must-revalidate")); + server->sendHeader(F("Cache-Control"), F("no-cache, no-store, must-revalidate")); // @HTTPHEAD send cache server->sendHeader(F("Pragma"), F("no-cache")); server->sendHeader(F("Expires"), F("-1")); - // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(message.length())); server->send ( 404, FPSTR(HTTP_HEAD_CT2), message ); } @@ -2291,7 +2277,7 @@ boolean WiFiManager::captivePortal() { #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_VERBOSE,F("<- Request redirected to captive portal")); #endif - server->sendHeader(F("Location"), (String)F("http://") + serverLoc, true); + server->sendHeader(F("Location"), (String)F("http://") + serverLoc, true); // @HTTPHEAD send redirect server->send ( 302, FPSTR(HTTP_HEAD_CT2), ""); // Empty content inhibits Content-length header so we have to close the socket ourselves. server->client().stop(); // Stop is needed because we sent no content length return true; @@ -2314,7 +2300,6 @@ void WiFiManager::handleClose(){ handleRequest(); String page = getHTTPHead(FPSTR(S_titleclose)); // @token titleclose page += FPSTR(S_closing); // @token closing - // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); HTTPSend(page); } @@ -3659,7 +3644,6 @@ void WiFiManager::handleUpdate() { page += FPSTR(HTTP_UPDATE); page += FPSTR(HTTP_END); - // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); HTTPSend(page); } @@ -3776,7 +3760,6 @@ void WiFiManager::handleUpdateDone() { } page += FPSTR(HTTP_END); - // server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); HTTPSend(page); delay(1000); // send page From d8c81ecca1c41ce0db9f5357405b00b16e2e4bb4 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Thu, 24 Feb 2022 11:43:42 -0600 Subject: [PATCH 004/100] macro test --- WiFiManager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index cd58a171..9fa330cd 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -588,8 +588,12 @@ void WiFiManager::setupHTTPServer(){ server.reset(new WM_WebServer(_httpPort)); + #define G(string_literal) (String(FPSTR(string_literal)).c_str()) + + // workaround for Uri() bug https://github.com/esp8266/Arduino/issues/7102 + /* Setup httpd callbacks, web pages: root, wifi config pages, SO captive portal detectors and not found. */ - server->on(String(FPSTR(R_root)).c_str(), std::bind(&WiFiManager::handleRoot, this)); + server->on(G(R_root), std::bind(&WiFiManager::handleRoot, this)); server->on(String(FPSTR(R_wifi)).c_str(), std::bind(&WiFiManager::handleWifi, this, true)); server->on(String(FPSTR(R_wifinoscan)).c_str(), std::bind(&WiFiManager::handleWifi, this, false)); server->on(String(FPSTR(R_wifisave)).c_str(), std::bind(&WiFiManager::handleWifiSave, this)); From fd7f400b258b2c7028aea623ee2a197c1b09aa0a Mon Sep 17 00:00:00 2001 From: tablatronix Date: Thu, 24 Feb 2022 11:44:45 -0600 Subject: [PATCH 005/100] Revert "Both infoids and _ap_password are intialized by check time. (#1344)" This reverts commit 9f6dcad791533b847c710029446498b9e001d4d9. --- WiFiManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 9fa330cd..81ae9354 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -1940,7 +1940,7 @@ void WiFiManager::handleInfo() { #endif for(size_t i=0; i"); if(_showInfoUpdate){ @@ -3266,7 +3266,7 @@ String WiFiManager::toStringIp(IPAddress ip) { boolean WiFiManager::validApPassword(){ // check that ap password is valid, return false - if (_apPassword.isEmpty()) _apPassword = ""; + if (_apPassword == NULL) _apPassword = ""; if (_apPassword != "") { if (_apPassword.length() < 8 || _apPassword.length() > 63) { #ifdef WM_DEBUG_LEVEL From 0aecb22904563e1250a0d5d02d07b8332abceb7d Mon Sep 17 00:00:00 2001 From: tablatronix Date: Thu, 24 Feb 2022 11:50:08 -0600 Subject: [PATCH 006/100] Fix old sdk esp8266 error w softapssid --- WiFiManager.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 81ae9354..bc688155 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -2092,12 +2092,14 @@ String WiFiManager::getInfoData(String id){ p.replace(FPSTR(T_1),WiFi.softAPgetHostname()); } #endif + #ifndef WM_NOSOFTAPSSID #ifdef ESP8266 else if(id==F("apssid")){ p = FPSTR(HTTP_INFO_apssid); p.replace(FPSTR(T_1),htmlEntities(WiFi.softAPSSID())); } #endif + #endif else if(id==F("apbssid")){ p = FPSTR(HTTP_INFO_apbssid); p.replace(FPSTR(T_1),(String)WiFi.BSSIDstr()); From e6d21b84364524f474f05b1fddf97541bd174e7a Mon Sep 17 00:00:00 2001 From: tablatronix Date: Thu, 24 Feb 2022 12:15:11 -0600 Subject: [PATCH 007/100] use macro for webserver routes fstring helper --- WiFiManager.cpp | 33 ++++++++++++++++----------------- WiFiManager.h | 2 ++ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index bc688155..652723f5 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -587,28 +587,27 @@ void WiFiManager::setupHTTPServer(){ } server.reset(new WM_WebServer(_httpPort)); - - #define G(string_literal) (String(FPSTR(string_literal)).c_str()) - - // workaround for Uri() bug https://github.com/esp8266/Arduino/issues/7102 + /* Setup httpd callbacks, web pages: root, wifi config pages, SO captive portal detectors and not found. */ + + // G macro workaround for Uri() bug https://github.com/esp8266/Arduino/issues/7102 server->on(G(R_root), std::bind(&WiFiManager::handleRoot, this)); - server->on(String(FPSTR(R_wifi)).c_str(), std::bind(&WiFiManager::handleWifi, this, true)); - server->on(String(FPSTR(R_wifinoscan)).c_str(), std::bind(&WiFiManager::handleWifi, this, false)); - server->on(String(FPSTR(R_wifisave)).c_str(), std::bind(&WiFiManager::handleWifiSave, this)); - server->on(String(FPSTR(R_info)).c_str(), std::bind(&WiFiManager::handleInfo, this)); - server->on(String(FPSTR(R_param)).c_str(), std::bind(&WiFiManager::handleParam, this)); - server->on(String(FPSTR(R_paramsave)).c_str(), std::bind(&WiFiManager::handleParamSave, this)); - server->on(String(FPSTR(R_restart)).c_str(), std::bind(&WiFiManager::handleReset, this)); - server->on(String(FPSTR(R_exit)).c_str(), std::bind(&WiFiManager::handleExit, this)); - server->on(String(FPSTR(R_close)).c_str(), std::bind(&WiFiManager::handleClose, this)); - server->on(String(FPSTR(R_erase)).c_str(), std::bind(&WiFiManager::handleErase, this, false)); - server->on(String(FPSTR(R_status)).c_str(), std::bind(&WiFiManager::handleWiFiStatus, this)); + server->on(G(R_wifi), std::bind(&WiFiManager::handleWifi, this, true)); + server->on(G(R_wifinoscan), std::bind(&WiFiManager::handleWifi, this, false)); + server->on(G(R_wifisave), std::bind(&WiFiManager::handleWifiSave, this)); + server->on(G(R_info), std::bind(&WiFiManager::handleInfo, this)); + server->on(G(R_param), std::bind(&WiFiManager::handleParam, this)); + server->on(G(R_paramsave), std::bind(&WiFiManager::handleParamSave, this)); + server->on(G(R_restart), std::bind(&WiFiManager::handleReset, this)); + server->on(G(R_exit), std::bind(&WiFiManager::handleExit, this)); + server->on(G(R_close), std::bind(&WiFiManager::handleClose, this)); + server->on(G(R_erase), std::bind(&WiFiManager::handleErase, this, false)); + server->on(G(R_status), std::bind(&WiFiManager::handleWiFiStatus, this)); server->onNotFound (std::bind(&WiFiManager::handleNotFound, this)); - server->on(String(FPSTR(R_update)).c_str(), std::bind(&WiFiManager::handleUpdate, this)); - server->on(String(FPSTR(R_updatedone)).c_str(), HTTP_POST, std::bind(&WiFiManager::handleUpdateDone, this), std::bind(&WiFiManager::handleUpdating, this)); + server->on(G(R_update), std::bind(&WiFiManager::handleUpdate, this)); + server->on(G(R_updatedone), HTTP_POST, std::bind(&WiFiManager::handleUpdateDone, this), std::bind(&WiFiManager::handleUpdating, this)); server->begin(); // Web server start #ifdef WM_DEBUG_LEVEL diff --git a/WiFiManager.h b/WiFiManager.h index 5c135110..641f88e5 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -46,6 +46,8 @@ #define WM_WEBSERVERSHIM // use webserver shim lib +#define G(string_literal) (String(FPSTR(string_literal)).c_str()) + #ifdef ESP8266 extern "C" { From 713fcfc740bcbfe3a57e0055e42b27c6e11428b3 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Thu, 10 Mar 2022 15:41:07 -0600 Subject: [PATCH 008/100] disable country in example --- examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino index b92d34fb..79f1d387 100644 --- a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -172,7 +172,8 @@ void setup() { // set country // setting wifi country seems to improve OSX soft ap connectivity, // may help others as well, default is CN which has different channels - wm.setCountry("US"); + + // wm.setCountry("US"); // crashing on esp32 2.0 // set Hostname From 8f2c7ae8708f2553be2e7836f6b895b22d34d118 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Thu, 10 Mar 2022 15:45:49 -0600 Subject: [PATCH 009/100] remove test --- WiFiManager.cpp | 1 + examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 652723f5..1c3598a0 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -3291,6 +3291,7 @@ boolean WiFiManager::validApPassword(){ * @return string encoded string */ String WiFiManager::htmlEntities(String str) { + // str.replace(" "," "); str.replace("&","&"); str.replace("<","<"); str.replace(">",">"); diff --git a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino index 79f1d387..ced31a4c 100644 --- a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -209,7 +209,7 @@ void setup() { // wm.setConnectRetries(2); // connect after portal save toggle - wm.setSaveConnect(false); // do not connect, only save + // wm.setSaveConnect(false); // do not connect, only save // show static ip fields // wm.setShowStaticFields(true); From acdad80a43a7f39ae41fca3e7ea3675bedc90631 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Thu, 10 Mar 2022 22:34:03 -0600 Subject: [PATCH 010/100] add callback debuggin --- WiFiManager.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 1c3598a0..4b15506d 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -588,7 +588,6 @@ void WiFiManager::setupHTTPServer(){ server.reset(new WM_WebServer(_httpPort)); - /* Setup httpd callbacks, web pages: root, wifi config pages, SO captive portal detectors and not found. */ // G macro workaround for Uri() bug https://github.com/esp8266/Arduino/issues/7102 @@ -630,6 +629,9 @@ void WiFiManager::setupDNSD(){ void WiFiManager::setupConfigPortal() { if ( _webservercallback != NULL) { + #ifdef WM_DEBUG_LEVEL + DEBUG_WM(DEBUG_VERBOSE,F("[CB] _webservercallback calling")); + #endif _webservercallback(); } // @todo add a new callback maybe, after webserver started, callback cannot override handlers, but can grab them first @@ -697,6 +699,9 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo // do AP callback if set if ( _apcallback != NULL) { + #ifdef WM_DEBUG_LEVEL + DEBUG_WM(DEBUG_VERBOSE,F("[CB] _apcallback calling")); + #endif _apcallback(this); } @@ -831,6 +836,9 @@ uint8_t WiFiManager::processConfigPortal(){ #endif if ( _savewificallback != NULL) { + #ifdef WM_DEBUG_LEVEL + DEBUG_WM(DEBUG_VERBOSE,F("[CB] _savewificallback calling")); + #endif _savewificallback(); } if(!_connectonsave) return WL_IDLE_STATUS; @@ -849,7 +857,7 @@ uint8_t WiFiManager::processConfigPortal(){ // confirm or verify data was saved to make this more accurate callback if ( _savewificallback != NULL) { #ifdef WM_DEBUG_LEVEL - DEBUG_WM(DEBUG_VERBOSE,F("WiFi/Param save callback")); + DEBUG_WM(DEBUG_VERBOSE,F("[CB] WiFi/Param save callback")); #endif _savewificallback(); } From e830fa26e3dbd68e4ac9de695c433d07741d7d91 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Fri, 11 Mar 2022 00:04:21 -0600 Subject: [PATCH 011/100] Adding a data attribute for ssid for input value so it has nothing to do with the html , and can have different encoding, we could also just use IDs but scan cannot change, or use bssid #1370 --- WiFiManager.cpp | 7 ++++--- WiFiManager.h | 2 +- strings_en.h | 6 ++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 4b15506d..8f5d49de 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -1562,7 +1562,8 @@ String WiFiManager::WiFiManager::getScanItemOut(){ // Serial.println(WiFi.BSSIDstr(indices[i])); continue; // No idea why I am seeing these, lets just skip them for now } - item.replace(FPSTR(T_v), htmlEntities(WiFi.SSID(indices[i]))); // ssid no encoding + item.replace(FPSTR(T_V), htmlEntities(WiFi.SSID(indices[i]))); // ssid no encoding + item.replace(FPSTR(T_v), htmlEntities(WiFi.SSID(indices[i]),true)); // ssid no encoding if(tok_e) item.replace(FPSTR(T_e), encryptionTypeStr(enc_type)); if(tok_r) item.replace(FPSTR(T_r), (String)rssiperc); // rssi percentage 0-100 if(tok_R) item.replace(FPSTR(T_R), (String)WiFi.RSSI(indices[i])); // rssi db @@ -3298,11 +3299,11 @@ boolean WiFiManager::validApPassword(){ * @param string str string to replace entities * @return string encoded string */ -String WiFiManager::htmlEntities(String str) { - // str.replace(" "," "); +String WiFiManager::htmlEntities(String str, bool whitespace) { str.replace("&","&"); str.replace("<","<"); str.replace(">",">"); + if(whitespace) str.replace(" "," "); // str.replace("-","–"); // str.replace("\"","""); // str.replace("/": "/"); diff --git a/WiFiManager.h b/WiFiManager.h index 641f88e5..4d5b9482 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -384,7 +384,7 @@ class WiFiManager void debugPlatformInfo(); // helper for html - String htmlEntities(String str); + String htmlEntities(String str, bool whitespace = false); // set the country code for wifi settings, CN void setCountry(String cc); diff --git a/strings_en.h b/strings_en.h index 09ab44a6..bd71d58a 100644 --- a/strings_en.h +++ b/strings_en.h @@ -24,7 +24,7 @@ const char HTTP_HEAD_START[] PROGMEM = "" "{v}"; const char HTTP_SCRIPT[] PROGMEM = ""; // @todo add button states, disable on click , show ack , spinner etc @@ -33,6 +33,7 @@ const char HTTP_HEAD_END[] PROGMEM = "

\n", // MENU_WIFI "

\n", // MENU_WIFINOSCAN @@ -50,7 +51,7 @@ const char * const HTTP_PORTAL_MENU[] PROGMEM = { const char HTTP_PORTAL_OPTIONS[] PROGMEM = ""; const char HTTP_ITEM_QI[] PROGMEM = ""; // rssi icons const char HTTP_ITEM_QP[] PROGMEM = "
{r}%
"; // rssi percentage {h} = hidden showperc pref -const char HTTP_ITEM[] PROGMEM = "
{v}{qi}{qp}
"; // {q} = HTTP_ITEM_QI, {r} = HTTP_ITEM_QP +const char HTTP_ITEM[] PROGMEM = "
{v}{qi}{qp}
"; // {q} = HTTP_ITEM_QI, {r} = HTTP_ITEM_QP // const char HTTP_ITEM[] PROGMEM = "
{v} {R} {r}% {q} {e}
"; // test all tokens const char HTTP_FORM_START[] PROGMEM = "
"; @@ -301,6 +302,7 @@ const char T_1[] PROGMEM = "{1}"; // @token 1 const char T_2[] PROGMEM = "{2}"; // @token 2 const char T_3[] PROGMEM = "{3}"; // @token 2 const char T_v[] PROGMEM = "{v}"; // @token v +const char T_V[] PROGMEM = "{V}"; // @token v const char T_I[] PROGMEM = "{I}"; // @token I const char T_i[] PROGMEM = "{i}"; // @token i const char T_n[] PROGMEM = "{n}"; // @token n From 0d61a6b55fca68b5a5d9a6bacc9861a71d7861e1 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Fri, 11 Mar 2022 00:05:01 -0600 Subject: [PATCH 012/100] esp32 crashes on cb route shared pointer --- examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino index ced31a4c..ff22a13f 100644 --- a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -55,7 +55,7 @@ void saveParamCallback(){ } void bindServerCallback(){ - wm.server->on("/custom",handleRoute); + // wm.server->on("/custom",handleRoute); // this is now crashing esp32 for some reason // wm.server->on("/info",handleRoute); // you can override wm! } From 0994c4b3f869cddc827d677d92d112cf6a43df6e Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Fri, 11 Mar 2022 08:34:08 -0600 Subject: [PATCH 013/100] regression, webserver callbacks before reset crashes any webserver event handlers bound before the webserver new reset would cause memory access issues when triggered. Should remove all events on reset or make memory safe, not sure if this is the correct way to be reseting the webserver, but there were issues with the ports not releasing etc. --- WiFiManager.cpp | 17 +++++++++-------- .../OnDemandConfigPortal.ino | 3 ++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 8f5d49de..e619f009 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -587,6 +587,15 @@ void WiFiManager::setupHTTPServer(){ } server.reset(new WM_WebServer(_httpPort)); + // This is not the safest way to reset the webserver, it can cause crashes on callbacks initilized before this and since its a shared pointer... + + if ( _webservercallback != NULL) { + #ifdef WM_DEBUG_LEVEL + DEBUG_WM(DEBUG_VERBOSE,F("[CB] _webservercallback calling")); + #endif + _webservercallback(); + } + // @todo add a new callback maybe, after webserver started, callback cannot override handlers, but can grab them first /* Setup httpd callbacks, web pages: root, wifi config pages, SO captive portal detectors and not found. */ @@ -628,14 +637,6 @@ void WiFiManager::setupDNSD(){ void WiFiManager::setupConfigPortal() { - if ( _webservercallback != NULL) { - #ifdef WM_DEBUG_LEVEL - DEBUG_WM(DEBUG_VERBOSE,F("[CB] _webservercallback calling")); - #endif - _webservercallback(); - } - // @todo add a new callback maybe, after webserver started, callback cannot override handlers, but can grab them first - setupHTTPServer(); if(_preloadwifiscan) WiFi_scanNetworks(true,true); // preload wifiscan , async diff --git a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino index ff22a13f..d2bcce27 100644 --- a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -24,6 +24,7 @@ WiFiManager wm; // TEST OPTION FLAGS bool TEST_CP = false; // always start the configportal, even if ap found +bool TEST_CP = true; // always start the configportal, even if ap found int TESP_CP_TIMEOUT = 90; // test cp timeout bool TEST_NET = true; // do a network test after connect, (gets ntp time) @@ -55,7 +56,7 @@ void saveParamCallback(){ } void bindServerCallback(){ - // wm.server->on("/custom",handleRoute); // this is now crashing esp32 for some reason + wm.server->on("/custom",handleRoute); // this is now crashing esp32 for some reason // wm.server->on("/info",handleRoute); // you can override wm! } From 1f3b2e34ae773224d03284291d257720135e63e7 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Sun, 13 Mar 2022 21:26:13 -0500 Subject: [PATCH 014/100] typo --- WiFiManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index e619f009..fa4094cb 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -2725,8 +2725,8 @@ void WiFiManager::setRemoveDuplicateAPs(boolean removeDuplicates) { * @access public * @param boolean shoudlBlock [false] */ -void WiFiManager::setConfigPortalBlocking(boolean shoudlBlock) { - _configPortalIsBlocking = shoudlBlock; +void WiFiManager::setConfigPortalBlocking(boolean shouldBlock) { + _configPortalIsBlocking = shouldBlock; } /** From d70f358f3eb51cf3ed05de944ffdee5aa4110c66 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Sun, 13 Mar 2022 21:34:26 -0500 Subject: [PATCH 015/100] add check to dissallow starting cp if already running This will avoid support inquiries and add a log --- WiFiManager.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index fa4094cb..102071f7 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -657,6 +657,13 @@ boolean WiFiManager::startConfigPortal() { boolean WiFiManager::startConfigPortal(char const *apName, char const *apPassword) { _begin(); + if(configPortalActive){ + #ifdef WM_DEBUG_LEVEL + DEBUG_WM(DEBUG_VERBOSE,F("Starting Config Portal FAILED, is already running")); + #endif + return false; + } + //setup AP _apName = apName; // @todo check valid apname ? _apPassword = apPassword; From eb5ba12df1cc3de9daeefc556360b2150d49ab72 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Sun, 13 Mar 2022 21:34:26 -0500 Subject: [PATCH 016/100] #1371 --- WiFiManager.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index fa4094cb..102071f7 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -657,6 +657,13 @@ boolean WiFiManager::startConfigPortal() { boolean WiFiManager::startConfigPortal(char const *apName, char const *apPassword) { _begin(); + if(configPortalActive){ + #ifdef WM_DEBUG_LEVEL + DEBUG_WM(DEBUG_VERBOSE,F("Starting Config Portal FAILED, is already running")); + #endif + return false; + } + //setup AP _apName = apName; // @todo check valid apname ? _apPassword = apPassword; From b4368308ca96d76f4d41859e83537108b5cc7599 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Mon, 14 Mar 2022 06:43:23 -0500 Subject: [PATCH 017/100] remove bad example --- .../AutoConnectNonBlocking/AutoConnectNonBlocking.ino | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/NonBlocking/AutoConnectNonBlocking/AutoConnectNonBlocking.ino b/examples/NonBlocking/AutoConnectNonBlocking/AutoConnectNonBlocking.ino index 28c50249..ab523960 100644 --- a/examples/NonBlocking/AutoConnectNonBlocking/AutoConnectNonBlocking.ino +++ b/examples/NonBlocking/AutoConnectNonBlocking/AutoConnectNonBlocking.ino @@ -19,9 +19,6 @@ void setup() { else { Serial.println("Configportal running"); } - - wm.startConfigPortal(); - // wm.startWebPortal(); } void loop() { From e9a02d46683617f266a11003171fc31a2298467c Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Fri, 25 Mar 2022 14:36:46 -0500 Subject: [PATCH 018/100] add some button feedback --- strings_en.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/strings_en.h b/strings_en.h index bd71d58a..27d25781 100644 --- a/strings_en.h +++ b/strings_en.h @@ -100,7 +100,9 @@ const char HTTP_STYLE[] PROGMEM = " @@ -318,7 +337,12 @@

/info


/erase Erase WiFi configuration and reboot Device. Device will not reconnect to a network until new WiFi configuration data is entered. -

More information about WiFiManager at https://github.com/tzapu/WiFiManager +

About


+ Version v1.x.x-xxxxx
+ Build_date
+ Build_file
+ Arduino_version
+

Github https://github.com/tzapu/WiFiManager

Form UPLOAD
diff --git a/strings_en.h b/strings_en.h index 27d25781..12e63bb6 100644 --- a/strings_en.h +++ b/strings_en.h @@ -13,9 +13,12 @@ #ifndef _WM_STRINGS_H_ #define _WM_STRINGS_H_ + #ifndef WIFI_MANAGER_OVERRIDE_STRINGS // !!! ABOVE WILL NOT WORK if you define in your sketch, must be build flag, if anyone one knows how to order includes to be able to do this it would be neat.. I have seen it done.. +const char WM_VERSION_STR[] PROGMEM = "v1.0.10-beta"; + const char HTTP_HEAD_START[] PROGMEM = "" "" "" @@ -136,7 +139,7 @@ const char HTTP_HELP[] PROGMEM = "/erase" "Erase WiFi configuration and reboot Device. Device will not reconnect to a network until new WiFi configuration data is entered." "" - "

More information about WiFiManager at https://github.com/tzapu/WiFiManager."; + "

Github https://github.com/tzapu/WiFiManager."; #else const char HTTP_HELP[] PROGMEM = ""; #endif @@ -166,6 +169,7 @@ const char HTTP_JS[] PROGMEM = #endif // Info html +// @todo remove html elements from progmem, repetetive strings #ifdef ESP32 const char HTTP_INFO_esphead[] PROGMEM = "

esp32


"; const char HTTP_INFO_chiprev[] PROGMEM = "
Chip Rev
{1}
"; @@ -205,6 +209,10 @@ const char HTTP_INFO_stamac[] PROGMEM = "
Station MAC
{1}
"; const char HTTP_INFO_conx[] PROGMEM = "
Connected
{1}
"; const char HTTP_INFO_autoconx[] PROGMEM = "
Autoconnect
{1}
"; +const char HTTP_INFO_aboutver[] PROGMEM = "
WiFiManager
{1}
"; +const char HTTP_INFO_aboutarduino[] PROGMEM = "
Arduino
{1}
"; +const char HTTP_INFO_aboutsdk[] PROGMEM = "
ESP-SDK/IDF
{1}
"; +const char HTTP_INFO_aboutdate[] PROGMEM = "
Build Date
{1}
"; const char S_brand[] PROGMEM = "WiFiManager"; const char S_debugPrefix[] PROGMEM = "*wm:"; From 9cec5a25a86f2a1ce4c99013f87f9259e8baa0e0 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Fri, 25 Mar 2022 14:41:03 -0500 Subject: [PATCH 020/100] bump version --- library.json | 2 +- library.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.json b/library.json index 1c2f505e..ae62724f 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "WiFiManager", - "version": "2.0.9-beta", + "version": "2.0.10-beta", "keywords": "wifi,wi-fi,esp,esp8266,esp32,espressif8266,espressif32,nodemcu,wemos,arduino", "description": "WiFi Configuration manager with web configuration portal for ESP boards", "authors": diff --git a/library.properties b/library.properties index 71f53afa..b81c4ac1 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=WiFiManager -version=2.0.9-beta +version=2.0.10-beta author=tzapu maintainer=tablatronix sentence=WiFi Configuration manager with web configuration portal for Espressif ESPx boards, by tzapu From 91826229cb8e80c24d49ee32a243220c77f55c08 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Sat, 26 Mar 2022 13:01:01 -0500 Subject: [PATCH 021/100] oops --- examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino index d2bcce27..be431586 100644 --- a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -24,7 +24,6 @@ WiFiManager wm; // TEST OPTION FLAGS bool TEST_CP = false; // always start the configportal, even if ap found -bool TEST_CP = true; // always start the configportal, even if ap found int TESP_CP_TIMEOUT = 90; // test cp timeout bool TEST_NET = true; // do a network test after connect, (gets ntp time) From 278c57b4ecc7c8c96160d6463a32e3b2d6bfd548 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Mon, 28 Mar 2022 08:23:16 -0500 Subject: [PATCH 022/100] fixes #1379 --- WiFiManager.cpp | 1 + WiFiManager.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 1f1629a8..703283ed 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -516,6 +516,7 @@ bool WiFiManager::startAP(){ */ void WiFiManager::startWebPortal() { if(configPortalActive || webPortalActive) return; + connect = abort = false; setupConfigPortal(); webPortalActive = true; } diff --git a/WiFiManager.h b/WiFiManager.h index 15e48e70..9e696c8b 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -646,8 +646,8 @@ class WiFiManager String getInfoData(String id); // flags - boolean connect; - boolean abort; + boolean connect = false; + boolean abort = false; boolean reset = false; boolean configPortalActive = false; boolean webPortalActive = false; From ea4ee025f2bd221610aaaab54042d581905b8d2f Mon Sep 17 00:00:00 2001 From: John Date: Mon, 28 Mar 2022 21:41:08 -0400 Subject: [PATCH 023/100] Output "Unknown" if Arduino/ESP-IDF version is unknown (#1382) Closes #1381 --- WiFiManager.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WiFiManager.h b/WiFiManager.h index 9e696c8b..54affb60 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -66,10 +66,10 @@ // #pragma message "ESP_ARDUINO_VERSION_PATCH = " STRING(ESP_ARDUINO_VERSION_PATCH) #define VER_ARDUINO_STR STRING(ESP_ARDUINO_VERSION_MAJOR) "." STRING(ESP_ARDUINO_VERSION_MINOR) "." STRING(ESP_ARDUINO_VERSION_PATCH) #else - #include + // #include // #pragma message "ESP_ARDUINO_VERSION_GIT = " STRING(ARDUINO_ESP32_GIT_VER)// 0x46d5afb1 // #pragma message "ESP_ARDUINO_VERSION_DESC = " STRING(ARDUINO_ESP32_GIT_DESC) // 1.0.6 - #define VER_ARDUINO_STR STRING(ARDUINO_ESP32_GIT_DESC) + #define VER_ARDUINO_STR "Unknown" // #pragma message "ESP_ARDUINO_VERSION_REL = " STRING(ARDUINO_ESP32_RELEASE) //"1_0_6" #endif From 88b97c7caab44926e21d789495e55bcf7e19b333 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Tue, 29 Mar 2022 13:31:41 -0500 Subject: [PATCH 024/100] #1383 fix --- WiFiManager.cpp | 2 +- WiFiManager.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 703283ed..16676f2d 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -3674,7 +3674,7 @@ void WiFiManager::WiFi_autoReconnect(){ DEBUG_WM(DEBUG_VERBOSE,F("ESP32 event handler enabled")); #endif using namespace std::placeholders; - wm_event_id = WiFi.onEvent(std::bind(&WiFiManager::WiFiEvent,this,_1,_2)); + if(wm_event_id !=0) wm_event_id = WiFi.onEvent(std::bind(&WiFiManager::WiFiEvent,this,_1,_2)); // } #endif } diff --git a/WiFiManager.h b/WiFiManager.h index 9e696c8b..cb88c40a 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -481,7 +481,7 @@ class WiFiManager bool _allowExit = true; // allow exit non blocking #ifdef ESP32 - wifi_event_id_t wm_event_id; + wifi_event_id_t wm_event_id = 0; static uint8_t _lastconxresulttmp; // tmp var for esp32 callback #endif From 6a85acdf8531ca8745391d6b15cdd1130076acac Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Tue, 29 Mar 2022 13:34:58 -0500 Subject: [PATCH 025/100] add customMenuHTML --- WiFiManager.cpp | 20 ++++++++++++++++--- WiFiManager.h | 10 +++++++--- .../OnDemandConfigPortal.ino | 15 +++++++++++--- strings_en.h | 7 ++++--- 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 16676f2d..2cf04644 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -1383,6 +1383,10 @@ String WiFiManager::getMenuOut(){ for(auto menuId :_menuIds ){ if((String)_menutokens[menuId] == "param" && _paramsCount == 0) continue; // no params set, omit params from menu, @todo this may be undesired by someone, use only menu to force? + if((String)_menutokens[menuId] == "custom" && _customMenuHTML!=NULL){ + page += _customMenuHTML; + continue; + } page += HTTP_PORTAL_MENU[menuId]; } @@ -2733,12 +2737,22 @@ void WiFiManager::setPreOtaUpdateCallback( std::function func ) { /** * set custom head html - * custom element will be added to head, eg. new style tag etc. + * custom element will be added to head, eg. new meta,style,script tag etc. + * @access public + * @param char element + */ +void WiFiManager::setCustomHeadElement(const char* html) { + _customHeadElement = html; +} + +/** + * set custom menu html + * custom element will be added to menu under custom menu item. * @access public * @param char element */ -void WiFiManager::setCustomHeadElement(const char* element) { - _customHeadElement = element; +void WiFiManager::setCustomMenuHTML(const char* html) { + _customMenuHTML = html; } /** diff --git a/WiFiManager.h b/WiFiManager.h index cb88c40a..edf7b8db 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -295,9 +295,12 @@ class WiFiManager // setConfigPortalTimeout is ignored in this mode, user is responsible for closing configportal void setConfigPortalBlocking(boolean shouldBlock); + //add custom html at inside for all pages + void setCustomHeadElement(const char* html); + //if this is set, customise style - void setCustomHeadElement(const char* element); - + void setCustomMenuHTML(const char* html); + //if this is true, remove duplicated Access Points - defaut true void setRemoveDuplicateAPs(boolean removeDuplicates); @@ -510,7 +513,8 @@ class WiFiManager boolean _enableConfigPortal = true; // use config portal if autoconnect failed String _hostname = ""; // hostname for esp8266 for dhcp, and or MDNS - const char* _customHeadElement = ""; // store custom head element html from user + const char* _customHeadElement = ""; // store custom head element html from user isnide + const char* _customMenuHTML = ""; // store custom head element html from user inside <> String _bodyClass = ""; // class to add to body String _title = FPSTR(S_brand); // app title - default WiFiManager diff --git a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino index be431586..84566391 100644 --- a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -23,7 +23,7 @@ WiFiManager wm; // TEST OPTION FLAGS -bool TEST_CP = false; // always start the configportal, even if ap found +bool TEST_CP = true; // always start the configportal, even if ap found int TESP_CP_TIMEOUT = 90; // test cp timeout bool TEST_NET = true; // do a network test after connect, (gets ntp time) @@ -90,6 +90,7 @@ void setup() { // wm.erase(); // setup some parameters + WiFiManagerParameter custom_html("

This Is Custom HTML

"); // only custom html WiFiManagerParameter custom_mqtt_server("server", "mqtt server", "", 40); WiFiManagerParameter custom_mqtt_port("port", "mqtt port", "", 6); @@ -143,6 +144,14 @@ void setup() { custom_html.setValue("test",4); custom_token.setValue("test",4); + // set custom html head content , inside + const char* headhtml = ""; + wm.setCustomHeadElement(headhtml); + + // set custom html menu content , inside + const char* menuhtml = "
\n"; + wm.setCustomMenuHTML(menuhtml); + // invert theme, dark wm.setDarkMode(true); @@ -155,7 +164,7 @@ void setup() { wm.setMenu(menu,9); // custom menu array must provide length */ - std::vector menu = {"wifi","wifinoscan","info","param","close","sep","erase","update","restart","exit"}; + std::vector menu = {"wifi","wifinoscan","info","param","custom","close","sep","erase","update","restart","exit"}; wm.setMenu(menu); // custom menu, pass vector // wm.setParamsPage(true); // move params to seperate page, not wifi, do not combine with setmenu! @@ -242,7 +251,7 @@ void setup() { delay(1000); Serial.println("TEST_CP ENABLED"); wm.setConfigPortalTimeout(TESP_CP_TIMEOUT); - wm.startConfigPortal("WM_ConnectAP"); + wm.startConfigPortal("WM_ConnectAP","12345678"); } else { //if you get here you have connected to the WiFi diff --git a/strings_en.h b/strings_en.h index 12e63bb6..c37c38cd 100644 --- a/strings_en.h +++ b/strings_en.h @@ -259,8 +259,8 @@ const char D_HR[] PROGMEM = "--------------------"; // ----------------------------------------------------------------------------------------------- // DO NOT EDIT BELOW THIS LINE -const uint8_t _nummenutokens = 10; -const char * const _menutokens[10] PROGMEM = { +const uint8_t _nummenutokens = 11; +const char * const _menutokens[_nummenutokens] PROGMEM = { "wifi", "wifinoscan", "info", @@ -270,7 +270,8 @@ const char * const _menutokens[10] PROGMEM = { "exit", "erase", "update", - "sep" + "sep", + "custom" }; const char R_root[] PROGMEM = "/"; From 9cd81e3af9ff3a0940588c030ce324a7e1399873 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Tue, 29 Mar 2022 14:46:08 -0500 Subject: [PATCH 026/100] debug --- examples/Basic/Basic.ino | 2 +- .../OnDemandConfigPortal/OnDemandConfigPortal.ino | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/Basic/Basic.ino b/examples/Basic/Basic.ino index 5f163041..59c95d90 100644 --- a/examples/Basic/Basic.ino +++ b/examples/Basic/Basic.ino @@ -13,7 +13,7 @@ void setup() { // reset settings - wipe stored credentials for testing // these are stored by the esp library - //wm.resetSettings(); + wm.resetSettings(); // Automatically connect using saved credentials, // if connection fails, it starts an access point with the specified name ( "AutoConnectAP"), diff --git a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino index be431586..8b44fa33 100644 --- a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -65,7 +65,7 @@ void handleRoute(){ } void setup() { - WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP + // WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP // put your setup code here, to run once: Serial.begin(115200); @@ -259,10 +259,11 @@ void setup() { } void wifiInfo(){ - WiFi.printDiag(Serial); - Serial.println("SAVED: " + (String)wm.getWiFiIsSaved() ? "YES" : "NO"); - Serial.println("SSID: " + (String)wm.getWiFiSSID()); - Serial.println("PASS: " + (String)wm.getWiFiPass()); + Serial.println("[WIFI] WIFI INFO DEBUG"); + // WiFi.printDiag(Serial); + Serial.println("[WIFI] SAVED: " + (String)(wm.getWiFiIsSaved() ? "YES" : "NO")); + Serial.println("[WIFI] SSID: " + (String)wm.getWiFiSSID()); + Serial.println("[WIFI] PASS: " + (String)wm.getWiFiPass()); } void loop() { From 918e02ddfd01b983b60aa2d66ded0fe8c95a276e Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Tue, 29 Mar 2022 14:46:42 -0500 Subject: [PATCH 027/100] add resetsetting delay, some complaints its not working shrug --- WiFiManager.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 1f1629a8..ce67e71d 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -2510,9 +2510,10 @@ void WiFiManager::resetSettings() { DEBUG_WM(F("resetSettings")); #endif WiFi_enableSTA(true,true); // must be sta to disconnect erase - - if (_resetcallback != NULL) + delay(500); // ensure sta is enabled + if (_resetcallback != NULL){ _resetcallback(); + } #ifdef ESP32 WiFi.disconnect(true,true); From 1e628625aa1267d4b2d0a8bb121c5b8d5d9a626d Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Thu, 7 Apr 2022 08:37:43 -0500 Subject: [PATCH 028/100] fixes #1386 8 --- WiFiManager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 2fc81c66..5c24b1e9 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -1427,7 +1427,7 @@ bool WiFiManager::WiFi_scanNetworks(bool force,bool async){ DEBUG_WM(DEBUG_DEV,"NO APs found forcing new scan"); force = true; } - if(force || (millis()-_lastscan > 60000)){ + if(force || (_lastscan>0 && (millis()-_lastscan > 60000))){ int8_t res; _startscan = millis(); if(async && _asyncScan){ @@ -1477,7 +1477,7 @@ bool WiFiManager::WiFi_scanNetworks(bool force,bool async){ DEBUG_WM(DEBUG_VERBOSE,F("WiFi Scan completed"), "in "+(String)(_lastscan - _startscan)+" ms"); #endif return true; - } + } else { #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_VERBOSE,F("Scan is cached"),(String)(millis()-_lastscan )+" ms ago"); @@ -1489,7 +1489,7 @@ bool WiFiManager::WiFi_scanNetworks(bool force,bool async){ String WiFiManager::WiFiManager::getScanItemOut(){ String page; - if(!_numNetworks) WiFi_scanNetworks(); // scan in case this gets called before any scans + if(!_numNetworks) WiFi_scanNetworks(true); // scan in case this gets called before any scans int n = _numNetworks; if (n == 0) { From 379ffee475c7c3fff90aa65fa9bd23f24d178738 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Thu, 7 Apr 2022 08:38:23 -0500 Subject: [PATCH 029/100] clean up variable declarations --- WiFiManager.h | 24 ++++++++++--------- .../OnDemandConfigPortal.ino | 3 +++ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/WiFiManager.h b/WiFiManager.h index 74d678b0..1eaeb783 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -431,6 +431,7 @@ class WiFiManager std::unique_ptr server; private: + // vars std::vector _menuIds; std::vector _menuIdsParams = {"wifi","param","info","exit"}; std::vector _menuIdsUpdate = {"wifi","param","info","update","exit"}; @@ -445,9 +446,16 @@ class WiFiManager IPAddress _sta_static_sn; IPAddress _sta_static_dns; + unsigned long _configPortalStart = 0; // ms config portal start time (updated for timeouts) + unsigned long _webPortalAccessed = 0; // ms last web access time + uint8_t _lastconxresult = WL_IDLE_STATUS; // store last result when doing connect operations + int _numNetworks = 0; // init index for numnetworks wifiscans + unsigned long _lastscan = 0; // ms for timing wifi scans + unsigned long _startscan = 0; // ms for timing wifi scans + unsigned long _startconn = 0; // ms for timing wifi connects + // defaults const byte DNS_PORT = 53; - const byte HTTP_PORT = 80; String _apName = "no-net"; String _apPassword = ""; String _ssid = ""; // var temp ssid @@ -459,26 +467,20 @@ class WiFiManager unsigned long _configPortalTimeout = 0; // ms close config portal loop if set (depending on _cp/webClientCheck options) unsigned long _connectTimeout = 0; // ms stop trying to connect to ap if set unsigned long _saveTimeout = 0; // ms stop trying to connect to ap on saves, in case bugs in esp waitforconnectresult - unsigned long _configPortalStart = 0; // ms config portal start time (updated for timeouts) - unsigned long _webPortalAccessed = 0; // ms last web access time + WiFiMode_t _usermode = WIFI_STA; // Default user mode String _wifissidprefix = FPSTR(S_ssidpre); // auto apname prefix prefix+chipid - uint8_t _lastconxresult = WL_IDLE_STATUS; // store last result when doing connect operations - int _numNetworks = 0; // init index for numnetworks wifiscans - unsigned long _lastscan = 0; // ms for timing wifi scans - unsigned long _startscan = 0; // ms for timing wifi scans int _cpclosedelay = 2000; // delay before wifisave, prevents captive portal from closing to fast. bool _cleanConnect = false; // disconnect before connect in connectwifi, increases stability on connects bool _connectonsave = true; // connect to wifi when saving creds bool _disableSTA = false; // disable sta when starting ap, always bool _disableSTAConn = true; // disable sta when starting ap, if sta is not connected ( stability ) bool _channelSync = false; // use same wifi sta channel when starting ap - int32_t _apChannel = 0; // channel to use for ap + int32_t _apChannel = 0; // default channel to use for ap, 0 for auto bool _apHidden = false; // store softap hidden value uint16_t _httpPort = 80; // port for webserver // uint8_t _retryCount = 0; // counter for retries, probably not needed if synchronous uint8_t _connectRetries = 1; // number of sta connect retries, force reconnect, wait loop (connectimeout) does not always work and first disconnect bails - unsigned long _startconn = 0; // ms for timing wifi connects bool _aggresiveReconn = false; // use an agrressive reconnect strategy, WILL delay conxs // on some conn failure modes will add delays and many retries to work around esp and ap bugs, ie, anti de-auth protections bool _allowExit = true; // allow exit non blocking @@ -494,8 +496,8 @@ class WiFiManager // parameter options int _minimumQuality = -1; // filter wifiscan ap by this rssi - int _staShowStaticFields = 0; // ternary 1=always show static ip fields, 0=only if set, -1=never(cannot change ips via web!) - int _staShowDns = 0; // ternary 1=always show dns, 0=only if set, -1=never(cannot change dns via web!) + int _staShowStaticFields = 0; // ternary 1=always show static ip fields, 0=only if set, -1=never(cannot change ips via web!) + int _staShowDns = 0; // ternary 1=always show dns, 0=only if set, -1=never(cannot change dns via web!) boolean _removeDuplicateAPs = true; // remove dup aps from wifiscan boolean _showPassword = false; // show or hide saved password on wifi form, might be a security issue! boolean _shouldBreakAfterConfig = false; // stop configportal on save failure diff --git a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino index 169a8afe..fc8ec32b 100644 --- a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -243,6 +243,9 @@ void setup() { wifiInfo(); + // to preload autoconnect with credentials + // wm.preloadWiFi("ssid","password"); + if(!wm.autoConnect("WM_AutoConnectAP","12345678")) { Serial.println("failed to connect and hit timeout"); } From 590e212ddb4ff319fb6982ba9bd9c1e528d941f2 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Thu, 7 Apr 2022 08:41:57 -0500 Subject: [PATCH 030/100] better fix $1386 --- WiFiManager.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 5c24b1e9..40166c16 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -637,9 +637,8 @@ void WiFiManager::setupDNSD(){ } void WiFiManager::setupConfigPortal() { - setupHTTPServer(); - + _lastscan = 0; // reset network scan cache if(_preloadwifiscan) WiFi_scanNetworks(true,true); // preload wifiscan , async } @@ -1489,7 +1488,7 @@ bool WiFiManager::WiFi_scanNetworks(bool force,bool async){ String WiFiManager::WiFiManager::getScanItemOut(){ String page; - if(!_numNetworks) WiFi_scanNetworks(true); // scan in case this gets called before any scans + if(!_numNetworks) WiFi_scanNetworks(); // scan in case this gets called before any scans int n = _numNetworks; if (n == 0) { From 7bffda3fe67ae7d4cb567fbc6bfa7d4322871d29 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Fri, 8 Apr 2022 20:44:08 -0500 Subject: [PATCH 031/100] adds option to keep cfgp open on wifi save // if true (default) then stop the config portal from autoConnect when wifi is saved void setDisableConfigPortal(boolean enable); Name will change --- WiFiManager.cpp | 17 ++++++++++++++--- WiFiManager.h | 8 ++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 40166c16..577c800b 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -727,7 +727,7 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo if(!_configPortalIsBlocking){ #ifdef WM_DEBUG_LEVEL - DEBUG_WM(DEBUG_VERBOSE,F("Config Portal Running, non blocking/processing")); + DEBUG_WM(DEBUG_VERBOSE,F("Config Portal Running, non blocking (processing)")); if(_configPortalTimeout > 0) DEBUG_WM(DEBUG_VERBOSE,F("Portal Timeout In"),(String)(_configPortalTimeout/1000) + (String)F(" seconds")); #endif return result; // skip blocking loop @@ -850,7 +850,7 @@ uint8_t WiFiManager::processConfigPortal(){ _savewificallback(); } if(!_connectonsave) return WL_IDLE_STATUS; - shutdownConfigPortal(); + if(_disableConfigPortal) shutdownConfigPortal(); return WL_CONNECTED; // CONNECT SUCCESS } #ifdef WM_DEBUG_LEVEL @@ -869,7 +869,7 @@ uint8_t WiFiManager::processConfigPortal(){ #endif _savewificallback(); } - shutdownConfigPortal(); + if(_disableConfigPortal) shutdownConfigPortal(); return WL_CONNECT_FAILED; // CONNECT FAIL } else if(_configPortalIsBlocking){ @@ -2899,6 +2899,17 @@ void WiFiManager::setEnableConfigPortal(boolean enable) _enableConfigPortal = enable; } +/** + * toggle configportal if autoconnect failed + * if enabled, then the configportal will be de-activated on wifi save + * @since $dev + * @access public + * @param boolean enabled [true] + */ +void WiFiManager::setDisableConfigPortal(boolean enable) +{ + _disableConfigPortal = enable; +} /** * set the hostname (dhcp client id) diff --git a/WiFiManager.h b/WiFiManager.h index 1eaeb783..0c03607c 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -333,7 +333,10 @@ class WiFiManager // if true (default) then start the config portal from autoConnect if connection failed void setEnableConfigPortal(boolean enable); - + + // if true (default) then stop the config portal from autoConnect when wifi is saved + void setDisableConfigPortal(boolean enable); + // set a custom hostname, sets sta and ap dhcp client id for esp32, and sta for esp8266 bool setHostname(const char * hostname); bool setHostname(String hostname); @@ -512,7 +515,8 @@ class WiFiManager boolean _showInfoErase = true; // info page erase button boolean _showInfoUpdate = true; // info page update button boolean _showBack = false; // show back button - boolean _enableConfigPortal = true; // use config portal if autoconnect failed + boolean _enableConfigPortal = true; // FOR autoconnect - start config portal if autoconnect failed + boolean _disableConfigPortal = true; // FOR autoconnect - stop config portal if cp wifi save String _hostname = ""; // hostname for esp8266 for dhcp, and or MDNS const char* _customHeadElement = ""; // store custom head element html from user isnide From 483b83489b5d0638e0d17bba8490982778caea6e Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Mon, 11 Apr 2022 20:23:43 -0500 Subject: [PATCH 032/100] Fix #1383 --- WiFiManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 577c800b..31be71e6 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -3699,7 +3699,7 @@ void WiFiManager::WiFi_autoReconnect(){ DEBUG_WM(DEBUG_VERBOSE,F("ESP32 event handler enabled")); #endif using namespace std::placeholders; - if(wm_event_id !=0) wm_event_id = WiFi.onEvent(std::bind(&WiFiManager::WiFiEvent,this,_1,_2)); + if(wm_event_id == 0) wm_event_id = WiFi.onEvent(std::bind(&WiFiManager::WiFiEvent,this,_1,_2)); // } #endif } From cd01cbf77d559a424a1872d2595b550978330673 Mon Sep 17 00:00:00 2001 From: Ovidiu Pruteanu Date: Tue, 12 Apr 2022 16:11:31 +0300 Subject: [PATCH 033/100] Add .idea to .gitignore for JetBrains IDEs (#1391) --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 807b300c..4139bc4f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ .cache .pioenvs .piolibdeps +.idea .vscode !.vscode/extensions.json /platformio_override.ini From 13b43076f9d860468ee866bdb2001b519d65111e Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Thu, 14 Apr 2022 12:08:37 -0500 Subject: [PATCH 034/100] bump beta --- library.json | 2 +- library.properties | 2 +- strings_en.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library.json b/library.json index ae62724f..dfff70b2 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "WiFiManager", - "version": "2.0.10-beta", + "version": "2.0.11-beta", "keywords": "wifi,wi-fi,esp,esp8266,esp32,espressif8266,espressif32,nodemcu,wemos,arduino", "description": "WiFi Configuration manager with web configuration portal for ESP boards", "authors": diff --git a/library.properties b/library.properties index b81c4ac1..1c3a8ad1 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=WiFiManager -version=2.0.10-beta +version=2.0.11-beta author=tzapu maintainer=tablatronix sentence=WiFi Configuration manager with web configuration portal for Espressif ESPx boards, by tzapu diff --git a/strings_en.h b/strings_en.h index c37c38cd..771ef2bf 100644 --- a/strings_en.h +++ b/strings_en.h @@ -17,7 +17,7 @@ #ifndef WIFI_MANAGER_OVERRIDE_STRINGS // !!! ABOVE WILL NOT WORK if you define in your sketch, must be build flag, if anyone one knows how to order includes to be able to do this it would be neat.. I have seen it done.. -const char WM_VERSION_STR[] PROGMEM = "v1.0.10-beta"; +const char WM_VERSION_STR[] PROGMEM = "v1.0.11-beta"; const char HTTP_HEAD_START[] PROGMEM = "" "" From b7ca079d9dbc84ff4edf28973a2d45c863884676 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Tue, 19 Apr 2022 20:55:24 -0500 Subject: [PATCH 035/100] add favicon example --- .../OnDemandConfigPortal.ino | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino index fc8ec32b..49eae9ac 100644 --- a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -144,11 +144,21 @@ void setup() { custom_html.setValue("test",4); custom_token.setValue("test",4); + // const char* icon = " + // "; + + // set custom html head content , inside - const char* headhtml = ""; - wm.setCustomHeadElement(headhtml); + // examples of favicon, or meta tags etc + // const char* headhtml = ""; + // const char* headhtml = ""; + // wm.setCustomHeadElement(headhtml); - // set custom html menu content , inside + // set custom html menu content , inside menu item "custom", see setMenu() const char* menuhtml = "

\n"; wm.setCustomMenuHTML(menuhtml); From 833420fe9954d2fcb96e4d9a2e221ea2a5e5267f Mon Sep 17 00:00:00 2001 From: alexmaurer-madis Date: Tue, 3 May 2022 16:38:44 +0200 Subject: [PATCH 036/100] WM_VERSION_STR correction (used in About section) (#1407) From "v1.0.11-beta" to "v2.0.11-beta" I think the major version was forgotten to be updated. --- strings_en.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings_en.h b/strings_en.h index 771ef2bf..68277193 100644 --- a/strings_en.h +++ b/strings_en.h @@ -17,7 +17,7 @@ #ifndef WIFI_MANAGER_OVERRIDE_STRINGS // !!! ABOVE WILL NOT WORK if you define in your sketch, must be build flag, if anyone one knows how to order includes to be able to do this it would be neat.. I have seen it done.. -const char WM_VERSION_STR[] PROGMEM = "v1.0.11-beta"; +const char WM_VERSION_STR[] PROGMEM = "v2.0.11-beta"; const char HTTP_HEAD_START[] PROGMEM = "" "" From 8d34744b2956672b56ee5c85af9952f634faa7be Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Sun, 8 May 2022 09:24:28 -0500 Subject: [PATCH 037/100] fixes #1414 added a prefix to macros --- WiFiManager.cpp | 28 ++++++++++++++-------------- WiFiManager.h | 30 +++++++++++++++--------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 31be71e6..a1d41dd6 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -601,22 +601,22 @@ void WiFiManager::setupHTTPServer(){ /* Setup httpd callbacks, web pages: root, wifi config pages, SO captive portal detectors and not found. */ // G macro workaround for Uri() bug https://github.com/esp8266/Arduino/issues/7102 - server->on(G(R_root), std::bind(&WiFiManager::handleRoot, this)); - server->on(G(R_wifi), std::bind(&WiFiManager::handleWifi, this, true)); - server->on(G(R_wifinoscan), std::bind(&WiFiManager::handleWifi, this, false)); - server->on(G(R_wifisave), std::bind(&WiFiManager::handleWifiSave, this)); - server->on(G(R_info), std::bind(&WiFiManager::handleInfo, this)); - server->on(G(R_param), std::bind(&WiFiManager::handleParam, this)); - server->on(G(R_paramsave), std::bind(&WiFiManager::handleParamSave, this)); - server->on(G(R_restart), std::bind(&WiFiManager::handleReset, this)); - server->on(G(R_exit), std::bind(&WiFiManager::handleExit, this)); - server->on(G(R_close), std::bind(&WiFiManager::handleClose, this)); - server->on(G(R_erase), std::bind(&WiFiManager::handleErase, this, false)); - server->on(G(R_status), std::bind(&WiFiManager::handleWiFiStatus, this)); + server->on(WM_G(R_root), std::bind(&WiFiManager::handleRoot, this)); + server->on(WM_G(R_wifi), std::bind(&WiFiManager::handleWifi, this, true)); + server->on(WM_G(R_wifinoscan), std::bind(&WiFiManager::handleWifi, this, false)); + server->on(WM_G(R_wifisave), std::bind(&WiFiManager::handleWifiSave, this)); + server->on(WM_G(R_info), std::bind(&WiFiManager::handleInfo, this)); + server->on(WM_G(R_param), std::bind(&WiFiManager::handleParam, this)); + server->on(WM_G(R_paramsave), std::bind(&WiFiManager::handleParamSave, this)); + server->on(WM_G(R_restart), std::bind(&WiFiManager::handleReset, this)); + server->on(WM_G(R_exit), std::bind(&WiFiManager::handleExit, this)); + server->on(WM_G(R_close), std::bind(&WiFiManager::handleClose, this)); + server->on(WM_G(R_erase), std::bind(&WiFiManager::handleErase, this, false)); + server->on(WM_G(R_status), std::bind(&WiFiManager::handleWiFiStatus, this)); server->onNotFound (std::bind(&WiFiManager::handleNotFound, this)); - server->on(G(R_update), std::bind(&WiFiManager::handleUpdate, this)); - server->on(G(R_updatedone), HTTP_POST, std::bind(&WiFiManager::handleUpdateDone, this), std::bind(&WiFiManager::handleUpdating, this)); + server->on(WM_G(R_update), std::bind(&WiFiManager::handleUpdate, this)); + server->on(WM_G(R_updatedone), HTTP_POST, std::bind(&WiFiManager::handleUpdateDone, this), std::bind(&WiFiManager::handleUpdating, this)); server->begin(); // Web server start #ifdef WM_DEBUG_LEVEL diff --git a/WiFiManager.h b/WiFiManager.h index 0c03607c..60e4c0c7 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -46,31 +46,31 @@ #define WM_WEBSERVERSHIM // use webserver shim lib -#define G(string_literal) (String(FPSTR(string_literal)).c_str()) +#define WM_G(string_literal) (String(FPSTR(string_literal)).c_str()) -#define STRING2(x) #x -#define STRING(x) STRING2(x) +#define WM_STRING2(x) #x +#define WM_STRING(x) STRING2(x) // #include #ifdef ESP_IDF_VERSION - // #pragma message "ESP_IDF_VERSION_MAJOR = " STRING(ESP_IDF_VERSION_MAJOR) - // #pragma message "ESP_IDF_VERSION_MINOR = " STRING(ESP_IDF_VERSION_MINOR) - // #pragma message "ESP_IDF_VERSION_PATCH = " STRING(ESP_IDF_VERSION_PATCH) - #define VER_IDF_STR STRING(ESP_IDF_VERSION_MAJOR) "." STRING(ESP_IDF_VERSION_MINOR) "." STRING(ESP_IDF_VERSION_PATCH) + // #pragma message "ESP_IDF_VERSION_MAJOR = " WM_STRING(ESP_IDF_VERSION_MAJOR) + // #pragma message "ESP_IDF_VERSION_MINOR = " WM_STRING(ESP_IDF_VERSION_MINOR) + // #pragma message "ESP_IDF_VERSION_PATCH = " WM_STRING(ESP_IDF_VERSION_PATCH) + #define VER_IDF_STR WM_STRING(ESP_IDF_VERSION_MAJOR) "." WM_STRING(ESP_IDF_VERSION_MINOR) "." WM_STRING(ESP_IDF_VERSION_PATCH) #endif // #include "esp_arduino_version.h" #ifdef ESP_ARDUINO_VERSION - // #pragma message "ESP_ARDUINO_VERSION_MAJOR = " STRING(ESP_ARDUINO_VERSION_MAJOR) - // #pragma message "ESP_ARDUINO_VERSION_MINOR = " STRING(ESP_ARDUINO_VERSION_MINOR) - // #pragma message "ESP_ARDUINO_VERSION_PATCH = " STRING(ESP_ARDUINO_VERSION_PATCH) - #define VER_ARDUINO_STR STRING(ESP_ARDUINO_VERSION_MAJOR) "." STRING(ESP_ARDUINO_VERSION_MINOR) "." STRING(ESP_ARDUINO_VERSION_PATCH) + // #pragma message "ESP_ARDUINO_VERSION_MAJOR = " WM_STRING(ESP_ARDUINO_VERSION_MAJOR) + // #pragma message "ESP_ARDUINO_VERSION_MINOR = " WM_STRING(ESP_ARDUINO_VERSION_MINOR) + // #pragma message "ESP_ARDUINO_VERSION_PATCH = " WM_STRING(ESP_ARDUINO_VERSION_PATCH) + #define VER_ARDUINO_STR WM_STRING(ESP_ARDUINO_VERSION_MAJOR) "." WM_STRING(ESP_ARDUINO_VERSION_MINOR) "." WM_STRING(ESP_ARDUINO_VERSION_PATCH) #else // #include - // #pragma message "ESP_ARDUINO_VERSION_GIT = " STRING(ARDUINO_ESP32_GIT_VER)// 0x46d5afb1 - // #pragma message "ESP_ARDUINO_VERSION_DESC = " STRING(ARDUINO_ESP32_GIT_DESC) // 1.0.6 + // #pragma message "ESP_ARDUINO_VERSION_GIT = " WM_STRING(ARDUINO_ESP32_GIT_VER)// 0x46d5afb1 + // #pragma message "ESP_ARDUINO_VERSION_DESC = " WM_STRING(ARDUINO_ESP32_GIT_DESC) // 1.0.6 #define VER_ARDUINO_STR "Unknown" - // #pragma message "ESP_ARDUINO_VERSION_REL = " STRING(ARDUINO_ESP32_RELEASE) //"1_0_6" + // #pragma message "ESP_ARDUINO_VERSION_REL = " WM_STRING(ARDUINO_ESP32_RELEASE) //"1_0_6" #endif #ifdef ESP8266 @@ -484,7 +484,7 @@ class WiFiManager uint16_t _httpPort = 80; // port for webserver // uint8_t _retryCount = 0; // counter for retries, probably not needed if synchronous uint8_t _connectRetries = 1; // number of sta connect retries, force reconnect, wait loop (connectimeout) does not always work and first disconnect bails - bool _aggresiveReconn = false; // use an agrressive reconnect strategy, WILL delay conxs + bool _aggresiveReconn = true; // use an agrressive reconnect strategy, WILL delay conxs // on some conn failure modes will add delays and many retries to work around esp and ap bugs, ie, anti de-auth protections bool _allowExit = true; // allow exit non blocking From 86e413dc2aff663245a2d932efc5f3a9fe663c3b Mon Sep 17 00:00:00 2001 From: Anthony Bryant Date: Sun, 8 May 2022 15:27:17 +0100 Subject: [PATCH 038/100] Escape single quotes in htmlEntities() (#1413) This should allow SSIDs that contain single quotes to populate data-ssid correctly. Without this patch, clicking on an SSID containing a single quote will either: * Not use the whole SSID, in cases where there's text before the quote: `foo'bar` will appear in the SSID box as just `foo` * Fall back to innerText, in cases where the quote is the first character in the SSID: `'); DROP TABLE WIFI; --` will appear in the SSID box as a version that has spaces converted to non-breaking spaces, causing the connection to eventually fail with WL_NO_SSID_AVAIL. --- WiFiManager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index a1d41dd6..dc10035e 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -3363,6 +3363,7 @@ String WiFiManager::htmlEntities(String str, bool whitespace) { str.replace("&","&"); str.replace("<","<"); str.replace(">",">"); + str.replace("'","'"); if(whitespace) str.replace(" "," "); // str.replace("-","–"); // str.replace("\"","""); From 137410e184e1c9990dd1523deb77b06ccc55555e Mon Sep 17 00:00:00 2001 From: Michael Ammann Date: Sun, 8 May 2022 16:28:07 +0200 Subject: [PATCH 039/100] Silence debug output (#1404) This is probably a left over from debugging, can we remove or at least move it to a DEBUG_WM --- WiFiManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index dc10035e..1cfcd6f1 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -1667,7 +1667,7 @@ String WiFiManager::getParamOut(){ char valLength[5]; for (int i = 0; i < _paramsCount; i++) { - Serial.println((String)_params[i]->_length); + //Serial.println((String)_params[i]->_length); if (_params[i] == NULL || _params[i]->_length == 0 || _params[i]->_length > 99999) { // try to detect param scope issues, doesnt always catch but works ok #ifdef WM_DEBUG_LEVEL From e7bb9bc28e071cf06697d0b4e03f8d94ada0720c Mon Sep 17 00:00:00 2001 From: Perry Date: Sun, 8 May 2022 07:30:33 -0700 Subject: [PATCH 040/100] Change Stream to Print (#1307) * Change Stream to Print 1/2 Update WifiManager to use base class Print instead of Stream. I debug into a custom buffer, and that buffer implements Print, but not Stream. * Change Stream to Print 2/2 Update WifiManager to use base class Print instead of Stream. I debug into a custom buffer, and that buffer implements Print, but not Stream. --- WiFiManager.cpp | 2 +- WiFiManager.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 1cfcd6f1..7576e4ff 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -199,7 +199,7 @@ int WiFiManager::getParametersCount() { **/ // constructors -WiFiManager::WiFiManager(Stream& consolePort):_debugPort(consolePort){ +WiFiManager::WiFiManager(Print& consolePort):_debugPort(consolePort){ WiFiManagerInit(); } diff --git a/WiFiManager.h b/WiFiManager.h index 60e4c0c7..9016ace9 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -179,7 +179,7 @@ class WiFiManagerParameter { class WiFiManager { public: - WiFiManager(Stream& consolePort); + WiFiManager(Print& consolePort); WiFiManager(); ~WiFiManager(); void WiFiManagerInit(); @@ -706,9 +706,9 @@ class WiFiManager // @todo use DEBUG_ESP_PORT ? #ifdef WM_DEBUG_PORT - Stream& _debugPort = WM_DEBUG_PORT; + Print& _debugPort = WM_DEBUG_PORT; #else - Stream& _debugPort = Serial; // debug output stream ref + Print& _debugPort = Serial; // debug output stream ref #endif template From c56eec9018f93e491011bfa374fb944ee26a7ef7 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Sun, 15 May 2022 08:26:04 -0500 Subject: [PATCH 041/100] change css disabled for all --- strings_en.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings_en.h b/strings_en.h index 68277193..a656ef6d 100644 --- a/strings_en.h +++ b/strings_en.h @@ -110,7 +110,7 @@ const char HTTP_STYLE[] PROGMEM = ""; #ifndef WM_NOHELP From 9c7fed4fe1d4896a1e9cefeccc29df5a3cbb5618 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Sun, 15 May 2022 08:29:51 -0500 Subject: [PATCH 042/100] update template --- extras/WiFiManager.template.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/extras/WiFiManager.template.html b/extras/WiFiManager.template.html index e0643ecd..8d3589ee 100644 --- a/extras/WiFiManager.template.html +++ b/extras/WiFiManager.template.html @@ -192,9 +192,8 @@ /*opacity: 80%;*/ } -input:disabled { +:disabled { opacity: 0.5; - /* not working in cp ?? */ } From c6e2b1b349d8532838443c6b1c18400c7902a9aa Mon Sep 17 00:00:00 2001 From: JoergAJ <84235628+JoergAJ@users.noreply.github.com> Date: Thu, 16 Jun 2022 22:33:51 +0200 Subject: [PATCH 043/100] Updated links in README.md (#1431) * Update README.md Updated links to examples * Update README.md Updated links * Update README.md * Update README.md * Update README.md --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2d6ab656..d5d30687 100644 --- a/README.md +++ b/README.md @@ -171,8 +171,8 @@ Also see [examples](https://github.com/tzapu/WiFiManager/tree/master/examples). [PlatformIO](https://platformio.org/) is an emerging ecosystem for IoT development, and is an alternative to using the Arduino IDE. Install `WiFiManager` -using the platformio [library manager](https://docs.platformio.org/en/latest/librarymanager/index.htm) in your editor, -or using the [PlatformIO Core CLI](https://docs.platformio.org/en/latest/userguide/demo.html#library-manager), +using the platformio [library manager](https://docs.platformio.org/en/latest/librarymanager/index.html#librarymanager) in your editor, +or using the [PlatformIO Core CLI](https://docs.platformio.org/en/latest/core/index.html), or by adding it to your `platformio.ini` as shown below (recommended approach). The simplest way is to open the `platformio.ini` file at the root of your project, and `WifiManager` to the common top-level env @@ -229,7 +229,7 @@ IF YOU NEED TO SAVE PARAMETERS EVEN ON WIFI FAIL OR EMPTY, you must set `setBrea void setBreakAfterConfig(boolean shouldBreak); ``` -See [AutoConnectWithFSParameters Example](https://github.com/tzapu/WiFiManager/tree/master/examples/AutoConnectWithFSParameters). +See [AutoConnectWithFSParameters Example](https://github.com/tzapu/WiFiManager/tree/master/examples/Parameters/SPIFFS/AutoConnectWithFSParameters). ```cpp wifiManager.setSaveConfigCallback(saveConfigCallback); ``` @@ -269,7 +269,7 @@ void loop() { } } ``` -See example for a more complex version. [OnDemandConfigPortal](https://github.com/tzapu/WiFiManager/tree/master/examples/OnDemandConfigPortal) +See example for a more complex version. [OnDemandConfigPortal](https://github.com/tzapu/WiFiManager/tree/master/examples/OnDemand/OnDemandConfigPortal) #### Exiting from the Configuration Portal Normally, once entered, the configuration portal will continue to loop until WiFi credentials have been successfully entered or a timeout is reached. @@ -291,7 +291,7 @@ Usage scenario would be: ``` - if connection to AP fails, configuration portal starts and you can set /change the values (or use on demand configuration portal) -- once configuration is done and connection is established [save config callback]() is called +- once configuration is done and connection is established save config callback() is called - once WiFiManager returns control to your application, read and save the new values using the `WiFiManagerParameter` object. ```cpp mqtt_server = custom_mqtt_server.getValue(); @@ -299,7 +299,7 @@ Usage scenario would be: This feature is a lot more involved than all the others, so here are some examples to fully show how it is done. You should also take a look at adding custom HTML to your form. -- Save and load custom parameters to file system in json form [AutoConnectWithFSParameters](https://github.com/tzapu/WiFiManager/tree/master/examples/AutoConnectWithFSParameters) +- Save and load custom parameters to file system in json form [AutoConnectWithFSParameters](https://github.com/tzapu/WiFiManager/tree/master/examples/Parameters/SPIFFS/AutoConnectWithFSParameters) - *Save and load custom parameters to EEPROM* (not done yet) #### Custom IP Configuration From 0ab747c62a032f7370f5ccd4a92cf30359d6f2e2 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Fri, 17 Jun 2022 11:13:39 -0500 Subject: [PATCH 044/100] going through todos --- WiFiManager.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 7576e4ff..cbff2a62 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -226,7 +226,7 @@ WiFiManager::~WiFiManager() { _params = NULL; } - // @todo remove event + // remove event // WiFi.onEvent(std::bind(&WiFiManager::WiFiEvent,this,_1,_2)); #ifdef ESP32 WiFi.removeEvent(wm_event_id); @@ -312,7 +312,7 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { DEBUG_WM(F("AutoConnect: ESP Already Connected")); #endif setSTAConfig(); - // @todo not sure if this check makes sense, causes dup setSTAConfig in connectwifi, + // @todo not sure if this is safe, causes dup setSTAConfig in connectwifi, // and we have no idea WHAT we are connected to } @@ -486,7 +486,7 @@ bool WiFiManager::startAP(){ if(_debugLevel >= DEBUG_DEV) debugSoftAPConfig(); - // @todo add softAP retry here + // @todo add softAP retry here to dela with unknown failures delay(500); // slight delay to make sure we get an AP IP #ifdef WM_DEBUG_LEVEL @@ -677,7 +677,6 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo if(!validApPassword()) return false; // HANDLE issues with STA connections, shutdown sta if not connected, or else this will hang channel scanning and softap will not respond - // @todo sometimes still cannot connect to AP for no known reason, no events in log either if(_disableSTA || (!WiFi.isConnected() && _disableSTAConn)){ // this fixes most ap problems, however, simply doing mode(WIFI_AP) does not work if sta connection is hanging, must `wifi_station_disconnect` WiFi_Disconnect(); @@ -687,7 +686,6 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo #endif } else { - // @todo even if sta is connected, it is possible that softap connections will fail, IOS says "invalid password", windows says "cannot connect to this network" researching WiFi_enableSTA(true); } @@ -756,6 +754,7 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo // status change, break // @todo what is this for, should be moved inside the processor + // I think.. this is to detect autoconnect by esp in background, there are also many open issues about autoreconnect not working if(state != WL_IDLE_STATUS){ result = (state == WL_CONNECTED); // true if connected DEBUG_WM(DEBUG_DEV,F("configportal loop break")); @@ -914,6 +913,7 @@ bool WiFiManager::shutdownConfigPortal(){ server->handleClient(); // @todo what is the proper way to shutdown and free the server up + // debug - many open issues aobut port not clearing for use with other servers server->stop(); server.reset(); @@ -971,7 +971,7 @@ uint8_t WiFiManager::connectWifi(String ssid, String pass, bool connect) { // make sure sta is on before `begin` so it does not call enablesta->mode while persistent is ON ( which would save WM AP state to eeprom !) // WiFi.setAutoReconnect(false); if(_cleanConnect) WiFi_Disconnect(); // disconnect before begin, in case anything is hung, this causes a 2 seconds delay for connect - // @todo find out what status is when this is needed, can we detect it and handle it, say in between states or idle_status + // @todo find out what status is when this is needed, can we detect it and handle it, say in between states or idle_status to avoid these // if retry without delay (via begin()), the IDF is still busy even after returning status // E (5130) wifi:sta is connecting, return error @@ -3343,7 +3343,7 @@ boolean WiFiManager::validApPassword(){ DEBUG_WM(F("AccessPoint set password is INVALID or <8 chars")); #endif _apPassword = ""; - return false; // @todo FATAL or fallback to empty ? + return false; // @todo FATAL or fallback to empty , currently fatal, fail secure. } #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_VERBOSE,F("AccessPoint set password is VALID")); @@ -3423,7 +3423,7 @@ bool WiFiManager::WiFiSetCountry(){ // ret = esp_wifi_set_bandwidth(WIFI_IF_AP,WIFI_BW_HT20); // WIFI_BW_HT40 #ifdef ESP32 esp_err_t err = ESP_OK; - // @todo check if wifi is init, no idea how, doesnt seem to be exposed atm ( might be now! ) + // @todo check if wifi is init, no idea how, doesnt seem to be exposed atm ( check again it might be now! ) if(WiFi.getMode() == WIFI_MODE_NULL){ DEBUG_WM(DEBUG_ERROR,"[ERROR] cannot set country, wifi not init"); } // exception if wifi not init! @@ -3473,7 +3473,7 @@ bool WiFiManager::WiFi_Mode(WiFiMode_t m,bool persistent) { return ret; #elif defined(ESP32) if(persistent && esp32persistent) WiFi.persistent(true); - ret = WiFi.mode(m); // @todo persistent check persistant mode , NI + ret = WiFi.mode(m); // @todo persistent check persistant mode, was eventually added to esp lib, but have to add version checking probably if(persistent && esp32persistent) WiFi.persistent(false); return ret; #endif @@ -3490,7 +3490,7 @@ bool WiFiManager::WiFi_Disconnect() { #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_DEV,F("WiFi station disconnect")); #endif - ETS_UART_INTR_DISABLE(); // @todo probably not needed + ETS_UART_INTR_DISABLE(); // @todo possibly not needed ret = wifi_station_disconnect(); ETS_UART_INTR_ENABLE(); return ret; From ca4b63220c1cc60e97f36b05593c7ff0c5834a9d Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Fri, 17 Jun 2022 11:36:21 -0500 Subject: [PATCH 045/100] remove double non blocking timeout handler --- WiFiManager.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index cbff2a62..d66da7cc 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -783,12 +783,7 @@ boolean WiFiManager::process(){ MDNS.update(); #endif - if(configPortalActive && !_configPortalIsBlocking){ - if(configPortalHasTimeout()) shutdownConfigPortal(); - } - if(webPortalActive || (configPortalActive && !_configPortalIsBlocking)){ - // if timed out or abort, break if(_allowExit && (configPortalHasTimeout() || abort)){ #ifdef WM_DEBUG_LEVEL From b257590e98508655c1d037e11cfea63d79997f9a Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Fri, 17 Jun 2022 11:46:49 -0500 Subject: [PATCH 046/100] comments --- WiFiManager.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/WiFiManager.h b/WiFiManager.h index 9016ace9..ad11faf6 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -486,7 +486,8 @@ class WiFiManager uint8_t _connectRetries = 1; // number of sta connect retries, force reconnect, wait loop (connectimeout) does not always work and first disconnect bails bool _aggresiveReconn = true; // use an agrressive reconnect strategy, WILL delay conxs // on some conn failure modes will add delays and many retries to work around esp and ap bugs, ie, anti de-auth protections - bool _allowExit = true; // allow exit non blocking + // https://github.com/tzapu/WiFiManager/issues/1067 + bool _allowExit = true; // allow exit in nonblocking, else user exit/abort calls will be ignored including cptimeout #ifdef ESP32 wifi_event_id_t wm_event_id = 0; @@ -527,6 +528,7 @@ class WiFiManager // internal options // wifiscan notes + // currently disabled due to issues with caching, sometimes first scan is empty esp32 wifi not init yet race, or portals hit server nonstop flood // The following are background wifi scanning optimizations // experimental to make scans faster, preload scans after starting cp, and visiting home page, so when you click wifi its already has your list // ideally we would add async and xhr here but I am holding off on js requirements atm From 1af8f4540d29094aaf2e81e90a070d7111dd4e8f Mon Sep 17 00:00:00 2001 From: Martijn Hendriks Date: Fri, 17 Jun 2022 19:35:17 +0200 Subject: [PATCH 047/100] Update strings_en.h (#1430) show/hide wifi password during input --- strings_en.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/strings_en.h b/strings_en.h index a656ef6d..bc487f8c 100644 --- a/strings_en.h +++ b/strings_en.h @@ -30,7 +30,9 @@ const char HTTP_SCRIPT[] PROGMEM = ""; // @todo add button states, disable on click , show ack , spinner etc +"if(p)document.getElementById('p').focus();};" +"function f() {var x = document.getElementById('p');x.type==='password'?x.type='text':x.type='password';}" +""; // @todo add button states, disable on click , show ack , spinner etc const char HTTP_HEAD_END[] PROGMEM = "
"; // {c} = _bodyclass // example of embedded logo, base64 encoded inline, No styling here @@ -58,7 +60,7 @@ const char HTTP_ITEM[] PROGMEM = "
{v} {R} {r}% {q} {e}
"; // test all tokens const char HTTP_FORM_START[] PROGMEM = "
"; -const char HTTP_FORM_WIFI[] PROGMEM = "
"; +const char HTTP_FORM_WIFI[] PROGMEM = "
Show Password"; const char HTTP_FORM_WIFI_END[] PROGMEM = ""; const char HTTP_FORM_STATIC_HEAD[] PROGMEM = "

"; const char HTTP_FORM_END[] PROGMEM = "

"; From 7078bd1786c02a0d4da33772a534eedf20069288 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Fri, 17 Jun 2022 12:35:53 -0500 Subject: [PATCH 048/100] add template js #1430 --- extras/WiFiManager.template.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extras/WiFiManager.template.html b/extras/WiFiManager.template.html index 8d3589ee..d928a8c6 100644 --- a/extras/WiFiManager.template.html +++ b/extras/WiFiManager.template.html @@ -203,6 +203,7 @@ p = l.nextElementSibling.classList.contains('l'); document.getElementById('p').disabled = !p; if(p)document.getElementById('p').focus()}; + function f() {var x = document.getElementById('p');x.type==='password'?x.type='text':x.type='password';} @@ -250,7 +251,7 @@

/wifi


-



+

Show Password

custom parameter


From b5671834e4934b401a24fd5863661f54ada402e6 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Fri, 17 Jun 2022 13:50:33 -0500 Subject: [PATCH 049/100] Moves presavecallback after static ip copy #1429 --- WiFiManager.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index d66da7cc..91b691a4 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -594,7 +594,7 @@ void WiFiManager::setupHTTPServer(){ #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_VERBOSE,F("[CB] _webservercallback calling")); #endif - _webservercallback(); + _webservercallback(); // @CALLBACK } // @todo add a new callback maybe, after webserver started, callback cannot override handlers, but can grab them first @@ -841,7 +841,7 @@ uint8_t WiFiManager::processConfigPortal(){ #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_VERBOSE,F("[CB] _savewificallback calling")); #endif - _savewificallback(); + _savewificallback(); // @CALLBACK } if(!_connectonsave) return WL_IDLE_STATUS; if(_disableConfigPortal) shutdownConfigPortal(); @@ -861,7 +861,7 @@ uint8_t WiFiManager::processConfigPortal(){ #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_VERBOSE,F("[CB] WiFi/Param save callback")); #endif - _savewificallback(); + _savewificallback(); // @CALLBACK } if(_disableConfigPortal) shutdownConfigPortal(); return WL_CONNECT_FAILED; // CONNECT FAIL @@ -1738,17 +1738,11 @@ void WiFiManager::handleWifiSave() { #endif handleRequest(); - // @todo use new callback for before paramsaves - if (!_paramsInWifi && _presavecallback != NULL) { - _presavecallback(); - } - //SAVE/connect here _ssid = server->arg(F("s")).c_str(); _pass = server->arg(F("p")).c_str(); - if(_paramsInWifi) doParamSave(); - + // set static ips from server args if (server->arg(FPSTR(S_ip)) != "") { //_sta_static_ip.fromString(server->arg(FPSTR(S_ip)); String ip = server->arg(FPSTR(S_ip)); @@ -1779,6 +1773,13 @@ void WiFiManager::handleWifiSave() { #endif } + // @todo use new callback for before paramsaves + if (!_paramsInWifi && _presavecallback != NULL) { + _presavecallback(); // @CALLBACK + } + + if(_paramsInWifi) doParamSave(); + String page; if(_ssid == ""){ @@ -1827,7 +1828,7 @@ void WiFiManager::handleParamSave() { void WiFiManager::doParamSave(){ // @todo use new callback for before paramsaves, is this really needed? if ( _presavecallback != NULL) { - _presavecallback(); + _presavecallback(); // @CALLBACK } //parameters @@ -1865,7 +1866,7 @@ void WiFiManager::doParamSave(){ } if ( _saveparamscallback != NULL) { - _saveparamscallback(); + _saveparamscallback(); // @CALLBACK } } @@ -2511,7 +2512,7 @@ void WiFiManager::resetSettings() { WiFi_enableSTA(true,true); // must be sta to disconnect erase delay(500); // ensure sta is enabled if (_resetcallback != NULL){ - _resetcallback(); + _resetcallback(); // @CALLBACK } #ifdef ESP32 @@ -3747,7 +3748,7 @@ void WiFiManager::handleUpdating(){ // Use new callback for before OTA update if (_preotaupdatecallback != NULL) { - _preotaupdatecallback(); + _preotaupdatecallback(); // @CALLBACK } #ifdef ESP8266 WiFiUDP::stopAll(); From 317c026952173d03fdb6d310a43fc70b3f232e80 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Fri, 17 Jun 2022 14:07:11 -0500 Subject: [PATCH 050/100] adds setPreSaveParamsCallback //called when saving params before anything else happens void setPreSaveParamsCallback( std::function func ); --- WiFiManager.cpp | 18 +++++++++++++----- WiFiManager.h | 10 +++++++--- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 91b691a4..9e8dcb4b 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -1773,11 +1773,10 @@ void WiFiManager::handleWifiSave() { #endif } - // @todo use new callback for before paramsaves - if (!_paramsInWifi && _presavecallback != NULL) { + if (_presavecallback != NULL) { _presavecallback(); // @CALLBACK } - + if(_paramsInWifi) doParamSave(); String page; @@ -1827,8 +1826,8 @@ void WiFiManager::handleParamSave() { void WiFiManager::doParamSave(){ // @todo use new callback for before paramsaves, is this really needed? - if ( _presavecallback != NULL) { - _presavecallback(); // @CALLBACK + if ( _presaveparamscallback != NULL) { + _presaveparamscallback(); // @CALLBACK } //parameters @@ -2713,6 +2712,15 @@ void WiFiManager::setSaveParamsCallback( std::function func ) { _saveparamscallback = func; } +/** + * setPreSaveParamsCallback, set a pre save params callback on params save prior to anything else + * @access public + * @param {[type]} void (*func)(void) + */ +void WiFiManager::setPreSaveParamsCallback( std::function func ) { + _presaveparamscallback = func; +} + /** * setPreSaveConfigCallback, set a callback to fire before saving wifi or params * @access public diff --git a/WiFiManager.h b/WiFiManager.h index ad11faf6..81c3c4f8 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -244,12 +244,15 @@ class WiFiManager //called when wifi settings have been changed and connection was successful ( or setBreakAfterConfig(true) ) void setSaveConfigCallback( std::function func ); - //called when saving either params-in-wifi or params page - void setSaveParamsCallback( std::function func ); - //called when saving params-in-wifi or params before anything else happens (eg wifi) void setPreSaveConfigCallback( std::function func ); + //called when saving params before anything else happens + void setPreSaveParamsCallback( std::function func ); + + //called when saving either params-in-wifi or params page + void setSaveParamsCallback( std::function func ); + //called just before doing OTA update void setPreOtaUpdateCallback( std::function func ); @@ -729,6 +732,7 @@ class WiFiManager std::function _webservercallback; std::function _savewificallback; std::function _presavecallback; + std::function _presaveparamscallback; std::function _saveparamscallback; std::function _resetcallback; std::function _preotaupdatecallback; From a2c33744f65450b1cf1933def268df62988cbad3 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Fri, 17 Jun 2022 14:21:13 -0500 Subject: [PATCH 051/100] rename wifi callbacks --- WiFiManager.cpp | 22 +++++++++++----------- WiFiManager.h | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 9e8dcb4b..fbcbbd9c 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -1773,8 +1773,8 @@ void WiFiManager::handleWifiSave() { #endif } - if (_presavecallback != NULL) { - _presavecallback(); // @CALLBACK + if (_presavewificallback != NULL) { + _presavewificallback(); // @CALLBACK } if(_paramsInWifi) doParamSave(); @@ -2694,6 +2694,15 @@ void WiFiManager::setSaveConfigCallback( std::function func ) { _savewificallback = func; } +/** + * setPreSaveConfigCallback, set a callback to fire before saving wifi or params + * @access public + * @param {[type]} void (*func)(void) + */ +void WiFiManager::setPreSaveConfigCallback( std::function func ) { + _presavewificallback = func; +} + /** * setConfigResetCallback, set a callback to occur when a resetSettings() occurs * @access public @@ -2721,15 +2730,6 @@ void WiFiManager::setPreSaveParamsCallback( std::function func ) { _presaveparamscallback = func; } -/** - * setPreSaveConfigCallback, set a callback to fire before saving wifi or params - * @access public - * @param {[type]} void (*func)(void) - */ -void WiFiManager::setPreSaveConfigCallback( std::function func ) { - _presavecallback = func; -} - /** * setPreOtaUpdateCallback, set a callback to fire before OTA update * @access public diff --git a/WiFiManager.h b/WiFiManager.h index 81c3c4f8..5a2c0d60 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -731,7 +731,7 @@ class WiFiManager std::function _apcallback; std::function _webservercallback; std::function _savewificallback; - std::function _presavecallback; + std::function _presavewificallback; std::function _presaveparamscallback; std::function _saveparamscallback; std::function _resetcallback; From f9a47786b7d3009e7066f96315c833daf7976a0b Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Mon, 20 Jun 2022 22:12:52 -0500 Subject: [PATCH 052/100] adds otacallback and progress example callback for Update lib #1435 --- .../OnDemandConfigPortal.ino | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino index 49eae9ac..95767176 100644 --- a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -34,6 +34,21 @@ bool WMISBLOCKING = true; // use blocking or non blocking mode, non global pa // char ssid[] = "*************"; // your network SSID (name) // char pass[] = "********"; // your network password + // called after AP mode and config portal has started + // setAPCallback( std::function func ); + // called after webserver has started + // setWebServerCallback( std::function func ); + // called when settings reset have been triggered + // setConfigResetCallback( std::function func ); + // called when wifi settings have been changed and connection was successful ( or setBreakAfterConfig(true) ) + // setSaveConfigCallback( std::function func ); + // called when saving either params-in-wifi or params page + // setSaveParamsCallback( std::function func ); + // called when saving params-in-wifi or params before anything else happens (eg wifi) + // setPreSaveConfigCallback( std::function func ); + // called just before doing OTA update + // setPreOtaUpdateCallback( std::function func ); + void saveWifiCallback(){ Serial.println("[CALLBACK] saveCallback fired"); } @@ -64,6 +79,12 @@ void handleRoute(){ wm.server->send(200, "text/plain", "hello from user code"); } +void handlePreOtaUpdateCallback(){ + Update.onProgress([](unsigned int progress, unsigned int total) { + Serial.printf("CUSTOM Progress: %u%%\r", (progress / (total / 100))); + }); +} + void setup() { // WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP @@ -128,6 +149,7 @@ void setup() { wm.setWebServerCallback(bindServerCallback); wm.setSaveConfigCallback(saveWifiCallback); wm.setSaveParamsCallback(saveParamCallback); + wm.setPreOtaUpdateCallback(handlePreOtaUpdateCallback); // add all your parameters here wm.addParameter(&custom_html); From b05a71b618406ffda633736b1a1c4a69a6b4794b Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Mon, 20 Jun 2022 22:13:30 -0500 Subject: [PATCH 053/100] add comments for httpupdate callbacks --- WiFiManager.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 7576e4ff..67761adb 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -3768,6 +3768,11 @@ void WiFiManager::handleUpdating(){ DEBUG_WM(DEBUG_VERBOSE,"Update file: ", upload.filename.c_str()); #endif + // Update.onProgress(THandlerFunction_Progress fn); + // Update.onProgress([](unsigned int progress, unsigned int total) { + // Serial.printf("Progress: %u%%\r", (progress / (total / 100))); + // }); + if (!Update.begin(maxSketchSpace)) { // start with max available size #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_ERROR,F("[ERROR] OTA Update ERROR"), Update.getError()); @@ -3778,7 +3783,7 @@ void WiFiManager::handleUpdating(){ } // UPLOAD WRITE else if (upload.status == UPLOAD_FILE_WRITE) { - Serial.print("."); + // Serial.print("."); if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) { #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_ERROR,F("[ERROR] OTA Update WRITE ERROR"), Update.getError()); From 260a9abee8aa11cfc21d4f741530a93364e3ca28 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Tue, 21 Jun 2022 08:21:58 -0500 Subject: [PATCH 054/100] add input type example --- examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino index 49eae9ac..c324374f 100644 --- a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -97,6 +97,7 @@ void setup() { WiFiManagerParameter custom_token("api_token", "api token", "", 16); WiFiManagerParameter custom_tokenb("invalid token", "invalid token", "", 0); // id is invalid, cannot contain spaces WiFiManagerParameter custom_ipaddress("input_ip", "input IP", "", 15,"pattern='\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}'"); // custom input attrs (ip mask) + WiFiManagerParameter custom_input_type("input_pwd", "input pass", "", 15,"type='password'"); // custom input attrs (ip mask) const char _customHtml_checkbox[] = "type=\"checkbox\""; WiFiManagerParameter custom_checkbox("my_checkbox", "My Checkbox", "T", 2, _customHtml_checkbox,WFM_LABEL_AFTER); @@ -137,6 +138,7 @@ void setup() { wm.addParameter(&custom_tokenb); wm.addParameter(&custom_ipaddress); wm.addParameter(&custom_checkbox); + wm.addParameter(&custom_input_type); wm.addParameter(&custom_html_inputs); From 9e408e41a8000a7b87d8651a3e7e148c30421d5f Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Wed, 22 Jun 2022 10:50:47 -0500 Subject: [PATCH 055/100] LittleFS Basic example --- .../LittleFS/LittleFSParameters.ino | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 examples/Parameters/LittleFS/LittleFSParameters.ino diff --git a/examples/Parameters/LittleFS/LittleFSParameters.ino b/examples/Parameters/LittleFS/LittleFSParameters.ino new file mode 100644 index 00000000..188b3c16 --- /dev/null +++ b/examples/Parameters/LittleFS/LittleFSParameters.ino @@ -0,0 +1,79 @@ +/** + * Basic example using LittleFS to store data + */ + +#include +#include +#include + +String readFile(fs::FS &fs, const char * path){ + Serial.printf("Reading file: %s\r\n", path); + File file = fs.open(path, "r"); + if(!file || file.isDirectory()){ + Serial.println("- empty file or failed to open file"); + return String(); + } + Serial.println("- read from file:"); + String fileContent; + while(file.available()){ + fileContent+=String((char)file.read()); + } + file.close(); + Serial.println(fileContent); + return fileContent; +} +void writeFile(fs::FS &fs, const char * path, const char * message){ + Serial.printf("Writing file: %s\r\n", path); + File file = fs.open(path, "w"); + if(!file){ + Serial.println("- failed to open file for writing"); + return; + } + if(file.print(message)){ + Serial.println("- file written"); + } else { + Serial.println("- write failed"); + } + file.close(); +} + +int data = 4; + +#include +#define TRIGGER_PIN 2 +int timeout = 120; // seconds to run for + +void setup() { +if (!LittleFS.begin()) { //to start littlefs +Serial.println("LittleFS mount failed"); +return; +} +data = readFile(LittleFS, "/data.txt").toInt(); +WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP + // put your setup code here, to run once: + pinMode(TRIGGER_PIN, INPUT_PULLUP); + WiFiManager wm; + //wm.resetSettings(); + bool res; + res = wm.autoConnect("Setup"); + if(!res) { + Serial.println("Failed to connect"); + // ESP.restart(); + } + +} + +void loop() { +if ( digitalRead(TRIGGER_PIN) == LOW) { + WiFiManager wm; + //wm.resetSettings(); + wm.setConfigPortalTimeout(timeout); + if (!wm.startConfigPortal("Sharmander")) { + Serial.println("failed to connect and hit timeout"); + delay(3000); + ESP.restart(); + delay(5000); + } + Serial.println("connected...yeey :)"); +} +} \ No newline at end of file From afd328b3b2775b8a8c5b778ed5449326d4ee4807 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Fri, 24 Jun 2022 20:07:17 -0500 Subject: [PATCH 056/100] Fix hostname #1403 --- WiFiManager.cpp | 14 ++++++++++---- .../OnDemandConfigPortal/OnDemandConfigPortal.ino | 8 ++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 1125192b..bff08a10 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -275,6 +275,12 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { _startconn = millis(); _begin(); + // sethostname before wifi ready + // https://github.com/tzapu/WiFiManager/issues/1403 + if(_hostname != ""){ + setupHostname(true); + } + // attempt to connect using saved settings, on fail fallback to AP config portal if(!WiFi.enableSTA(true)){ // handle failure mode Brownout detector etc. @@ -298,9 +304,9 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { WiFi_autoReconnect(); // set hostname before stating - if(_hostname != ""){ - setupHostname(true); - } + // if(_hostname != ""){ + // setupHostname(true); + // } // if already connected, or try stored connect // @note @todo ESP32 has no autoconnect, so connectwifi will always be called unless user called begin etc before @@ -386,7 +392,7 @@ bool WiFiManager::setupHostname(bool restart){ #endif #elif defined(ESP32) // @note hostname must be set after STA_START - delay(200); // do not remove, give time for STA_START + // @note, this may have changed at some point, now it wont work, I have to set it before. #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_VERBOSE,F("Setting WiFi hostname")); diff --git a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino index 362533c8..f7d4b52d 100644 --- a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -23,7 +23,7 @@ WiFiManager wm; // TEST OPTION FLAGS -bool TEST_CP = true; // always start the configportal, even if ap found +bool TEST_CP = false; // always start the configportal, even if ap found int TESP_CP_TIMEOUT = 90; // test cp timeout bool TEST_NET = true; // do a network test after connect, (gets ntp time) @@ -34,6 +34,8 @@ bool WMISBLOCKING = true; // use blocking or non blocking mode, non global pa // char ssid[] = "*************"; // your network SSID (name) // char pass[] = "********"; // your network password + +//callbacks // called after AP mode and config portal has started // setAPCallback( std::function func ); // called after webserver has started @@ -220,7 +222,8 @@ void setup() { // set Hostname - wm.setHostname(("WM_"+wm.getDefaultAPName()).c_str()); + wm.setHostname(("WM_"+wm.getDefaultAPName()).c_str()); + // wm.setHostname("WM_RANDO_1234"); // set custom channel // wm.setWiFiAPChannel(13); @@ -310,6 +313,7 @@ void wifiInfo(){ Serial.println("[WIFI] SAVED: " + (String)(wm.getWiFiIsSaved() ? "YES" : "NO")); Serial.println("[WIFI] SSID: " + (String)wm.getWiFiSSID()); Serial.println("[WIFI] PASS: " + (String)wm.getWiFiPass()); + Serial.println("[WIFI] HOSTNAME: " + (String)WiFi.getHostname()); } void loop() { From 14aeb7575f04225feb826badfc85c9fb4ceebc5d Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Fri, 24 Jun 2022 23:44:03 -0500 Subject: [PATCH 057/100] Fix hostname for esp8266, needs to run after sta ughh --- WiFiManager.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index bff08a10..6ca3018f 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -277,9 +277,11 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { // sethostname before wifi ready // https://github.com/tzapu/WiFiManager/issues/1403 + #ifdef ESP32 if(_hostname != ""){ setupHostname(true); } + #endif // attempt to connect using saved settings, on fail fallback to AP config portal if(!WiFi.enableSTA(true)){ @@ -303,10 +305,11 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { // so we must force it on else, if not connectimeout then waitforconnectionresult gets stuck endless loop WiFi_autoReconnect(); - // set hostname before stating - // if(_hostname != ""){ - // setupHostname(true); - // } + #ifdef ESP8266 + if(_hostname != ""){ + setupHostname(true); + } + #endif // if already connected, or try stored connect // @note @todo ESP32 has no autoconnect, so connectwifi will always be called unless user called begin etc before From 06c63720f60ec6e169c9c4cb10f52896f6b97d74 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Sun, 26 Jun 2022 16:39:33 -0500 Subject: [PATCH 058/100] #1421 remove temp --- WiFiManager.cpp | 2 +- WiFiManager.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 6ca3018f..7bc55b43 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -2172,7 +2172,7 @@ String WiFiManager::getInfoData(String id){ p.replace(FPSTR(T_1),WiFi.getAutoConnect() ? FPSTR(S_enable) : FPSTR(S_disable)); } #endif - #ifdef ESP32 + #ifdef ESP32 && !defined(WM_NOTEMP) else if(id==F("temp")){ // temperature is not calibrated, varying large offsets are present, use for relative temp changes only p = FPSTR(HTTP_INFO_temp); diff --git a/WiFiManager.h b/WiFiManager.h index 5a2c0d60..df540d08 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -39,6 +39,10 @@ #define WM_NOSOFTAPSSID // no softapssid() @todo shim #endif +#ifdef ARDUINO_ESP32S3_DEV +#define WM_NOTEMP +#endif + // #include "soc/efuse_reg.h" // include to add efuse chip rev to info, getChipRevision() is almost always the same though, so not sure why it matters. // #define esp32autoreconnect // implement esp32 autoreconnect event listener kludge, @DEPRECATED From 65fec943173e254c36b152867a53c23a4135c713 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Sun, 26 Jun 2022 23:22:10 -0500 Subject: [PATCH 059/100] fix compiler warnings #1421 --- WiFiManager.cpp | 2 +- .../AutoConnectWithFSParameters.ino | 6 +++--- .../AutoConnectWithFSParametersAndCustomIP.ino | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 7bc55b43..fb57985e 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -2172,7 +2172,7 @@ String WiFiManager::getInfoData(String id){ p.replace(FPSTR(T_1),WiFi.getAutoConnect() ? FPSTR(S_enable) : FPSTR(S_disable)); } #endif - #ifdef ESP32 && !defined(WM_NOTEMP) + #if defined(ESP32) && !defined(WM_NOTEMP) else if(id==F("temp")){ // temperature is not calibrated, varying large offsets are present, use for relative temp changes only p = FPSTR(HTTP_INFO_temp); diff --git a/examples/Parameters/SPIFFS/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino b/examples/Parameters/SPIFFS/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino index 0e1cd0cf..a9c7b790 100644 --- a/examples/Parameters/SPIFFS/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino +++ b/examples/Parameters/SPIFFS/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino @@ -46,7 +46,7 @@ void setup() { configFile.readBytes(buf.get(), size); -#ifdef ARDUINOJSON_VERSION_MAJOR >= 6 + #if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6 DynamicJsonDocument json(1024); auto deserializeError = deserializeJson(json, buf.get()); serializeJson(json, Serial); @@ -133,7 +133,7 @@ void setup() { //save the custom parameters to FS if (shouldSaveConfig) { Serial.println("saving config"); -#ifdef ARDUINOJSON_VERSION_MAJOR >= 6 + #if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6 DynamicJsonDocument json(1024); #else DynamicJsonBuffer jsonBuffer; @@ -148,7 +148,7 @@ void setup() { Serial.println("failed to open config file for writing"); } -#ifdef ARDUINOJSON_VERSION_MAJOR >= 6 +#if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6 serializeJson(json, Serial); serializeJson(json, configFile); #else diff --git a/examples/Parameters/SPIFFS/AutoConnectWithFSParametersAndCustomIP/AutoConnectWithFSParametersAndCustomIP.ino b/examples/Parameters/SPIFFS/AutoConnectWithFSParametersAndCustomIP/AutoConnectWithFSParametersAndCustomIP.ino index 27b9da92..63523e9b 100644 --- a/examples/Parameters/SPIFFS/AutoConnectWithFSParametersAndCustomIP/AutoConnectWithFSParametersAndCustomIP.ino +++ b/examples/Parameters/SPIFFS/AutoConnectWithFSParametersAndCustomIP/AutoConnectWithFSParametersAndCustomIP.ino @@ -51,7 +51,7 @@ void setup() { std::unique_ptr buf(new char[size]); configFile.readBytes(buf.get(), size); -#ifdef ARDUINOJSON_VERSION_MAJOR >= 6 + #if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6 DynamicJsonDocument json(1024); auto deserializeError = deserializeJson(json, buf.get()); serializeJson(json, Serial); @@ -153,7 +153,7 @@ void setup() { //save the custom parameters to FS if (shouldSaveConfig) { Serial.println("saving config"); -#ifdef ARDUINOJSON_VERSION_MAJOR >= 6 + #if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6 DynamicJsonDocument json(1024); #else DynamicJsonBuffer jsonBuffer; @@ -172,7 +172,7 @@ void setup() { Serial.println("failed to open config file for writing"); } -#ifdef ARDUINOJSON_VERSION_MAJOR >= 6 + #if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6 serializeJson(json, Serial); serializeJson(json, configFile); #else From 01bd8a398b8cdd01edc6b8068818e2fec24c9157 Mon Sep 17 00:00:00 2001 From: 45gfg9 Date: Wed, 29 Jun 2022 02:14:06 +0800 Subject: [PATCH 060/100] Update WiFiManager.cpp (#1443) Avoid constructing two String objects and adding them together. Just concatenate c-strings. --- WiFiManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index fb57985e..a237c0d9 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -2209,7 +2209,7 @@ String WiFiManager::getInfoData(String id){ } else if(id==F("aboutdate")){ p = FPSTR(HTTP_INFO_aboutdate); - p.replace(FPSTR(T_1),String(__DATE__) + " " + String(__TIME__)); + p.replace(FPSTR(T_1),String(__DATE__ " " __TIME__)); } return p; } From 605d1e897adf0e949b3b44d39b9d8e0515916a60 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Thu, 30 Jun 2022 12:14:23 -0500 Subject: [PATCH 061/100] add missing debug toggle --- examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino index f7d4b52d..8726a240 100644 --- a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -106,6 +106,8 @@ void setup() { Serial.println("[ERROR] TEST"); Serial.println("[INFORMATION] TEST"); + + wm.setDebugOutput(true); wm.debugPlatformInfo(); //reset settings - for testing @@ -222,7 +224,7 @@ void setup() { // set Hostname - wm.setHostname(("WM_"+wm.getDefaultAPName()).c_str()); + // wm.setHostname(("WM_"+wm.getDefaultAPName()).c_str()); // wm.setHostname("WM_RANDO_1234"); // set custom channel From b8205e71f35c942c3714537563d0553b6f5828a6 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Thu, 30 Jun 2022 13:40:38 -0500 Subject: [PATCH 062/100] add connection fixes for esp32 wifi not started yet --- WiFiManager.cpp | 9 +++++++++ .../Super/OnDemandConfigPortal/OnDemandConfigPortal.ino | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index a237c0d9..9180d428 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -271,6 +271,14 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { #ifdef WM_DEBUG_LEVEL DEBUG_WM(F("AutoConnect")); #endif + + #ifdef ESP32 + if(WiFi.getMode() != WIFI_STA){ + WiFi.mode(WIFI_STA); + } + #endif + + if(getWiFiIsSaved()){ _startconn = millis(); _begin(); @@ -332,6 +340,7 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { DEBUG_WM(DEBUG_VERBOSE,F("Connected in"),(String)((millis()-_startconn)) + " ms"); DEBUG_WM(F("STA IP Address:"),WiFi.localIP()); #endif + // Serial.println("Connected in " + (String)((millis()-_startconn)) + " ms"); _lastconxresult = WL_CONNECTED; if(_hostname != ""){ diff --git a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino index 8726a240..f37c8de5 100644 --- a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -95,7 +95,6 @@ void setup() { // Serial1.begin(115200); // Serial.setDebugOutput(true); - delay(1000); Serial.println("\n Starting"); // WiFi.setSleepMode(WIFI_NONE_SLEEP); // disable sleep, can improve ap stability @@ -310,6 +309,7 @@ void setup() { } void wifiInfo(){ + // can contain gargbage on esp32 if wifi is not ready yet Serial.println("[WIFI] WIFI INFO DEBUG"); // WiFi.printDiag(Serial); Serial.println("[WIFI] SAVED: " + (String)(wm.getWiFiIsSaved() ? "YES" : "NO")); From f2ed2cb99716a6d2b628ca900989cd5a9b722c0e Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Wed, 13 Jul 2022 22:14:58 -0500 Subject: [PATCH 063/100] #1452 Possible fix --- WiFiManager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 9180d428..72bdff43 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -807,6 +807,7 @@ boolean WiFiManager::process(){ #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_DEV,F("process loop abort")); #endif + webPortalActive = false; shutdownConfigPortal(); return false; } From 7d498ed50ab92577ecbd0c5ba2b875910356d1ce Mon Sep 17 00:00:00 2001 From: JoergAJ <84235628+JoergAJ@users.noreply.github.com> Date: Fri, 15 Jul 2022 18:59:12 +0200 Subject: [PATCH 064/100] Added links in readme file (#1446) * Update README.md Updated links to examples * Update README.md Updated links * Update README.md * Update README.md * Update README.md * Update README.md added placeholder links for buttons * Update README.md added links to the action workflow (compile_library /examples) + expressif links to the product pages --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d5d30687..01cdfc3f 100644 --- a/README.md +++ b/README.md @@ -8,19 +8,19 @@ Espressif ESPx WiFi Connection manager with fallback web configuration portal ![Release](https://img.shields.io/github/v/release/tzapu/WiFiManager?include_prereleases) -![Build CI Status](https://github.com/tzapu/WiFiManager/actions/workflows/compile_library.yml/badge.svg) +[![Build CI Status](https://github.com/tzapu/WiFiManager/actions/workflows/compile_library.yml/badge.svg)](https://github.com/tzapu/WiFiManager/actions/workflows/compile_library.yml) -![Build CI Status Examples](https://github.com/tzapu/WiFiManager/actions/workflows/compile_examples.yaml/badge.svg) +[![Build CI Status Examples](https://github.com/tzapu/WiFiManager/actions/workflows/compile_examples.yaml/badge.svg)](https://github.com/tzapu/WiFiManager/actions/workflows/compile_examples.yaml) [![arduino-library-badge](https://www.ardu-badge.com/badge/WiFiManager.svg?)](https://www.ardu-badge.com/WiFiManager) [![Build with PlatformIO](https://img.shields.io/badge/PlatformIO-Library-orange?)](https://platformio.org/lib/show/567/WiFiManager/installation) -![ESP8266](https://img.shields.io/badge/ESP-8266-000000.svg?longCache=true&style=flat&colorA=CC101F) +[![ESP8266](https://img.shields.io/badge/ESP-8266-000000.svg?longCache=true&style=flat&colorA=CC101F)](https://www.espressif.com/en/products/socs/esp8266) -![ESP32](https://img.shields.io/badge/ESP-32-000000.svg?longCache=true&style=flat&colorA=CC101F) -![ESP32](https://img.shields.io/badge/ESP-32S2-000000.svg?longCache=true&style=flat&colorA=CC101F) -![ESP32](https://img.shields.io/badge/ESP-32C3-000000.svg?longCache=true&style=flat&colorA=CC101F) +[![ESP32](https://img.shields.io/badge/ESP-32-000000.svg?longCache=true&style=flat&colorA=CC101F)](https://www.espressif.com/en/products/socs/esp32) +[![ESP32](https://img.shields.io/badge/ESP-32S2-000000.svg?longCache=true&style=flat&colorA=CC101F)](https://www.espressif.com/en/products/socs/esp32-s2) +[![ESP32](https://img.shields.io/badge/ESP-32C3-000000.svg?longCache=true&style=flat&colorA=CC101F)](https://www.espressif.com/en/products/socs/esp32-c3) Member to Member Support / Chat From 5ded0c9ef8c015799bbeb72f465097845c91628a Mon Sep 17 00:00:00 2001 From: John Date: Tue, 9 Aug 2022 11:44:06 -0400 Subject: [PATCH 065/100] Use esp_wifi_set_country_code for ESP32 (#1470) Replaces the use of esp_wifi_set_country() with esp_wifi_set_country_code() for ESP32 in order to both solve a crash under Arduino 2.x and remove the requirement to independently maintain country-specific channel settings --- WiFiManager.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 72bdff43..d10fc33f 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -3450,16 +3450,19 @@ bool WiFiManager::WiFiSetCountry(){ if(WiFi.getMode() == WIFI_MODE_NULL){ DEBUG_WM(DEBUG_ERROR,"[ERROR] cannot set country, wifi not init"); } // exception if wifi not init! - else if(_wificountry == "US") err = esp_wifi_set_country(&WM_COUNTRY_US); - else if(_wificountry == "JP") err = esp_wifi_set_country(&WM_COUNTRY_JP); - else if(_wificountry == "CN") err = esp_wifi_set_country(&WM_COUNTRY_CN); + // Assumes that _wificountry is set to one of the supported country codes : "01"(world safe mode) "AT","AU","BE","BG","BR", + // "CA","CH","CN","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GR","HK","HR","HU", + // "IE","IN","IS","IT","JP","KR","LI","LT","LU","LV","MT","MX","NL","NO","NZ","PL","PT", + // "RO","SE","SI","SK","TW","US" + // If an invalid country code is passed, ESP_ERR_WIFI_ARG will be returned + // This also uses 802.11d mode, which matches the STA to the country code of the AP it connects to (meaning + // that the country code will be overridden if connecting to a "foreign" AP) + else err = esp_wifi_set_country_code(_wificountry.c_str(), true); + #ifdef WM_DEBUG_LEVEL - else{ - DEBUG_WM(DEBUG_ERROR,"[ERROR] country code not found"); - } if(err){ if(err == ESP_ERR_WIFI_NOT_INIT) DEBUG_WM(DEBUG_ERROR,"[ERROR] ESP_ERR_WIFI_NOT_INIT"); - else if(err == ESP_ERR_INVALID_ARG) DEBUG_WM(DEBUG_ERROR,"[ERROR] ESP_ERR_WIFI_ARG"); + else if(err == ESP_ERR_INVALID_ARG) DEBUG_WM(DEBUG_ERROR,"[ERROR] ESP_ERR_WIFI_ARG (invalid country code)"); else if(err != ESP_OK)DEBUG_WM(DEBUG_ERROR,"[ERROR] unknown error",(String)err); } #endif From 58baeaba6f0558199b4696ccfb8c005e813c352a Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Tue, 9 Aug 2022 10:59:33 -0500 Subject: [PATCH 066/100] adds temporary fallbacks for esp32 set country Find better way to check version feature check, arduino ver is not always available. --- WiFiManager.cpp | 10 ++++++++-- WiFiManager.h | 8 ++++++++ .../OnDemandConfigPortal/OnDemandConfigPortal.ino | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index d10fc33f..4a41b98c 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -3457,8 +3457,14 @@ bool WiFiManager::WiFiSetCountry(){ // If an invalid country code is passed, ESP_ERR_WIFI_ARG will be returned // This also uses 802.11d mode, which matches the STA to the country code of the AP it connects to (meaning // that the country code will be overridden if connecting to a "foreign" AP) - else err = esp_wifi_set_country_code(_wificountry.c_str(), true); - + else { + #ifndef WM_NOCOUNTRY + err = esp_wifi_set_country_code(_wificountry.c_str(), true); + #else + DEBUG_WM(DEBUG_ERROR,"[ERROR] esp wifi set country is not available"); + err = true; + #endif + } #ifdef WM_DEBUG_LEVEL if(err){ if(err == ESP_ERR_WIFI_NOT_INIT) DEBUG_WM(DEBUG_ERROR,"[ERROR] ESP_ERR_WIFI_NOT_INIT"); diff --git a/WiFiManager.h b/WiFiManager.h index df540d08..4c057ee1 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -638,10 +638,18 @@ class WiFiManager #define WM_ARDUINOEVENTS #else #define WM_NOSOFTAPSSID + #define WM_NOCOUNTRY #endif + #else + #define WM_NOCOUNTRY + #endif + + #ifdef WM_NOCOUNTRY + #warning "ESP32 set country unavailable" #endif + #ifdef WM_ARDUINOEVENTS void WiFiEvent(WiFiEvent_t event, arduino_event_info_t info); #else diff --git a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino index f37c8de5..e627b061 100644 --- a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -219,7 +219,7 @@ void setup() { // setting wifi country seems to improve OSX soft ap connectivity, // may help others as well, default is CN which has different channels - // wm.setCountry("US"); // crashing on esp32 2.0 + wm.setCountry("US"); // crashing on esp32 2.0 // set Hostname From 8e0a17e5c890c7a6d21790f327b2fb21a68dfc71 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 9 Aug 2022 12:00:03 -0400 Subject: [PATCH 067/100] Change test action to install from local directory (#1473) * Change test action to install from local directory * Update GH action for ESP8266 as well --- .github/workflows/compile_examples.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/compile_examples.yaml b/.github/workflows/compile_examples.yaml index 315adb4a..18c5d2e4 100644 --- a/.github/workflows/compile_examples.yaml +++ b/.github/workflows/compile_examples.yaml @@ -55,7 +55,7 @@ jobs: - name: Install 3rd party dependecies run: | pio lib -g install \ - https://github.com/tzapu/WiFiManager \ + file://. \ https://github.com/bblanchon/ArduinoJson \ https://github.com/knolleary/pubsubclient @@ -108,11 +108,11 @@ jobs: - name: Install 3rd party dependecies run: | pio lib -g install \ - https://github.com/tzapu/WiFiManager \ + file://. \ https://github.com/bblanchon/ArduinoJson \ https://github.com/knolleary/pubsubclient - name: Run PlatformIO Examples run: pio ci --board=esp32dev env: - PLATFORMIO_CI_SRC: ${{ matrix.example }} \ No newline at end of file + PLATFORMIO_CI_SRC: ${{ matrix.example }} From e9dec77a83855520bec22e83d1a77a2b6e4719dc Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Tue, 9 Aug 2022 11:04:07 -0500 Subject: [PATCH 068/100] beta ver bump --- library.json | 2 +- library.properties | 2 +- strings_en.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library.json b/library.json index dfff70b2..e77262e3 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "WiFiManager", - "version": "2.0.11-beta", + "version": "2.0.12-beta", "keywords": "wifi,wi-fi,esp,esp8266,esp32,espressif8266,espressif32,nodemcu,wemos,arduino", "description": "WiFi Configuration manager with web configuration portal for ESP boards", "authors": diff --git a/library.properties b/library.properties index 1c3a8ad1..db9faadc 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=WiFiManager -version=2.0.11-beta +version=2.0.12-beta author=tzapu maintainer=tablatronix sentence=WiFi Configuration manager with web configuration portal for Espressif ESPx boards, by tzapu diff --git a/strings_en.h b/strings_en.h index bc487f8c..386571d4 100644 --- a/strings_en.h +++ b/strings_en.h @@ -17,7 +17,7 @@ #ifndef WIFI_MANAGER_OVERRIDE_STRINGS // !!! ABOVE WILL NOT WORK if you define in your sketch, must be build flag, if anyone one knows how to order includes to be able to do this it would be neat.. I have seen it done.. -const char WM_VERSION_STR[] PROGMEM = "v2.0.11-beta"; +const char WM_VERSION_STR[] PROGMEM = "v2.0.12-beta"; const char HTTP_HEAD_START[] PROGMEM = "" "" From 19cb05e55b7eb02bd8154db774ad20161a0b654e Mon Sep 17 00:00:00 2001 From: John Date: Tue, 9 Aug 2022 18:05:52 -0400 Subject: [PATCH 069/100] Explicitly add dependencies --- library.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library.json b/library.json index e77262e3..d96e8e94 100644 --- a/library.json +++ b/library.json @@ -21,6 +21,11 @@ "url": "https://github.com/tzapu/WiFiManager.git" }, "frameworks": "arduino", + "dependencies": { + "me-no-dev/ESPAsyncWebServer": "*", + "me-no-dev/AsyncTCP": "*", + "bbx10/DNSServer": "^1.1.0" + }, "platforms": [ "espressif8266", From 4d38ca7a8320dde6a2e3bfa22ca8077487ea107a Mon Sep 17 00:00:00 2001 From: John Date: Tue, 9 Aug 2022 23:33:06 -0400 Subject: [PATCH 070/100] Incorporate fixes to async branch --- .github/workflows/compile_examples.yaml | 102 +++++++++--------- .github/workflows/compile_library.yml | 4 +- WiFiManager.cpp | 20 ++-- WiFiManager.h | 1 - .../OnDemandConfigPortal.ino | 3 +- library.json | 8 ++ 6 files changed, 71 insertions(+), 67 deletions(-) diff --git a/.github/workflows/compile_examples.yaml b/.github/workflows/compile_examples.yaml index 18c5d2e4..46f67136 100644 --- a/.github/workflows/compile_examples.yaml +++ b/.github/workflows/compile_examples.yaml @@ -11,58 +11,58 @@ on: - '.github/workflows/compile_library.yml' jobs: - esp8266: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - example: - - "examples/Parameters/SPIFFS/AutoConnectWithFSParametersAndCustomIP/AutoConnectWithFSParametersAndCustomIP.ino" - - "examples/Parameters/SPIFFS/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino" - - "examples/NonBlocking/OnDemandNonBlocking/onDemandNonBlocking.ino" - - "examples/NonBlocking/AutoConnectNonBlockingwParams/AutoConnectNonBlockingwParams.ino" - - "examples/NonBlocking/AutoConnectNonBlocking/AutoConnectNonBlocking.ino" - - "examples/Basic/Basic.ino" - - "examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino" - - "examples/Advanced/Advanced.ino" - - "examples/Old_examples/AutoConnectWithStaticIP/AutoConnectWithStaticIP.ino" - - "examples/Old_examples/AutoConnectWithFeedback/AutoConnectWithFeedback.ino" - - "examples/Old_examples/AutoConnectWithReset/AutoConnectWithReset.ino" - - "examples/Old_examples/AutoConnectWithTimeout/AutoConnectWithTimeout.ino" - - "examples/ParamsChildClass/ParamsChildClass.ino" - - "examples/OnDemand/OnDemandConfigPortal/OnDemandConfigPortal.ino" - - "examples/OnDemand/OnDemandWebPortal/onDemandWebPortal.ino" + # esp8266: + # runs-on: ubuntu-latest + # strategy: + # fail-fast: false + # matrix: + # example: + # - "examples/Parameters/SPIFFS/AutoConnectWithFSParametersAndCustomIP/AutoConnectWithFSParametersAndCustomIP.ino" + # - "examples/Parameters/SPIFFS/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino" + # - "examples/NonBlocking/OnDemandNonBlocking/onDemandNonBlocking.ino" + # - "examples/NonBlocking/AutoConnectNonBlockingwParams/AutoConnectNonBlockingwParams.ino" + # - "examples/NonBlocking/AutoConnectNonBlocking/AutoConnectNonBlocking.ino" + # - "examples/Basic/Basic.ino" + # - "examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino" + # - "examples/Advanced/Advanced.ino" + # - "examples/Old_examples/AutoConnectWithStaticIP/AutoConnectWithStaticIP.ino" + # - "examples/Old_examples/AutoConnectWithFeedback/AutoConnectWithFeedback.ino" + # - "examples/Old_examples/AutoConnectWithReset/AutoConnectWithReset.ino" + # - "examples/Old_examples/AutoConnectWithTimeout/AutoConnectWithTimeout.ino" + # - "examples/ParamsChildClass/ParamsChildClass.ino" + # - "examples/OnDemand/OnDemandConfigPortal/OnDemandConfigPortal.ino" + # - "examples/OnDemand/OnDemandWebPortal/onDemandWebPortal.ino" - steps: - - uses: actions/checkout@v2 - - name: Cache pip - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: ${{ runner.os }}-pip- - - name: Cache PlatformIO - uses: actions/cache@v2 - with: - path: ~/.platformio - key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} - - name: Set up Python - uses: actions/setup-python@v2 - - name: Install PlatformIO - run: | - python -m pip install --upgrade pip - pip install --upgrade platformio - - name: Install 3rd party dependecies - run: | - pio lib -g install \ - file://. \ - https://github.com/bblanchon/ArduinoJson \ - https://github.com/knolleary/pubsubclient + # steps: + # - uses: actions/checkout@v2 + # - name: Cache pip + # uses: actions/cache@v2 + # with: + # path: ~/.cache/pip + # key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + # restore-keys: ${{ runner.os }}-pip- + # - name: Cache PlatformIO + # uses: actions/cache@v2 + # with: + # path: ~/.platformio + # key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} + # - name: Set up Python + # uses: actions/setup-python@v2 + # - name: Install PlatformIO + # run: | + # python -m pip install --upgrade pip + # pip install --upgrade platformio + # - name: Install 3rd party dependecies + # run: | + # pio lib -g install \ + # file://. \ + # https://github.com/bblanchon/ArduinoJson \ + # https://github.com/knolleary/pubsubclient - - name: Run PlatformIO Examples - run: pio ci --board=nodemcuv2 - env: - PLATFORMIO_CI_SRC: ${{ matrix.example }} + # - name: Run PlatformIO Examples + # run: pio ci --board=nodemcuv2 + # env: + # PLATFORMIO_CI_SRC: ${{ matrix.example }} esp32: runs-on: ubuntu-latest @@ -105,7 +105,7 @@ jobs: run: | python -m pip install --upgrade pip pip install --upgrade platformio - - name: Install 3rd party dependecies + - name: Install 3rd party dependencies run: | pio lib -g install \ file://. \ diff --git a/.github/workflows/compile_library.yml b/.github/workflows/compile_library.yml index 5660b928..00a9bd5b 100644 --- a/.github/workflows/compile_library.yml +++ b/.github/workflows/compile_library.yml @@ -20,8 +20,8 @@ jobs: fail-fast: false matrix: board: - - "nodemcuv2" - "lolin32" + # - "nodemcuv2" steps: - uses: actions/checkout@v2 @@ -50,4 +50,4 @@ jobs: echo "void loop() {}" >> main.ino - name: Run PlatformIO - run: pio ci --board=${{ matrix.board }} . + run: pio ci --board=${{ matrix.board }} --lib="." . diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 4bda0eae..f89ab23c 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -1261,10 +1261,6 @@ String WiFiManager::getHTTPHead(String title){ return page; } -void WiFiManager::HTTPSend(String content){ - server->send(200, FPSTR(HTTP_HEAD_CT), content); -} - /** * HTTPD handler for page requests */ @@ -1824,7 +1820,7 @@ void WiFiManager::handleWifiSave(AsyncWebServerRequest *request) { _presavewificallback(); // @CALLBACK } - if(_paramsInWifi) doParamSave(); + if(_paramsInWifi) doParamSave(request); String page; @@ -3860,13 +3856,13 @@ void WiFiManager::handleUpdating(AsyncWebServerRequest *request,String filename, } // UPLOAD WRITE - else if (upload.status == UPLOAD_FILE_WRITE) { - // Serial.print("."); - if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) { - #ifdef WM_DEBUG_LEVEL - DEBUG_WM(DEBUG_ERROR,F("[ERROR] OTA Update WRITE ERROR"), Update.getError()); - //Update.printError(Serial); // write failure - #endif + if (indexon("/custom",handleRoute); // this is now crashing esp32 for some reason + // wm.server->on("/custom",handleRoute); // this is now crashing esp32 for some reason + wm.server->on("/custom", HTTP_ANY, std::bind(handleRoute, wm, std::placeholders::_1, true)); // wm.server->on("/info",handleRoute); // you can override wm! } diff --git a/library.json b/library.json index e77262e3..23eb55d0 100644 --- a/library.json +++ b/library.json @@ -21,6 +21,14 @@ "url": "https://github.com/tzapu/WiFiManager.git" }, "frameworks": "arduino", + "dependencies": { + "me-no-dev/AsyncTCP": "*", + "bbx10/DNSServer": "^1.1.0", + "external-repo": "https://github.com/me-no-dev/ESPAsyncWebServer.git" + }, + "build": { + "libLDFMode": "chain+" + }, "platforms": [ "espressif8266", From b90af1ac4d1c86e71836041c21b7c6539d60bb72 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Wed, 17 Aug 2022 19:24:45 -0500 Subject: [PATCH 071/100] fixes #1068 esp32 S2 Esp32 has seeveral variations on when you can sethostname, might vary with versions so will try to add a best practice for all --- WiFiManager.cpp | 11 +++++++++-- .../OnDemandConfigPortal/OnDemandConfigPortal.ino | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 4a41b98c..25d0d2d3 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -272,13 +272,20 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { DEBUG_WM(F("AutoConnect")); #endif + // sethostname before wifi ready + // https://github.com/tzapu/WiFiManager/issues/1403 + #ifdef ESP32 + if(_hostname != ""){ + setupHostname(false); + } + #endif + #ifdef ESP32 if(WiFi.getMode() != WIFI_STA){ WiFi.mode(WIFI_STA); } #endif - if(getWiFiIsSaved()){ _startconn = millis(); _begin(); @@ -287,7 +294,7 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { // https://github.com/tzapu/WiFiManager/issues/1403 #ifdef ESP32 if(_hostname != ""){ - setupHostname(true); + setupHostname(false); } #endif diff --git a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino index e627b061..920d9ba7 100644 --- a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -223,7 +223,7 @@ void setup() { // set Hostname - // wm.setHostname(("WM_"+wm.getDefaultAPName()).c_str()); + wm.setHostname(("WM_"+wm.getDefaultAPName()).c_str()); // wm.setHostname("WM_RANDO_1234"); // set custom channel From 94bb90322bf85de2c9ec592858f20643161bc11f Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Thu, 18 Aug 2022 22:10:41 -0500 Subject: [PATCH 072/100] #1403 try to increase hostname reliability and keep connect times low --- WiFiManager.cpp | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 25d0d2d3..6f699fa8 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -272,17 +272,19 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { DEBUG_WM(F("AutoConnect")); #endif - // sethostname before wifi ready - // https://github.com/tzapu/WiFiManager/issues/1403 #ifdef ESP32 - if(_hostname != ""){ - setupHostname(false); - } - #endif - - #ifdef ESP32 - if(WiFi.getMode() != WIFI_STA){ - WiFi.mode(WIFI_STA); + setupHostname(true); + + if(_hostname){ + // disable wifi if already on + if(WiFi.getMode() & WIFI_STA){ + WiFi.mode(WIFI_OFF); + int timeout = millis()+1200; + // async loop for mode change + while(WiFi.getMode()!= WIFI_OFF && millis() Date: Wed, 24 Aug 2022 18:10:55 -0500 Subject: [PATCH 073/100] Update discord link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 01cdfc3f..a6209ddf 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Member to Member Support / Chat [![Join the chat at https://gitter.im/tablatronix/WiFiManager](https://badges.gitter.im/tablatronix/WiFiManager.svg)](https://gitter.im/tablatronix/WiFiManager?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![Discord](https://img.shields.io/badge/Discord-WiFiManager-%237289da.svg?logo=discord)](https://discord.gg/dkjJbHwC) +[![Discord](https://img.shields.io/badge/Discord-WiFiManager-%237289da.svg?logo=discord)](https://discord.gg/WgjVprfN) The configuration portal is of the captive variety, so on various devices it will present the configuration dialogue as soon as you connect to the created access point. From 58202986400f102dc38324d8d04fd6be8c5b3109 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Wed, 31 Aug 2022 14:36:30 -0500 Subject: [PATCH 074/100] cleanup dev example --- .../OnDemandConfigPortal/OnDemandConfigPortal.ino | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino index 920d9ba7..6ac38eb3 100644 --- a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -88,13 +88,12 @@ void handlePreOtaUpdateCallback(){ } void setup() { - // WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP + // WiFi.mode(WIFI_STA); // explicitly set mode, esp can default to STA+AP // put your setup code here, to run once: Serial.begin(115200); - // Serial1.begin(115200); - // Serial.setDebugOutput(true); + // Serial.setDebugOutput(true); Serial.println("\n Starting"); // WiFi.setSleepMode(WIFI_NONE_SLEEP); // disable sleep, can improve ap stability @@ -111,7 +110,7 @@ void setup() { //reset settings - for testing // wm.resetSettings(); - // wm.erase(); + // wm.erase(); // setup some parameters @@ -219,7 +218,7 @@ void setup() { // setting wifi country seems to improve OSX soft ap connectivity, // may help others as well, default is CN which has different channels - wm.setCountry("US"); // crashing on esp32 2.0 + // wm.setCountry("US"); // crashing on esp32 2.0 // set Hostname @@ -388,7 +387,7 @@ void getTime() { } Serial.println(""); struct tm timeinfo; - gmtime_r(&now, &timeinfo); // @NOTE doesnt work in esp2.3.0 + gmtime_r(&now, &timeinfo); Serial.print("Current time: "); Serial.print(asctime(&timeinfo)); } From 9abf5abdf64df973c7e8bf238f81a53e8cdc1d3a Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Wed, 31 Aug 2022 15:34:20 -0500 Subject: [PATCH 075/100] fixes #1206 --- WiFiManager.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 6f699fa8..a9420190 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -32,7 +32,7 @@ WiFiManagerParameter::WiFiManagerParameter(const char *custom) { _id = NULL; _label = NULL; _length = 1; - _value = NULL; + _value = nullptr; _labelPlacement = WFM_LABEL_DEFAULT; _customHTML = custom; } @@ -58,6 +58,7 @@ void WiFiManagerParameter::init(const char *id, const char *label, const char *d _label = label; _labelPlacement = labelPlacement; _customHTML = custom; + _value = nullptr; setValue(defaultValue,length); } @@ -86,8 +87,14 @@ void WiFiManagerParameter::setValue(const char *defaultValue, int length) { // // return false; //@todo bail // } - _length = length; - _value = new char[_length + 1]; + if(_length != length){ + _length = length; + if( _value != nullptr){ + delete[] _value; + } + _value = new char[_length + 1]; + } + memset(_value, 0, _length + 1); // explicit null if (defaultValue != NULL) { From d04d1f677b8094f865f839cd500c510d36c2e0f6 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Wed, 31 Aug 2022 16:40:01 -0500 Subject: [PATCH 076/100] enabling #538 Turning on wifi scan preload and async scanning, with hardcoded cachetime of 30seconds. Should make wifi page load faster, and make interface seem smoother. Will have to test with various enviroments and on S2/x3 chips --- WiFiManager.cpp | 15 ++++++++++++--- WiFiManager.h | 13 ++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index a9420190..6f75c268 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -1452,11 +1452,20 @@ bool WiFiManager::WiFi_scanNetworks(bool force,bool async){ // DEBUG_WM(DEBUG_DEV,_numNetworks,(millis()-_lastscan )); // DEBUG_WM(DEBUG_DEV,"scanNetworks force:",force == true); #endif - if(_numNetworks == 0){ + + // if 0 networks, rescan @note this was a kludge, now disabling to test real cause ( maybe wifi not init etc) + // enable only if preload failed? + if(_numNetworks == 0 && _autoforcerescan){ DEBUG_WM(DEBUG_DEV,"NO APs found forcing new scan"); force = true; } - if(force || (_lastscan>0 && (millis()-_lastscan > 60000))){ + + // if scan is empty or stale (last scantime > _scancachetime), this avoids fast reloading wifi page and constant scan delayed page loads appearing to freeze. + if(!_lastscan || (_lastscan>0 && (millis()-_lastscan > _scancachetime))){ + force = true; + } + + if(force){ int8_t res; _startscan = millis(); if(async && _asyncScan){ @@ -3731,7 +3740,7 @@ String WiFiManager::WiFi_psk(bool persistent) const { WiFi.reconnect(); #endif } - else if(event == ARDUINO_EVENT_WIFI_SCAN_DONE){ + else if(event == ARDUINO_EVENT_WIFI_SCAN_DONE && _asyncScan){ uint16_t scans = WiFi.scanComplete(); WiFi_scanComplete(scans); } diff --git a/WiFiManager.h b/WiFiManager.h index 4c057ee1..cedffab1 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -544,10 +544,17 @@ class WiFiManager // async enables asyncronous scans, so they do not block anything // the refresh button bypasses cache // no aps found is problematic as scans are always going to want to run, leading to page load delays - boolean _preloadwifiscan = false; // preload wifiscan if true - boolean _asyncScan = false; // perform wifi network scan async - unsigned int _scancachetime = 30000; // ms cache time for background scans + // + // These settings really only make sense with _preloadwifiscan true + // but not limited to, we could run continuous background scans on various page hits, or xhr hits + // which would be better coupled with asyncscan + // atm preload is only done on root hit and startcp + boolean _preloadwifiscan = true; // preload wifiscan if true + unsigned int _scancachetime = 30000; // ms cache time for preload scans + boolean _asyncScan = true; // perform wifi network scan async + boolean _autoforcerescan = false; // automatically force rescan if scan networks is 0, ignoring cache + boolean _disableIpFields = false; // modify function of setShow_X_Fields(false), forces ip fields off instead of default show if set, eg. _staShowStaticFields=-1 String _wificountry = ""; // country code, @todo define in strings lang From 201ad2e838b2fe39295bf3819a46d02c49a37279 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Thu, 1 Sep 2022 07:54:41 -0500 Subject: [PATCH 077/100] Disable temp sensor for all esp32 until can find a better check --- WiFiManager.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WiFiManager.h b/WiFiManager.h index cedffab1..43d0524a 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -39,7 +39,8 @@ #define WM_NOSOFTAPSSID // no softapssid() @todo shim #endif -#ifdef ARDUINO_ESP32S3_DEV +// #ifdef ARDUINO_ESP32S3_DEV +#ifdef ESP32 #define WM_NOTEMP #endif From bb8aec4ce5c8e89a25dec4c3a1611dac75c6dabf Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Thu, 1 Sep 2022 10:43:19 -0500 Subject: [PATCH 078/100] remove reset from basic --- examples/Basic/Basic.ino | 4 ++-- examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/Basic/Basic.ino b/examples/Basic/Basic.ino index 59c95d90..bf1e263b 100644 --- a/examples/Basic/Basic.ino +++ b/examples/Basic/Basic.ino @@ -2,7 +2,7 @@ void setup() { - WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP + // WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP // it is a good practice to make sure your code sets wifi mode how you want it. // put your setup code here, to run once: @@ -13,7 +13,7 @@ void setup() { // reset settings - wipe stored credentials for testing // these are stored by the esp library - wm.resetSettings(); + // wm.resetSettings(); // Automatically connect using saved credentials, // if connection fails, it starts an access point with the specified name ( "AutoConnectAP"), diff --git a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino index 6ac38eb3..a648366f 100644 --- a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -113,7 +113,7 @@ void setup() { // wm.erase(); // setup some parameters - + WiFiManagerParameter custom_html("

This Is Custom HTML

"); // only custom html WiFiManagerParameter custom_mqtt_server("server", "mqtt server", "", 40); WiFiManagerParameter custom_mqtt_port("port", "mqtt port", "", 6); From 62d951c8e4f56115fc1615d546cde3a630a1b4f7 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Thu, 1 Sep 2022 10:43:44 -0500 Subject: [PATCH 079/100] try to fixup arduino version debugging info --- WiFiManager.cpp | 4 +++- WiFiManager.h | 62 ++++++++++++++++++++++++++++--------------------- 2 files changed, 39 insertions(+), 27 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 6f75c268..6a6f86d9 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -3332,8 +3332,10 @@ void WiFiManager::debugPlatformInfo(){ #endif #elif defined(ESP32) #ifdef WM_DEBUG_LEVEL - DEBUG_WM(F("Free heap: "), ESP.getFreeHeap()); + DEBUG_WM(F("WM version: "), WM_VERSION_STR); + DEBUG_WM(F("Arduino version: "), VER_ARDUINO_STR); DEBUG_WM(F("ESP SDK version: "), ESP.getSdkVersion()); + DEBUG_WM(F("Free heap: "), ESP.getFreeHeap()); #endif // esp_chip_info_t chipInfo; // esp_chip_info(&chipInfo); diff --git a/WiFiManager.h b/WiFiManager.h index 43d0524a..ecf955a6 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -41,7 +41,7 @@ // #ifdef ARDUINO_ESP32S3_DEV #ifdef ESP32 -#define WM_NOTEMP +#define WM_NOTEMP // disabled temp sensor, have to determine which chip we are on #endif // #include "soc/efuse_reg.h" // include to add efuse chip rev to info, getChipRevision() is almost always the same though, so not sure why it matters. @@ -53,31 +53,6 @@ #define WM_G(string_literal) (String(FPSTR(string_literal)).c_str()) -#define WM_STRING2(x) #x -#define WM_STRING(x) STRING2(x) - -// #include -#ifdef ESP_IDF_VERSION - // #pragma message "ESP_IDF_VERSION_MAJOR = " WM_STRING(ESP_IDF_VERSION_MAJOR) - // #pragma message "ESP_IDF_VERSION_MINOR = " WM_STRING(ESP_IDF_VERSION_MINOR) - // #pragma message "ESP_IDF_VERSION_PATCH = " WM_STRING(ESP_IDF_VERSION_PATCH) - #define VER_IDF_STR WM_STRING(ESP_IDF_VERSION_MAJOR) "." WM_STRING(ESP_IDF_VERSION_MINOR) "." WM_STRING(ESP_IDF_VERSION_PATCH) -#endif - -// #include "esp_arduino_version.h" -#ifdef ESP_ARDUINO_VERSION - // #pragma message "ESP_ARDUINO_VERSION_MAJOR = " WM_STRING(ESP_ARDUINO_VERSION_MAJOR) - // #pragma message "ESP_ARDUINO_VERSION_MINOR = " WM_STRING(ESP_ARDUINO_VERSION_MINOR) - // #pragma message "ESP_ARDUINO_VERSION_PATCH = " WM_STRING(ESP_ARDUINO_VERSION_PATCH) - #define VER_ARDUINO_STR WM_STRING(ESP_ARDUINO_VERSION_MAJOR) "." WM_STRING(ESP_ARDUINO_VERSION_MINOR) "." WM_STRING(ESP_ARDUINO_VERSION_PATCH) -#else - // #include - // #pragma message "ESP_ARDUINO_VERSION_GIT = " WM_STRING(ARDUINO_ESP32_GIT_VER)// 0x46d5afb1 - // #pragma message "ESP_ARDUINO_VERSION_DESC = " WM_STRING(ARDUINO_ESP32_GIT_DESC) // 1.0.6 - #define VER_ARDUINO_STR "Unknown" - // #pragma message "ESP_ARDUINO_VERSION_REL = " WM_STRING(ARDUINO_ESP32_RELEASE) //"1_0_6" -#endif - #ifdef ESP8266 extern "C" { @@ -132,6 +107,41 @@ #include #include "strings_en.h" +// prep string concat vars +#define WM_STRING2(x) #x +#define WM_STRING(x) WM_STRING2(x) + +#define VER_ARDUINO_STR "Unknown" +#define VER_IDF_STR "Unknown" + +// #include +#ifdef ESP_IDF_VERSION + // #pragma message "ESP_IDF_VERSION_MAJOR = " WM_STRING(ESP_IDF_VERSION_MAJOR) + // #pragma message "ESP_IDF_VERSION_MINOR = " WM_STRING(ESP_IDF_VERSION_MINOR) + // #pragma message "ESP_IDF_VERSION_PATCH = " WM_STRING(ESP_IDF_VERSION_PATCH) + #define VER_IDF_STR WM_STRING(ESP_IDF_VERSION_MAJOR) "." WM_STRING(ESP_IDF_VERSION_MINOR) "." WM_STRING(ESP_IDF_VERSION_PATCH) +#endif + +#ifdef Arduino_h + #include "esp_arduino_version.h" + // esp_get_idf_version + #ifdef ESP_ARDUINO_VERSION + // #pragma message "ESP_ARDUINO_VERSION_MAJOR = " WM_STRING(ESP_ARDUINO_VERSION_MAJOR) + // #pragma message "ESP_ARDUINO_VERSION_MINOR = " WM_STRING(ESP_ARDUINO_VERSION_MINOR) + // #pragma message "ESP_ARDUINO_VERSION_PATCH = " WM_STRING(ESP_ARDUINO_VERSION_PATCH) + #define VER_ARDUINO_STR WM_STRING(ESP_ARDUINO_VERSION_MAJOR) "." WM_STRING(ESP_ARDUINO_VERSION_MINOR) "." WM_STRING(ESP_ARDUINO_VERSION_PATCH) + #else + #include + // #pragma message "ESP_ARDUINO_VERSION_GIT = " WM_STRING(ARDUINO_ESP32_GIT_VER)// 0x46d5afb1 + // #pragma message "ESP_ARDUINO_VERSION_DESC = " WM_STRING(ARDUINO_ESP32_GIT_DESC) // 1.0.6 + // #pragma message "ESP_ARDUINO_VERSION_REL = " WM_STRING(ARDUINO_ESP32_RELEASE) //"1_0_6" + #define VER_ARDUINO_STR WM_STRING(ESP_ARDUINO_VERSION_MAJOR) "." WM_STRING(ESP_ARDUINO_VERSION_MINOR) "." WM_STRING(ESP_ARDUINO_VERSION_PATCH) + #endif +#endif + +// #pragma message "VER_IDF_STR = " WM_STRING(VER_IDF_STR) +// #pragma message "VER_ARDUINO_STR = " WM_STRING(VER_ARDUINO_STR) + #ifndef WIFI_MANAGER_MAX_PARAMS #define WIFI_MANAGER_MAX_PARAMS 5 // params will autoincrement and realloc by this amount when max is reached #endif From 60efff754e75f307a019165aca962dde2a484d7f Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Thu, 1 Sep 2022 11:53:53 -0500 Subject: [PATCH 080/100] fix redefine --- WiFiManager.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/WiFiManager.h b/WiFiManager.h index ecf955a6..52662a0a 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -111,8 +111,6 @@ #define WM_STRING2(x) #x #define WM_STRING(x) WM_STRING2(x) -#define VER_ARDUINO_STR "Unknown" -#define VER_IDF_STR "Unknown" // #include #ifdef ESP_IDF_VERSION @@ -120,6 +118,8 @@ // #pragma message "ESP_IDF_VERSION_MINOR = " WM_STRING(ESP_IDF_VERSION_MINOR) // #pragma message "ESP_IDF_VERSION_PATCH = " WM_STRING(ESP_IDF_VERSION_PATCH) #define VER_IDF_STR WM_STRING(ESP_IDF_VERSION_MAJOR) "." WM_STRING(ESP_IDF_VERSION_MINOR) "." WM_STRING(ESP_IDF_VERSION_PATCH) +#else + #define VER_IDF_STR "Unknown" #endif #ifdef Arduino_h @@ -137,8 +137,11 @@ // #pragma message "ESP_ARDUINO_VERSION_REL = " WM_STRING(ARDUINO_ESP32_RELEASE) //"1_0_6" #define VER_ARDUINO_STR WM_STRING(ESP_ARDUINO_VERSION_MAJOR) "." WM_STRING(ESP_ARDUINO_VERSION_MINOR) "." WM_STRING(ESP_ARDUINO_VERSION_PATCH) #endif +#else +#define VER_ARDUINO_STR "Unknown" #endif + // #pragma message "VER_IDF_STR = " WM_STRING(VER_IDF_STR) // #pragma message "VER_ARDUINO_STR = " WM_STRING(VER_ARDUINO_STR) From 7bdcfd501eb18d6c48be37f8608de775e44a90ae Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Thu, 1 Sep 2022 15:27:31 -0500 Subject: [PATCH 081/100] fix esp8266 versioning --- WiFiManager.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/WiFiManager.h b/WiFiManager.h index 52662a0a..c1887f74 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -123,7 +123,9 @@ #endif #ifdef Arduino_h + #ifdef ESP32 #include "esp_arduino_version.h" + #endif // esp_get_idf_version #ifdef ESP_ARDUINO_VERSION // #pragma message "ESP_ARDUINO_VERSION_MAJOR = " WM_STRING(ESP_ARDUINO_VERSION_MAJOR) From b676daf37ca337d19ab8c0e7936141bc7e0ec052 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Mon, 12 Sep 2022 11:23:04 -0500 Subject: [PATCH 082/100] oops #1403 --- WiFiManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 6a6f86d9..0d2f4a16 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -282,7 +282,7 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { #ifdef ESP32 setupHostname(true); - if(_hostname){ + if(_hostname != ""){ // disable wifi if already on if(WiFi.getMode() & WIFI_STA){ WiFi.mode(WIFI_OFF); From 2b24b91f8884079612b31bef45c6da3a3b8ae6bf Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Mon, 12 Sep 2022 12:06:40 -0500 Subject: [PATCH 083/100] fixes #1490 Does not fix wifi not init yet thanks @erriez --- WiFiManager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 0d2f4a16..dbbc3d44 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -279,6 +279,8 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { DEBUG_WM(F("AutoConnect")); #endif + bool wifiIsSaved = getWiFiIsSaved(); + #ifdef ESP32 setupHostname(true); @@ -295,7 +297,7 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { } #endif - if(getWiFiIsSaved()){ + if(wifiIsSaved){ _startconn = millis(); _begin(); From 6fb63f834ac9094cb7279207cf364c5931e52204 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Mon, 12 Sep 2022 16:05:16 -0500 Subject: [PATCH 084/100] remove wifiissaved check --- WiFiManager.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index dbbc3d44..0853000a 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -297,7 +297,9 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { } #endif - if(wifiIsSaved){ + // check if wifi is saved, (has autoconnect) to speed up cp start + // NOT wifi init safe + // if(wifiIsSaved){ _startconn = millis(); _begin(); @@ -364,12 +366,12 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { #ifdef WM_DEBUG_LEVEL DEBUG_WM(F("AutoConnect: FAILED")); #endif - } - else { - #ifdef WM_DEBUG_LEVEL - DEBUG_WM(F("No Credentials are Saved, skipping connect")); - #endif - } + // } + // else { + // #ifdef WM_DEBUG_LEVEL + // DEBUG_WM(F("No Credentials are Saved, skipping connect")); + // #endif + // } // possibly skip the config portal if (!_enableConfigPortal) { From 1b5d71bac79482fb72be832b8e2df0448e6d14d6 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Mon, 12 Sep 2022 16:06:23 -0500 Subject: [PATCH 085/100] workaround for #1482 --- WiFiManager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 0853000a..2a71921d 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -717,6 +717,7 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo // HANDLE issues with STA connections, shutdown sta if not connected, or else this will hang channel scanning and softap will not respond if(_disableSTA || (!WiFi.isConnected() && _disableSTAConn)){ // this fixes most ap problems, however, simply doing mode(WIFI_AP) does not work if sta connection is hanging, must `wifi_station_disconnect` + WiFi.mode(WIFI_AP_STA); WiFi_Disconnect(); WiFi_enableSTA(false); #ifdef WM_DEBUG_LEVEL @@ -724,7 +725,7 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo #endif } else { - WiFi_enableSTA(true); + // WiFi_enableSTA(true); } // init configportal globals to known states From c34770ec32e823e58fe66404e48add7cf9a66a43 Mon Sep 17 00:00:00 2001 From: Thiti Yamsung Date: Thu, 15 Sep 2022 19:07:55 +0700 Subject: [PATCH 086/100] feat(callback): add config portal timeout callback for handle config portal timeout (#1497) --- WiFiManager.cpp | 21 +++++++++++++++++++++ WiFiManager.h | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 2a71921d..271c599d 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -786,6 +786,12 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo #endif shutdownConfigPortal(); result = abort ? portalAbortResult : portalTimeoutResult; // false, false + if (_configportaltimeoutcallback != NULL) { + #ifdef WM_DEBUG_LEVEL + DEBUG_WM(DEBUG_VERBOSE,F("[CB] config portal timeout callback")); + #endif + _configportaltimeoutcallback(); // @CALLBACK + } break; } @@ -830,6 +836,12 @@ boolean WiFiManager::process(){ #endif webPortalActive = false; shutdownConfigPortal(); + if (_configportaltimeoutcallback != NULL) { + #ifdef WM_DEBUG_LEVEL + DEBUG_WM(DEBUG_VERBOSE,F("[CB] config portal timeout callback")); + #endif + _configportaltimeoutcallback(); // @CALLBACK + } return false; } @@ -2788,6 +2800,15 @@ void WiFiManager::setPreOtaUpdateCallback( std::function func ) { _preotaupdatecallback = func; } +/** + * setConfigPortalTimeoutCallback, set a callback to config portal is timeout + * @access public + * @param {[type]} void (*func)(void) + */ +void WiFiManager::setConfigPortalTimeoutCallback( std::function func ) { + _configportaltimeoutcallback = func; +} + /** * set custom head html * custom element will be added to head, eg. new meta,style,script tag etc. diff --git a/WiFiManager.h b/WiFiManager.h index c1887f74..19115160 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -276,6 +276,9 @@ class WiFiManager //called just before doing OTA update void setPreOtaUpdateCallback( std::function func ); + //called when config portal is timeout + void setConfigPortalTimeoutCallback( std::function func ); + //sets timeout before AP,webserver loop ends and exits even if there has been no setup. //useful for devices that failed to connect at some point and got stuck in a webserver loop //in seconds setConfigPortalTimeout is a new name for setTimeout, ! not used if setConfigPortalBlocking @@ -771,6 +774,7 @@ class WiFiManager std::function _saveparamscallback; std::function _resetcallback; std::function _preotaupdatecallback; + std::function _configportaltimeoutcallback; template auto optionalIPFromString(T *obj, const char *s) -> decltype( obj->fromString(s) ) { From 297a1af26017e1813638ef386b2094cd4c5b552d Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Fri, 16 Sep 2022 10:21:34 -0500 Subject: [PATCH 087/100] clean up --- WiFiManager.cpp | 12 +++-- examples/Tests/wifi_softap/wifi_softap.ino | 51 ++++++++++++++++++++++ 2 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 examples/Tests/wifi_softap/wifi_softap.ino diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 6a6f86d9..bfb03249 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -828,13 +828,19 @@ boolean WiFiManager::process(){ return false; } - uint8_t state = processConfigPortal(); + uint8_t state = processConfigPortal(); // state is WL_IDLE or WL_CONNECTED/FAILED return state == WL_CONNECTED; } return false; } -//using esp wl_status enums as returns for now, should be fine +/** + * [processConfigPortal description] + * using esp wl_status enums as returns for now, should be fine + * returns WL_IDLE_STATUS or WL_CONNECTED/WL_CONNECT_FAILED upon connect/save flag + * + * @return {[type]} [description] + */ uint8_t WiFiManager::processConfigPortal(){ if(configPortalActive){ //DNS handler @@ -2354,7 +2360,7 @@ void WiFiManager::handleNotFound() { */ boolean WiFiManager::captivePortal() { #ifdef WM_DEBUG_LEVEL - DEBUG_WM(DEBUG_DEV,"-> " + server->hostHeader()); + DEBUG_WM(DEBUG_MAX,"-> " + server->hostHeader()); #endif if(!_enableCaptivePortal) return false; // skip redirections, @todo maybe allow redirection even when no cp ? might be useful diff --git a/examples/Tests/wifi_softap/wifi_softap.ino b/examples/Tests/wifi_softap/wifi_softap.ino new file mode 100644 index 00000000..aa3e45c8 --- /dev/null +++ b/examples/Tests/wifi_softap/wifi_softap.ino @@ -0,0 +1,51 @@ +// wifi_basic.ino + +#include +#include + +// #define NVSERASE +#ifdef NVSERASE +#include +#include +#endif + +void setup(){ + Serial.begin(115200); + delay(2000); + Serial.println("Startup...."); + + #ifdef NVSERASE + esp_err_t err; + err = nvs_flash_init(); + err = nvs_flash_erase(); + #endif + + Serial.setDebugOutput(true); + + WiFi.begin("hellowifi","noonehere"); + + while (WiFi.status() != WL_CONNECTED && millis()<15000) { + delay(500); + Serial.print("."); + } + + if(WiFi.status() == WL_CONNECTED){ + Serial.println(""); + Serial.println("WiFi connected."); + Serial.println("IP address: "); + // Serial.println(WiFi.localIP()); + } + else { + Serial.println("WiFi NOT CONNECTED, starting ap"); + /////////////// + /// BUG + // WiFi.enableSTA(false); // BREAKS softap start, says ok BUT no ap found + + delay(2000); + WiFi.softAP("espsoftap","12345678"); + } +} + +void loop(){ + +} \ No newline at end of file From dda1c45fa95a3c1b03511ad23ab4d64e9679fef4 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Fri, 16 Sep 2022 10:21:52 -0500 Subject: [PATCH 088/100] disable captive portal checks on ota uploades --- WiFiManager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index bfb03249..6416e5a2 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -3801,7 +3801,8 @@ void WiFiManager::handleUpdating(){ // combine route handlers into one callback and use argument or post checking instead of mutiple functions maybe, if POST process else server upload page? // [x] add upload checking, do we need too check file? // convert output to debugger if not moving to example - if (captivePortal()) return; // If captive portal redirect instead of displaying the page + + // if (captivePortal()) return; // If captive portal redirect instead of displaying the page bool error = false; unsigned long _configPortalTimeoutSAV = _configPortalTimeout; // store cp timeout _configPortalTimeout = 0; // disable timeout From 3545410ba4467b8affd8ae00e4f6dc26c5ba6f2f Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Fri, 16 Sep 2022 10:22:34 -0500 Subject: [PATCH 089/100] remove captive portal check on ota done, remove serial debug --- WiFiManager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 6416e5a2..cb94cc08 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -3813,7 +3813,7 @@ void WiFiManager::handleUpdating(){ // UPLOAD START if (upload.status == UPLOAD_FILE_START) { - if(_debug) Serial.setDebugOutput(true); + // if(_debug) Serial.setDebugOutput(true); uint32_t maxSketchSpace; // Use new callback for before OTA update @@ -3831,7 +3831,7 @@ void WiFiManager::handleUpdating(){ #endif #ifdef WM_DEBUG_LEVEL - DEBUG_WM(DEBUG_VERBOSE,"Update file: ", upload.filename.c_str()); + DEBUG_WM(DEBUG_VERBOSE,"[OTA] Update file: ", upload.filename.c_str()); #endif // Update.onProgress(THandlerFunction_Progress fn); @@ -3867,7 +3867,7 @@ void WiFiManager::handleUpdating(){ #endif } else { - Update.printError(Serial); + // Update.printError(Serial); error = true; } } @@ -3884,7 +3884,7 @@ void WiFiManager::handleUpdating(){ // upload and ota done, show status void WiFiManager::handleUpdateDone() { DEBUG_WM(DEBUG_VERBOSE, F("<- Handle update done")); - if (captivePortal()) return; // If captive portal redirect instead of displaying the page + // if (captivePortal()) return; // If captive portal redirect instead of displaying the page String page = getHTTPHead(FPSTR(S_options)); // @token options String str = FPSTR(HTTP_ROOT_MAIN); From d5536fbc69a36bafcbebc4d0931cad83f0708cfc Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Tue, 20 Sep 2022 19:37:26 -0500 Subject: [PATCH 090/100] remove workardound for arduino 2.0.5 #1482 --- WiFiManager.cpp | 4 +++- WiFiManager.h | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 5488cbf4..ded4e254 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -717,7 +717,9 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo // HANDLE issues with STA connections, shutdown sta if not connected, or else this will hang channel scanning and softap will not respond if(_disableSTA || (!WiFi.isConnected() && _disableSTAConn)){ // this fixes most ap problems, however, simply doing mode(WIFI_AP) does not work if sta connection is hanging, must `wifi_station_disconnect` - WiFi.mode(WIFI_AP_STA); + #ifdef WM_DISCONWORKAROUND + WiFi.mode(WIFI_AP_STA); + #endif WiFi_Disconnect(); WiFi_enableSTA(false); #ifdef WM_DEBUG_LEVEL diff --git a/WiFiManager.h b/WiFiManager.h index 19115160..08643a69 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -659,6 +659,7 @@ class WiFiManager #if defined(ESP_ARDUINO_VERSION) && defined(ESP_ARDUINO_VERSION_VAL) #define WM_ARDUINOVERCHECK ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(2, 0, 0) + #define WM_ARDUINOVERCHECK_204 ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 5) #ifdef WM_ARDUINOVERCHECK #define WM_ARDUINOEVENTS @@ -667,6 +668,10 @@ class WiFiManager #define WM_NOCOUNTRY #endif + #ifdef WM_ARDUINOVERCHECK_204 + #define WM_DISCONWORKAROUND + #endif + #else #define WM_NOCOUNTRY #endif From 15459925b050f9fcef5c301ee281f44d4dfac430 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Tue, 20 Sep 2022 19:39:50 -0500 Subject: [PATCH 091/100] ver bump --- library.json | 2 +- library.properties | 2 +- strings_en.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library.json b/library.json index e77262e3..d8bbf983 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "WiFiManager", - "version": "2.0.12-beta", + "version": "2.0.13-beta", "keywords": "wifi,wi-fi,esp,esp8266,esp32,espressif8266,espressif32,nodemcu,wemos,arduino", "description": "WiFi Configuration manager with web configuration portal for ESP boards", "authors": diff --git a/library.properties b/library.properties index db9faadc..791cd61e 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=WiFiManager -version=2.0.12-beta +version=2.0.13-beta author=tzapu maintainer=tablatronix sentence=WiFi Configuration manager with web configuration portal for Espressif ESPx boards, by tzapu diff --git a/strings_en.h b/strings_en.h index 386571d4..382ab01f 100644 --- a/strings_en.h +++ b/strings_en.h @@ -17,7 +17,7 @@ #ifndef WIFI_MANAGER_OVERRIDE_STRINGS // !!! ABOVE WILL NOT WORK if you define in your sketch, must be build flag, if anyone one knows how to order includes to be able to do this it would be neat.. I have seen it done.. -const char WM_VERSION_STR[] PROGMEM = "v2.0.12-beta"; +const char WM_VERSION_STR[] PROGMEM = "v2.0.13-beta"; const char HTTP_HEAD_START[] PROGMEM = "" "" From 0ae78ee3399f406e67d7520310e1bbeb5514d95c Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Tue, 20 Sep 2022 22:07:50 -0500 Subject: [PATCH 092/100] add heaadings to template --- extras/WiFiManager.template.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/extras/WiFiManager.template.html b/extras/WiFiManager.template.html index d928a8c6..20787e13 100644 --- a/extras/WiFiManager.template.html +++ b/extras/WiFiManager.template.html @@ -302,7 +302,11 @@

custom parameter


H4 Color Header S

content
-

/info


+

Heading 1

+

Heading 2

+

Heading 3

+

Heading 4

+

WIFI HEAD (WIFI_OFF)


Chip ID
123456
Flash Chip ID
1234556
From 9eee18ab3248230614d6828b4be9d3e5ebe178d0 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Tue, 20 Sep 2022 22:08:54 -0500 Subject: [PATCH 093/100] add esp32 temp sensor back --- WiFiManager.cpp | 3 +-- WiFiManager.h | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index ded4e254..ac5ae569 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -1989,7 +1989,7 @@ void WiFiManager::handleInfo() { #elif defined(ESP32) // add esp_chip_info ? - infos = 26; + infos = 27; String infoids[] = { F("esphead"), F("uptime"), @@ -2017,7 +2017,6 @@ void WiFiManager::handleInfo() { F("apmac"), F("aphost"), F("apbssid") - // F("temp") }; #endif diff --git a/WiFiManager.h b/WiFiManager.h index 08643a69..116dc609 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -39,8 +39,20 @@ #define WM_NOSOFTAPSSID // no softapssid() @todo shim #endif -// #ifdef ARDUINO_ESP32S3_DEV -#ifdef ESP32 +// #ifdef CONFIG_IDF_TARGET_ESP32S2 +// #warning ESP32S2 +// #endif + +// #ifdef CONFIG_IDF_TARGET_ESP32C3 +// #warning ESP32C3 +// #endif + +// #ifdef CONFIG_IDF_TARGET_ESP32S3 +// #warning ESP32S3 +// #endif + +#if defined(ARDUINO_ESP32S3_DEV) || defined(CONFIG_IDF_TARGET_ESP32S3) +#warning "WM_NOTEMP" #define WM_NOTEMP // disabled temp sensor, have to determine which chip we are on #endif From 6d23d7591f8ef0cabba887dcc4fb531f9eb1f666 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Tue, 20 Sep 2022 22:09:57 -0500 Subject: [PATCH 094/100] remove hall sensor, fix temp --- WiFiManager.cpp | 3 ++- strings_en.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index ac5ae569..53f21492 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -2002,6 +2002,7 @@ void WiFiManager::handleInfo() { F("memsketch"), F("memsmeter"), F("lastreset"), + F("temp"), F("wifihead"), F("conx"), F("stassid"), @@ -2238,7 +2239,7 @@ String WiFiManager::getInfoData(String id){ p.replace(FPSTR(T_1),(String)temperatureRead()); p.replace(FPSTR(T_2),(String)((temperatureRead()+32)*1.8)); // p.replace(FPSTR(T_3),(String)hallRead()); - p.replace(FPSTR(T_3),"NA"); + // p.replace(FPSTR(T_3),"NA"); // removed hall sensor as reads can cause issues with adcs } #endif else if(id==F("aboutver")){ diff --git a/strings_en.h b/strings_en.h index 382ab01f..25916dc4 100644 --- a/strings_en.h +++ b/strings_en.h @@ -178,7 +178,8 @@ const char HTTP_JS[] PROGMEM = const char HTTP_INFO_lastreset[] PROGMEM = "
Last reset reason
CPU0: {1}
CPU1: {2}
"; const char HTTP_INFO_aphost[] PROGMEM = "
Access Point Hostname
{1}
"; const char HTTP_INFO_psrsize[] PROGMEM = "
PSRAM Size
{1} bytes
"; - const char HTTP_INFO_temp[] PROGMEM = "
Temperature
{1} C° / {2} F°
Hall
{3}
"; + const char HTTP_INFO_temp[] PROGMEM = "
Temperature
{1} C° / {2} F°
"; + // const char HTTP_INFO_temp[] PROGMEM = "
Hall
{3}
"; #else const char HTTP_INFO_esphead[] PROGMEM = "

esp8266


"; const char HTTP_INFO_fchipid[] PROGMEM = "
Flash Chip ID
{1}
"; From 30efa2e028b3afd9967fc91a9eca75a2589310ea Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Tue, 20 Sep 2022 22:11:15 -0500 Subject: [PATCH 095/100] add esp model and wifi mode status to info page headers --- WiFiManager.cpp | 13 +++++++++---- strings_en.h | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 53f21492..f6d74173 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -2052,9 +2052,14 @@ void WiFiManager::handleInfo() { String WiFiManager::getInfoData(String id){ String p; - // @todo add WM versioning - if(id==F("esphead"))p = FPSTR(HTTP_INFO_esphead); - else if(id==F("wifihead"))p = FPSTR(HTTP_INFO_wifihead); + if(id==F("esphead")){ + p = FPSTR(HTTP_INFO_esphead); + p.replace(FPSTR(T_1),(String)ESP.getChipModel()); + } + else if(id==F("wifihead")){ + p = FPSTR(HTTP_INFO_wifihead); + p.replace(FPSTR(T_1),getModeString(WiFi.getMode())); + } else if(id==F("uptime")){ // subject to rollover! p = FPSTR(HTTP_INFO_uptime); @@ -2107,7 +2112,7 @@ String WiFiManager::getInfoData(String id){ p = FPSTR(HTTP_INFO_bootver); p.replace(FPSTR(T_1),(String)system_get_boot_version()); } - #endif + #endif else if(id==F("cpufreq")){ p = FPSTR(HTTP_INFO_cpufreq); p.replace(FPSTR(T_1),(String)ESP.getCpuFreqMHz()); diff --git a/strings_en.h b/strings_en.h index 25916dc4..5ea622ec 100644 --- a/strings_en.h +++ b/strings_en.h @@ -173,7 +173,7 @@ const char HTTP_JS[] PROGMEM = // Info html // @todo remove html elements from progmem, repetetive strings #ifdef ESP32 - const char HTTP_INFO_esphead[] PROGMEM = "

esp32


"; + const char HTTP_INFO_esphead[] PROGMEM = "

{1}


"; const char HTTP_INFO_chiprev[] PROGMEM = "
Chip Rev
{1}
"; const char HTTP_INFO_lastreset[] PROGMEM = "
Last reset reason
CPU0: {1}
CPU1: {2}
"; const char HTTP_INFO_aphost[] PROGMEM = "
Access Point Hostname
{1}
"; @@ -192,7 +192,7 @@ const char HTTP_JS[] PROGMEM = const char HTTP_INFO_memsmeter[] PROGMEM = "
"; const char HTTP_INFO_memsketch[] PROGMEM = "
Memory - Sketch Size
Used / Total bytes
{1} / {2}"; const char HTTP_INFO_freeheap[] PROGMEM = "
Memory - Free Heap
{1} bytes available
"; -const char HTTP_INFO_wifihead[] PROGMEM = "

WiFi


"; +const char HTTP_INFO_wifihead[] PROGMEM = "

WiFi ({1})


"; const char HTTP_INFO_uptime[] PROGMEM = "
Uptime
{1} Mins {2} Secs
"; const char HTTP_INFO_chipid[] PROGMEM = "
Chip ID
{1}
"; const char HTTP_INFO_idesize[] PROGMEM = "
Flash Size
{1} bytes
"; From 4ff7d7049a59e35807160c7ae4c4150faf1125bc Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Tue, 20 Sep 2022 22:11:35 -0500 Subject: [PATCH 096/100] add chip model etc to debugging --- WiFiManager.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index f6d74173..e14e92cb 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -3364,28 +3364,25 @@ void WiFiManager::debugPlatformInfo(){ #ifdef ESP8266 system_print_meminfo(); #ifdef WM_DEBUG_LEVEL - DEBUG_WM(F("getCoreVersion(): "),ESP.getCoreVersion()); - DEBUG_WM(F("system_get_sdk_version(): "),system_get_sdk_version()); - DEBUG_WM(F("system_get_boot_version():"),system_get_boot_version()); - DEBUG_WM(F("getFreeHeap(): "),(String)ESP.getFreeHeap()); + DEBUG_WM(F("[SYS] getCoreVersion(): "),ESP.getCoreVersion()); + DEBUG_WM(F("[SYS] system_get_sdk_version(): "),system_get_sdk_version()); + DEBUG_WM(F("[SYS] system_get_boot_version():"),system_get_boot_version()); + DEBUG_WM(F("[SYS] getFreeHeap(): "),(String)ESP.getFreeHeap()); #endif #elif defined(ESP32) #ifdef WM_DEBUG_LEVEL - DEBUG_WM(F("WM version: "), WM_VERSION_STR); - DEBUG_WM(F("Arduino version: "), VER_ARDUINO_STR); - DEBUG_WM(F("ESP SDK version: "), ESP.getSdkVersion()); - DEBUG_WM(F("Free heap: "), ESP.getFreeHeap()); + DEBUG_WM(F("[SYS] WM version: "), WM_VERSION_STR); + DEBUG_WM(F("[SYS] Arduino version: "), VER_ARDUINO_STR); + DEBUG_WM(F("[SYS] ESP SDK version: "), ESP.getSdkVersion()); + DEBUG_WM(F("[SYS] Free heap: "), ESP.getFreeHeap()); #endif - // esp_chip_info_t chipInfo; - // esp_chip_info(&chipInfo); + #ifdef WM_DEBUG_LEVEL - // DEBUG_WM("Chip Info: Model: ",chipInfo.model); - // DEBUG_WM("Chip Info: Cores: ",chipInfo.cores); - // DEBUG_WM("Chip Info: Rev: ",chipInfo.revision); - // DEBUG_WM(printf("Chip Info: Model: %d, cores: %d, revision: %d", chipInfo.model.c_str(), chipInfo.cores, chipInfo.revision)); - // DEBUG_WM("Chip Rev: ",(String)ESP.getChipRevision()); + DEBUG_WM(F("[SYS] Chip ID:"),WIFI_getChipId()); + DEBUG_WM(F("[SYS] Chip Model:"), ESP.getChipModel()); + DEBUG_WM(F("[SYS] Chip Cores:"), ESP.getChipCores()); + DEBUG_WM(F("[SYS] Chip Rev:"), ESP.getChipRevision()); #endif - // core version is not avail #endif } From 696b920273e8122cf4dff37d6f90e558950bfc7d Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Tue, 20 Sep 2022 22:11:52 -0500 Subject: [PATCH 097/100] update rtc for resetreasons on multiple models --- WiFiManager.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/WiFiManager.h b/WiFiManager.h index 116dc609..19d24631 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -109,7 +109,21 @@ #endif #ifdef WM_RTC - #include + #ifdef ESP_IDF_VERSION_MAJOR // IDF 4+ + #if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4 + #include "esp32/rom/rtc.h" + #elif CONFIG_IDF_TARGET_ESP32S2 + #include "esp32s2/rom/rtc.h" + #elif CONFIG_IDF_TARGET_ESP32C3 + #include "esp32c3/rom/rtc.h" + #elif CONFIG_IDF_TARGET_ESP32S3 + #include "esp32s3/rom/rtc.h" + #else + #error Target CONFIG_IDF_TARGET is not supported + #endif + #else // ESP32 Before IDF 4.0 + #include "rom/rtc.h" + #endif #endif #else From 993b1ad9a9270b8d6b541cdacaea4ade71841eb7 Mon Sep 17 00:00:00 2001 From: Thiti Yamsung Date: Wed, 21 Sep 2022 18:54:31 +0700 Subject: [PATCH 098/100] fix: not found getChipModel method for ESP8266 (#1503) --- WiFiManager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index e14e92cb..41b3bb89 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -2054,7 +2054,9 @@ String WiFiManager::getInfoData(String id){ String p; if(id==F("esphead")){ p = FPSTR(HTTP_INFO_esphead); - p.replace(FPSTR(T_1),(String)ESP.getChipModel()); + #ifdef ESP32 + p.replace(FPSTR(T_1), (String)ESP.getChipModel()); + #endif } else if(id==F("wifihead")){ p = FPSTR(HTTP_INFO_wifihead); From 7fa6387d99b2b54c1e66f7cf1ef3e8bfab9ba19d Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Wed, 21 Sep 2022 11:55:56 -0500 Subject: [PATCH 099/100] #1504 --- WiFiManager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 41b3bb89..75987302 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -58,6 +58,7 @@ void WiFiManagerParameter::init(const char *id, const char *label, const char *d _label = label; _labelPlacement = labelPlacement; _customHTML = custom; + _length = 1; _value = nullptr; setValue(defaultValue,length); } From e0f29c6e0d3817f5326fb524ad2427ac44f38fdf Mon Sep 17 00:00:00 2001 From: John Date: Sun, 25 Sep 2022 13:22:29 -0400 Subject: [PATCH 100/100] Revert to specifying repo rather than using LDF --- library.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library.json b/library.json index 10876b50..0357a370 100644 --- a/library.json +++ b/library.json @@ -22,9 +22,9 @@ }, "frameworks": "arduino", "dependencies": { - "me-no-dev/ESPAsyncWebServer": "*", "me-no-dev/AsyncTCP": "*", - "bbx10/DNSServer": "^1.1.0" + "bbx10/DNSServer": "^1.1.0", + "external-repo": "https://github.com/me-no-dev/ESPAsyncWebServer.git" }, "build": { "libLDFMode": "chain+" @@ -34,4 +34,4 @@ "espressif8266", "espressif32" ] -} \ No newline at end of file +}