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 01/72] 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 02/72] 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 03/72] 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 04/72] 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 05/72] 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 06/72] 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


{v}
-



+

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 07/72] 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 08/72] 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 09/72] 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 10/72] 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 11/72] 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 12/72] 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 13/72] 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 14/72] 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 15/72] 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 16/72] #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 17/72] 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 18/72] 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 19/72] 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 20/72] 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 21/72] #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 22/72] 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 23/72] 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 24/72] 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 25/72] 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 26/72] 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 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 27/72] 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 28/72] #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 29/72] 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 30/72] 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 31/72] 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 32/72] 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 33/72] 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 34/72] 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 35/72] 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 36/72] 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 37/72] 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 38/72] 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 39/72] 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 40/72] 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 41/72] 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 42/72] 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 43/72] 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 44/72] 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 45/72] 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 46/72] 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 47/72] 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 48/72] 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 49/72] 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 50/72] 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 51/72] 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 52/72] 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 53/72] 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 54/72] 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 55/72] #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 9e4b7cb66dda0047e305982a74595a46c54de6fe Mon Sep 17 00:00:00 2001 From: Shawn A <807787+tablatronix@users.noreply.github.com> Date: Sun, 25 Sep 2022 11:48:03 -0500 Subject: [PATCH 56/72] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index a6209ddf..a5c912a9 100644 --- a/README.md +++ b/README.md @@ -26,8 +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/WgjVprfN) - +[![Discord](https://img.shields.io/badge/Discord-WiFiManager-%237289da.svg?logo=discord)](https://discord.gg/nS5WGkaQH5) 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. **This works with the ESP8266 Arduino platform** From 48d4dbcfe5595d662c10156b3bb85f3d3ff0a2cc Mon Sep 17 00:00:00 2001 From: Avi B <474746+abrender@users.noreply.github.com> Date: Mon, 3 Oct 2022 21:55:56 -0400 Subject: [PATCH 57/72] Support for WifiManager as ESP-IDF component (#1489) Enables support for WifiManager as an ESP-IDF component. ESP-IDF is a popular development framework for ESP32 chips. This file is based on the CMakeLists.txt file from the popular Adafruit-GFX-Library library. --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..7bd408a5 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.5) + +idf_component_register( + SRCS "WiFiManager.cpp" + INCLUDE_DIRS "." + REQUIRES arduino +) + +project(WiFiManager) From 476952c2da93dbadaab7cf84e81a1d3c00656d5d Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Tue, 4 Oct 2022 16:35:43 -0500 Subject: [PATCH 58/72] add back button to saves --- WiFiManager.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 75987302..c2d8dda1 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -1859,6 +1859,8 @@ void WiFiManager::handleWifiSave() { page = getHTTPHead(FPSTR(S_titlewifisaved)); // @token titlewifisaved page += FPSTR(HTTP_SAVED); } + + if(_showBack) page += FPSTR(HTTP_BACKBTN); page += FPSTR(HTTP_END); server->sendHeader(FPSTR(HTTP_HEAD_CORS), FPSTR(HTTP_HEAD_CORS_ALLOW_ALL)); // @HTTPHEAD send cors @@ -1885,6 +1887,7 @@ void WiFiManager::handleParamSave() { String page = getHTTPHead(FPSTR(S_titleparamsaved)); // @token titleparamsaved page += FPSTR(HTTP_PARAMSAVED); + if(_showBack) page += FPSTR(HTTP_BACKBTN); page += FPSTR(HTTP_END); HTTPSend(page); From dbefaed1a23902f16b796eaab2bbb5b15080d79c Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Fri, 14 Oct 2022 11:34:50 -0500 Subject: [PATCH 59/72] fix #1509 --- WiFiManager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WiFiManager.h b/WiFiManager.h index 19d24631..02286e47 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -150,7 +150,7 @@ #ifdef Arduino_h #ifdef ESP32 - #include "esp_arduino_version.h" + // #include "esp_arduino_version.h" // esp32 arduino > 2.x #endif // esp_get_idf_version #ifdef ESP_ARDUINO_VERSION From 701d58fd0751f27008a3851ae5bd73d79ed50a17 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Fri, 14 Oct 2022 11:35:51 -0500 Subject: [PATCH 60/72] fixes #1511 --- WiFiManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index c2d8dda1..edd1ed3a 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -280,7 +280,7 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { DEBUG_WM(F("AutoConnect")); #endif - bool wifiIsSaved = getWiFiIsSaved(); + // bool wifiIsSaved = getWiFiIsSaved(); #ifdef ESP32 setupHostname(true); From 9f5981e2fd40db86780299d5ba3a3840b891a998 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Fri, 14 Oct 2022 11:50:32 -0500 Subject: [PATCH 61/72] v bump --- library.json | 2 +- library.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.json b/library.json index d8bbf983..eaf4b5e3 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "WiFiManager", - "version": "2.0.13-beta", + "version": "2.0.14-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 791cd61e..3dbc5f44 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=WiFiManager -version=2.0.13-beta +version=2.0.14-beta author=tzapu maintainer=tablatronix sentence=WiFi Configuration manager with web configuration portal for Espressif ESPx boards, by tzapu From 71937d11553482d757694c922fd0fea58fe304ad Mon Sep 17 00:00:00 2001 From: Shawn A <807787+tablatronix@users.noreply.github.com> Date: Thu, 10 Nov 2022 13:07:45 -0600 Subject: [PATCH 62/72] Update ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index eb07c02d..80f7d31b 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,4 +1,4 @@ -## PLEASE TRY DEVELOPMENT BRANCH before submitting bugs on release or master, in case they were already fixed. ## +## PLEASE TRY Latest Master BRANCH before submitting bugs, in case they were already fixed. ## Issues without basic info will be ignored or closed! From 6eb8432357d75e56929ddda2c6914c6170efd916 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Mon, 28 Nov 2022 15:30:44 -0600 Subject: [PATCH 63/72] add scan mode options examples --- examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino index a648366f..2546c6af 100644 --- a/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -105,6 +105,10 @@ void setup() { Serial.println("[INFORMATION] TEST"); + // WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN); // wifi_scan_method_t scanMethod + // WiFi.setSortMethod(WIFI_CONNECT_AP_BY_SIGNAL); // wifi_sort_method_t sortMethod - WIFI_CONNECT_AP_BY_SIGNAL,WIFI_CONNECT_AP_BY_SECURITY + // WiFi.setMinSecurity(WIFI_AUTH_WPA2_PSK); + wm.setDebugOutput(true); wm.debugPlatformInfo(); From 0080e3581ee9c73b8dc79e4750bfd4108885fa01 Mon Sep 17 00:00:00 2001 From: Shawn A <807787+tablatronix@users.noreply.github.com> Date: Mon, 28 Nov 2022 16:15:20 -0600 Subject: [PATCH 64/72] Refactor strings BREAKING (#1474) * refactor strings, split out consts breaking! * move consts out of strings file BREAKING You will have to remove the constants from your strings files and add the new include instead, a simple diff should obviously show the changes * adds WM_STRINGS_FILE for env overrides * Revert "move consts out of strings file BREAKING" This reverts commit bb9f092413153825d8e7acde1dcc1489e840df1e. * Create wm_strings_en.h * final clean up of strings_en.h, legacy * comments --- WiFiManager.h | 10 +- strings_en.h | 505 +----------------------------------------------- wm_consts_en.h | 254 ++++++++++++++++++++++++ wm_strings_en.h | 274 ++++++++++++++++++++++++++ 4 files changed, 545 insertions(+), 498 deletions(-) create mode 100644 wm_consts_en.h create mode 100644 wm_strings_en.h diff --git a/WiFiManager.h b/WiFiManager.h index 02286e47..b3654367 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -131,13 +131,19 @@ #include #include -#include "strings_en.h" + + +// Include wm strings vars +// Pass in strings env override via WM_STRINGS_FILE +#ifndef WM_STRINGS_FILE +#define WM_STRINGS_FILE "wm_strings_en.h" // this includes constants as dependency +#endif +#include WM_STRINGS_FILE // prep string concat vars #define WM_STRING2(x) #x #define WM_STRING(x) WM_STRING2(x) - // #include #ifdef ESP_IDF_VERSION // #pragma message "ESP_IDF_VERSION_MAJOR = " WM_STRING(ESP_IDF_VERSION_MAJOR) diff --git a/strings_en.h b/strings_en.h index 5ea622ec..cabeb58b 100644 --- a/strings_en.h +++ b/strings_en.h @@ -1,502 +1,15 @@ /** - * strings_en.h - * engligh strings for - * WiFiManager, a library for the ESP8266/Arduino platform - * for configuration of WiFi credentials using a Captive Portal - * - * @author Creator tzapu - * @author tablatronix - * @version 0.0.0 - * @license MIT + * Contents of this file have moved to 2 new locations + * wm_strings_nn.h + * wm_consts_nn.h */ -#ifndef _WM_STRINGS_H_ -#define _WM_STRINGS_H_ +#warning "This file is deprecated" +#ifndef _STRINGS_EN_H_ +#define _STRINGS_EN_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.. +// strings files must include a consts file! +#include "wm_strings_en.h" // include constants, tokens, routes -const char WM_VERSION_STR[] PROGMEM = "v2.0.13-beta"; - -const char HTTP_HEAD_START[] PROGMEM = "" -"" -"" -"" -"" -"{v}"; - -const char HTTP_SCRIPT[] PROGMEM = ""; // @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 -// const char HTTP_ROOT_MAIN[] PROGMEM = "

{v}

WiFiManager

"; -const char HTTP_ROOT_MAIN[] PROGMEM = "

{t}

{v}

"; - -const char * const HTTP_PORTAL_MENU[] PROGMEM = { -"
\n", // MENU_WIFI -"

\n", // MENU_WIFINOSCAN -"

\n", // MENU_INFO -"

\n",//MENU_PARAM -"

\n", // MENU_CLOSE -"

\n",// MENU_RESTART -"

\n", // MENU_EXIT -"

\n", // MENU_ERASE -"

\n",// MENU_UPDATE -"

" // MENU_SEP -}; - -// const char HTTP_PORTAL_OPTIONS[] PROGMEM = strcat(HTTP_PORTAL_MENU[0] , HTTP_PORTAL_MENU[3] , HTTP_PORTAL_MENU[7]); -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} {R} {r}% {q} {e}
"; // test all tokens - -const char HTTP_FORM_START[] 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 = "

"; -const char HTTP_FORM_LABEL[] PROGMEM = ""; -const char HTTP_FORM_PARAM_HEAD[] PROGMEM = "

"; -const char HTTP_FORM_PARAM[] PROGMEM = "
\n"; // do not remove newline! - -const char HTTP_SCAN_LINK[] PROGMEM = "
"; -const char HTTP_SAVED[] PROGMEM = "
Saving Credentials
Trying to connect ESP to network.
If it fails reconnect to AP to try again
"; -const char HTTP_PARAMSAVED[] PROGMEM = "
Saved
"; -const char HTTP_END[] PROGMEM = "
"; -const char HTTP_ERASEBTN[] PROGMEM = "
"; -const char HTTP_UPDATEBTN[] PROGMEM = "
"; -const char HTTP_BACKBTN[] PROGMEM = "

"; - -const char HTTP_STATUS_ON[] PROGMEM = "
Connected to {v}
with IP {i}
"; -const char HTTP_STATUS_OFF[] PROGMEM = "
Not Connected to {v}{r}
"; // {c=class} {v=ssid} {r=status_off} -const char HTTP_STATUS_OFFPW[] PROGMEM = "
Authentication Failure"; // STATION_WRONG_PASSWORD, no eps32 -const char HTTP_STATUS_OFFNOAP[] PROGMEM = "
AP not found"; // WL_NO_SSID_AVAIL -const char HTTP_STATUS_OFFFAIL[] PROGMEM = "
Could not Connect"; // WL_CONNECT_FAILED -const char HTTP_STATUS_NONE[] PROGMEM = "
No AP set
"; -const char HTTP_BR[] PROGMEM = "
"; - -const char HTTP_STYLE[] PROGMEM = ""; - -#ifndef WM_NOHELP -const char HTTP_HELP[] PROGMEM = - "

Available Pages


" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "
PageFunction
/Menu page.
/wifiShow WiFi scan results and enter WiFi configuration.(/0wifi noscan)
/wifisaveSave WiFi configuration information and configure device. Needs variables supplied.
/paramParameter page
/infoInformation page
/uOTA Update
/closeClose the captiveportal popup,configportal will remain active
/exitExit Config Portal, configportal will close
/restartReboot the device
/eraseErase WiFi configuration and reboot Device. Device will not reconnect to a network until new WiFi configuration data is entered.
" - "

Github https://github.com/tzapu/WiFiManager."; -#else -const char HTTP_HELP[] PROGMEM = ""; -#endif - -const char HTTP_UPDATE[] PROGMEM = "Upload New Firmware

* May not function inside captive portal, Open in browser http://192.168.4.1"; -const char HTTP_UPDATE_FAIL[] PROGMEM = "
Update Failed!
Reboot device and try again
"; -const char HTTP_UPDATE_SUCCESS[] PROGMEM = "
Update Successful.
Device Rebooting now...
"; - -#ifdef WM_JSTEST -const char HTTP_JS[] PROGMEM = -""; -#endif - -// Info html -// @todo remove html elements from progmem, repetetive strings -#ifdef 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}
"; - const char HTTP_INFO_psrsize[] PROGMEM = "
PSRAM Size
{1} bytes
"; - 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}
"; - const char HTTP_INFO_corever[] PROGMEM = "
Core Version
{1}
"; - const char HTTP_INFO_bootver[] PROGMEM = "
Boot Version
{1}
"; - const char HTTP_INFO_lastreset[] PROGMEM = "
Last reset reason
{1}
"; - const char HTTP_INFO_flashsize[] PROGMEM = "
Real Flash Size
{1} bytes
"; -#endif - -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 ({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
"; -const char HTTP_INFO_sdkver[] PROGMEM = "
SDK Version
{1}
"; -const char HTTP_INFO_cpufreq[] PROGMEM = "
CPU Frequency
{1}MHz
"; -const char HTTP_INFO_apip[] PROGMEM = "
Access Point IP
{1}
"; -const char HTTP_INFO_apmac[] PROGMEM = "
Access Point MAC
{1}
"; -const char HTTP_INFO_apssid[] PROGMEM = "
Access Point SSID
{1}
"; -const char HTTP_INFO_apbssid[] PROGMEM = "
BSSID
{1}
"; -const char HTTP_INFO_stassid[] PROGMEM = "
Station SSID
{1}
"; -const char HTTP_INFO_staip[] PROGMEM = "
Station IP
{1}
"; -const char HTTP_INFO_stagw[] PROGMEM = "
Station Gateway
{1}
"; -const char HTTP_INFO_stasub[] PROGMEM = "
Station Subnet
{1}
"; -const char HTTP_INFO_dnss[] PROGMEM = "
DNS Server
{1}
"; -const char HTTP_INFO_host[] PROGMEM = "
Hostname
{1}
"; -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:"; -const char S_y[] PROGMEM = "Yes"; -const char S_n[] PROGMEM = "No"; -const char S_enable[] PROGMEM = "Enabled"; -const char S_disable[] PROGMEM = "Disabled"; -const char S_GET[] PROGMEM = "GET"; -const char S_POST[] PROGMEM = "POST"; -const char S_NA[] PROGMEM = "Unknown"; -const char S_passph[] PROGMEM = "********"; -const char S_titlewifisaved[] PROGMEM = "Credentials Saved"; -const char S_titlewifisettings[] PROGMEM = "Settings Saved"; -const char S_titlewifi[] PROGMEM = "Config ESP"; -const char S_titleinfo[] PROGMEM = "Info"; -const char S_titleparam[] PROGMEM = "Setup"; -const char S_titleparamsaved[] PROGMEM = "Setup Saved"; -const char S_titleexit[] PROGMEM = "Exit"; -const char S_titlereset[] PROGMEM = "Reset"; -const char S_titleerase[] PROGMEM = "Erase"; -const char S_titleclose[] PROGMEM = "Close"; -const char S_options[] PROGMEM = "options"; -const char S_nonetworks[] PROGMEM = "No networks found. Refresh to scan again."; -const char S_staticip[] PROGMEM = "Static IP"; -const char S_staticgw[] PROGMEM = "Static Gateway"; -const char S_staticdns[] PROGMEM = "Static DNS"; -const char S_subnet[] PROGMEM = "Subnet"; -const char S_exiting[] PROGMEM = "Exiting"; -const char S_resetting[] PROGMEM = "Module will reset in a few seconds."; -const char S_closing[] PROGMEM = "You can close the page, portal will continue to run"; -const char S_error[] PROGMEM = "An Error Occured"; -const char S_notfound[] PROGMEM = "File Not Found\n\n"; -const char S_uri[] PROGMEM = "URI: "; -const char S_method[] PROGMEM = "\nMethod: "; -const char S_args[] PROGMEM = "\nArguments: "; -const char S_parampre[] PROGMEM = "param_"; - -// debug strings -const char D_HR[] PROGMEM = "--------------------"; - -// END WIFI_MANAGER_OVERRIDE_STRINGS -#endif - -// ----------------------------------------------------------------------------------------------- -// DO NOT EDIT BELOW THIS LINE - -const uint8_t _nummenutokens = 11; -const char * const _menutokens[_nummenutokens] PROGMEM = { - "wifi", - "wifinoscan", - "info", - "param", - "close", - "restart", - "exit", - "erase", - "update", - "sep", - "custom" -}; - -const char R_root[] PROGMEM = "/"; -const char R_wifi[] PROGMEM = "/wifi"; -const char R_wifinoscan[] PROGMEM = "/0wifi"; -const char R_wifisave[] PROGMEM = "/wifisave"; -const char R_info[] PROGMEM = "/info"; -const char R_param[] PROGMEM = "/param"; -const char R_paramsave[] PROGMEM = "/paramsave"; -const char R_restart[] PROGMEM = "/restart"; -const char R_exit[] PROGMEM = "/exit"; -const char R_close[] PROGMEM = "/close"; -const char R_erase[] PROGMEM = "/erase"; -const char R_status[] PROGMEM = "/status"; -const char R_update[] PROGMEM = "/update"; -const char R_updatedone[] PROGMEM = "/u"; - - -//Strings -const char S_ip[] PROGMEM = "ip"; -const char S_gw[] PROGMEM = "gw"; -const char S_sn[] PROGMEM = "sn"; -const char S_dns[] PROGMEM = "dns"; - -// softap ssid default prefix -#ifdef ESP8266 - const char S_ssidpre[] PROGMEM = "ESP"; -#elif defined(ESP32) - const char S_ssidpre[] PROGMEM = "ESP32"; -#else - const char S_ssidpre[] PROGMEM = "WM"; -#endif - -//Tokens -//@todo consolidate and reduce -const char T_ss[] PROGMEM = "{"; // token start sentinel -const char T_es[] PROGMEM = "}"; // token end sentinel -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 -const char T_p[] PROGMEM = "{p}"; // @token p -const char T_t[] PROGMEM = "{t}"; // @token t -const char T_l[] PROGMEM = "{l}"; // @token l -const char T_c[] PROGMEM = "{c}"; // @token c -const char T_e[] PROGMEM = "{e}"; // @token e -const char T_q[] PROGMEM = "{q}"; // @token q -const char T_r[] PROGMEM = "{r}"; // @token r -const char T_R[] PROGMEM = "{R}"; // @token R -const char T_h[] PROGMEM = "{h}"; // @token h - -// http -const char HTTP_HEAD_CL[] PROGMEM = "Content-Length"; -const char HTTP_HEAD_CT[] PROGMEM = "text/html"; -const char HTTP_HEAD_CT2[] PROGMEM = "text/plain"; -const char HTTP_HEAD_CORS[] PROGMEM = "Access-Control-Allow-Origin"; -const char HTTP_HEAD_CORS_ALLOW_ALL[] PROGMEM = "*"; - -const char * const WIFI_STA_STATUS[] PROGMEM -{ - "WL_IDLE_STATUS", // 0 STATION_IDLE - "WL_NO_SSID_AVAIL", // 1 STATION_NO_AP_FOUND - "WL_SCAN_COMPLETED", // 2 - "WL_CONNECTED", // 3 STATION_GOT_IP - "WL_CONNECT_FAILED", // 4 STATION_CONNECT_FAIL, STATION_WRONG_PASSWORD(NI) - "WL_CONNECTION_LOST", // 5 - "WL_DISCONNECTED", // 6 - "WL_STATION_WRONG_PASSWORD" // 7 KLUDGE -}; - -#ifdef ESP32 -const char * const AUTH_MODE_NAMES[] PROGMEM -{ - "OPEN", - "WEP", - "WPA_PSK", - "WPA2_PSK", - "WPA_WPA2_PSK", - "WPA2_ENTERPRISE", - "MAX" -}; -#elif defined(ESP8266) -const char * const AUTH_MODE_NAMES[] PROGMEM -{ - "", - "", - "WPA_PSK", // 2 ENC_TYPE_TKIP - "", - "WPA2_PSK", // 4 ENC_TYPE_CCMP - "WEP", // 5 ENC_TYPE_WEP - "", - "OPEN", //7 ENC_TYPE_NONE - "WPA_WPA2_PSK", // 8 ENC_TYPE_AUTO -}; -#endif - -const char* const WIFI_MODES[] PROGMEM = { "NULL", "STA", "AP", "STA+AP" }; - - -#ifdef ESP32 -// as 2.5.2 -// typedef struct { -// char cc[3]; /**< country code string */ -// uint8_t schan; /**< start channel */ -// uint8_t nchan; /**< total channel number */ -// int8_t max_tx_power; /**< This field is used for getting WiFi maximum transmitting power, call esp_wifi_set_max_tx_power to set the maximum transmitting power. */ -// wifi_country_policy_t policy; /**< country policy */ -// } wifi_country_t; -const wifi_country_t WM_COUNTRY_US{"US",1,11,CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER,WIFI_COUNTRY_POLICY_AUTO}; -const wifi_country_t WM_COUNTRY_CN{"CN",1,13,CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER,WIFI_COUNTRY_POLICY_AUTO}; -const wifi_country_t WM_COUNTRY_JP{"JP",1,14,CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER,WIFI_COUNTRY_POLICY_AUTO}; -#elif defined(ESP8266) && !defined(WM_NOCOUNTRY) -// typedef struct { -// char cc[3]; /**< country code string */ -// uint8_t schan; /**< start channel */ -// uint8_t nchan; /**< total channel number */ -// uint8_t policy; /**< country policy */ -// } wifi_country_t; -const wifi_country_t WM_COUNTRY_US{"US",1,11,WIFI_COUNTRY_POLICY_AUTO}; -const wifi_country_t WM_COUNTRY_CN{"CN",1,13,WIFI_COUNTRY_POLICY_AUTO}; -const wifi_country_t WM_COUNTRY_JP{"JP",1,14,WIFI_COUNTRY_POLICY_AUTO}; -#endif - - -/* -* ESP32 WiFi Events - -0 SYSTEM_EVENT_WIFI_READY < ESP32 WiFi ready -1 SYSTEM_EVENT_SCAN_DONE < ESP32 finish scanning AP -2 SYSTEM_EVENT_STA_START < ESP32 station start -3 SYSTEM_EVENT_STA_STOP < ESP32 station stop -4 SYSTEM_EVENT_STA_CONNECTED < ESP32 station connected to AP -5 SYSTEM_EVENT_STA_DISCONNECTED < ESP32 station disconnected from AP -6 SYSTEM_EVENT_STA_AUTHMODE_CHANGE < the auth mode of AP connected by ESP32 station changed -7 SYSTEM_EVENT_STA_GOT_IP < ESP32 station got IP from connected AP -8 SYSTEM_EVENT_STA_LOST_IP < ESP32 station lost IP and the IP is reset to 0 -9 SYSTEM_EVENT_STA_WPS_ER_SUCCESS < ESP32 station wps succeeds in enrollee mode -10 SYSTEM_EVENT_STA_WPS_ER_FAILED < ESP32 station wps fails in enrollee mode -11 SYSTEM_EVENT_STA_WPS_ER_TIMEOUT < ESP32 station wps timeout in enrollee mode -12 SYSTEM_EVENT_STA_WPS_ER_PIN < ESP32 station wps pin code in enrollee mode -13 SYSTEM_EVENT_AP_START < ESP32 soft-AP start -14 SYSTEM_EVENT_AP_STOP < ESP32 soft-AP stop -15 SYSTEM_EVENT_AP_STACONNECTED < a station connected to ESP32 soft-AP -16 SYSTEM_EVENT_AP_STADISCONNECTED < a station disconnected from ESP32 soft-AP -17 SYSTEM_EVENT_AP_STAIPASSIGNED < ESP32 soft-AP assign an IP to a connected station -18 SYSTEM_EVENT_AP_PROBEREQRECVED < Receive probe request packet in soft-AP interface -19 SYSTEM_EVENT_GOT_IP6 < ESP32 station or ap or ethernet interface v6IP addr is preferred -20 SYSTEM_EVENT_ETH_START < ESP32 ethernet start -21 SYSTEM_EVENT_ETH_STOP < ESP32 ethernet stop -22 SYSTEM_EVENT_ETH_CONNECTED < ESP32 ethernet phy link up -23 SYSTEM_EVENT_ETH_DISCONNECTED < ESP32 ethernet phy link down -24 SYSTEM_EVENT_ETH_GOT_IP < ESP32 ethernet got IP from connected AP -25 SYSTEM_EVENT_MAX - - -typedef enum { - ARDUINO_EVENT_WIFI_READY = 0, - ARDUINO_EVENT_WIFI_SCAN_DONE, - ARDUINO_EVENT_WIFI_STA_START, - ARDUINO_EVENT_WIFI_STA_STOP, - ARDUINO_EVENT_WIFI_STA_CONNECTED, - ARDUINO_EVENT_WIFI_STA_DISCONNECTED, - ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE, - ARDUINO_EVENT_WIFI_STA_GOT_IP, - ARDUINO_EVENT_WIFI_STA_GOT_IP6, - ARDUINO_EVENT_WIFI_STA_LOST_IP, - ARDUINO_EVENT_WIFI_AP_START, - ARDUINO_EVENT_WIFI_AP_STOP, - ARDUINO_EVENT_WIFI_AP_STACONNECTED, - ARDUINO_EVENT_WIFI_AP_STADISCONNECTED, - ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED, - ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED, - ARDUINO_EVENT_WIFI_AP_GOT_IP6, - ARDUINO_EVENT_WIFI_FTM_REPORT, - ARDUINO_EVENT_ETH_START, - ARDUINO_EVENT_ETH_STOP, - ARDUINO_EVENT_ETH_CONNECTED, - ARDUINO_EVENT_ETH_DISCONNECTED, - ARDUINO_EVENT_ETH_GOT_IP, - ARDUINO_EVENT_ETH_GOT_IP6, - ARDUINO_EVENT_WPS_ER_SUCCESS, - ARDUINO_EVENT_WPS_ER_FAILED, - ARDUINO_EVENT_WPS_ER_TIMEOUT, - ARDUINO_EVENT_WPS_ER_PIN, - ARDUINO_EVENT_WPS_ER_PBC_OVERLAP, - ARDUINO_EVENT_SC_SCAN_DONE, - ARDUINO_EVENT_SC_FOUND_CHANNEL, - ARDUINO_EVENT_SC_GOT_SSID_PSWD, - ARDUINO_EVENT_SC_SEND_ACK_DONE, - ARDUINO_EVENT_PROV_INIT, - ARDUINO_EVENT_PROV_DEINIT, - ARDUINO_EVENT_PROV_START, - ARDUINO_EVENT_PROV_END, - ARDUINO_EVENT_PROV_CRED_RECV, - ARDUINO_EVENT_PROV_CRED_FAIL, - ARDUINO_EVENT_PROV_CRED_SUCCESS, - ARDUINO_EVENT_MAX -} arduino_event_id_t; - -typedef union { - wifi_event_sta_scan_done_t wifi_scan_done; - wifi_event_sta_authmode_change_t wifi_sta_authmode_change; - wifi_event_sta_connected_t wifi_sta_connected; - wifi_event_sta_disconnected_t wifi_sta_disconnected; - wifi_event_sta_wps_er_pin_t wps_er_pin; - wifi_event_sta_wps_fail_reason_t wps_fail_reason; - wifi_event_ap_probe_req_rx_t wifi_ap_probereqrecved; - wifi_event_ap_staconnected_t wifi_ap_staconnected; - wifi_event_ap_stadisconnected_t wifi_ap_stadisconnected; - wifi_event_ftm_report_t wifi_ftm_report; - ip_event_ap_staipassigned_t wifi_ap_staipassigned; - ip_event_got_ip_t got_ip; - ip_event_got_ip6_t got_ip6; - smartconfig_event_got_ssid_pswd_t sc_got_ssid_pswd; - esp_eth_handle_t eth_connected; - wifi_sta_config_t prov_cred_recv; - wifi_prov_sta_fail_reason_t prov_fail_reason; -} arduino_event_info_t; - -*/ -#endif +#endif \ No newline at end of file diff --git a/wm_consts_en.h b/wm_consts_en.h new file mode 100644 index 00000000..9079e649 --- /dev/null +++ b/wm_consts_en.h @@ -0,0 +1,254 @@ +/** + * wm_consts.h + * internal const strings/tokens + * WiFiManager, a library for the ESP8266/Arduino platform + * for configuration of WiFi credentials using a Captive Portal + * + * @author Creator tzapu + * @author tablatronix + * @version 0.0.0 + * @license MIT + */ + +#ifndef _WM_CONSTS_H +#define _WM_CONSTS_H + + +// ----------------------------------------------------------------------------------------------- +// TOKENS + +const char WM_VERSION_STR[] PROGMEM = "v2.0.12-beta"; + + +const uint8_t _nummenutokens = 11; +const char * const _menutokens[_nummenutokens] PROGMEM = { + "wifi", + "wifinoscan", + "info", + "param", + "close", + "restart", + "exit", + "erase", + "update", + "sep", + "custom" +}; + +const char R_root[] PROGMEM = "/"; +const char R_wifi[] PROGMEM = "/wifi"; +const char R_wifinoscan[] PROGMEM = "/0wifi"; +const char R_wifisave[] PROGMEM = "/wifisave"; +const char R_info[] PROGMEM = "/info"; +const char R_param[] PROGMEM = "/param"; +const char R_paramsave[] PROGMEM = "/paramsave"; +const char R_restart[] PROGMEM = "/restart"; +const char R_exit[] PROGMEM = "/exit"; +const char R_close[] PROGMEM = "/close"; +const char R_erase[] PROGMEM = "/erase"; +const char R_status[] PROGMEM = "/status"; +const char R_update[] PROGMEM = "/update"; +const char R_updatedone[] PROGMEM = "/u"; + + +//Strings +const char S_ip[] PROGMEM = "ip"; +const char S_gw[] PROGMEM = "gw"; +const char S_sn[] PROGMEM = "sn"; +const char S_dns[] PROGMEM = "dns"; + + + +//Tokens +//@todo consolidate and reduce +const char T_ss[] PROGMEM = "{"; // token start sentinel +const char T_es[] PROGMEM = "}"; // token end sentinel +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 +const char T_p[] PROGMEM = "{p}"; // @token p +const char T_t[] PROGMEM = "{t}"; // @token t +const char T_l[] PROGMEM = "{l}"; // @token l +const char T_c[] PROGMEM = "{c}"; // @token c +const char T_e[] PROGMEM = "{e}"; // @token e +const char T_q[] PROGMEM = "{q}"; // @token q +const char T_r[] PROGMEM = "{r}"; // @token r +const char T_R[] PROGMEM = "{R}"; // @token R +const char T_h[] PROGMEM = "{h}"; // @token h + +// http +const char HTTP_HEAD_CL[] PROGMEM = "Content-Length"; +const char HTTP_HEAD_CT[] PROGMEM = "text/html"; +const char HTTP_HEAD_CT2[] PROGMEM = "text/plain"; +const char HTTP_HEAD_CORS[] PROGMEM = "Access-Control-Allow-Origin"; +const char HTTP_HEAD_CORS_ALLOW_ALL[] PROGMEM = "*"; + +const char * const WIFI_STA_STATUS[] PROGMEM +{ + "WL_IDLE_STATUS", // 0 STATION_IDLE + "WL_NO_SSID_AVAIL", // 1 STATION_NO_AP_FOUND + "WL_SCAN_COMPLETED", // 2 + "WL_CONNECTED", // 3 STATION_GOT_IP + "WL_CONNECT_FAILED", // 4 STATION_CONNECT_FAIL, STATION_WRONG_PASSWORD(NI) + "WL_CONNECTION_LOST", // 5 + "WL_DISCONNECTED", // 6 + "WL_STATION_WRONG_PASSWORD" // 7 KLUDGE +}; + +#ifdef ESP32 +const char * const AUTH_MODE_NAMES[] PROGMEM +{ + "OPEN", + "WEP", + "WPA_PSK", + "WPA2_PSK", + "WPA_WPA2_PSK", + "WPA2_ENTERPRISE", + "MAX" +}; +#elif defined(ESP8266) +const char * const AUTH_MODE_NAMES[] PROGMEM +{ + "", + "", + "WPA_PSK", // 2 ENC_TYPE_TKIP + "", + "WPA2_PSK", // 4 ENC_TYPE_CCMP + "WEP", // 5 ENC_TYPE_WEP + "", + "OPEN", //7 ENC_TYPE_NONE + "WPA_WPA2_PSK", // 8 ENC_TYPE_AUTO +}; +#endif + +const char* const WIFI_MODES[] PROGMEM = { "NULL", "STA", "AP", "STA+AP" }; + + +#ifdef ESP32 +// as 2.5.2 +// typedef struct { +// char cc[3]; /**< country code string */ +// uint8_t schan; /**< start channel */ +// uint8_t nchan; /**< total channel number */ +// int8_t max_tx_power; /**< This field is used for getting WiFi maximum transmitting power, call esp_wifi_set_max_tx_power to set the maximum transmitting power. */ +// wifi_country_policy_t policy; /**< country policy */ +// } wifi_country_t; +const wifi_country_t WM_COUNTRY_US{"US",1,11,CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER,WIFI_COUNTRY_POLICY_AUTO}; +const wifi_country_t WM_COUNTRY_CN{"CN",1,13,CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER,WIFI_COUNTRY_POLICY_AUTO}; +const wifi_country_t WM_COUNTRY_JP{"JP",1,14,CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER,WIFI_COUNTRY_POLICY_AUTO}; +#elif defined(ESP8266) && !defined(WM_NOCOUNTRY) +// typedef struct { +// char cc[3]; /**< country code string */ +// uint8_t schan; /**< start channel */ +// uint8_t nchan; /**< total channel number */ +// uint8_t policy; /**< country policy */ +// } wifi_country_t; +const wifi_country_t WM_COUNTRY_US{"US",1,11,WIFI_COUNTRY_POLICY_AUTO}; +const wifi_country_t WM_COUNTRY_CN{"CN",1,13,WIFI_COUNTRY_POLICY_AUTO}; +const wifi_country_t WM_COUNTRY_JP{"JP",1,14,WIFI_COUNTRY_POLICY_AUTO}; +#endif + + +/* +* ESP32 WiFi Events + +0 SYSTEM_EVENT_WIFI_READY < ESP32 WiFi ready +1 SYSTEM_EVENT_SCAN_DONE < ESP32 finish scanning AP +2 SYSTEM_EVENT_STA_START < ESP32 station start +3 SYSTEM_EVENT_STA_STOP < ESP32 station stop +4 SYSTEM_EVENT_STA_CONNECTED < ESP32 station connected to AP +5 SYSTEM_EVENT_STA_DISCONNECTED < ESP32 station disconnected from AP +6 SYSTEM_EVENT_STA_AUTHMODE_CHANGE < the auth mode of AP connected by ESP32 station changed +7 SYSTEM_EVENT_STA_GOT_IP < ESP32 station got IP from connected AP +8 SYSTEM_EVENT_STA_LOST_IP < ESP32 station lost IP and the IP is reset to 0 +9 SYSTEM_EVENT_STA_WPS_ER_SUCCESS < ESP32 station wps succeeds in enrollee mode +10 SYSTEM_EVENT_STA_WPS_ER_FAILED < ESP32 station wps fails in enrollee mode +11 SYSTEM_EVENT_STA_WPS_ER_TIMEOUT < ESP32 station wps timeout in enrollee mode +12 SYSTEM_EVENT_STA_WPS_ER_PIN < ESP32 station wps pin code in enrollee mode +13 SYSTEM_EVENT_AP_START < ESP32 soft-AP start +14 SYSTEM_EVENT_AP_STOP < ESP32 soft-AP stop +15 SYSTEM_EVENT_AP_STACONNECTED < a station connected to ESP32 soft-AP +16 SYSTEM_EVENT_AP_STADISCONNECTED < a station disconnected from ESP32 soft-AP +17 SYSTEM_EVENT_AP_STAIPASSIGNED < ESP32 soft-AP assign an IP to a connected station +18 SYSTEM_EVENT_AP_PROBEREQRECVED < Receive probe request packet in soft-AP interface +19 SYSTEM_EVENT_GOT_IP6 < ESP32 station or ap or ethernet interface v6IP addr is preferred +20 SYSTEM_EVENT_ETH_START < ESP32 ethernet start +21 SYSTEM_EVENT_ETH_STOP < ESP32 ethernet stop +22 SYSTEM_EVENT_ETH_CONNECTED < ESP32 ethernet phy link up +23 SYSTEM_EVENT_ETH_DISCONNECTED < ESP32 ethernet phy link down +24 SYSTEM_EVENT_ETH_GOT_IP < ESP32 ethernet got IP from connected AP +25 SYSTEM_EVENT_MAX + + +typedef enum { + ARDUINO_EVENT_WIFI_READY = 0, + ARDUINO_EVENT_WIFI_SCAN_DONE, + ARDUINO_EVENT_WIFI_STA_START, + ARDUINO_EVENT_WIFI_STA_STOP, + ARDUINO_EVENT_WIFI_STA_CONNECTED, + ARDUINO_EVENT_WIFI_STA_DISCONNECTED, + ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE, + ARDUINO_EVENT_WIFI_STA_GOT_IP, + ARDUINO_EVENT_WIFI_STA_GOT_IP6, + ARDUINO_EVENT_WIFI_STA_LOST_IP, + ARDUINO_EVENT_WIFI_AP_START, + ARDUINO_EVENT_WIFI_AP_STOP, + ARDUINO_EVENT_WIFI_AP_STACONNECTED, + ARDUINO_EVENT_WIFI_AP_STADISCONNECTED, + ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED, + ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED, + ARDUINO_EVENT_WIFI_AP_GOT_IP6, + ARDUINO_EVENT_WIFI_FTM_REPORT, + ARDUINO_EVENT_ETH_START, + ARDUINO_EVENT_ETH_STOP, + ARDUINO_EVENT_ETH_CONNECTED, + ARDUINO_EVENT_ETH_DISCONNECTED, + ARDUINO_EVENT_ETH_GOT_IP, + ARDUINO_EVENT_ETH_GOT_IP6, + ARDUINO_EVENT_WPS_ER_SUCCESS, + ARDUINO_EVENT_WPS_ER_FAILED, + ARDUINO_EVENT_WPS_ER_TIMEOUT, + ARDUINO_EVENT_WPS_ER_PIN, + ARDUINO_EVENT_WPS_ER_PBC_OVERLAP, + ARDUINO_EVENT_SC_SCAN_DONE, + ARDUINO_EVENT_SC_FOUND_CHANNEL, + ARDUINO_EVENT_SC_GOT_SSID_PSWD, + ARDUINO_EVENT_SC_SEND_ACK_DONE, + ARDUINO_EVENT_PROV_INIT, + ARDUINO_EVENT_PROV_DEINIT, + ARDUINO_EVENT_PROV_START, + ARDUINO_EVENT_PROV_END, + ARDUINO_EVENT_PROV_CRED_RECV, + ARDUINO_EVENT_PROV_CRED_FAIL, + ARDUINO_EVENT_PROV_CRED_SUCCESS, + ARDUINO_EVENT_MAX +} arduino_event_id_t; + +typedef union { + wifi_event_sta_scan_done_t wifi_scan_done; + wifi_event_sta_authmode_change_t wifi_sta_authmode_change; + wifi_event_sta_connected_t wifi_sta_connected; + wifi_event_sta_disconnected_t wifi_sta_disconnected; + wifi_event_sta_wps_er_pin_t wps_er_pin; + wifi_event_sta_wps_fail_reason_t wps_fail_reason; + wifi_event_ap_probe_req_rx_t wifi_ap_probereqrecved; + wifi_event_ap_staconnected_t wifi_ap_staconnected; + wifi_event_ap_stadisconnected_t wifi_ap_stadisconnected; + wifi_event_ftm_report_t wifi_ftm_report; + ip_event_ap_staipassigned_t wifi_ap_staipassigned; + ip_event_got_ip_t got_ip; + ip_event_got_ip6_t got_ip6; + smartconfig_event_got_ssid_pswd_t sc_got_ssid_pswd; + esp_eth_handle_t eth_connected; + wifi_sta_config_t prov_cred_recv; + wifi_prov_sta_fail_reason_t prov_fail_reason; +} arduino_event_info_t; + +*/ + +#endif \ No newline at end of file diff --git a/wm_strings_en.h b/wm_strings_en.h new file mode 100644 index 00000000..383ac445 --- /dev/null +++ b/wm_strings_en.h @@ -0,0 +1,274 @@ +/** + * wm_strings_en.h + * engligh strings for + * WiFiManager, a library for the ESP8266/Arduino platform + * for configuration of WiFi credentials using a Captive Portal + * + * @author Creator tzapu + * @author tablatronix + * @version 0.0.0 + * @license MIT + */ + +#ifndef _WM_STRINGS_EN_H_ +#define _WM_STRINGS_EN_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.. + +// strings files must include a consts file! +#include "wm_consts_en.h" // include constants, tokens, routes + +const char WM_LANGUAGE[] PROGMEM = "en-US"; // i18n lang code + +const char HTTP_HEAD_START[] PROGMEM = "" +"" +"" +"" +"" +"{v}"; + +const char HTTP_SCRIPT[] PROGMEM = ""; // @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 +// const char HTTP_ROOT_MAIN[] PROGMEM = "

{v}

WiFiManager

"; +const char HTTP_ROOT_MAIN[] PROGMEM = "

{t}

{v}

"; + +const char * const HTTP_PORTAL_MENU[] PROGMEM = { +"

\n", // MENU_WIFI +"

\n", // MENU_WIFINOSCAN +"

\n", // MENU_INFO +"

\n",//MENU_PARAM +"

\n", // MENU_CLOSE +"

\n",// MENU_RESTART +"

\n", // MENU_EXIT +"

\n", // MENU_ERASE +"

\n",// MENU_UPDATE +"

" // MENU_SEP +}; + +// const char HTTP_PORTAL_OPTIONS[] PROGMEM = strcat(HTTP_PORTAL_MENU[0] , HTTP_PORTAL_MENU[3] , HTTP_PORTAL_MENU[7]); +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} {R} {r}% {q} {e}
"; // test all tokens + +const char HTTP_FORM_START[] 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 = "

"; +const char HTTP_FORM_LABEL[] PROGMEM = ""; +const char HTTP_FORM_PARAM_HEAD[] PROGMEM = "

"; +const char HTTP_FORM_PARAM[] PROGMEM = "
\n"; // do not remove newline! + +const char HTTP_SCAN_LINK[] PROGMEM = "
"; +const char HTTP_SAVED[] PROGMEM = "
Saving Credentials
Trying to connect ESP to network.
If it fails reconnect to AP to try again
"; +const char HTTP_PARAMSAVED[] PROGMEM = "
Saved
"; +const char HTTP_END[] PROGMEM = "
"; +const char HTTP_ERASEBTN[] PROGMEM = "
"; +const char HTTP_UPDATEBTN[] PROGMEM = "
"; +const char HTTP_BACKBTN[] PROGMEM = "

"; + +const char HTTP_STATUS_ON[] PROGMEM = "
Connected to {v}
with IP {i}
"; +const char HTTP_STATUS_OFF[] PROGMEM = "
Not Connected to {v}{r}
"; // {c=class} {v=ssid} {r=status_off} +const char HTTP_STATUS_OFFPW[] PROGMEM = "
Authentication Failure"; // STATION_WRONG_PASSWORD, no eps32 +const char HTTP_STATUS_OFFNOAP[] PROGMEM = "
AP not found"; // WL_NO_SSID_AVAIL +const char HTTP_STATUS_OFFFAIL[] PROGMEM = "
Could not Connect"; // WL_CONNECT_FAILED +const char HTTP_STATUS_NONE[] PROGMEM = "
No AP set
"; +const char HTTP_BR[] PROGMEM = "
"; + +const char HTTP_STYLE[] PROGMEM = ""; + +#ifndef WM_NOHELP +const char HTTP_HELP[] PROGMEM = + "

Available Pages


" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "
PageFunction
/Menu page.
/wifiShow WiFi scan results and enter WiFi configuration.(/0wifi noscan)
/wifisaveSave WiFi configuration information and configure device. Needs variables supplied.
/paramParameter page
/infoInformation page
/uOTA Update
/closeClose the captiveportal popup,configportal will remain active
/exitExit Config Portal, configportal will close
/restartReboot the device
/eraseErase WiFi configuration and reboot Device. Device will not reconnect to a network until new WiFi configuration data is entered.
" + "

Github https://github.com/tzapu/WiFiManager."; +#else +const char HTTP_HELP[] PROGMEM = ""; +#endif + +const char HTTP_UPDATE[] PROGMEM = "Upload New Firmware

* May not function inside captive portal, Open in browser http://192.168.4.1"; +const char HTTP_UPDATE_FAIL[] PROGMEM = "
Update Failed!
Reboot device and try again
"; +const char HTTP_UPDATE_SUCCESS[] PROGMEM = "
Update Successful.
Device Rebooting now...
"; + +#ifdef WM_JSTEST +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}
"; + 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}
"; +#else + const char HTTP_INFO_esphead[] PROGMEM = "

esp8266


"; + const char HTTP_INFO_fchipid[] PROGMEM = "
Flash Chip ID
{1}
"; + const char HTTP_INFO_corever[] PROGMEM = "
Core Version
{1}
"; + const char HTTP_INFO_bootver[] PROGMEM = "
Boot Version
{1}
"; + const char HTTP_INFO_lastreset[] PROGMEM = "
Last reset reason
{1}
"; + const char HTTP_INFO_flashsize[] PROGMEM = "
Real Flash Size
{1} bytes
"; +#endif + +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_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
"; +const char HTTP_INFO_sdkver[] PROGMEM = "
SDK Version
{1}
"; +const char HTTP_INFO_cpufreq[] PROGMEM = "
CPU Frequency
{1}MHz
"; +const char HTTP_INFO_apip[] PROGMEM = "
Access Point IP
{1}
"; +const char HTTP_INFO_apmac[] PROGMEM = "
Access Point MAC
{1}
"; +const char HTTP_INFO_apssid[] PROGMEM = "
Access Point SSID
{1}
"; +const char HTTP_INFO_apbssid[] PROGMEM = "
BSSID
{1}
"; +const char HTTP_INFO_stassid[] PROGMEM = "
Station SSID
{1}
"; +const char HTTP_INFO_staip[] PROGMEM = "
Station IP
{1}
"; +const char HTTP_INFO_stagw[] PROGMEM = "
Station Gateway
{1}
"; +const char HTTP_INFO_stasub[] PROGMEM = "
Station Subnet
{1}
"; +const char HTTP_INFO_dnss[] PROGMEM = "
DNS Server
{1}
"; +const char HTTP_INFO_host[] PROGMEM = "
Hostname
{1}
"; +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:"; +const char S_y[] PROGMEM = "Yes"; +const char S_n[] PROGMEM = "No"; +const char S_enable[] PROGMEM = "Enabled"; +const char S_disable[] PROGMEM = "Disabled"; +const char S_GET[] PROGMEM = "GET"; +const char S_POST[] PROGMEM = "POST"; +const char S_NA[] PROGMEM = "Unknown"; +const char S_passph[] PROGMEM = "********"; +const char S_titlewifisaved[] PROGMEM = "Credentials Saved"; +const char S_titlewifisettings[] PROGMEM = "Settings Saved"; +const char S_titlewifi[] PROGMEM = "Config ESP"; +const char S_titleinfo[] PROGMEM = "Info"; +const char S_titleparam[] PROGMEM = "Setup"; +const char S_titleparamsaved[] PROGMEM = "Setup Saved"; +const char S_titleexit[] PROGMEM = "Exit"; +const char S_titlereset[] PROGMEM = "Reset"; +const char S_titleerase[] PROGMEM = "Erase"; +const char S_titleclose[] PROGMEM = "Close"; +const char S_options[] PROGMEM = "options"; +const char S_nonetworks[] PROGMEM = "No networks found. Refresh to scan again."; +const char S_staticip[] PROGMEM = "Static IP"; +const char S_staticgw[] PROGMEM = "Static Gateway"; +const char S_staticdns[] PROGMEM = "Static DNS"; +const char S_subnet[] PROGMEM = "Subnet"; +const char S_exiting[] PROGMEM = "Exiting"; +const char S_resetting[] PROGMEM = "Module will reset in a few seconds."; +const char S_closing[] PROGMEM = "You can close the page, portal will continue to run"; +const char S_error[] PROGMEM = "An Error Occured"; +const char S_notfound[] PROGMEM = "File Not Found\n\n"; +const char S_uri[] PROGMEM = "URI: "; +const char S_method[] PROGMEM = "\nMethod: "; +const char S_args[] PROGMEM = "\nArguments: "; +const char S_parampre[] PROGMEM = "param_"; + +// debug strings +const char D_HR[] PROGMEM = "--------------------"; + + +// softap ssid default prefix +#ifdef ESP8266 + const char S_ssidpre[] PROGMEM = "ESP"; +#elif defined(ESP32) + const char S_ssidpre[] PROGMEM = "ESP32"; +#else + const char S_ssidpre[] PROGMEM = "WM"; +#endif + +// END WIFI_MANAGER_OVERRIDE_STRINGS +#endif + +#endif From 7cdaf5c78537311ed673658002aa988f45bd3e28 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Mon, 28 Nov 2022 16:32:13 -0600 Subject: [PATCH 65/72] 2.0.0-RC.1 --- library.json | 2 +- library.properties | 2 +- wm_consts_en.h | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/library.json b/library.json index eaf4b5e3..c6682398 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "WiFiManager", - "version": "2.0.14-beta", + "version": "2.0.0-rc.1", "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 3dbc5f44..86eff0aa 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=WiFiManager -version=2.0.14-beta +version=2.0.0-rc.1 author=tzapu maintainer=tablatronix sentence=WiFi Configuration manager with web configuration portal for Espressif ESPx boards, by tzapu diff --git a/wm_consts_en.h b/wm_consts_en.h index 9079e649..5ae3444c 100644 --- a/wm_consts_en.h +++ b/wm_consts_en.h @@ -17,8 +17,7 @@ // ----------------------------------------------------------------------------------------------- // TOKENS -const char WM_VERSION_STR[] PROGMEM = "v2.0.12-beta"; - +const char WM_VERSION_STR[] PROGMEM = "v2.0.0-rc.1"; const uint8_t _nummenutokens = 11; const char * const _menutokens[_nummenutokens] PROGMEM = { From fe9774fe0f231767f3fc59de1a03a9c44f06adc3 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Mon, 28 Nov 2022 16:34:44 -0600 Subject: [PATCH 66/72] lower debug level --- WiFiManager.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WiFiManager.h b/WiFiManager.h index b3654367..641b9892 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -770,7 +770,7 @@ class WiFiManager // Set default debug level #ifndef WM_DEBUG_LEVEL - #define WM_DEBUG_LEVEL DEBUG_VERBOSE // development default, not release + #define WM_DEBUG_LEVEL DEBUG_NOTIFY #endif // override debug level OFF @@ -781,7 +781,7 @@ class WiFiManager #ifdef WM_DEBUG_LEVEL uint8_t _debugLevel = (uint8_t)WM_DEBUG_LEVEL; #else - uint8_t _debugLevel = DEBUG_VERBOSE; // default debug level + uint8_t _debugLevel = 0; // default debug level #endif // @todo use DEBUG_ESP_PORT ? From 118ca1ec301e6ca9e16cd62828bf79d3c4c4c1e0 Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Thu, 8 Dec 2022 10:15:06 -0600 Subject: [PATCH 67/72] fixes #1528 --- WiFiManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index edd1ed3a..0a4af8a3 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -88,7 +88,7 @@ void WiFiManagerParameter::setValue(const char *defaultValue, int length) { // // return false; //@todo bail // } - if(_length != length){ + if(_length != length || _value == nullptr){ _length = length; if( _value != nullptr){ delete[] _value; From 26a33e3e1174db6c5c57f982b828a9c0eb4d7c4e Mon Sep 17 00:00:00 2001 From: Shawn A <807787+tablatronix@users.noreply.github.com> Date: Thu, 8 Dec 2022 10:18:15 -0600 Subject: [PATCH 68/72] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index a5c912a9..75c82c3b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # WiFiManager -## DEVELOPMENT Version Espressif ESPx WiFi Connection manager with fallback web configuration portal From 430a9bcdcb7a066315de98f70c14706d14e83d7d Mon Sep 17 00:00:00 2001 From: tablatronix <807787+tablatronix@users.noreply.github.com> Date: Sat, 10 Dec 2022 11:22:15 -0600 Subject: [PATCH 69/72] I think i versioned this wrong --- library.json | 2 +- library.properties | 2 +- wm_consts_en.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library.json b/library.json index c6682398..6b92d24a 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "WiFiManager", - "version": "2.0.0-rc.1", + "version": "2.0.15-rc.1", "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 86eff0aa..d3588236 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=WiFiManager -version=2.0.0-rc.1 +version=2.0.15-rc.1 author=tzapu maintainer=tablatronix sentence=WiFi Configuration manager with web configuration portal for Espressif ESPx boards, by tzapu diff --git a/wm_consts_en.h b/wm_consts_en.h index 5ae3444c..fc21b42f 100644 --- a/wm_consts_en.h +++ b/wm_consts_en.h @@ -17,7 +17,7 @@ // ----------------------------------------------------------------------------------------------- // TOKENS -const char WM_VERSION_STR[] PROGMEM = "v2.0.0-rc.1"; +const char WM_VERSION_STR[] PROGMEM = "v2.0.15-rc.1"; const uint8_t _nummenutokens = 11; const char * const _menutokens[_nummenutokens] PROGMEM = { From bacaf521e40624bd311f7480857688d572f000cf Mon Sep 17 00:00:00 2001 From: Philipp Date: Sun, 11 Dec 2022 18:21:14 +0100 Subject: [PATCH 70/72] Unified casing of strings (#1529) --- wm_strings_en.h | 72 ++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/wm_strings_en.h b/wm_strings_en.h index 383ac445..2c014bf6 100644 --- a/wm_strings_en.h +++ b/wm_strings_en.h @@ -44,7 +44,7 @@ const char HTTP_ROOT_MAIN[] PROGMEM = "

{t}

{v}

"; const char * const HTTP_PORTAL_MENU[] PROGMEM = { "

\n", // MENU_WIFI -"

\n", // MENU_WIFINOSCAN +"

\n", // MENU_WIFINOSCAN "

\n", // MENU_INFO "

\n",//MENU_PARAM "

\n", // MENU_CLOSE @@ -75,15 +75,15 @@ const char HTTP_SCAN_LINK[] PROGMEM = "
Saving Credentials
Trying to connect ESP to network.
If it fails reconnect to AP to try again
"; const char HTTP_PARAMSAVED[] PROGMEM = "
Saved
"; const char HTTP_END[] PROGMEM = ""; -const char HTTP_ERASEBTN[] PROGMEM = "
"; +const char HTTP_ERASEBTN[] PROGMEM = "
"; const char HTTP_UPDATEBTN[] PROGMEM = "
"; const char HTTP_BACKBTN[] PROGMEM = "

"; const char HTTP_STATUS_ON[] PROGMEM = "
Connected to {v}
with IP {i}
"; -const char HTTP_STATUS_OFF[] PROGMEM = "
Not Connected to {v}{r}
"; // {c=class} {v=ssid} {r=status_off} -const char HTTP_STATUS_OFFPW[] PROGMEM = "
Authentication Failure"; // STATION_WRONG_PASSWORD, no eps32 +const char HTTP_STATUS_OFF[] PROGMEM = "
Not connected to {v}{r}
"; // {c=class} {v=ssid} {r=status_off} +const char HTTP_STATUS_OFFPW[] PROGMEM = "
Authentication failure"; // STATION_WRONG_PASSWORD, no eps32 const char HTTP_STATUS_OFFNOAP[] PROGMEM = "
AP not found"; // WL_NO_SSID_AVAIL -const char HTTP_STATUS_OFFFAIL[] PROGMEM = "
Could not Connect"; // WL_CONNECT_FAILED +const char HTTP_STATUS_OFFFAIL[] PROGMEM = "
Could not connect"; // WL_CONNECT_FAILED const char HTTP_STATUS_NONE[] PROGMEM = "
No AP set
"; const char HTTP_BR[] PROGMEM = "
"; @@ -120,7 +120,7 @@ const char HTTP_STYLE[] PROGMEM = "