diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0721ba23..1a779837 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,10 +22,10 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p ### How to submit a bug report -Please ensure to specify the following: +Please ensure to specify the following, or your post will be ignored and deleted: * Arduino IDE version (e.g. 1.8.19) or Platform.io version -* `ESP8266` or `ESP32` Core Version (e.g. ESP8266 core v3.0.2 or ESP32 v2.0.4) +* `ESP8266` or `ESP32` Core Version (e.g. ESP8266 core v3.0.2 or ESP32 v2.0.5) * Contextual information (e.g. what you were trying to achieve) * Simplest possible steps to reproduce * Anything that might be relevant in your opinion, such as: @@ -39,10 +39,10 @@ Please ensure to specify the following: Arduino IDE version: 1.8.19 ESP8266 Core Version 3.0.2 OS: Ubuntu 20.04 LTS -Linux xy-Inspiron-3593 5.15.0-46-generic #49~20.04.1-Ubuntu SMP Thu Aug 4 19:15:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux +Linux xy-Inspiron-3593 5.15.0-48-generic #54~20.04.1-Ubuntu SMP Thu Sep 1 16:17:26 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux Context: -I encountered an endless loop while trying to connect to Local WiFi. +I encountered a crash when using this library Steps to reproduce: 1. ... diff --git a/Images/Configuration.png b/Images/Configuration.png index 2800497a..90c9cfae 100644 Binary files a/Images/Configuration.png and b/Images/Configuration.png differ diff --git a/changelog.md b/changelog.md index c19cd2b1..8f89de13 100644 --- a/changelog.md +++ b/changelog.md @@ -12,6 +12,7 @@ ## Table of Contents * [Changelog](#changelog) + * [Releases v1.15.0](#releases-v1150) * [Releases v1.14.1](#releases-v1141) * [Releases v1.14.0](#releases-v1140) * [Releases v1.13.0](#releases-v1130) @@ -53,6 +54,12 @@ ## Changelog +### Releases v1.15.0 + +1. Optionally display Credentials (SSIDs, PWDs) in Config Portal. Check [Populate portal wifi with saved credentials #91](https://github.com/khoih-prog/ESP_WiFiManager/discussions/91) and [Prepopulating the configuration with SSID and Password from stored file #115](https://github.com/khoih-prog/ESPAsync_WiFiManager/discussions/115) +2. Display `Credentials` Hint on Config Portal +3. Periodic code clean-up + ### Releases v1.14.1 1. Remove dependency on ESP_AsyncWebServer, ESPAsyncTCP and AsyncTCP in `library.properties`. Check ["no protocol" error #113](https://github.com/khoih-prog/ESPAsync_WiFiManager/issues/113)" diff --git a/examples/Async_AutoConnect/Async_AutoConnect.ino b/examples/Async_AutoConnect/Async_AutoConnect.ino index 20a7090c..be32c2b7 100644 --- a/examples/Async_AutoConnect/Async_AutoConnect.ino +++ b/examples/Async_AutoConnect/Async_AutoConnect.ino @@ -18,12 +18,16 @@ #error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting. #endif -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.14.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1014000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 +// To not display stored SSIDs and PWDs on Config Portal, select false. Default is true +// Even the stored Credentials are not display, just leave them all blank to reconnect and reuse the stored Credentials +//#define DISPLAY_STORED_CREDENTIALS_IN_CP false + //Ported to ESP32 #ifdef ESP32 #include @@ -780,6 +784,12 @@ void setup() Serial.print(F(", PWD = ")); Serial.println(AP_PASS); +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif + // Starts an access point //if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password)) if ( !ESPAsync_wifiManager.startConfigPortal(AP_SSID.c_str(), AP_PASS.c_str()) ) diff --git a/examples/Async_AutoConnectWithFSParameters/Async_AutoConnectWithFSParameters.ino b/examples/Async_AutoConnectWithFSParameters/Async_AutoConnectWithFSParameters.ino index f6200587..bbf49ec8 100644 --- a/examples/Async_AutoConnectWithFSParameters/Async_AutoConnectWithFSParameters.ino +++ b/examples/Async_AutoConnectWithFSParameters/Async_AutoConnectWithFSParameters.ino @@ -19,12 +19,16 @@ #error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting. #endif -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.14.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1014000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 +// To not display stored SSIDs and PWDs on Config Portal, select false. Default is true +// Even the stored Credentials are not display, just leave them all blank to reconnect and reuse the stored Credentials +//#define DISPLAY_STORED_CREDENTIALS_IN_CP false + #include //Ported to ESP32 @@ -1015,6 +1019,12 @@ void setup() Serial.print(F(", PWD = ")); Serial.println(AP_PASS); +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif + // Starts an access point //if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password)) if ( !ESPAsync_wifiManager.startConfigPortal(AP_SSID.c_str(), AP_PASS.c_str()) ) diff --git a/examples/Async_AutoConnectWithFSParametersAndCustomIP/Async_AutoConnectWithFSParametersAndCustomIP.ino b/examples/Async_AutoConnectWithFSParametersAndCustomIP/Async_AutoConnectWithFSParametersAndCustomIP.ino index 84ff7168..74a81412 100644 --- a/examples/Async_AutoConnectWithFSParametersAndCustomIP/Async_AutoConnectWithFSParametersAndCustomIP.ino +++ b/examples/Async_AutoConnectWithFSParametersAndCustomIP/Async_AutoConnectWithFSParametersAndCustomIP.ino @@ -19,12 +19,16 @@ #error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting. #endif -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.14.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1014000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 +// To not display stored SSIDs and PWDs on Config Portal, select false. Default is true +// Even the stored Credentials are not display, just leave them all blank to reconnect and reuse the stored Credentials +//#define DISPLAY_STORED_CREDENTIALS_IN_CP false + #include //this needs to be first, or it all crashes and burns... //For ESP32, To use ESP32 Dev Module, QIO, Flash 4MB/80MHz, Upload 921600 @@ -933,6 +937,12 @@ void setup() Serial.print(F(", PWD = ")); Serial.println(AP_PASS); +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif + // Starts an access point //if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password)) if ( !ESPAsync_wifiManager.startConfigPortal(AP_SSID.c_str(), AP_PASS.c_str()) ) diff --git a/examples/Async_AutoConnectWithFeedback/Async_AutoConnectWithFeedback.ino b/examples/Async_AutoConnectWithFeedback/Async_AutoConnectWithFeedback.ino index e89516a8..941da00a 100644 --- a/examples/Async_AutoConnectWithFeedback/Async_AutoConnectWithFeedback.ino +++ b/examples/Async_AutoConnectWithFeedback/Async_AutoConnectWithFeedback.ino @@ -18,12 +18,16 @@ #error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting. #endif -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.14.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1014000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 +// To not display stored SSIDs and PWDs on Config Portal, select false. Default is true +// Even the stored Credentials are not display, just leave them all blank to reconnect and reuse the stored Credentials +//#define DISPLAY_STORED_CREDENTIALS_IN_CP false + //Ported to ESP32 #ifdef ESP32 #include @@ -796,6 +800,12 @@ void setup() Serial.print(F(", PWD = ")); Serial.println(AP_PASS); +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif + // Starts an access point //if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password)) if ( !ESPAsync_wifiManager.startConfigPortal(AP_SSID.c_str(), AP_PASS.c_str()) ) diff --git a/examples/Async_AutoConnectWithFeedbackLED/Async_AutoConnectWithFeedbackLED.ino b/examples/Async_AutoConnectWithFeedbackLED/Async_AutoConnectWithFeedbackLED.ino index 5500a656..f430ca95 100644 --- a/examples/Async_AutoConnectWithFeedbackLED/Async_AutoConnectWithFeedbackLED.ino +++ b/examples/Async_AutoConnectWithFeedbackLED/Async_AutoConnectWithFeedbackLED.ino @@ -19,12 +19,16 @@ #error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting. #endif -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.14.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1014000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 +// To not display stored SSIDs and PWDs on Config Portal, select false. Default is true +// Even the stored Credentials are not display, just leave them all blank to reconnect and reuse the stored Credentials +//#define DISPLAY_STORED_CREDENTIALS_IN_CP false + //Ported to ESP32 #ifdef ESP32 #include @@ -825,6 +829,12 @@ void setup() Serial.print(AP_SSID); Serial.print(F(", PWD = ")); Serial.println(AP_PASS); + +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif // Starts an access point //if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password)) diff --git a/examples/Async_ConfigOnDRD_FS_MQTT_Ptr/Async_ConfigOnDRD_FS_MQTT_Ptr.ino b/examples/Async_ConfigOnDRD_FS_MQTT_Ptr/Async_ConfigOnDRD_FS_MQTT_Ptr.ino index 12801896..a3931f56 100644 --- a/examples/Async_ConfigOnDRD_FS_MQTT_Ptr/Async_ConfigOnDRD_FS_MQTT_Ptr.ino +++ b/examples/Async_ConfigOnDRD_FS_MQTT_Ptr/Async_ConfigOnDRD_FS_MQTT_Ptr.ino @@ -31,12 +31,16 @@ #error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting. #endif -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.14.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1014000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 +// To not display stored SSIDs and PWDs on Config Portal, select false. Default is true +// Even the stored Credentials are not display, just leave them all blank to reconnect and reuse the stored Credentials +//#define DISPLAY_STORED_CREDENTIALS_IN_CP false + #include // Now support ArduinoJson 6.0.0+ ( tested with v6.15.2 to v6.16.1 ) @@ -966,6 +970,12 @@ void wifi_manager() Serial.print(F(", PWD = ")); Serial.println(password); +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif + if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password.c_str())) { Serial.println(F("Not connected to WiFi but continuing anyway.")); @@ -1336,6 +1346,8 @@ void setup() if (initialConfig) { + loadConfigData(); + wifi_manager(); } else @@ -1347,21 +1359,21 @@ void setup() if (loadConfigData()) { #if USE_ESP_WIFIMANAGER_NTP - if ( strlen(WM_config.TZ_Name) > 0 ) - { - LOGERROR3(F("Current TZ_Name ="), WM_config.TZ_Name, F(", TZ = "), WM_config.TZ); + if ( strlen(WM_config.TZ_Name) > 0 ) + { + LOGERROR3(F("Current TZ_Name ="), WM_config.TZ_Name, F(", TZ = "), WM_config.TZ); #if ESP8266 - configTime(WM_config.TZ, "pool.ntp.org"); + configTime(WM_config.TZ, "pool.ntp.org"); #else - //configTzTime(WM_config.TZ, "pool.ntp.org" ); - configTzTime(WM_config.TZ, "time.nist.gov", "0.pool.ntp.org", "1.pool.ntp.org"); + //configTzTime(WM_config.TZ, "pool.ntp.org" ); + configTzTime(WM_config.TZ, "time.nist.gov", "0.pool.ntp.org", "1.pool.ntp.org"); #endif - } - else - { - Serial.println(F("Current Timezone is not set. Enter Config Portal to set.")); - } + } + else + { + Serial.println(F("Current Timezone is not set. Enter Config Portal to set.")); + } #endif for (uint8_t i = 0; i < NUM_WIFI_CREDENTIALS; i++) diff --git a/examples/Async_ConfigOnDRD_FS_MQTT_Ptr_Complex/Async_ConfigOnDRD_FS_MQTT_Ptr_Complex.ino b/examples/Async_ConfigOnDRD_FS_MQTT_Ptr_Complex/Async_ConfigOnDRD_FS_MQTT_Ptr_Complex.ino index 13bb1399..387d16e4 100644 --- a/examples/Async_ConfigOnDRD_FS_MQTT_Ptr_Complex/Async_ConfigOnDRD_FS_MQTT_Ptr_Complex.ino +++ b/examples/Async_ConfigOnDRD_FS_MQTT_Ptr_Complex/Async_ConfigOnDRD_FS_MQTT_Ptr_Complex.ino @@ -31,11 +31,15 @@ #error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting. #endif -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.14.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1014000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. -#define _ESPASYNC_WIFIMGR_LOGLEVEL_ 2 +#define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 + +// To not display stored SSIDs and PWDs on Config Portal, select false. Default is true +// Even the stored Credentials are not display, just leave them all blank to reconnect and reuse the stored Credentials +//#define DISPLAY_STORED_CREDENTIALS_IN_CP false // Optional ms delay in ConfigPortal loop, if necessary. Using 0 if not necessary #define TIME_BETWEEN_CONFIG_PORTAL_LOOP 0L @@ -1022,6 +1026,12 @@ void wifi_manager() Serial.print(F(", PWD = ")); Serial.println(password); +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif + if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password.c_str())) { Serial.println(F("Not connected to WiFi but continuing anyway.")); @@ -1382,8 +1392,11 @@ void setup() if (initialConfig) { + loadConfigData(); + wifi_manager(); } + else { // Pretend CP is necessary as we have no AP Credentials initialConfig = true; @@ -1392,21 +1405,21 @@ void setup() if (loadConfigData()) { #if USE_ESP_WIFIMANAGER_NTP - if ( strlen(WM_config.TZ_Name) > 0 ) - { - LOGERROR3(F("Current TZ_Name ="), WM_config.TZ_Name, F(", TZ = "), WM_config.TZ); + if ( strlen(WM_config.TZ_Name) > 0 ) + { + LOGERROR3(F("Current TZ_Name ="), WM_config.TZ_Name, F(", TZ = "), WM_config.TZ); #if ESP8266 - configTime(WM_config.TZ, "pool.ntp.org"); + configTime(WM_config.TZ, "pool.ntp.org"); #else - //configTzTime(WM_config.TZ, "pool.ntp.org" ); - configTzTime(WM_config.TZ, "time.nist.gov", "0.pool.ntp.org", "1.pool.ntp.org"); + //configTzTime(WM_config.TZ, "pool.ntp.org" ); + configTzTime(WM_config.TZ, "time.nist.gov", "0.pool.ntp.org", "1.pool.ntp.org"); #endif - } - else - { - Serial.println(F("Current Timezone is not set. Enter Config Portal to set.")); - } + } + else + { + Serial.println(F("Current Timezone is not set. Enter Config Portal to set.")); + } #endif for (uint8_t i = 0; i < NUM_WIFI_CREDENTIALS; i++) diff --git a/examples/Async_ConfigOnDRD_FS_MQTT_Ptr_Medium/Async_ConfigOnDRD_FS_MQTT_Ptr_Medium.ino b/examples/Async_ConfigOnDRD_FS_MQTT_Ptr_Medium/Async_ConfigOnDRD_FS_MQTT_Ptr_Medium.ino index 62c63b87..9767b4cf 100644 --- a/examples/Async_ConfigOnDRD_FS_MQTT_Ptr_Medium/Async_ConfigOnDRD_FS_MQTT_Ptr_Medium.ino +++ b/examples/Async_ConfigOnDRD_FS_MQTT_Ptr_Medium/Async_ConfigOnDRD_FS_MQTT_Ptr_Medium.ino @@ -31,11 +31,16 @@ #error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting. #endif -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.14.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1014000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000 + // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 +// To not display stored SSIDs and PWDs on Config Portal, select false. Default is true +// Even the stored Credentials are not display, just leave them all blank to reconnect and reuse the stored Credentials +//#define DISPLAY_STORED_CREDENTIALS_IN_CP false + #include // Now support ArduinoJson 6.0.0+ ( tested with v6.15.2 to v6.16.1 ) @@ -1005,6 +1010,12 @@ void wifi_manager() Serial.print(ssid); Serial.print(F(", PWD = ")); Serial.println(password); + +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password.c_str())) { @@ -1365,6 +1376,8 @@ void setup() if (initialConfig) { + loadConfigData(); + wifi_manager(); } else @@ -1376,21 +1389,21 @@ void setup() if (loadConfigData()) { #if USE_ESP_WIFIMANAGER_NTP - if ( strlen(WM_config.TZ_Name) > 0 ) - { - LOGERROR3(F("Current TZ_Name ="), WM_config.TZ_Name, F(", TZ = "), WM_config.TZ); + if ( strlen(WM_config.TZ_Name) > 0 ) + { + LOGERROR3(F("Current TZ_Name ="), WM_config.TZ_Name, F(", TZ = "), WM_config.TZ); #if ESP8266 - configTime(WM_config.TZ, "pool.ntp.org"); + configTime(WM_config.TZ, "pool.ntp.org"); #else - //configTzTime(WM_config.TZ, "pool.ntp.org" ); - configTzTime(WM_config.TZ, "time.nist.gov", "0.pool.ntp.org", "1.pool.ntp.org"); + //configTzTime(WM_config.TZ, "pool.ntp.org" ); + configTzTime(WM_config.TZ, "time.nist.gov", "0.pool.ntp.org", "1.pool.ntp.org"); #endif - } - else - { - Serial.println(F("Current Timezone is not set. Enter Config Portal to set.")); - } + } + else + { + Serial.println(F("Current Timezone is not set. Enter Config Portal to set.")); + } #endif for (uint8_t i = 0; i < NUM_WIFI_CREDENTIALS; i++) diff --git a/examples/Async_ConfigOnDoubleReset/Async_ConfigOnDoubleReset.ino b/examples/Async_ConfigOnDoubleReset/Async_ConfigOnDoubleReset.ino index 15321071..0acb25d1 100644 --- a/examples/Async_ConfigOnDoubleReset/Async_ConfigOnDoubleReset.ino +++ b/examples/Async_ConfigOnDoubleReset/Async_ConfigOnDoubleReset.ino @@ -42,11 +42,15 @@ #error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting. #endif -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.14.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1014000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. -#define _ESPASYNC_WIFIMGR_LOGLEVEL_ 1 +#define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 + +// To not display stored SSIDs and PWDs on Config Portal, select false. Default is true +// Even the stored Credentials are not display, just leave them all blank to reconnect and reuse the stored Credentials +//#define DISPLAY_STORED_CREDENTIALS_IN_CP false #include @@ -891,6 +895,12 @@ void setup() //switched off via webserver or device is restarted. //ESPAsync_wifiManager.setConfigPortalTimeout(600); +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif + // Starts an access point if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password.c_str())) Serial.println(F("Not connected to WiFi but continuing anyway.")); diff --git a/examples/Async_ConfigOnDoubleReset_Multi/Async_ConfigOnDoubleReset_Multi.ino b/examples/Async_ConfigOnDoubleReset_Multi/Async_ConfigOnDoubleReset_Multi.ino index 6bb1dc7b..d76cee1c 100644 --- a/examples/Async_ConfigOnDoubleReset_Multi/Async_ConfigOnDoubleReset_Multi.ino +++ b/examples/Async_ConfigOnDoubleReset_Multi/Async_ConfigOnDoubleReset_Multi.ino @@ -247,6 +247,12 @@ void setup() //switched off via webserver or device is restarted. //ESPAsync_wifiManager.setConfigPortalTimeout(600); +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif + // Starts an access point if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password.c_str())) Serial.println(F("Not connected to WiFi but continuing anyway.")); diff --git a/examples/Async_ConfigOnDoubleReset_TZ/Async_ConfigOnDoubleReset_TZ.ino b/examples/Async_ConfigOnDoubleReset_TZ/Async_ConfigOnDoubleReset_TZ.ino index fac0b209..238913d3 100644 --- a/examples/Async_ConfigOnDoubleReset_TZ/Async_ConfigOnDoubleReset_TZ.ino +++ b/examples/Async_ConfigOnDoubleReset_TZ/Async_ConfigOnDoubleReset_TZ.ino @@ -42,11 +42,15 @@ #error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting. #endif -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.14.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1014000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. -#define _ESPASYNC_WIFIMGR_LOGLEVEL_ 1 +#define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 + +// To not display stored SSIDs and PWDs on Config Portal, select false. Default is true +// Even the stored Credentials are not display, just leave them all blank to reconnect and reuse the stored Credentials +//#define DISPLAY_STORED_CREDENTIALS_IN_CP false #include @@ -890,6 +894,12 @@ void setup() //switched off via webserver or device is restarted. //ESPAsync_wifiManager.setConfigPortalTimeout(600); +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif + // Starts an access point if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password.c_str())) Serial.println(F("Not connected to WiFi but continuing anyway.")); diff --git a/examples/Async_ConfigOnStartup/Async_ConfigOnStartup.ino b/examples/Async_ConfigOnStartup/Async_ConfigOnStartup.ino index a643efa4..f4bc8641 100644 --- a/examples/Async_ConfigOnStartup/Async_ConfigOnStartup.ino +++ b/examples/Async_ConfigOnStartup/Async_ConfigOnStartup.ino @@ -33,12 +33,16 @@ #error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting. #endif -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.14.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1014000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 +// To not display stored SSIDs and PWDs on Config Portal, select false. Default is true +// Even the stored Credentials are not display, just leave them all blank to reconnect and reuse the stored Credentials +//#define DISPLAY_STORED_CREDENTIALS_IN_CP false + //For ESP32, To use ESP32 Dev Module, QIO, Flash 4MB/80MHz, Upload 921600 //Ported to ESP32 @@ -817,6 +821,12 @@ void setup() digitalWrite(LED_BUILTIN, LED_ON); // turn the LED on by making the voltage LOW to tell us we are in configuration mode. +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif + // Starts an access point if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password)) Serial.println(F("Not connected to WiFi but continuing anyway.")); diff --git a/examples/Async_ConfigOnSwitch/Async_ConfigOnSwitch.ino b/examples/Async_ConfigOnSwitch/Async_ConfigOnSwitch.ino index 28236b1f..f123e5a5 100644 --- a/examples/Async_ConfigOnSwitch/Async_ConfigOnSwitch.ino +++ b/examples/Async_ConfigOnSwitch/Async_ConfigOnSwitch.ino @@ -30,12 +30,16 @@ #error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting. #endif -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.14.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1014000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 +// To not display stored SSIDs and PWDs on Config Portal, select false. Default is true +// Even the stored Credentials are not display, just leave them all blank to reconnect and reuse the stored Credentials +//#define DISPLAY_STORED_CREDENTIALS_IN_CP false + //For ESP32, To use ESP32 Dev Module, QIO, Flash 4MB/80MHz, Upload 921600 //Ported to ESP32 @@ -950,6 +954,12 @@ void setup() //switched off via webserver or device is restarted. //ESPAsync_wifiManager.setConfigPortalTimeout(600); +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif + // Starts an access point if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password.c_str())) Serial.println(F("Not connected to WiFi but continuing anyway.")); @@ -1142,6 +1152,12 @@ void loop() initialConfig = true; } +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif + //Starts an access point //and goes into a blocking loop awaiting configuration if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password.c_str())) diff --git a/examples/Async_ConfigOnSwitchFS/Async_ConfigOnSwitchFS.ino b/examples/Async_ConfigOnSwitchFS/Async_ConfigOnSwitchFS.ino index 9cf1ff9f..db5f39ed 100644 --- a/examples/Async_ConfigOnSwitchFS/Async_ConfigOnSwitchFS.ino +++ b/examples/Async_ConfigOnSwitchFS/Async_ConfigOnSwitchFS.ino @@ -53,12 +53,16 @@ #error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting. #endif -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.14.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1014000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 +// To not display stored SSIDs and PWDs on Config Portal, select false. Default is true +// Even the stored Credentials are not display, just leave them all blank to reconnect and reuse the stored Credentials +//#define DISPLAY_STORED_CREDENTIALS_IN_CP false + #include // Now support ArduinoJson 6.0.0+ ( tested with v6.14.1 ) #include // get it from https://arduinojson.org/ or install via Arduino library manager @@ -1116,6 +1120,12 @@ void setup() //switched off via webserver or device is restarted. //ESPAsync_wifiManager.setConfigPortalTimeout(600); +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif + // Starts an access point if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password.c_str())) Serial.println(F("Not connected to WiFi but continuing anyway.")); @@ -1352,6 +1362,12 @@ void loop() ESPAsync_wifiManager.setCORSHeader("Your Access-Control-Allow-Origin"); #endif +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif + // Start an access point // and goes into a blocking loop awaiting configuration. // Once the user leaves the portal with the exit button diff --git a/examples/Async_ConfigOnSwitchFS_MQTT_Ptr/Async_ConfigOnSwitchFS_MQTT_Ptr.ino b/examples/Async_ConfigOnSwitchFS_MQTT_Ptr/Async_ConfigOnSwitchFS_MQTT_Ptr.ino index 7457c6db..dba088e5 100644 --- a/examples/Async_ConfigOnSwitchFS_MQTT_Ptr/Async_ConfigOnSwitchFS_MQTT_Ptr.ino +++ b/examples/Async_ConfigOnSwitchFS_MQTT_Ptr/Async_ConfigOnSwitchFS_MQTT_Ptr.ino @@ -35,12 +35,16 @@ #error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting. #endif -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.14.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1014000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 +// To not display stored SSIDs and PWDs on Config Portal, select false. Default is true +// Even the stored Credentials are not display, just leave them all blank to reconnect and reuse the stored Credentials +//#define DISPLAY_STORED_CREDENTIALS_IN_CP false + #include // for button #include // for button @@ -1043,6 +1047,12 @@ void wifi_manager() Serial.print(ssid); Serial.print(F(", PWD = ")); Serial.println(password); + +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password.c_str())) { @@ -1436,7 +1446,7 @@ void setup() if (initialConfig) { Serial.println(F("Open Config Portal without Timeout: No stored WiFi Credentials")); - + wifi_manager(); } else if ( WiFi.status() != WL_CONNECTED ) diff --git a/examples/Async_ConfigPortalParamsOnSwitch/Async_ConfigPortalParamsOnSwitch.ino b/examples/Async_ConfigPortalParamsOnSwitch/Async_ConfigPortalParamsOnSwitch.ino index 994b6de3..cea7bc01 100644 --- a/examples/Async_ConfigPortalParamsOnSwitch/Async_ConfigPortalParamsOnSwitch.ino +++ b/examples/Async_ConfigPortalParamsOnSwitch/Async_ConfigPortalParamsOnSwitch.ino @@ -32,12 +32,16 @@ #error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting. #endif -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.14.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1014000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 +// To not display stored SSIDs and PWDs on Config Portal, select false. Default is true +// Even the stored Credentials are not display, just leave them all blank to reconnect and reuse the stored Credentials +//#define DISPLAY_STORED_CREDENTIALS_IN_CP false + #include // Now support ArduinoJson 6.0.0+ ( tested with v6.14.1 ) #include // get it from https://arduinojson.org/ or install via Arduino library manager @@ -1059,6 +1063,12 @@ void setup() digitalWrite(LED_BUILTIN, LED_ON); // Turn led on as we are in configuration mode. +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif + //it starts an access point //and goes into a blocking loop awaiting configuration // If Invalid PortalSSID or PortalPassword => use default @@ -1288,6 +1298,12 @@ void loop() ESPAsync_wifiManager.setCORSHeader("Your Access-Control-Allow-Origin"); #endif +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif + // Start an access point and goes into a blocking loop awaiting configuration. // Once the user leaves the portal with the exit button // processing will continue diff --git a/examples/Async_ESP32_FSWebServer/Async_ESP32_FSWebServer.ino b/examples/Async_ESP32_FSWebServer/Async_ESP32_FSWebServer.ino index 3db5b913..05569118 100644 --- a/examples/Async_ESP32_FSWebServer/Async_ESP32_FSWebServer.ino +++ b/examples/Async_ESP32_FSWebServer/Async_ESP32_FSWebServer.ino @@ -34,12 +34,16 @@ #error This code is intended to run only on the ESP32 platform! Please check your Tools->Board setting. #endif -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.14.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1014000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 +// To not display stored SSIDs and PWDs on Config Portal, select false. Default is true +// Even the stored Credentials are not display, just leave them all blank to reconnect and reuse the stored Credentials +//#define DISPLAY_STORED_CREDENTIALS_IN_CP false + #include #include #include @@ -797,6 +801,12 @@ void setup() Serial.print(F(", PWD = ")); Serial.println(password); +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif + // Starts an access point if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password.c_str())) Serial.println(F("Not connected to WiFi but continuing anyway.")); diff --git a/examples/Async_ESP32_FSWebServer_DRD/Async_ESP32_FSWebServer_DRD.ino b/examples/Async_ESP32_FSWebServer_DRD/Async_ESP32_FSWebServer_DRD.ino index 03f76ff2..8853c468 100644 --- a/examples/Async_ESP32_FSWebServer_DRD/Async_ESP32_FSWebServer_DRD.ino +++ b/examples/Async_ESP32_FSWebServer_DRD/Async_ESP32_FSWebServer_DRD.ino @@ -34,12 +34,16 @@ #error This code is intended to run only on the ESP32 platform! Please check your Tools->Board setting. #endif -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.14.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1014000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 +// To not display stored SSIDs and PWDs on Config Portal, select false. Default is true +// Even the stored Credentials are not display, just leave them all blank to reconnect and reuse the stored Credentials +//#define DISPLAY_STORED_CREDENTIALS_IN_CP false + #include #include #include @@ -863,6 +867,12 @@ void setup() Serial.print(F(", PWD = ")); Serial.println(password); +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif + // Starts an access point if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password.c_str())) Serial.println(F("Not connected to WiFi but continuing anyway.")); diff --git a/examples/Async_ESP_FSWebServer/Async_ESP_FSWebServer.ino b/examples/Async_ESP_FSWebServer/Async_ESP_FSWebServer.ino index 51af98d6..f097f978 100644 --- a/examples/Async_ESP_FSWebServer/Async_ESP_FSWebServer.ino +++ b/examples/Async_ESP_FSWebServer/Async_ESP_FSWebServer.ino @@ -34,12 +34,16 @@ #error This code is intended to run on the ESP8266 platform! Please check your Tools->Board setting. #endif -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.12.2" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1012002 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 +// To not display stored SSIDs and PWDs on Config Portal, select false. Default is true +// Even the stored Credentials are not display, just leave them all blank to reconnect and reuse the stored Credentials +//#define DISPLAY_STORED_CREDENTIALS_IN_CP false + #include #include #include @@ -758,6 +762,12 @@ void setup() Serial.print(F(", PWD = ")); Serial.println(password); +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif + // Starts an access point if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password.c_str())) Serial.println(F("Not connected to WiFi but continuing anyway.")); diff --git a/examples/Async_ESP_FSWebServer_DRD/Async_ESP_FSWebServer_DRD.ino b/examples/Async_ESP_FSWebServer_DRD/Async_ESP_FSWebServer_DRD.ino index 2019e43a..87e2cd65 100644 --- a/examples/Async_ESP_FSWebServer_DRD/Async_ESP_FSWebServer_DRD.ino +++ b/examples/Async_ESP_FSWebServer_DRD/Async_ESP_FSWebServer_DRD.ino @@ -34,12 +34,16 @@ #error This code is intended to run on the ESP8266 platform! Please check your Tools->Board setting. #endif -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.12.2" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1012002 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.15.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1015000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 +// To not display stored SSIDs and PWDs on Config Portal, select false. Default is true +// Even the stored Credentials are not display, just leave them all blank to reconnect and reuse the stored Credentials +//#define DISPLAY_STORED_CREDENTIALS_IN_CP false + #include #include #include @@ -810,6 +814,12 @@ void setup() Serial.print(F(", PWD = ")); Serial.println(password); +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // New. Update Credentials, got from loadConfigData(), to display on CP + ESPAsync_wifiManager.setCredentials(WM_config.WiFi_Creds[0].wifi_ssid, WM_config.WiFi_Creds[0].wifi_pw, + WM_config.WiFi_Creds[1].wifi_ssid, WM_config.WiFi_Creds[1].wifi_pw); +#endif + // Starts an access point if (!ESPAsync_wifiManager.startConfigPortal((const char *) ssid.c_str(), password.c_str())) Serial.println(F("Not connected to WiFi but continuing anyway.")); diff --git a/keywords.txt b/keywords.txt index 81392fe9..69f07505 100644 --- a/keywords.txt +++ b/keywords.txt @@ -46,6 +46,7 @@ addParameter KEYWORD2 setBreakAfterConfig KEYWORD2 setCustomHeadElement KEYWORD2 setRemoveDuplicateAPs KEYWORD2 +setCredentials KEYWORD2 getSSID KEYWORD2 getPW KEYWORD2 getSSID1 KEYWORD2 diff --git a/library.json b/library.json index eb965fd5..fbe49d0f 100644 --- a/library.json +++ b/library.json @@ -1,8 +1,8 @@ { "name": "ESPAsync_WiFiManager", - "version": "1.14.1", + "version": "1.15.0", "keywords": "wifi, WiFiManager, esp8266, esp32, esp32-s2, esp32-s3, esp32-c3, AsyncWebServer, Async-WiFiManager, MultiWiFi, Async, Communication, Credentials, Config-Portal, DoubleReset, MultiReset, littlefs, spiffs, dns-server, iot, eeprom", - "description": "ESP32 (including ESP32-S2, ESP32-S3 and ESP32-C3), ESP8266 WiFi Connection Manager using AsyncWebServer, with enhanced GUI and fallback Web ConfigPortal. This Library is used for configuring ESP32 (including ESP32-S2, ESP32-S3 and ESP32-C3), ESP8266 modules WiFi Credentials at runtime. You can also specify static DNS servers, personalized HostName, fixed or random AP channel. Now with MultiWiFi auto(Re)connect, configurable CORS Header and auto-Timezone features. Auto detect ESP32 core and use either built-in LittleFS or external LITTLEFS library. Using AsyncDNSServer instead of DNSServer. Now using correct ESP32 chipIP", + "description": "ESP32 (including ESP32-S2, ESP32-S3 and ESP32-C3), ESP8266 WiFi Connection Manager using AsyncWebServer, with enhanced GUI and fallback Web ConfigPortal. This Library is used for configuring ESP32 (including ESP32-S2, ESP32-S3 and ESP32-C3), ESP8266 modules WiFi Credentials at runtime. You can also specify static DNS servers, personalized HostName, fixed or random AP channel. Now with MultiWiFi auto(Re)connect, configurable CORS Header and auto-Timezone features. Auto detect ESP32 core and use either built-in LittleFS or external LITTLEFS library. Using AsyncDNSServer instead of DNSServer. Now using correct ESP32 chipIP and optionally display Credentials on Config Portal", "authors": { "name": "Khoi Hoang", diff --git a/library.properties b/library.properties index 5f7a7f84..2327aead 100644 --- a/library.properties +++ b/library.properties @@ -1,10 +1,10 @@ name=ESPAsync_WiFiManager -version=1.14.1 +version=1.15.0 author=Khoi Hoang maintainer=Khoi Hoang license=MIT sentence=ESP32 (including ESP32-S2, ESP32-S3 and ESP32-C3), ESP8266 WiFi Connection Manager using AsyncWebServer, with enhanced GUI and fallback Web ConfigPortal. -paragraph=This Library is used for configuring ESP32 (including ESP32-S2, ESP32-S3 and ESP32-C3), ESP8266 modules WiFi Credentials at runtime. You can also specify static DNS servers, personalized HostName, fixed or random AP channel. Now with MultiWiFi auto(Re)connect, configurable CORS Header and auto-Timezone features. Auto detect ESP32 core and use either built-in LittleFS or external LITTLEFS library. Using AsyncDNSServer instead of DNSServer now. Now using correct ESP32 chipIP +paragraph=This Library is used for configuring ESP32 (including ESP32-S2, ESP32-S3 and ESP32-C3), ESP8266 modules WiFi Credentials at runtime. You can also specify static DNS servers, personalized HostName, fixed or random AP channel. Now with MultiWiFi auto(Re)connect, configurable CORS Header and auto-Timezone features. Auto detect ESP32 core and use either built-in LittleFS or external LITTLEFS library. Using AsyncDNSServer instead of DNSServer now. Now using correct ESP32 chipIP and optionally display Credentials on Config Portal category=Communication url=https://github.com/khoih-prog/ESPAsync_WiFiManager architectures=esp8266,esp32 diff --git a/src/ESPAsync_WiFiManager-Impl.h b/src/ESPAsync_WiFiManager-Impl.h index 6cd09e4c..8772619f 100644 --- a/src/ESPAsync_WiFiManager-Impl.h +++ b/src/ESPAsync_WiFiManager-Impl.h @@ -14,7 +14,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/ESPAsync_WiFiManager Licensed under MIT license - Version: 1.14.1 + Version: 1.15.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -29,6 +29,7 @@ 1.13.0 K Hoang 18/08/2022 Using AsynsDNSServer instead of DNSServer 1.14.0 K Hoang 09/09/2022 Fix ESP32 chipID and add ESP_getChipOUI() 1.14.1 K Hoang 15/09/2022 Remove dependency on ESP_AsyncWebServer, ESPAsyncTCP and AsyncTCP in `library.properties` + 1.15.0 K Hoang 07/10/2022 Optional display Credentials (SSIDs, PWDs) in Config Portal *****************************************************************************************************************************/ #pragma once @@ -36,7 +37,7 @@ #ifndef ESPAsync_WiFiManager_Impl_h #define ESPAsync_WiFiManager_Impl_h -///////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////// ESPAsync_WMParameter::ESPAsync_WMParameter(const char *custom) { @@ -172,7 +173,9 @@ ESPAsync_WMParameter** ESPAsync_WiFiManager::getParameters() { return _params; } -///////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////// +////////////////////////////////////////// /** [getParametersCount description] @@ -233,7 +236,6 @@ ESPAsync_WiFiManager::ESPAsync_WiFiManager(AsyncWebServer * webserver, AsyncDNSS #endif //WiFi not yet started here, must call WiFi.mode(WIFI_STA) and modify function WiFiGenericClass::mode(wifi_mode_t m) !!! - WiFi.mode(WIFI_STA); if (iHostname[0] == 0) @@ -401,9 +403,9 @@ void ESPAsync_WiFiManager::setupConfigPortal() LOGWARN1(F("AP PWD ="), _apPassword); } - // KH, To enable dynamic/random channel static int channel; + // Use random channel if _WiFiAPChannel == 0 if (_WiFiAPChannel == 0) channel = (_configPortalStart % MAX_WIFI_CHANNEL) + 1; @@ -422,7 +424,6 @@ void ESPAsync_WiFiManager::setupConfigPortal() // Can't use channel here WiFi.softAP(_apName); } - ////// delay(500); // Without delay I've seen the IP address blank @@ -460,6 +461,8 @@ bool ESPAsync_WiFiManager::autoConnect() return autoConnect(ssid.c_str(), NULL); } +////////////////////////////////////////// + /* This is not very useful as there has been an assumption that device has to be told to connect but Wifi already does it's best to connect in background. Calling this method will block until WiFi connects. Sketch can avoid @@ -467,6 +470,11 @@ bool ESPAsync_WiFiManager::autoConnect() See some discussion at https://github.com/tzapu/WiFiManager/issues/68 */ +// To permit autoConnect() to use STA static IP or DHCP IP. +#ifndef AUTOCONNECT_NO_INVALIDATE + #define AUTOCONNECT_NO_INVALIDATE true +#endif + ////////////////////////////////////////// bool ESPAsync_WiFiManager::autoConnect(char const *apName, char const *apPassword) @@ -502,9 +510,7 @@ bool ESPAsync_WiFiManager::autoConnect(char const *apName, char const *apPasswor return startConfigPortal(apName, apPassword); } - -/////////////////////////////////////////////////////////////////// -// NEW +////////////////////////////////////////// String ESPAsync_WiFiManager::networkListAsString() { @@ -580,7 +586,9 @@ void ESPAsync_WiFiManager::scan() if (wifiSSIDscan) { LOGDEBUG(F("Start scan")); + wifi_ssid_count_t n = WiFi.scanNetworks(false, true); + LOGDEBUG(F("Scan done")); if (n == WIFI_SCAN_FAILED) @@ -915,7 +923,10 @@ bool ESPAsync_WiFiManager::startConfigPortal(char const *apName, char const *apP yield(); #if ( defined(TIME_BETWEEN_CONFIG_PORTAL_LOOP) && (TIME_BETWEEN_CONFIG_PORTAL_LOOP > 0) ) -#warning Using delay in startConfigPortal loop + #if (_ESPASYNC_WIFIMGR_LOGLEVEL_ > 3) + #warning Using delay in startConfigPortal loop + #endif + delay(TIME_BETWEEN_CONFIG_PORTAL_LOOP); #endif } @@ -992,7 +1003,6 @@ void ESPAsync_WiFiManager::setWifiStaticIP() ////////////////////////////////////////// -// New from v1.1.1 int ESPAsync_WiFiManager::reconnectWifi() { int connectResult; @@ -1027,7 +1037,7 @@ int ESPAsync_WiFiManager::connectWifi(const String& ssid, const String& pass) // But update the Static/DHCP options if changed. if ( (ssid != "") || ( (ssid == "") && (WiFi_SSID() != "") ) ) { - //fix for auto connect racing issue. Move up from v1.1.0 to avoid resetSettings() + //fix for auto connect racing issue to avoid resetSettings() if (WiFi.status() == WL_CONNECTED) { LOGWARN(F("Already connected. Bailing out.")); @@ -1105,17 +1115,16 @@ wl_status_t ESPAsync_WiFiManager::waitForConnectResult() LOGWARN1(F("Connected after waiting (s) :"), waited / 1000); LOGWARN1(F("Local ip ="), WiFi.localIP()); - // Fix bug from v1.1.0+, connRes is sometimes not correct. - + // Fix bug, connRes is sometimes not correct. //return connRes; return WiFi.status(); } else { LOGERROR(F("Waiting WiFi connection with time out")); + unsigned long start = millis(); bool keepConnecting = true; - wl_status_t status; while (keepConnecting) @@ -1216,10 +1225,10 @@ void ESPAsync_WiFiManager::resetSettings() // Temporary fix for issue of not clearing WiFi SSID/PW from flash of ESP32 // See https://github.com/khoih-prog/ESPAsync_WiFiManager/issues/25 and https://github.com/espressif/arduino-esp32/issues/400 WiFi.begin("0", "0"); - ////// #endif delay(200); + return; } @@ -1278,7 +1287,6 @@ void ESPAsync_WiFiManager::setAPStaticIPConfig(const IPAddress& ip, const IPAddr ////////////////////////////////////////// -// KH, new using struct void ESPAsync_WiFiManager::setAPStaticIPConfig(const WiFi_AP_IPConfig& WM_AP_IPconfig) { LOGINFO(F("setAPStaticIPConfig")); @@ -1332,6 +1340,7 @@ void ESPAsync_WiFiManager::setSTAStaticIPConfig(const IPAddress& ip, const IPAdd const IPAddress& dns_address_1, const IPAddress& dns_address_2) { LOGINFO(F("setSTAStaticIPConfig for USE_CONFIGURABLE_DNS")); + _WiFi_STA_IPconfig._sta_static_ip = ip; _WiFi_STA_IPconfig._sta_static_gw = gw; _WiFi_STA_IPconfig._sta_static_sn = sn; @@ -1394,9 +1403,6 @@ void ESPAsync_WiFiManager::handleRoot(AsyncWebServerRequest *request) // Disable _configPortalTimeout when someone accessing Portal to give some time to config _configPortalTimeout = 0; - //wifiSSIDscan = true; - //scan(); - if (captivePortal(request)) { // If captive portal redirect instead of displaying the error page. @@ -1451,7 +1457,7 @@ void ESPAsync_WiFiManager::handleRoot(AsyncWebServerRequest *request) response->addHeader(FPSTR(WM_HTTP_CACHE_CONTROL), FPSTR(WM_HTTP_NO_STORE)); #if USING_CORS_FEATURE - // New from v1.1.0, for configure CORS Header, default to WM_HTTP_CORS_ALLOW_ALL = "*" + // For configuring CORS Header, default to WM_HTTP_CORS_ALLOW_ALL = "*" response->addHeader(FPSTR(WM_HTTP_CORS), _CORS_Header); #endif @@ -1463,7 +1469,6 @@ void ESPAsync_WiFiManager::handleRoot(AsyncWebServerRequest *request) #endif // ( USING_ESP32_S2 || USING_ESP32_C3 ) } - ////////////////////////////////////////// // Wifi config page handler @@ -1511,7 +1516,18 @@ void ESPAsync_WiFiManager::handleWifi(AsyncWebServerRequest *request) #endif // ( USING_ESP32_S2 || USING_ESP32_C3 ) + page += "*Hint: To reuse the saved WiFi credentials, leave SSID and PWD fields empty"; + page += FPSTR(WM_HTTP_FORM_START); + +#if DISPLAY_STORED_CREDENTIALS_IN_CP + // Populate SSIDs and PWDs if valid + page.replace("[[ssid]]", _ssid ); + page.replace("[[pwd]]", _pass ); + page.replace("[[ssid1]]", _ssid1 ); + page.replace("[[pwd1]]", _pass1 ); +#endif + char parLength[2]; page += FPSTR(WM_FLDSET_START); @@ -1664,7 +1680,6 @@ void ESPAsync_WiFiManager::handleWifi(AsyncWebServerRequest *request) response->addHeader(FPSTR(WM_HTTP_CACHE_CONTROL), FPSTR(WM_HTTP_NO_STORE)); #if USING_CORS_FEATURE - // New from v1.1.0, for configure CORS Header, default to WM_HTTP_CORS_ALLOW_ALL = "*" response->addHeader(FPSTR(WM_HTTP_CORS), _CORS_Header); #endif @@ -1689,7 +1704,6 @@ void ESPAsync_WiFiManager::handleWifiSave(AsyncWebServerRequest *request) _ssid = request->arg("s").c_str(); _pass = request->arg("p").c_str(); - // New from v1.1.0 _ssid1 = request->arg("s1").c_str(); _pass1 = request->arg("p1").c_str(); @@ -1707,6 +1721,7 @@ void ESPAsync_WiFiManager::handleWifiSave(AsyncWebServerRequest *request) LOGDEBUG(F("No TZ arg")); } #endif + /////////////////////// //parameters @@ -1786,8 +1801,6 @@ void ESPAsync_WiFiManager::handleWifiSave(AsyncWebServerRequest *request) page.replace("{v}", _apName); page.replace("{x}", _ssid); - - // KH, update from v1.1.0 page.replace("{x1}", _ssid1); ////// @@ -1806,7 +1819,6 @@ void ESPAsync_WiFiManager::handleWifiSave(AsyncWebServerRequest *request) response->addHeader(FPSTR(WM_HTTP_CACHE_CONTROL), FPSTR(WM_HTTP_NO_STORE)); #if USING_CORS_FEATURE - // New from v1.1.0, for configure CORS Header, default to WM_HTTP_CORS_ALLOW_ALL = "*" response->addHeader(FPSTR(WM_HTTP_CORS), _CORS_Header); #endif @@ -1863,7 +1875,6 @@ void ESPAsync_WiFiManager::handleServerClose(AsyncWebServerRequest *request) response->addHeader(FPSTR(WM_HTTP_CACHE_CONTROL), FPSTR(WM_HTTP_NO_STORE)); #if USING_CORS_FEATURE - // New from v1.1.0, for configure CORS Header, default to WM_HTTP_CORS_ALLOW_ALL = "*" response->addHeader(FPSTR(WM_HTTP_CORS), _CORS_Header); #endif @@ -1925,15 +1936,15 @@ void ESPAsync_WiFiManager::handleInfo(AsyncWebServerRequest *request) page += F("NameValueChip ID"); #ifdef ESP8266 - page += String(ESP.getChipId(), HEX); //ESP.getChipId(); + page += String(ESP.getChipId(), HEX); #else //ESP32 - page += String(ESP_getChipId(), HEX); //ESP.getChipId(); + page += String(ESP_getChipId(), HEX); page += F(""); page += F("Chip OUI"); page += F("0x"); - page += String(getChipOUI(), HEX); //ESP.getChipId(); + page += String(getChipOUI(), HEX); page += F(""); page += F("Chip Model"); @@ -1947,7 +1958,7 @@ void ESPAsync_WiFiManager::handleInfo(AsyncWebServerRequest *request) page += F("Flash Chip ID"); #ifdef ESP8266 - page += String(ESP.getFlashChipId(), HEX); //ESP.getFlashChipId(); + page += String(ESP.getFlashChipId(), HEX); #else //ESP32 // TODO page += F("TODO"); @@ -2015,7 +2026,6 @@ void ESPAsync_WiFiManager::handleInfo(AsyncWebServerRequest *request) response->addHeader(FPSTR(WM_HTTP_CACHE_CONTROL), FPSTR(WM_HTTP_NO_STORE)); #if USING_CORS_FEATURE - // New from v1.1.0, for configure CORS Header, default to WM_HTTP_CORS_ALLOW_ALL = "*" response->addHeader(FPSTR(WM_HTTP_CORS), _CORS_Header); #endif @@ -2071,7 +2081,6 @@ void ESPAsync_WiFiManager::handleState(AsyncWebServerRequest *request) response->addHeader(FPSTR(WM_HTTP_CACHE_CONTROL), FPSTR(WM_HTTP_NO_STORE)); #if USING_CORS_FEATURE - // New from v1.1.0, for configure CORS Header, default to WM_HTTP_CORS_ALLOW_ALL = "*" response->addHeader(FPSTR(WM_HTTP_CORS), _CORS_Header); #endif diff --git a/src/ESPAsync_WiFiManager.h b/src/ESPAsync_WiFiManager.h index 76e291e5..128f20fd 100644 --- a/src/ESPAsync_WiFiManager.h +++ b/src/ESPAsync_WiFiManager.h @@ -14,7 +14,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/ESPAsync_WiFiManager Licensed under MIT license - Version: 1.14.1 + Version: 1.15.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -29,6 +29,7 @@ 1.13.0 K Hoang 18/08/2022 Using AsynsDNSServer instead of DNSServer 1.14.0 K Hoang 09/09/2022 Fix ESP32 chipID and add ESP_getChipOUI() 1.14.1 K Hoang 15/09/2022 Remove dependency on ESP_AsyncWebServer, ESPAsyncTCP and AsyncTCP in `library.properties` + 1.15.0 K Hoang 07/10/2022 Optional display Credentials (SSIDs, PWDs) in Config Portal *****************************************************************************************************************************/ #pragma once diff --git a/src/ESPAsync_WiFiManager.hpp b/src/ESPAsync_WiFiManager.hpp index 09d0c1ff..d232d10b 100644 --- a/src/ESPAsync_WiFiManager.hpp +++ b/src/ESPAsync_WiFiManager.hpp @@ -14,7 +14,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/ESPAsync_WiFiManager Licensed under MIT license - Version: 1.14.1 + Version: 1.15.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -29,6 +29,7 @@ 1.13.0 K Hoang 18/08/2022 Using AsynsDNSServer instead of DNSServer 1.14.0 K Hoang 09/09/2022 Fix ESP32 chipID and add ESP_getChipOUI() 1.14.1 K Hoang 15/09/2022 Remove dependency on ESP_AsyncWebServer, ESPAsyncTCP and AsyncTCP in `library.properties` + 1.15.0 K Hoang 07/10/2022 Optional display Credentials (SSIDs, PWDs) in Config Portal *****************************************************************************************************************************/ #pragma once @@ -36,12 +37,14 @@ #ifndef ESPAsync_WiFiManager_hpp #define ESPAsync_WiFiManager_hpp +//////////////////////////////////////////////////// + #if !( defined(ESP8266) || defined(ESP32) ) #error This code is intended to run on the ESP8266 or ESP32 platform! Please check your Tools->Board setting. #elif ( ARDUINO_ESP32S2_DEV || ARDUINO_FEATHERS2 || ARDUINO_ESP32S2_THING_PLUS || ARDUINO_MICROS2 || \ ARDUINO_METRO_ESP32S2 || ARDUINO_MAGTAG29_ESP32S2 || ARDUINO_FUNHOUSE_ESP32S2 || \ ARDUINO_ADAFRUIT_FEATHER_ESP32S2_NOPSRAM ) - #if (_ESPASYNC_WIFIMGR_LOGLEVEL_ > 3) + #if (_ESPASYNC_WIFIMGR_LOGLEVEL_ > 3) #warning Using ESP32_S2. To follow library instructions to install esp32-s2 core and WebServer Patch #warning You have to select HUGE APP or 1.9-2.0 MB APP to be able to run Config Portal. Must use PSRAM #endif @@ -49,7 +52,7 @@ #define USING_ESP32_S2 true #elif ( ARDUINO_ESP32C3_DEV ) - #if (_ESPASYNC_WIFIMGR_LOGLEVEL_ > 3) + #if (_ESPASYNC_WIFIMGR_LOGLEVEL_ > 3) #if ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 2) ) #warning Using ESP32_C3 using core v2.0.0+. Either LittleFS, SPIFFS or EEPROM OK #else @@ -72,13 +75,17 @@ #define USING_ESP32_S3 true #endif -#define ESP_ASYNC_WIFIMANAGER_VERSION "ESPAsync_WiFiManager v1.14.1" +//////////////////////////////////////////////////// + +#define ESP_ASYNC_WIFIMANAGER_VERSION "ESPAsync_WiFiManager v1.15.0" #define ESP_ASYNC_WIFIMANAGER_VERSION_MAJOR 1 -#define ESP_ASYNC_WIFIMANAGER_VERSION_MINOR 14 -#define ESP_ASYNC_WIFIMANAGER_VERSION_PATCH 1 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MINOR 15 +#define ESP_ASYNC_WIFIMANAGER_VERSION_PATCH 0 + +#define ESP_ASYNC_WIFIMANAGER_VERSION_INT 1015000 -#define ESP_ASYNC_WIFIMANAGER_VERSION_INT 1014001 +//////////////////////////////////////////////////// #if ESP8266 #if (ARDUINO_ESP8266_GIT_VER == 0xcf6ff4c4) @@ -196,8 +203,12 @@ #endif #endif +//////////////////////////////////////////////////// + #include "ESPAsync_WiFiManager_Debug.h" +//////////////////////////////////////////////////// + //KH, for ESP32 #ifdef ESP8266 #include @@ -215,6 +226,8 @@ #include +//////////////////////////////////////////////////// + // fix crash on ESP32 (see https://github.com/alanswx/ESPAsyncWiFiManager/issues/44) #if defined(ESP8266) typedef int wifi_ssid_count_t; @@ -222,6 +235,8 @@ typedef int16_t wifi_ssid_count_t; #endif +//////////////////////////////////////////////////// + //KH, for ESP32 #ifdef ESP8266 extern "C" @@ -245,6 +260,8 @@ #define ESP_getChipOUI() getChipOUI() #endif +//////////////////////////////////////////////////// + typedef struct { IPAddress _ap_static_ip; @@ -253,6 +270,8 @@ typedef struct } WiFi_AP_IPConfig; +//////////////////////////////////////////////////// + // Thanks to @Amorphous for the feature and code // (https://community.blynk.cc/t/esp-wifimanager-for-esp32-and-esp8266/42257/13) // To enable to configure from sketch @@ -260,6 +279,8 @@ typedef struct #define USE_CONFIGURABLE_DNS false #endif +//////////////////////////////////////////////////// + typedef struct { IPAddress _sta_static_ip; @@ -269,9 +290,13 @@ typedef struct IPAddress _sta_static_dns2; } WiFi_STA_IPConfig; -#define WFM_LABEL_BEFORE 1 -#define WFM_LABEL_AFTER 2 -#define WFM_NO_LABEL 0 +//////////////////////////////////////////////////// + +#define WFM_LABEL_BEFORE 1 +#define WFM_LABEL_AFTER 2 +#define WFM_NO_LABEL 0 + +//////////////////////////////////////////////////// /** Handle CORS in pages */ // Default false for using only whenever necessary to avoid security issue when using CORS (Cross-Origin Resource Sharing) @@ -281,6 +306,8 @@ typedef struct #define USING_CORS_FEATURE false #endif +//////////////////////////////////////////////////// + #ifndef TIME_BETWEEN_MODAL_SCANS // Default to 30s #define TIME_BETWEEN_MODAL_SCANS 120000UL @@ -291,17 +318,23 @@ typedef struct #define TIME_BETWEEN_MODELESS_SCANS 120000UL #endif +//////////////////////////////////////////////////// + //KH // Mofidy HTTP_HEAD to WM_HTTP_HEAD_START to avoid conflict in Arduino esp8266 core 2.6.0+ const char WM_HTTP_200[] PROGMEM = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"; const char WM_HTTP_HEAD_START[] PROGMEM = "{v}"; +//////////////////////////////////////////////////// + const char WM_HTTP_STYLE[] PROGMEM = ""; -// KH, update from v1.1.0 +//////////////////////////////////////////////////// + const char WM_HTTP_SCRIPT[] PROGMEM = ""; -////// +//////////////////////////////////////////////////// +//////////////////////////////////////////////////// // To permit disable or configure NTP from sketch #ifndef USE_ESP_WIFIMANAGER_NTP @@ -309,6 +342,8 @@ const char WM_HTTP_SCRIPT[] PROGMEM = "

"; const char WM_HTTP_SCRIPT_NTP_HIDDEN[] PROGMEM = "

"; +//////////////////////////////////////////////////// + #if ESP8266 #if !(USE_CLOUDFLARE_NTP) #undef USE_CLOUDFLARE_NTP @@ -333,6 +370,8 @@ const char WM_HTTP_SCRIPT_NTP_HIDDEN[] PROGMEM = "

"; #else @@ -345,34 +384,60 @@ const char WM_HTTP_SCRIPT_NTP[] PROGMEM = "