From 01b909a1d2f05b9d991eb69a1d828285045706f9 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Mon, 18 May 2020 15:36:15 -0500 Subject: [PATCH 01/26] version alpha release --- WiFiManager.cpp | 3 ++- library.json | 2 +- library.properties | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index cfd9060..8501211 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -2426,7 +2426,8 @@ void WiFiManager::setMenu(std::vector& menu){ /** * set params as sperate page not in wifi - * NOT COMPATIBLE WITH setMenu! @todo scan menuids and insert param after wifi or something + * NOT COMPATIBLE WITH setMenu! + * @todo scan menuids and insert param after wifi or something, same for ota * @param bool enable * @since $dev */ diff --git a/library.json b/library.json index 0ceb4c8..5eff70e 100644 --- a/library.json +++ b/library.json @@ -25,5 +25,5 @@ "espressif8266", "espressif32" ], - "version": "1.0.0" + "version": "2.0.1-alpha" } diff --git a/library.properties b/library.properties index 5ee6e46..9f2fa8d 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=WiFiManager -version=1.0.0 +version=2.0.1-alpha author=tzapu,tablatronix maintainer=tablatronix sentence=WiFi Configuration manager with web configuration portal for ESP boards From b67d1656d85dd68682eb29b0cefd801242ffe361 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Mon, 18 May 2020 15:46:44 -0500 Subject: [PATCH 02/26] Fix esp32 mdns --- .../NonBlocking/OnDemandNonBlocking/onDemandNonBlocking.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/NonBlocking/OnDemandNonBlocking/onDemandNonBlocking.ino b/examples/NonBlocking/OnDemandNonBlocking/onDemandNonBlocking.ino index b231cc3..3813356 100644 --- a/examples/NonBlocking/OnDemandNonBlocking/onDemandNonBlocking.ino +++ b/examples/NonBlocking/OnDemandNonBlocking/onDemandNonBlocking.ino @@ -41,7 +41,9 @@ void setup() { } void loop() { + #ifdef ESP8266 MDNS.update(); + #endif doWiFiManager(); // put your main code here, to run repeatedly: } From 634fac4be0e4d14d6e4bd26fdbbfe13a17acd83c Mon Sep 17 00:00:00 2001 From: tablatronix Date: Mon, 18 May 2020 15:49:24 -0500 Subject: [PATCH 03/26] fix travis esp32 --- examples/Tests/AnonymousCB.ino | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/Tests/AnonymousCB.ino b/examples/Tests/AnonymousCB.ino index ff44976..f34d80f 100644 --- a/examples/Tests/AnonymousCB.ino +++ b/examples/Tests/AnonymousCB.ino @@ -4,7 +4,7 @@ bool _enteredConfigMode = false; void setup(){ Serial.begin(115200); -WiFiManager wifiManager; + WiFiManager wifiManager; // wifiManager.setAPCallback([this](WiFiManager* wifiManager) { wifiManager.setAPCallback([&](WiFiManager* wifiManager) { @@ -16,9 +16,11 @@ WiFiManager wifiManager; wifiManager.resetSettings(); if (!wifiManager.autoConnect()) { Serial.printf("*** Failed to connect and hit timeout\n"); - ESP.reset(); + ESP.restart(); delay(1000); } } -void loop(){} +void loop(){ + +} From f4a577bbc2d0132f149300c3210c0e854d9f100e Mon Sep 17 00:00:00 2001 From: Shawn A Date: Mon, 18 May 2020 16:31:13 -0500 Subject: [PATCH 04/26] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 34f19cb..1cf5703 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,11 @@ The configuration portal is of the captive variety, so on various devices it wil First attempt at a library. Lots more changes and fixes to do. Contributions are welcome. -**This works with the ESP8266 Arduino platform with a recent stable release(2.0.0 or newer)** +**This works with the ESP8266 Arduino platform** [https://github.com/esp8266/Arduino](https://github.com/esp8266/Arduino) -**This works with the ESP32 Arduino platform with staging** +**This works with the ESP32 Arduino platform** [https://github.com/espressif/arduino-esp32](https://github.com/espressif/arduino-esp32) From 95d116cea39420436e83d304a034b0dfae8024eb Mon Sep 17 00:00:00 2001 From: Shawn A Date: Mon, 18 May 2020 16:34:27 -0500 Subject: [PATCH 05/26] Update README.md :warning --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 1cf5703..42d4e7f 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ # WiFiManager ESP8266 WiFi Connection manager with fallback web configuration portal +:warning: This Documentation is out of date for this branch, see notes below + [![Build Status](https://travis-ci.org/tzapu/WiFiManager.svg?branch=development)](https://travis-ci.org/tzapu/WiFiManager) ![ESP8266](https://img.shields.io/badge/ESP-8266-000000.svg?longCache=true&style=flat&colorA=CC101F) From d71a14194bfe00319ec7c263a4035335cfacd086 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Tue, 19 May 2020 10:58:10 -0500 Subject: [PATCH 06/26] Fix MDNS stupid c++ macros --- WiFiManager.cpp | 24 +++++++++++++----------- WiFiManager.h | 8 +++++--- strings_en.h | 2 +- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 8501211..923b0f0 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -302,9 +302,9 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { if((String)_hostname != ""){ #ifdef ESP8266 - DEBUG_WM(DEBUG_DEV,"hostname: STA",WiFi.hostname()); + DEBUG_WM(DEBUG_DEV,"hostname: STA: ",WiFi.hostname()); #elif defined(ESP32) - DEBUG_WM(DEBUG_DEV,"hostname: STA",WiFi.getHostname()); + DEBUG_WM(DEBUG_DEV,"hostname: STA: ",WiFi.getHostname()); #endif } @@ -326,16 +326,17 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { } bool WiFiManager::setupHostname(bool restart){ - DEBUG_WM(DEBUG_VERBOSE,"Setting hostname:",_hostname); if((String)_hostname == "") { - DEBUG_WM(DEBUG_VERBOSE,"No Hostname to set"); + DEBUG_WM(DEBUG_DEV,"No Hostname to set"); return false; - } + } else DEBUG_WM(DEBUG_DEV,"setupHostname: ",_hostname); bool res = true; #ifdef ESP8266 + DEBUG_WM(DEBUG_VERBOSE,"Setting WiFi hostname"); res = WiFi.hostname(_hostname); - #ifdef ESP8266MDNS_H - DEBUG_WM(DEBUG_VERBOSE,"Setting MDNS hostname"); + // #ifdef ESP8266MDNS_H + #ifdef WM_MDNS + DEBUG_WM(DEBUG_VERBOSE,"Setting MDNS hostname, tcp 80"); if(MDNS.begin(_hostname)){ MDNS.addService("http", "tcp", 80); } @@ -344,8 +345,9 @@ bool WiFiManager::setupHostname(bool restart){ // @note hostname must be set after STA_START delay(200); // do not remove, give time for STA_START res = WiFi.setHostname(_hostname); - #ifdef ESP32MDNS_H - DEBUG_WM(DEBUG_VERBOSE,"Setting MDNS hostname"); + // #ifdef ESP32MDNS_H + #ifdef WM_MDNS + DEBUG_WM(DEBUG_VERBOSE,"Setting MDNS hostname, tcp 80"); if(MDNS.begin(_hostname)){ MDNS.addService("http", "tcp", 80); } @@ -431,7 +433,7 @@ bool WiFiManager::startAP(){ DEBUG_WM(DEBUG_VERBOSE,"setting softAP Hostname:",_hostname); bool res = WiFi.softAPsetHostname(_hostname); if(!res)DEBUG_WM(DEBUG_ERROR,F("[ERROR] hostname: AP set failed!")); - DEBUG_WM(DEBUG_DEV,F("hostname: AP"),WiFi.softAPgetHostname()); + DEBUG_WM(DEBUG_DEV,F("hostname: AP: "),WiFi.softAPgetHostname()); } #endif @@ -1343,7 +1345,7 @@ void WiFiManager::handleWiFiStatus(){ handleRequest(); String page; // String page = "{\"result\":true,\"count\":1}"; - #ifdef JSTEST + #ifdef WM_JSTEST page = FPSTR(HTTP_JS); #endif server->sendHeader(FPSTR(HTTP_HEAD_CL), String(page.length())); diff --git a/WiFiManager.h b/WiFiManager.h index 4fa1e6e..17118b6 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -22,11 +22,14 @@ #include -// #define WM_MDNS // also set MDNS with sethostname +// #define WM_MDNS // includes MDNS, also set MDNS with sethostname // #define WM_FIXERASECONFIG // use erase flash fix // #define WM_ERASE_NVS // esp32 erase(true) will erase NVS // #define WM_RTC // esp32 info page will include reset reasons +// #define WM_JSTEST // build flag for enabling js xhr tests +// #define WIFI_MANAGER_OVERRIDE_STRINGS // build flag for using own strings include + #ifdef ARDUINO_ESP8266_RELEASE_2_3_0 #warning "ARDUINO_ESP8266_RELEASE_2_3_0, some WM features disabled" #define WM_NOASYNC // esp8266 no async scan wifi @@ -67,7 +70,7 @@ #include #else #include - // Forthcoming official ? + // Forthcoming official ? probably never happening // https://github.com/esp8266/ESPWebServer #endif #endif @@ -85,7 +88,6 @@ #include #endif - #else #endif diff --git a/strings_en.h b/strings_en.h index 2560ff0..882cf6b 100644 --- a/strings_en.h +++ b/strings_en.h @@ -124,7 +124,7 @@ const char HTTP_HELP[] PROGMEM = "" "

More information about WiFiManager at https://github.com/tzapu/WiFiManager."; -#ifdef JSTEST +#ifdef WM_JSTEST const char HTTP_JS[] PROGMEM = ""; From 2cedf7b368cd9ce37ab92a1ca521980179b498cf Mon Sep 17 00:00:00 2001 From: tablatronix Date: Sun, 24 May 2020 14:11:25 -0500 Subject: [PATCH 13/26] 2.0.2 --- library.json | 2 +- library.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.json b/library.json index 5eff70e..09f7315 100644 --- a/library.json +++ b/library.json @@ -25,5 +25,5 @@ "espressif8266", "espressif32" ], - "version": "2.0.1-alpha" + "version": "2.0.2-alpha" } diff --git a/library.properties b/library.properties index 9f2fa8d..1597544 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=WiFiManager -version=2.0.1-alpha +version=2.0.2-alpha author=tzapu,tablatronix maintainer=tablatronix sentence=WiFi Configuration manager with web configuration portal for ESP boards From 9af72535efdff02c0b7b9e8594509a0d91adc9b9 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Mon, 25 May 2020 11:42:31 -0500 Subject: [PATCH 14/26] I messed up --- library.json | 2 +- library.properties | 2 +- strings_en.h | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/library.json b/library.json index 09f7315..96c4164 100644 --- a/library.json +++ b/library.json @@ -25,5 +25,5 @@ "espressif8266", "espressif32" ], - "version": "2.0.2-alpha" + "version": "2.0.3-alpha" } diff --git a/library.properties b/library.properties index 1597544..9ac084b 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=WiFiManager -version=2.0.2-alpha +version=2.0.3-alpha author=tzapu,tablatronix maintainer=tablatronix sentence=WiFi Configuration manager with web configuration portal for ESP boards diff --git a/strings_en.h b/strings_en.h index c409437..d56d0b1 100644 --- a/strings_en.h +++ b/strings_en.h @@ -20,7 +20,6 @@ const char HTTP_HEAD_START[] PROGMEM = ""; From 998243c60cfb146b0d4ff17ccd880b1b54848c88 Mon Sep 17 00:00:00 2001 From: Adrian Jost <22987140+adrianjost@users.noreply.github.com> Date: Sun, 7 Jun 2020 20:26:03 +0200 Subject: [PATCH 15/26] swap comments --- WiFiManager.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WiFiManager.h b/WiFiManager.h index 0834390..72041a5 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -323,10 +323,10 @@ class WiFiManager // check if the module has a saved ap to connect to bool getWiFiIsSaved(); - // helper to get saved ssid, if persistent get stored, else get current if connected + // helper to get saved password, if persistent get stored, else get current if connected String getWiFiPass(bool persistent = false); - // helper to get saved password, if persistent get stored, else get current if connected + // helper to get saved ssid, if persistent get stored, else get current if connected String getWiFiSSID(bool persistent = false); // debug output the softap config @@ -613,4 +613,4 @@ class WiFiManager #endif -#endif \ No newline at end of file +#endif From 994609f1e05b46a8a25c3f989cb3f66c0049f348 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Tue, 4 Aug 2020 23:24:28 -0500 Subject: [PATCH 16/26] add logging --- WiFiManager.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 1686a3e..718aedf 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -356,7 +356,6 @@ bool WiFiManager::setupHostname(bool restart){ if(!res)DEBUG_WM(DEBUG_ERROR,F("[ERROR] hostname: set failed!")); - // in sta mode restart , not sure about softap if(restart && (WiFi.status() == WL_CONNECTED)){ DEBUG_WM(DEBUG_VERBOSE,F("reconnecting to set new hostname")); // WiFi.reconnect(); // This does not reset dhcp @@ -838,6 +837,8 @@ bool WiFiManager::wifiConnectDefault(){ DEBUG_WM(F("Connecting to SAVED AP:"),WiFi_SSID(true)); DEBUG_WM(DEBUG_DEV,F("Using Password:"),WiFi_psk(true)); ret = WiFi_enableSTA(true,storeSTAmode); + delay(500); // THIS DELAY ? + DEBUG_WM(DEBUG_DEV,"Mode after delay: "+getModeString(WiFi.getMode())); if(!ret) DEBUG_WM(DEBUG_ERROR,"[ERROR] wifi enableSta failed"); ret = WiFi.begin(); if(!ret) DEBUG_WM(DEBUG_ERROR,"[ERROR] wifi begin failed"); @@ -2785,14 +2786,14 @@ bool WiFiManager::WiFi_Disconnect() { #ifdef ESP8266 if((WiFi.getMode() & WIFI_STA) != 0) { bool ret; - DEBUG_WM(DEBUG_DEV,F("WIFI station disconnect")); + DEBUG_WM(DEBUG_DEV,F("WiFi station disconnect")); ETS_UART_INTR_DISABLE(); // @todo probably not needed ret = wifi_station_disconnect(); ETS_UART_INTR_ENABLE(); return ret; } #elif defined(ESP32) - DEBUG_WM(DEBUG_DEV,F("WIFI station disconnect")); + DEBUG_WM(DEBUG_DEV,F("WiFi station disconnect")); return WiFi.disconnect(); // not persistent atm #endif return false; @@ -2800,7 +2801,7 @@ bool WiFiManager::WiFi_Disconnect() { // toggle STA without persistent bool WiFiManager::WiFi_enableSTA(bool enable,bool persistent) { - DEBUG_WM(DEBUG_DEV,F("WiFi station enable")); + DEBUG_WM(DEBUG_DEV,F("WiFi_enableSTA"),(String) enable? "enable" : "disable"); #ifdef ESP8266 WiFiMode_t newMode; WiFiMode_t currentMode = WiFi.getMode(); From fac59e1982aef5c1bcb5c1d5edbcab7aa4df7039 Mon Sep 17 00:00:00 2001 From: "David J. Fiddes" Date: Thu, 13 Aug 2020 18:19:55 +0100 Subject: [PATCH 17/26] Fix warning in WiFiManager::debugPlatformInfo for ESP32 This fixes an unused variable warning as the call to heap_caps_get_free_size() is not required. Tests: - Enable debug mode and verify free heap and ESP SDK version are correctly displayed - Cross check with the free heap reported via the captive portal info page --- WiFiManager.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 718aedf..6903c4f 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -2632,7 +2632,6 @@ void WiFiManager::debugPlatformInfo(){ DEBUG_WM(F("system_get_boot_version():"),system_get_boot_version()); DEBUG_WM(F("getFreeHeap(): "),(String)ESP.getFreeHeap()); #elif defined(ESP32) - size_t freeHeap = heap_caps_get_free_size(MALLOC_CAP_8BIT); DEBUG_WM("Free heap: ", ESP.getFreeHeap()); DEBUG_WM("ESP SDK version: ", ESP.getSdkVersion()); // esp_chip_info_t chipInfo; From d1656421bb752d0581fb65b2b235d636b2ec3a2c Mon Sep 17 00:00:00 2001 From: tablatronix Date: Mon, 14 Sep 2020 10:23:00 -0500 Subject: [PATCH 18/26] remove getheapstats, not exist in 2.3.0 --- WiFiManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 718aedf..050345e 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -2558,8 +2558,8 @@ void WiFiManager::DEBUG_WM(wm_debuglevel_t level,Generic text,Genericb textb) { uint16_t max; uint8_t frag; #ifdef ESP8266 - ESP.getHeapStats(&free, &max, &frag); - _debugPort.printf("[MEM] free: %5d | max: %5d | frag: %3d%% \n", free, max, frag); + // ESP.getHeapStats(&free, &max, &frag);// @todo Does not exist in 2.3.0 + // _debugPort.printf("[MEM] free: %5d | max: %5d | frag: %3d%% \n", free, max, frag); #elif defined ESP32 // total_free_bytes; ///< Total free bytes in the heap. Equivalent to multi_free_heap_size(). // total_allocated_bytes; ///< Total bytes allocated to data in the heap. From 61916627ed79f764a2a94df8792ae8b428b03d44 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Mon, 14 Sep 2020 10:23:09 -0500 Subject: [PATCH 19/26] example compile issue --- examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino index 28d1447..dcfab8c 100644 --- a/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -56,7 +56,7 @@ void saveWifiCallback(){ void configModeCallback (WiFiManager *myWiFiManager) { Serial.println("[CALLBACK] configModeCallback fired"); #ifdef ESP8266 - print_oled("WiFiManager Waiting\nIP: " + WiFi.softAPIP().toString() + "\nSSID: " + WiFi.softAPSSID(),1); + // print_oled("WiFiManager Waiting\nIP: " + WiFi.softAPIP().toString() + "\nSSID: " + WiFi.softAPSSID(),1); #endif // myWiFiManager->setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0)); // Serial.println(WiFi.softAPIP()); From 726bdfae4648306726cefb77ab74ef76d08cbbb6 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Tue, 15 Sep 2020 09:54:45 -0500 Subject: [PATCH 20/26] #1125 remove country from 2.3.0 --- WiFiManager.cpp | 9 ++++++--- WiFiManager.h | 1 + .../DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino | 2 +- strings_en.h | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 050345e..7416180 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -2592,13 +2592,16 @@ void WiFiManager::DEBUG_WM(wm_debuglevel_t level,Generic text,Genericb textb) { * @return {[type]} [description] */ void WiFiManager::debugSoftAPConfig(){ - wifi_country_t country; #ifdef ESP8266 softap_config config; wifi_softap_get_config(&config); - wifi_get_country(&country); + #if !defined(WM_NOCOUNTRY) + wifi_country_t country; + wifi_get_country(&country); + #endif #elif defined(ESP32) + wifi_country_t country; wifi_config_t conf_config; esp_wifi_get_config(WIFI_IF_AP, &conf_config); // == ESP_OK wifi_ap_config_t config = conf_config.ap; @@ -2745,7 +2748,7 @@ bool WiFiManager::WiFiSetCountry(){ else if(_wificountry == "CN") ret = esp_wifi_set_country(&WM_COUNTRY_CN) == ESP_OK; else DEBUG_WM(DEBUG_ERROR,"[ERROR] country code not found"); - #elif defined(ESP8266) + #elif defined(ESP8266) && !defined(WM_NOCOUNTRY) // if(WiFi.getMode() == WIFI_OFF); // exception if wifi not init! if(_wificountry == "US") ret = wifi_set_country((wifi_country_t*)&WM_COUNTRY_US); else if(_wificountry == "JP") ret = wifi_set_country((wifi_country_t*)&WM_COUNTRY_JP); diff --git a/WiFiManager.h b/WiFiManager.h index 72041a5..3e964af 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -33,6 +33,7 @@ #ifdef ARDUINO_ESP8266_RELEASE_2_3_0 #warning "ARDUINO_ESP8266_RELEASE_2_3_0, some WM features disabled" #define WM_NOASYNC // esp8266 no async scan wifi +#define WM_NOCOUNTRY // esp8266 no country #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. diff --git a/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino index dcfab8c..9b4bb78 100644 --- a/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -290,7 +290,7 @@ void getTime() { } Serial.println(""); struct tm timeinfo; - gmtime_r(&now, &timeinfo); + gmtime_r(&now, &timeinfo); // @NOTE doesnt work in esp2.3.0 Serial.print("Current time: "); Serial.print(asctime(&timeinfo)); } diff --git a/strings_en.h b/strings_en.h index d56d0b1..903efe6 100644 --- a/strings_en.h +++ b/strings_en.h @@ -348,7 +348,7 @@ const char* const WIFI_MODES[] PROGMEM = { "NULL", "STA", "AP", "STA+AP" }; const wifi_country_t WM_COUNTRY_US{"US",1,11,CONFIG_ESP32_PHY_MAX_TX_POWER,WIFI_COUNTRY_POLICY_AUTO}; const wifi_country_t WM_COUNTRY_CN{"CN",1,13,CONFIG_ESP32_PHY_MAX_TX_POWER,WIFI_COUNTRY_POLICY_AUTO}; const wifi_country_t WM_COUNTRY_JP{"JP",1,14,CONFIG_ESP32_PHY_MAX_TX_POWER,WIFI_COUNTRY_POLICY_AUTO}; -#elif defined(ESP8266) +#elif defined(ESP8266) && !defined(WM_NOCOUNTRY) // typedef struct { // char cc[3]; /**< country code string */ // uint8_t schan; /**< start channel */ From 08efbfcfe72e5db4d385a0683177339334aa5689 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Tue, 15 Sep 2020 10:18:43 -0500 Subject: [PATCH 21/26] remove country debug --- WiFiManager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 7416180..e553e17 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -2617,7 +2617,9 @@ void WiFiManager::debugSoftAPConfig(){ DEBUG_WM(F("authmode: "),config.authmode); DEBUG_WM(F("ssid_hidden: "),config.ssid_hidden); DEBUG_WM(F("max_connection: "),config.max_connection); - DEBUG_WM(F("country: "),(String)country.cc); + #if !defined(WM_NOCOUNTRY) + DEBUG_WM(F("country: "),(String)country.cc); + #endif DEBUG_WM(F("beacon_interval: "),(String)config.beacon_interval + "(ms)"); DEBUG_WM(FPSTR(D_HR)); } From e454c9969a327bcf1be221d19380381e08ca515c Mon Sep 17 00:00:00 2001 From: tablatronix Date: Sat, 17 Oct 2020 21:44:55 -0500 Subject: [PATCH 22/26] remove oled stuff --- .../OnDemandConfigPortal.ino | 62 +++---------------- 1 file changed, 7 insertions(+), 55 deletions(-) diff --git a/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino index 9b4bb78..e86a39c 100644 --- a/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -19,7 +19,6 @@ const char* modes[] = { "NULL", "STA", "AP", "STA+AP" }; unsigned long mtime = 0; - WiFiManager wm; // TEST OPTION FLAGS @@ -34,20 +33,6 @@ int ONDDEMANDPIN = 0; // gpio for button // char ssid[] = "*************"; // your network SSID (name) // char pass[] = "********"; // your network password -// OLED TEST , ssd1306 -// #define WM_OLED -#ifdef WM_OLED -#include -#include -#include -#define SCREEN_WIDTH 128 // OLED display width, in pixels -#define SCREEN_HEIGHT 32 // OLED display height, in pixels - -// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) -#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) -Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); -#endif - void saveWifiCallback(){ Serial.println("[CALLBACK] saveCallback fired"); } @@ -55,9 +40,6 @@ void saveWifiCallback(){ //gets called when WiFiManager enters configuration mode void configModeCallback (WiFiManager *myWiFiManager) { Serial.println("[CALLBACK] configModeCallback fired"); - #ifdef ESP8266 - // print_oled("WiFiManager Waiting\nIP: " + WiFi.softAPIP().toString() + "\nSSID: " + WiFi.softAPSSID(),1); - #endif // myWiFiManager->setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0)); // Serial.println(WiFi.softAPIP()); //if you used auto generated SSID, print it @@ -91,12 +73,13 @@ void setup() { Serial.println("\n Starting"); // WiFi.setSleepMode(WIFI_NONE_SLEEP); // disable sleep, can improve ap stability - - #ifdef WM_OLED - init_oled(); - #endif - print_oled(F("Starting..."),2); + Serial.println("Error - TEST"); + Serial.println("Information- - TEST"); + + Serial.println("[ERROR] TEST"); + Serial.println("[INFORMATION] TEST"); + wm.debugPlatformInfo(); //reset settings - for testing @@ -201,10 +184,8 @@ void setup() { wifiInfo(); - print_oled(F("Connecting..."),2); if(!wm.autoConnect("WM_AutoConnectAP","12345678")) { Serial.println("failed to connect and hit timeout"); - print_oled("Not Connected",2); } else if(TEST_CP) { // start configportal always @@ -216,7 +197,6 @@ void setup() { else { //if you get here you have connected to the WiFi Serial.println("connected...yeey :)"); - print_oled("Connected\nIP: " + WiFi.localIP().toString() + "\nSSID: " + WiFi.SSID(),1); } wifiInfo(); @@ -225,6 +205,7 @@ void setup() { #ifdef USEOTA ArduinoOTA.begin(); #endif + } void wifiInfo(){ @@ -258,7 +239,6 @@ void loop() { else { //if you get here you have connected to the WiFi Serial.println("connected...yeey :)"); - print_oled("Connected\nIP: " + WiFi.localIP().toString() + "\nSSID: " + WiFi.SSID(),1); getTime(); } } @@ -317,31 +297,3 @@ void debugchipid(){ // 507726A4AE30 // ESP32 Chip ID = 507726A4AE30 } - -#ifdef WM_OLED -void init_oled(){ - if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32 - Serial.println(F("SSD1306 allocation failed")); - } - - display.clearDisplay(); - display.setTextSize(1); // Normal 1:1 pixepl scale - display.setTextColor(WHITE); // Draw white text - display.setCursor(0,0); // Start at top-left corner - display.display(); -} - -void print_oled(String str,uint8_t size){ - display.clearDisplay(); - display.setTextSize(size); - display.setTextColor(WHITE); - display.setCursor(0,0); - display.println(str); - display.display(); -} -#else - void print_oled(String str,uint8_t size){ - (void)str; - (void)size; - } -#endif From a7fb6d5caff8e732ada8bb9cb40c219a3d941b28 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Thu, 19 Nov 2020 14:25:12 -0600 Subject: [PATCH 23/26] adds #1137 connect retries setConnectRetries() --- WiFiManager.cpp | 21 +++++++++++++++++-- WiFiManager.h | 7 ++++++- .../OnDemandConfigPortal.ino | 8 ++++--- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index eb796bf..ed74dd1 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -755,7 +755,7 @@ bool WiFiManager::shutdownConfigPortal(){ // clean up, flow is convoluted, and causes bugs uint8_t WiFiManager::connectWifi(String ssid, String pass) { DEBUG_WM(DEBUG_VERBOSE,F("Connecting as wifi client...")); - + uint8_t retry = 1; uint8_t connRes = (uint8_t)WL_NO_SSID_AVAIL; setSTAConfig(); @@ -766,6 +766,10 @@ uint8_t WiFiManager::connectWifi(String ssid, String pass) { 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 + while(retry <= _connectRetries){ + if(_connectRetries > 1){ + DEBUG_WM(F("Connect Wifi, ATTEMPT #"),(String)retry+" of "+(String)_connectRetries); + } // if ssid argument provided connect to that if (ssid != "") { wifiConnectNew(ssid,pass); @@ -783,11 +787,13 @@ uint8_t WiFiManager::connectWifi(String ssid, String pass) { connRes = waitForConnectResult(); } else { - DEBUG_WM(F("No wifi save required, skipping")); + DEBUG_WM(F("No wifi saved, skipping")); } } DEBUG_WM(DEBUG_VERBOSE,F("Connection result:"),getWLStatusString(connRes)); + retry++; +} // WPS enabled? https://github.com/esp8266/Arduino/pull/4889 #ifdef NO_EXTRA_4K_HEAP @@ -2057,6 +2063,17 @@ void WiFiManager::setConfigPortalTimeout(unsigned long seconds) { void WiFiManager::setConnectTimeout(unsigned long seconds) { _connectTimeout = seconds * 1000; } + +/** + * [setConnectRetries description] + * @access public + * @param {[type]} uint8_t numRetries [description] + */ +void WiFiManager::setConnectRetries(uint8_t numRetries){ + _connectRetries = numRetries; + if(_connectRetries > 10) numRetries = 10; // some cap +} + /** * toggle _cleanconnect, always disconnect before connecting * @param {[type]} bool enable [description] diff --git a/WiFiManager.h b/WiFiManager.h index 3e964af..2230c7f 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -226,6 +226,9 @@ class WiFiManager //sets timeout for which to attempt connecting, useful if you get a lot of failed connects void setConnectTimeout(unsigned long seconds); + + // sets number of retries for autoconnect, force retry after wait failure exit + void setConnectRetries(uint8_t numRetries); // default 1 //sets timeout for which to attempt connecting on saves, useful if there are bugs in esp waitforconnectloop void setSaveConnectTimeout(unsigned long seconds); @@ -403,7 +406,9 @@ class WiFiManager bool _channelSync = false; // use same wifi sta channel when starting ap int32_t _apChannel = 0; // channel to use for ap bool _apHidden = false; // store softap hidden value - uint16_t _httpPort = 80; // port for webserver + uint16_t _httpPort = 80; // port for webserver + // uint8_t _retryCount = 0; // counter for retries, probably not needed if synchronous + uint8_t _connectRetries = 1; // number of sta connect retries, force reconnect, wait loop (connectimeout) does not always work and first disconnect bails #ifdef ESP32 wifi_event_id_t wm_event_id; diff --git a/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino b/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino index e86a39c..e57c540 100644 --- a/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/examples/DEV/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -162,7 +162,10 @@ void setup() { // set connection timeout // wm.setConnectTimeout(20); - + + // set wifi connect retries + // wm.setConnectRetries(2); + // show static ip fields // wm.setShowStaticFields(true); @@ -171,8 +174,7 @@ void setup() { // This is sometimes necessary, it is still unknown when and why this is needed but it may solve some race condition or bug in esp SDK/lib // wm.setCleanConnect(true); // disconnect before connect, clean connect - // - wm.setBreakAfterConfig(true); + wm.setBreakAfterConfig(true); // needed to use saveWifiCallback // set custom webserver port, automatic captive portal does not work with custom ports! // wm.setHttpPort(8080); From 382879010901f8250485a0bc7cc83a88b1cddede Mon Sep 17 00:00:00 2001 From: tablatronix Date: Thu, 19 Nov 2020 14:25:21 -0600 Subject: [PATCH 24/26] remove warnings --- WiFiManager.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index ed74dd1..1c9cda5 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -2571,10 +2571,10 @@ void WiFiManager::DEBUG_WM(wm_debuglevel_t level,Generic text,Genericb textb) { if(!_debug || _debugLevel < level) return; if(_debugLevel >= DEBUG_MAX){ - uint32_t free; - uint16_t max; - uint8_t frag; #ifdef ESP8266 + // uint32_t free; + // uint16_t max; + // uint8_t frag; // ESP.getHeapStats(&free, &max, &frag);// @todo Does not exist in 2.3.0 // _debugPort.printf("[MEM] free: %5d | max: %5d | frag: %3d%% \n", free, max, frag); #elif defined ESP32 @@ -2587,9 +2587,9 @@ void WiFiManager::DEBUG_WM(wm_debuglevel_t level,Generic text,Genericb textb) { // total_blocks; ///< Total number of (variable size) blocks in the heap. multi_heap_info_t info; heap_caps_get_info(&info, MALLOC_CAP_INTERNAL); - free = info.total_free_bytes; - max = info.largest_free_block; - frag = 100 - (max * 100) / free; + uint32_t free = info.total_free_bytes; + uint16_t max = info.largest_free_block; + uint8_t frag = 100 - (max * 100) / free; _debugPort.printf("[MEM] free: %5d | max: %5d | frag: %3d%% \n", free, max, frag); #endif } From e1a263b47f78135c1f8dd250755216cdc1b0da49 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Thu, 19 Nov 2020 14:42:38 -0600 Subject: [PATCH 25/26] forgot to clamp 0 --- WiFiManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 1c9cda5..f07c2ee 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -2071,7 +2071,7 @@ void WiFiManager::setConnectTimeout(unsigned long seconds) { */ void WiFiManager::setConnectRetries(uint8_t numRetries){ _connectRetries = numRetries; - if(_connectRetries > 10) numRetries = 10; // some cap + constrain(_connectRetries,1,10); } /** From 5def8f84d4559998fc68bbc5f6be65ef324229b9 Mon Sep 17 00:00:00 2001 From: Lee Bussy Date: Sun, 22 Nov 2020 07:58:02 -0600 Subject: [PATCH 26/26] Use constrain properly --- WiFiManager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/WiFiManager.cpp b/WiFiManager.cpp index f07c2ee..9315f30 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -2070,8 +2070,7 @@ void WiFiManager::setConnectTimeout(unsigned long seconds) { * @param {[type]} uint8_t numRetries [description] */ void WiFiManager::setConnectRetries(uint8_t numRetries){ - _connectRetries = numRetries; - constrain(_connectRetries,1,10); + _connectRetries = constrain(numRetries,1,10); } /**