diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2f97567f..e8d31faa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,7 +29,7 @@ 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.4.0-91-generic #102-Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux +Linux xy-Inspiron-3593 5.4.0-94-generic #106-Ubuntu SMP Thu Jan 6 23:58:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux Context: I encountered an endless loop while trying to connect to Local WiFi. diff --git a/README.md b/README.md index b64bb644..51bb7a3a 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ ## Table of Contents * [Important Breaking Change from v1.10.0](#Important-Breaking-Change-from-v1100) + * [For v1.11.0 and up](#For-v1110-and-up) + * [For v1.10.0 only](#For-v1100-only) * [Why do we need this ESPAsync_WiFiManager library](#why-do-we-need-this-async-espasync_wifimanager-library) * [Features](#features) * [Why Async is better](#why-async-is-better) @@ -148,6 +150,46 @@ ### Important Breaking Change from v1.10.0 +#### For v1.11.0 and up + +Please have a look at [HOWTO Fix `Multiple Definitions` Linker Error](#howto-fix-multiple-definitions-linker-error) + +From v1.11.0, you just use + +``` +#include //https://github.com/khoih-prog/ESPAsync_WiFiManager +``` + +instead of both + +``` +#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error +#include //https://github.com/khoih-prog/ESPAsync_WiFiManager +``` + + +For complex project having `Multiple Definitions Linker Error` issue, you can use in many files (**Be careful**: `.hpp`, not `.h`) + +``` +#include //https://github.com/khoih-prog/ESPAsync_WiFiManager +``` + +but only in main(), .ino with setup() to avoid `Multiple Definitions Linker Error` + + +``` +#include //https://github.com/khoih-prog/ESPAsync_WiFiManager +``` + +--- + + +#### For v1.10.0 only + +It's advisable to use v1.11.0+ + Please have a look at [HOWTO Fix `Multiple Definitions` Linker Error](#howto-fix-multiple-definitions-linker-error) From v1.10.0, you must use @@ -218,7 +260,7 @@ This [**ESPAsync_WiFiManager** library](https://github.com/khoih-prog/ESPAsync_W ## Prerequisites - 1. [`Arduino IDE 1.8.19+` for Arduino](https://www.arduino.cc/en/Main/Software) + 1. [`Arduino IDE 1.8.19+` for Arduino](https://github.com/arduino/Arduino). [![GitHub release](https://img.shields.io/github/release/arduino/Arduino.svg)](https://github.com/arduino/Arduino/releases/latest) 2. [`ESP8266 Core 3.0.2+`](https://github.com/esp8266/Arduino) for ESP8266-based boards. [![Latest release](https://img.shields.io/github/release/esp8266/Arduino.svg)](https://github.com/esp8266/Arduino/releases/latest/) 3. [`ESP32 Core 2.0.2+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards. [![Latest release](https://img.shields.io/github/release/espressif/arduino-esp32.svg)](https://github.com/espressif/arduino-esp32/releases/latest/) 4. [`ESPAsyncWebServer v1.2.3+`](https://github.com/me-no-dev/ESPAsyncWebServer) for all ESP32/ESP8266-based boards. You have to use the latest [forked ESPAsyncWebServer](https://github.com/khoih-prog/ESPAsyncWebServer) if the PR [Fix compiler error for ESP32-C3 and mbed TLS v2.7.0+ #970](https://github.com/me-no-dev/ESPAsyncWebServer/pull/970) hasn't been merged. @@ -303,14 +345,14 @@ The current library implementation, using `xyz-Impl.h` instead of standard `xyz. You can use ``` -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager +#include //https://github.com/khoih-prog/ESPAsync_WiFiManager ``` -in many files. But be sure to use the following `#include ` **in just 1 `.h`, `.cpp` or `.ino` file**, which must **not be included in any other file**, to avoid `Multiple Definitions` Linker Error +in many files. But be sure to use the following `#include ` **in just 1 `.h`, `.cpp` or `.ino` file**, which must **not be included in any other file**, to avoid `Multiple Definitions` Linker Error ``` // To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager +#include //https://github.com/khoih-prog/ESPAsync_WiFiManager ``` Check [Async_ConfigOnDoubleReset_Multi](examples/Async_ConfigOnDoubleReset_Multi) for an example how and where to do so. @@ -2137,8 +2179,8 @@ ESPAsync_wifiManager.setRemoveDuplicateAPs(false); #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.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 @@ -2471,7 +2513,9 @@ IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager #define HTTP_PORT 80 @@ -3507,7 +3551,7 @@ This is terminal debug output when running [Async_ConfigOnDRD_FS_MQTT_Ptr_Medium ``` Starting Async_ConfigOnDRD_FS_MQTT_Ptr_Medium using LittleFS on ESP32_DEV -ESPAsync_WiFiManager v1.10.0 +ESPAsync_WiFiManager v1.11.0 ESP_DoubleResetDetector v1.2.1 Config File not found Can't read Config File, using default values @@ -3526,7 +3570,7 @@ Opening Configuration Portal. No timeout : DRD or No stored Credentials.. ``` Starting Async_ConfigOnDRD_FS_MQTT_Ptr_Medium using LittleFS on ESP32_DEV -ESPAsync_WiFiManager v1.10.0 +ESPAsync_WiFiManager v1.11.0 ESP_DoubleResetDetector v1.2.1 Config File not found Can't read Config File, using default values @@ -3614,7 +3658,7 @@ This is terminal debug output when running [Async_ConfigOnDRD_FS_MQTT_Ptr_Comple ``` Starting Async_ConfigOnDRD_FS_MQTT_Ptr_Complex using LittleFS on ESP8266_NODEMCU_ESP12E -ESPAsync_WiFiManager v1.10.0 +ESPAsync_WiFiManager v1.11.0 ESP_DoubleResetDetector v1.2.1 {"AIO_SERVER_Label":"io.adafruit.com","AIO_SERVERPORT_Label":"1883","AIO_USERNAME_Label":"user_name","AIO_KEY_Label":"aio_key"} Config File successfully parsed @@ -3654,7 +3698,7 @@ TWWWW WTWWW ``` Starting Async_ConfigOnDRD_FS_MQTT_Ptr_Complex using LittleFS on ESP8266_NODEMCU_ESP12E -ESPAsync_WiFiManager v1.10.0 +ESPAsync_WiFiManager v1.11.0 ESP_DoubleResetDetector v1.2.1 {"AIO_SERVER_Label":"io.adafruit.com","AIO_SERVERPORT_Label":"1883","AIO_USERNAME_Label":"user_name","AIO_KEY_Label":"aio_key"} Config File successfully parsed @@ -3744,7 +3788,7 @@ This is terminal debug output when running [Async_ConfigOnDoubleReset](examples/ ```cpp Starting Async_ConfigOnDoubleReset with DoubleResetDetect using SPIFFS on ESP32_DEV -ESPAsync_WiFiManager v1.10.0 +ESPAsync_WiFiManager v1.11.0 ESP_DoubleResetDetector v1.2.1 [WM] RFC925 Hostname = ConfigOnDoubleReset [WM] setSTAStaticIPConfig for USE_CONFIGURABLE_DNS @@ -3803,7 +3847,7 @@ This is terminal debug output when running [Async_ConfigOnDoubleReset](examples/ ```cpp Starting Async_ConfigOnDoubleReset with DoubleResetDetect using LittleFS on ESP8266_NODEMCU_ESP12E -ESPAsync_WiFiManager v1.10.0 +ESPAsync_WiFiManager v1.11.0 ESP_DoubleResetDetector v1.2.1 [WM] RFC925 Hostname = ConfigOnDoubleReset [WM] setSTAStaticIPConfig for USE_CONFIGURABLE_DNS @@ -3863,7 +3907,7 @@ This is terminal debug output when running [Async_ESP_FSWebServer_DRD](examples/ ```cpp Starting Async_ESP_FSWebServer_DRD using LittleFS on ESP8266_NODEMCU_ESP12E -ESPAsync_WiFiManager v1.10.0 +ESPAsync_WiFiManager v1.11.0 ESP_DoubleResetDetector v1.2.1 Opening / directory FS File: CanadaFlag_1.png, size: 40.25KB @@ -3941,7 +3985,7 @@ This is terminal debug output when running [Async_ESP32_FSWebServer_DRD](example ``` Starting Async_ESP32_FSWebServer_DRD using LittleFS on ESP32_DEV -ESPAsync_WiFiManager v1.10.0 +ESPAsync_WiFiManager v1.11.0 ESP_DoubleResetDetector v1.2.1 FS File: /CanadaFlag_1.png, size: 40.25KB FS File: /CanadaFlag_2.png, size: 8.12KB @@ -4052,7 +4096,7 @@ This is terminal debug output when running [Async_ConfigOnDoubleReset](examples/ ``` Starting Async_ConfigOnDoubleReset using LittleFS on ESP32S2_DEV -ESPAsync_WiFiManager v1.10.0 +ESPAsync_WiFiManager v1.11.0 ESP_DoubleResetDetector v1.2.1 ESP Self-Stored: SSID = HueNet1, Pass = 12345678 [WM] * Add SSID = HueNet1 , PW = 12345678 @@ -4089,7 +4133,7 @@ This is terminal debug output when running [Async_ConfigOnDoubleReset_TZ](exampl ``` Starting Async_ConfigOnDoubleReset_TZ using LittleFS on ESP32_DEV -ESPAsync_WiFiManager v1.10.0 +ESPAsync_WiFiManager v1.11.0 ESP_DoubleResetDetector v1.2.1 ESP Self-Stored: SSID = HueNet1, Pass = password [WM] * Add SSID = HueNet1 , PW = password @@ -4133,7 +4177,7 @@ Local Date/Time: Sat May 1 00:17:30 2021 ``` Starting Async_ConfigOnDoubleReset_TZ using LittleFS on ESP32_DEV -ESPAsync_WiFiManager v1.10.0 +ESPAsync_WiFiManager v1.11.0 ESP_DoubleResetDetector v1.2.1 ESP Self-Stored: SSID = HueNet1, Pass = password [WM] * Add SSID = HueNet1 , PW = password @@ -4180,7 +4224,7 @@ This is terminal debug output when running [Async_ESP_FSWebServer_DRD](examples/ ``` Starting Async_ESP_FSWebServer_DRD using LittleFS on ESP8266_NODEMCU_ESP12E -ESPAsync_WiFiManager v1.10.0 +ESPAsync_WiFiManager v1.11.0 ESP_DoubleResetDetector v1.2.1 Opening / directory FS File: drd.dat, size: 4B @@ -4253,7 +4297,7 @@ Local Date/Time: Sat May 1 03:12:54 2021 ``` Starting Async_ESP_FSWebServer_DRD using LittleFS on ESP8266_NODEMCU_ESP12E -ESPAsync_WiFiManager v1.10.0 +ESPAsync_WiFiManager v1.11.0 ESP_DoubleResetDetector v1.2.1 Opening / directory FS File: drd.dat, size: 4B @@ -4312,7 +4356,7 @@ This is terminal debug output when running [Async_ConfigOnDoubleReset_TZ](exampl ``` Starting Async_ConfigOnDoubleReset_TZ using SPIFFS on ESP32C3_DEV -ESPAsync_WiFiManager v1.10.0 +ESPAsync_WiFiManager v1.11.0 ESP_DoubleResetDetector v1.2.1 ESP Self-Stored: SSID = HueNet1, Pass = 12345678 [WM] * Add SSID = HueNet1 , PW = 12345678 diff --git a/changelog.md b/changelog.md index 5851c071..83889336 100644 --- a/changelog.md +++ b/changelog.md @@ -12,6 +12,7 @@ ## Table of Contents * [Changelog](#changelog) + * [Releases v1.11.0](#releases-v1110) * [Releases v1.10.0](#releases-v1100) * [Releases v1.9.8](#releases-v198) * [Releases v1.9.7](#releases-v197) @@ -46,6 +47,10 @@ ## Changelog +### Releases v1.11.0 + +1. Reduce the breaking effect of v1.10.0 by enabling compatibility with old code to include only `ESPAsync_WiFiManager.h`. Check [Important Breaking Change from v1.10.0](https://github.com/khoih-prog/ESPAsync_WiFiManager#Important-Breaking-Change-from-v1100) + ### Releases v1.10.0 1. Fix `multiple-definitions` linker error and weird bug related to `src_cpp`. Check [Different behaviour using the src_cpp or src_h lib #80](https://github.com/khoih-prog/ESPAsync_WiFiManager/discussions/80) diff --git a/examples/Async_AutoConnect/Async_AutoConnect.ino b/examples/Async_AutoConnect/Async_AutoConnect.ino index 52aa2a93..10fdb302 100644 --- a/examples/Async_AutoConnect/Async_AutoConnect.ino +++ b/examples/Async_AutoConnect/Async_AutoConnect.ino @@ -18,8 +18,8 @@ #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.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 @@ -247,7 +247,9 @@ IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager #define HTTP_PORT 80 diff --git a/examples/Async_AutoConnectWithFSParameters/Async_AutoConnectWithFSParameters.ino b/examples/Async_AutoConnectWithFSParameters/Async_AutoConnectWithFSParameters.ino index 044bec27..198e44a1 100644 --- a/examples/Async_AutoConnectWithFSParameters/Async_AutoConnectWithFSParameters.ino +++ b/examples/Async_AutoConnectWithFSParameters/Async_AutoConnectWithFSParameters.ino @@ -19,8 +19,8 @@ #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.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 @@ -262,7 +262,9 @@ IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager #define HTTP_PORT 80 diff --git a/examples/Async_AutoConnectWithFSParametersAndCustomIP/Async_AutoConnectWithFSParametersAndCustomIP.ino b/examples/Async_AutoConnectWithFSParametersAndCustomIP/Async_AutoConnectWithFSParametersAndCustomIP.ino index a8a29e25..2b9ad3e2 100644 --- a/examples/Async_AutoConnectWithFSParametersAndCustomIP/Async_AutoConnectWithFSParametersAndCustomIP.ino +++ b/examples/Async_AutoConnectWithFSParametersAndCustomIP/Async_AutoConnectWithFSParametersAndCustomIP.ino @@ -19,8 +19,8 @@ #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.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 @@ -259,7 +259,9 @@ IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager #define HTTP_PORT 80 diff --git a/examples/Async_AutoConnectWithFeedback/Async_AutoConnectWithFeedback.ino b/examples/Async_AutoConnectWithFeedback/Async_AutoConnectWithFeedback.ino index 718fc88f..7a3408a0 100644 --- a/examples/Async_AutoConnectWithFeedback/Async_AutoConnectWithFeedback.ino +++ b/examples/Async_AutoConnectWithFeedback/Async_AutoConnectWithFeedback.ino @@ -18,8 +18,8 @@ #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.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 @@ -251,7 +251,9 @@ IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager #define HTTP_PORT 80 diff --git a/examples/Async_AutoConnectWithFeedbackLED/Async_AutoConnectWithFeedbackLED.ino b/examples/Async_AutoConnectWithFeedbackLED/Async_AutoConnectWithFeedbackLED.ino index 642ca05d..5509dca1 100644 --- a/examples/Async_AutoConnectWithFeedbackLED/Async_AutoConnectWithFeedbackLED.ino +++ b/examples/Async_AutoConnectWithFeedbackLED/Async_AutoConnectWithFeedbackLED.ino @@ -19,8 +19,8 @@ #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.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 @@ -255,7 +255,9 @@ IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager #define HTTP_PORT 80 diff --git a/examples/Async_AutoConnect_ESP32_minimal/Async_AutoConnect_ESP32_minimal.ino b/examples/Async_AutoConnect_ESP32_minimal/Async_AutoConnect_ESP32_minimal.ino index fd799b8b..3701f49c 100644 --- a/examples/Async_AutoConnect_ESP32_minimal/Async_AutoConnect_ESP32_minimal.ino +++ b/examples/Async_AutoConnect_ESP32_minimal/Async_AutoConnect_ESP32_minimal.ino @@ -8,7 +8,8 @@ #error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting. #endif #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager AsyncWebServer webServer(80); #if !( USING_ESP32_S2 || USING_ESP32_C3 ) DNSServer dnsServer; diff --git a/examples/Async_AutoConnect_ESP8266_minimal/Async_AutoConnect_ESP8266_minimal.ino b/examples/Async_AutoConnect_ESP8266_minimal/Async_AutoConnect_ESP8266_minimal.ino index 98d80900..83314a68 100644 --- a/examples/Async_AutoConnect_ESP8266_minimal/Async_AutoConnect_ESP8266_minimal.ino +++ b/examples/Async_AutoConnect_ESP8266_minimal/Async_AutoConnect_ESP8266_minimal.ino @@ -8,7 +8,8 @@ #error This code is intended to run on ESP8266 platform! Please check your Tools->Board setting. #endif #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager AsyncWebServer webServer(80); DNSServer dnsServer; diff --git a/examples/Async_ConfigOnDRD_ESP32_minimal/Async_ConfigOnDRD_ESP32_minimal.ino b/examples/Async_ConfigOnDRD_ESP32_minimal/Async_ConfigOnDRD_ESP32_minimal.ino index 5aedc9ac..695918a4 100644 --- a/examples/Async_ConfigOnDRD_ESP32_minimal/Async_ConfigOnDRD_ESP32_minimal.ino +++ b/examples/Async_ConfigOnDRD_ESP32_minimal/Async_ConfigOnDRD_ESP32_minimal.ino @@ -15,7 +15,8 @@ #error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting. #endif #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager #define DRD_TIMEOUT 10 #define DRD_ADDRESS 0 #include //https://github.com/khoih-prog/ESP_DoubleResetDetector diff --git a/examples/Async_ConfigOnDRD_ESP8266_minimal/Async_ConfigOnDRD_ESP8266_minimal.ino b/examples/Async_ConfigOnDRD_ESP8266_minimal/Async_ConfigOnDRD_ESP8266_minimal.ino index 0136c080..5686b693 100644 --- a/examples/Async_ConfigOnDRD_ESP8266_minimal/Async_ConfigOnDRD_ESP8266_minimal.ino +++ b/examples/Async_ConfigOnDRD_ESP8266_minimal/Async_ConfigOnDRD_ESP8266_minimal.ino @@ -11,7 +11,8 @@ #error This code is intended to run on the ESP8266 platform! Please check your Tools->Board setting. #endif #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager #define DRD_TIMEOUT 10 #define DRD_ADDRESS 0 #include //https://github.com/khoih-prog/ESP_DoubleResetDetector 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 3e305fb8..3c0dbdd9 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,8 +31,8 @@ #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.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 @@ -365,8 +365,9 @@ IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager #define HTTP_PORT 80 // Create an ESP32 WiFiClient class to connect to the MQTT server 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 4ed3e588..e9e69e3b 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,8 +31,8 @@ #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.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 2 @@ -355,7 +355,9 @@ IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager //////////////// // Create WMParam_Data 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 fa1586a2..d6aa9476 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,8 +31,8 @@ #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.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 @@ -352,7 +352,9 @@ IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager //////////////// diff --git a/examples/Async_ConfigOnDoubleReset/Async_ConfigOnDoubleReset.ino b/examples/Async_ConfigOnDoubleReset/Async_ConfigOnDoubleReset.ino index f38ccddb..7bb7b0e6 100644 --- a/examples/Async_ConfigOnDoubleReset/Async_ConfigOnDoubleReset.ino +++ b/examples/Async_ConfigOnDoubleReset/Async_ConfigOnDoubleReset.ino @@ -42,8 +42,8 @@ #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.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 1 @@ -339,7 +339,9 @@ IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager #define HTTP_PORT 80 diff --git a/examples/Async_ConfigOnDoubleReset_Multi/Async_ConfigOnDoubleReset_Multi.h b/examples/Async_ConfigOnDoubleReset_Multi/Async_ConfigOnDoubleReset_Multi.h index a7f7c668..44fba77a 100644 --- a/examples/Async_ConfigOnDoubleReset_Multi/Async_ConfigOnDoubleReset_Multi.h +++ b/examples/Async_ConfigOnDoubleReset_Multi/Async_ConfigOnDoubleReset_Multi.h @@ -42,8 +42,8 @@ #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.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 1 @@ -339,8 +339,7 @@ extern IPAddress APStaticIP; // = IPAddress(192, 168, 100, 1); extern IPAddress APStaticGW; // = IPAddress(192, 168, 100, 1); extern IPAddress APStaticSN; // = IPAddress(255, 255, 255, 0); -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager -//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager +#include //https://github.com/khoih-prog/ESPAsync_WiFiManager #define HTTP_PORT 80 diff --git a/examples/Async_ConfigOnDoubleReset_Multi/Async_ConfigOnDoubleReset_Multi.ino b/examples/Async_ConfigOnDoubleReset_Multi/Async_ConfigOnDoubleReset_Multi.ino index c117b92f..31f40ec4 100644 --- a/examples/Async_ConfigOnDoubleReset_Multi/Async_ConfigOnDoubleReset_Multi.ino +++ b/examples/Async_ConfigOnDoubleReset_Multi/Async_ConfigOnDoubleReset_Multi.ino @@ -46,7 +46,9 @@ #include "Async_ConfigOnDoubleReset_Multi.h" #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager void setup() { diff --git a/examples/Async_ConfigOnDoubleReset_TZ/Async_ConfigOnDoubleReset_TZ.ino b/examples/Async_ConfigOnDoubleReset_TZ/Async_ConfigOnDoubleReset_TZ.ino index 6c6cc54a..adb2293c 100644 --- a/examples/Async_ConfigOnDoubleReset_TZ/Async_ConfigOnDoubleReset_TZ.ino +++ b/examples/Async_ConfigOnDoubleReset_TZ/Async_ConfigOnDoubleReset_TZ.ino @@ -42,8 +42,8 @@ #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.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 1 @@ -339,7 +339,9 @@ IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager #define HTTP_PORT 80 diff --git a/examples/Async_ConfigOnStartup/Async_ConfigOnStartup.ino b/examples/Async_ConfigOnStartup/Async_ConfigOnStartup.ino index 83277632..1a30cd3a 100644 --- a/examples/Async_ConfigOnStartup/Async_ConfigOnStartup.ino +++ b/examples/Async_ConfigOnStartup/Async_ConfigOnStartup.ino @@ -33,8 +33,8 @@ #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.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 @@ -267,7 +267,9 @@ IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager #define HTTP_PORT 80 diff --git a/examples/Async_ConfigOnSwitch/Async_ConfigOnSwitch.ino b/examples/Async_ConfigOnSwitch/Async_ConfigOnSwitch.ino index e0fcf849..40cb81fa 100644 --- a/examples/Async_ConfigOnSwitch/Async_ConfigOnSwitch.ino +++ b/examples/Async_ConfigOnSwitch/Async_ConfigOnSwitch.ino @@ -30,8 +30,8 @@ #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.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 @@ -388,7 +388,9 @@ IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager #define HTTP_PORT 80 diff --git a/examples/Async_ConfigOnSwitchFS/Async_ConfigOnSwitchFS.ino b/examples/Async_ConfigOnSwitchFS/Async_ConfigOnSwitchFS.ino index a52c4562..c10dee43 100644 --- a/examples/Async_ConfigOnSwitchFS/Async_ConfigOnSwitchFS.ino +++ b/examples/Async_ConfigOnSwitchFS/Async_ConfigOnSwitchFS.ino @@ -53,8 +53,8 @@ #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.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 @@ -431,7 +431,9 @@ IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager #define HTTP_PORT 80 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 9e1dc8a6..278c2542 100644 --- a/examples/Async_ConfigOnSwitchFS_MQTT_Ptr/Async_ConfigOnSwitchFS_MQTT_Ptr.ino +++ b/examples/Async_ConfigOnSwitchFS_MQTT_Ptr/Async_ConfigOnSwitchFS_MQTT_Ptr.ino @@ -35,8 +35,8 @@ #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.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 @@ -421,7 +421,9 @@ IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager #define HTTP_PORT 80 diff --git a/examples/Async_ConfigPortalParamsOnSwitch/Async_ConfigPortalParamsOnSwitch.ino b/examples/Async_ConfigPortalParamsOnSwitch/Async_ConfigPortalParamsOnSwitch.ino index 2db872a3..037de536 100644 --- a/examples/Async_ConfigPortalParamsOnSwitch/Async_ConfigPortalParamsOnSwitch.ino +++ b/examples/Async_ConfigPortalParamsOnSwitch/Async_ConfigPortalParamsOnSwitch.ino @@ -32,8 +32,8 @@ #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.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 @@ -401,7 +401,9 @@ IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager #define HTTP_PORT 80 diff --git a/examples/Async_ESP32_FSWebServer/Async_ESP32_FSWebServer.ino b/examples/Async_ESP32_FSWebServer/Async_ESP32_FSWebServer.ino index 9c296a3f..7c1e49f8 100644 --- a/examples/Async_ESP32_FSWebServer/Async_ESP32_FSWebServer.ino +++ b/examples/Async_ESP32_FSWebServer/Async_ESP32_FSWebServer.ino @@ -34,8 +34,8 @@ #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.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 @@ -234,7 +234,9 @@ IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager String host = "async-esp32fs"; 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 b401ea4c..1e97fb28 100644 --- a/examples/Async_ESP32_FSWebServer_DRD/Async_ESP32_FSWebServer_DRD.ino +++ b/examples/Async_ESP32_FSWebServer_DRD/Async_ESP32_FSWebServer_DRD.ino @@ -34,8 +34,8 @@ #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.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 @@ -267,7 +267,9 @@ IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager String host = "async-esp32fs"; diff --git a/examples/Async_ESP_FSWebServer/Async_ESP_FSWebServer.ino b/examples/Async_ESP_FSWebServer/Async_ESP_FSWebServer.ino index 25699ad0..dd2136f6 100644 --- a/examples/Async_ESP_FSWebServer/Async_ESP_FSWebServer.ino +++ b/examples/Async_ESP_FSWebServer/Async_ESP_FSWebServer.ino @@ -34,8 +34,8 @@ #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.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 @@ -216,7 +216,9 @@ IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager String host = "async-esp8266fs"; 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 40a682c7..43454839 100644 --- a/examples/Async_ESP_FSWebServer_DRD/Async_ESP_FSWebServer_DRD.ino +++ b/examples/Async_ESP_FSWebServer_DRD/Async_ESP_FSWebServer_DRD.ino @@ -34,8 +34,8 @@ #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.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 @@ -232,7 +232,9 @@ IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager String host = "async-esp8266fs"; diff --git a/examples/ModelessConnect/ModelessConnect.ino b/examples/ModelessConnect/ModelessConnect.ino index 8bed8515..ee2e3865 100644 --- a/examples/ModelessConnect/ModelessConnect.ino +++ b/examples/ModelessConnect/ModelessConnect.ino @@ -19,8 +19,8 @@ #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.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 @@ -110,7 +110,9 @@ IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager #define HTTP_PORT 80 diff --git a/examples/ModelessWithInterrupts/ModelessWithInterrupts.ino b/examples/ModelessWithInterrupts/ModelessWithInterrupts.ino index b084e137..524e39de 100644 --- a/examples/ModelessWithInterrupts/ModelessWithInterrupts.ino +++ b/examples/ModelessWithInterrupts/ModelessWithInterrupts.ino @@ -19,8 +19,8 @@ #error This code is intended to run on the ESP8266! Please check your Tools->Board setting. #endif -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.10.0" -#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1010000 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN_TARGET "ESPAsync_WiFiManager v1.11.0" +#define ESP_ASYNC_WIFIMANAGER_VERSION_MIN 1011000 // Use from 0 to 4. Higher number, more debugging messages and memory usage. #define _ESPASYNC_WIFIMGR_LOGLEVEL_ 3 @@ -97,7 +97,9 @@ IPAddress APStaticGW = IPAddress(192, 168, 100, 1); IPAddress APStaticSN = IPAddress(255, 255, 255, 0); #include //https://github.com/khoih-prog/ESPAsync_WiFiManager -#include //https://github.com/khoih-prog/ESPAsync_WiFiManager + +// Redundant, for v1.10.0 only +//#include //https://github.com/khoih-prog/ESPAsync_WiFiManager #define HTTP_PORT 80 diff --git a/library.json b/library.json index c24d372e..4c542c8d 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ESPAsync_WiFiManager", - "version": "1.10.0", + "version": "1.11.0", "keywords": "wifi, wi-fi, WiFiManager, esp8266, esp32, esp32-s2, esp32-c3, AsyncWebServer, Async-WebServer, Async-WiFiManager, MultiWiFi, Async, Communication, Credentials, Config-Portal, DoubleReset, MultiReset, littlefs, spiffs, eeprom, dns-server, iot", "description": "ESP32 (including ESP32-S2 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 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", "authors": @@ -57,5 +57,5 @@ "frameworks": "*", "platforms": ["espressif8266", "espressif32"], "examples": "examples/*/*/*.ino", - "headers": ["ESPAsync_WiFiManager.h", "ESPAsync_WiFiManager-Impl.h"] + "headers": ["ESPAsync_WiFiManager.h", "ESPAsync_WiFiManager.hpp", "ESPAsync_WiFiManager-Impl.h"] } diff --git a/library.properties b/library.properties index f550e744..d9de34f0 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=ESPAsync_WiFiManager -version=1.10.0 +version=1.11.0 author=Khoi Hoang maintainer=Khoi Hoang license=MIT @@ -9,4 +9,4 @@ category=Communication url=https://github.com/khoih-prog/ESPAsync_WiFiManager architectures=esp8266,esp32 depends=ESP Async WebServer,ESP AsyncTCP,AsyncTCP,ESP_DoubleResetDetector -includes=ESPAsync_WiFiManager.h,ESPAsync_WiFiManager-Impl.h +includes=ESPAsync_WiFiManager.h,ESPAsync_WiFiManager.hpp,ESPAsync_WiFiManager-Impl.h diff --git a/src/ESPAsync_WiFiManager-Impl.h b/src/ESPAsync_WiFiManager-Impl.h index 88f1305c..d8a5728d 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.10.0 + Version: 1.11.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -48,6 +48,7 @@ 1.9.7 K Hoang 30/11/2021 Fix bug to permit using HTTP port different from 80 1.9.8 K Hoang 01/12/2021 Fix bug returning IP `255.255.255.255` in core v2.0.0+ when using `hostname` 1.10.0 K Hoang 29/12/2021 Fix `multiple-definitions` linker error and weird bug related to src_cpp + 1.11.0 K Hoang 17/01/2022 Enable compatibility with old code to include only ESP_WiFiManager.h *****************************************************************************************************************************/ #pragma once diff --git a/src/ESPAsync_WiFiManager.h b/src/ESPAsync_WiFiManager.h index e8f1a6c6..66dd56c1 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.10.0 + Version: 1.11.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -48,6 +48,7 @@ 1.9.7 K Hoang 30/11/2021 Fix bug to permit using HTTP port different from 80 1.9.8 K Hoang 01/12/2021 Fix bug returning IP `255.255.255.255` in core v2.0.0+ when using `hostname` 1.10.0 K Hoang 29/12/2021 Fix `multiple-definitions` linker error and weird bug related to src_cpp + 1.11.0 K Hoang 17/01/2022 Enable compatibility with old code to include only ESP_WiFiManager.h *****************************************************************************************************************************/ #pragma once @@ -55,770 +56,8 @@ #ifndef ESPAsync_WiFiManager_h #define ESPAsync_WiFiManager_h -#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 ) - #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 - #define USING_ESP32_S2 true -#elif defined( ARDUINO_ESP32C3_DEV ) - #warning Using ESP32_C3. To follow library instructions to install esp32-c3 core. Only SPIFFS and EEPROM OK. - #warning You have to select Flash size 2MB and Minimal APP (1.3MB + 700KB) for some boards - #define USING_ESP32_C3 true -#endif - -#define ESP_ASYNC_WIFIMANAGER_VERSION "ESPAsync_WiFiManager v1.10.0" - -#define ESP_ASYNC_WIFIMANAGER_VERSION_MAJOR 1 -#define ESP_ASYNC_WIFIMANAGER_VERSION_MINOR 10 -#define ESP_ASYNC_WIFIMANAGER_VERSION_PATCH 0 - -#define ESP_ASYNC_WIFIMANAGER_VERSION_INT 1010000 - -#if ESP8266 - #if (ARDUINO_ESP8266_GIT_VER == 0xcf6ff4c4) - #define USING_ESP8266_CORE_VERSION 30002 - #define ESP8266_CORE_VERSION "ESP8266 core v3.0.2" - #warning USING_ESP8266_CORE_VERSION "3.0.2" - #elif (ARDUINO_ESP8266_GIT_VER == 0xcbf44fb3) - #define USING_ESP8266_CORE_VERSION 30001 - #define ESP8266_CORE_VERSION "ESP8266 core v3.0.1" - #warning USING_ESP8266_CORE_VERSION "3.0.1" - #elif (ARDUINO_ESP8266_GIT_VER == 0xefb0341a) - #define USING_ESP8266_CORE_VERSION 30000 - #define ESP8266_CORE_VERSION "ESP8266 core v3.0.0" - #warning USING_ESP8266_CORE_VERSION "3.0.0" - #elif (ARDUINO_ESP8266_GIT_VER == 0x2843a5ac) - #define USING_ESP8266_CORE_VERSION 20704 - #define ESP8266_CORE_VERSION "ESP8266 core v2.7.4" - #warning USING_ESP8266_CORE_VERSION "2.7.4" - #elif (ARDUINO_ESP8266_GIT_VER == 0x5d3af165) - #define USING_ESP8266_CORE_VERSION 20703 - #define ESP8266_CORE_VERSION "ESP8266 core v2.7.3" - #warning USING_ESP8266_CORE_VERSION "2.7.3" - #elif (ARDUINO_ESP8266_GIT_VER == 0x39c79d9b) - #define USING_ESP8266_CORE_VERSION 20702 - #define ESP8266_CORE_VERSION "ESP8266 core v2.7.2" - #warning USING_ESP8266_CORE_VERSION "2.7.2" - #elif (ARDUINO_ESP8266_GIT_VER == 0xa5432625) - #define USING_ESP8266_CORE_VERSION 20701 - #define ESP8266_CORE_VERSION "ESP8266 core v2.7.1" - #warning USING_ESP8266_CORE_VERSION "2.7.1" - #elif (ARDUINO_ESP8266_GIT_VER == 0x3d128e5c) - #define USING_ESP8266_CORE_VERSION 20603 - #define ESP8266_CORE_VERSION "ESP8266 core v2.6.3" - #warning USING_ESP8266_CORE_VERSION "2.6.3" - #elif (ARDUINO_ESP8266_GIT_VER == 0x482516e3) - #define USING_ESP8266_CORE_VERSION 20602 - #define ESP8266_CORE_VERSION "ESP8266 core v2.6.2" - #warning USING_ESP8266_CORE_VERSION "2.6.2" - #elif (ARDUINO_ESP8266_GIT_VER == 0x482516e3) - #define USING_ESP8266_CORE_VERSION 20601 - #define ESP8266_CORE_VERSION "ESP8266 core v2.6.1" - #warning USING_ESP8266_CORE_VERSION "2.6.1" - #elif (ARDUINO_ESP8266_GIT_VER == 0x643ec203) - #define USING_ESP8266_CORE_VERSION 20600 - #define ESP8266_CORE_VERSION "ESP8266 core v2.6.0" - #warning USING_ESP8266_CORE_VERSION "2.6.0" - #elif (ARDUINO_ESP8266_GIT_VER == 0x8b899c12) - #define USING_ESP8266_CORE_VERSION 20502 - #define ESP8266_CORE_VERSION "ESP8266 core v2.5.2" - #warning USING_ESP8266_CORE_VERSION "2.5.2" - #elif (ARDUINO_ESP8266_GIT_VER == 0x00000000) - #define USING_ESP8266_CORE_VERSION 20402 - #define ESP8266_CORE_VERSION "ESP8266 core v2.4.2" - #warning USING_ESP8266_CORE_VERSION "2.4.2" - #elif (ARDUINO_ESP8266_GIT_VER == 0x643ec203) - #define USING_ESP8266_CORE_VERSION 0 - #define ESP8266_CORE_VERSION "ESP8266 core too old" - #warning USING_ESP8266_CORE_VERSION "0.0.0" - #else - #define USING_ESP8266_CORE_VERSION 999999 - #define ESP8266_CORE_VERSION "ESP8266 core unknown" - #warning USING_ESP8266_CORE_VERSION "x.y.z" - #endif -#endif - -#include "ESPAsync_WiFiManager_Debug.h" - -//KH, for ESP32 -#ifdef ESP8266 - #include - #include -#else //ESP32 - #include - #include -#endif - -#include -#include -#undef min -#undef max -#include - -// fix crash on ESP32 (see https://github.com/alanswx/ESPAsyncWiFiManager/issues/44) -#if defined(ESP8266) - typedef int wifi_ssid_count_t; -#else - typedef int16_t wifi_ssid_count_t; -#endif - -//KH, for ESP32 -#ifdef ESP8266 - extern "C" - { - #include "user_interface.h" - } - - #define ESP_getChipId() (ESP.getChipId()) -#else //ESP32 - #include - #define ESP_getChipId() ((uint32_t)ESP.getEfuseMac()) -#endif - -typedef struct -{ - IPAddress _ap_static_ip; - IPAddress _ap_static_gw; - IPAddress _ap_static_sn; - -} 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 -#if !defined(USE_CONFIGURABLE_DNS) - #define USE_CONFIGURABLE_DNS false -#endif - -typedef struct -{ - IPAddress _sta_static_ip; - IPAddress _sta_static_gw; - IPAddress _sta_static_sn; - IPAddress _sta_static_dns1; - IPAddress _sta_static_dns2; -} WiFi_STA_IPConfig; - -#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) -#ifndef USING_CORS_FEATURE - // Contributed by AlesSt (https://github.com/AlesSt) to solve AJAX CORS protection problem of API redirects on client side - // See more in https://github.com/khoih-prog/ESP_WiFiManager/issues/27 and https://en.wikipedia.org/wiki/Cross-origin_resource_sharing - #define USING_CORS_FEATURE false -#endif - -#ifndef TIME_BETWEEN_MODAL_SCANS - // Default to 30s - #define TIME_BETWEEN_MODAL_SCANS 120000UL -#endif - -#ifndef TIME_BETWEEN_MODELESS_SCANS - // Default to 60s - #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 - // To enable NTP config - #define USE_ESP_WIFIMANAGER_NTP true -#endif - -#if USE_ESP_WIFIMANAGER_NTP - -#include "utils/TZ.h" - -const char WM_HTTP_SCRIPT_NTP_MSG[] PROGMEM = "

Your Timezone is :

"; -const char WM_HTTP_SCRIPT_NTP_HIDDEN[] PROGMEM = "

"; - -#if ESP8266 - #if !(USE_CLOUDFLARE_NTP) - #undef USE_CLOUDFLARE_NTP - #define USE_CLOUDFLARE_NTP true - #warning Forcing USE_CLOUDFLARE_NTP for ESP8266 as low memory can cause blank page - #endif -#endif - -// To permit disable or configure NTP from sketch -#ifndef USE_CLOUDFLARE_NTP - #define USE_CLOUDFLARE_NTP false -#endif - -#if USE_CLOUDFLARE_NTP -const char WM_HTTP_SCRIPT_NTP[] PROGMEM = ""; -#else -const char WM_HTTP_SCRIPT_NTP[] PROGMEM = ""; -#endif - -#else - const char WM_HTTP_SCRIPT_NTP_MSG[] PROGMEM = ""; - const char WM_HTTP_SCRIPT_NTP_HIDDEN[] PROGMEM = ""; - const char WM_HTTP_SCRIPT_NTP[] PROGMEM = ""; -#endif - -const char WM_HTTP_HEAD_END[] PROGMEM = "
"; - -const char WM_FLDSET_START[] PROGMEM = "
"; -const char WM_FLDSET_END[] PROGMEM = "
"; - -const char WM_HTTP_PORTAL_OPTIONS[] PROGMEM = "



"; -const char WM_HTTP_ITEM[] PROGMEM = "
{v} {r}%
"; -const char JSON_ITEM[] PROGMEM = "{\"SSID\":\"{v}\", \"Encryption\":{i}, \"Quality\":\"{r}\"}"; - - -// KH, update from v1.1.0 -const char WM_HTTP_FORM_START[] PROGMEM = "
"; -////// - -const char WM_HTTP_FORM_LABEL_BEFORE[] PROGMEM = "
"; -const char WM_HTTP_FORM_LABEL_AFTER[] PROGMEM = "
"; - -const char WM_HTTP_FORM_LABEL[] PROGMEM = ""; -const char WM_HTTP_FORM_PARAM[] PROGMEM = ""; - -const char WM_HTTP_FORM_END[] PROGMEM = "
"; - -// KH, update from v1.1.0 -const char WM_HTTP_SAVED[] PROGMEM = "
Credentials Saved
Try connecting ESP to the {x}/{x1} network. Wait around 10 seconds then check if it's OK.

The {v} AP will run on the same WiFi channel of the {x}/{x1} AP. You may have to manually reconnect to the {v} AP.

"; -////// - -const char WM_HTTP_END[] PROGMEM = "
"; - -const char WM_HTTP_HEAD_CL[] = "Content-Length"; -const char WM_HTTP_HEAD_CT[] = "text/html"; -const char WM_HTTP_HEAD_CT2[] = "text/plain"; - -const char WM_HTTP_HEAD_JSON[] ="application/json"; - -//KH Add repeatedly used const -const char WM_HTTP_CACHE_CONTROL[] = "Cache-Control"; -const char WM_HTTP_NO_STORE[] = "no-cache, no-store, must-revalidate"; -const char WM_HTTP_PRAGMA[] = "Pragma"; -const char WM_HTTP_NO_CACHE[] = "no-cache"; -const char WM_HTTP_EXPIRES[] = "Expires"; -const char WM_HTTP_CORS[] = "Access-Control-Allow-Origin"; -const char WM_HTTP_CORS_ALLOW_ALL[] = "*"; - -#if USE_AVAILABLE_PAGES -const char WM_HTTP_AVAILABLE_PAGES[] PROGMEM = "

Available Pages

PageFunction
/Menu page.
/wifiEnter WiFi Config Page with scan results.
/wifisaveSave Config. Portal Info with supplied variables.
/closeClose the Config Portal.
/iThis Info page.
/rDelete WiFi configuration and reboot. ESP device will not reconnect to a network until new WiFi configuration data is entered.
/stateCurrent device state in JSON format. Interface for programmatic WiFi configuration.
/scanRun a WiFi scan and return results in JSON format. Interface for programmatic WiFi configuration.
"; -#else - const char WM_HTTP_AVAILABLE_PAGES[] PROGMEM = ""; -#endif - -#define WIFI_MANAGER_MAX_PARAMS 20 - -// To permit autoConnect() to use STA static IP or DHCP IP. -#ifndef AUTOCONNECT_NO_INVALIDATE - #define AUTOCONNECT_NO_INVALIDATE true -#endif - -///////////////////////////////////////////////////////////////////////////// - -typedef struct -{ - const char *_id; - const char *_placeholder; - char *_value; - int _length; - int _labelPlacement; - -} WMParam_Data; - - -class ESPAsync_WMParameter -{ - public: - - ESPAsync_WMParameter(const char *custom); - ESPAsync_WMParameter(const char *id, const char *placeholder, const char *defaultValue, int length, - const char *custom = "", int labelPlacement = WFM_LABEL_BEFORE); - - // KH, using struct - ESPAsync_WMParameter(const WMParam_Data& WMParam_data); - ////// - - ~ESPAsync_WMParameter(); - - // Using Struct - void setWMParam_Data(const WMParam_Data& WMParam_data); - void getWMParam_Data(WMParam_Data &WMParam_data); - ////// - - const char *getID(); - const char *getValue(); - const char *getPlaceholder(); - int getValueLength(); - int getLabelPlacement(); - const char *getCustomHTML(); - - private: - - WMParam_Data _WMParam_data; - - const char *_customHTML; - - void init(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom, int labelPlacement); - - friend class ESPAsync_WiFiManager; -}; - -#define USE_DYNAMIC_PARAMS true -#define DEFAULT_PORTAL_TIMEOUT 60000L - -// To permit disable/enable StaticIP configuration in Config Portal from sketch. Valid only if DHCP is used. -// You have to explicitly specify false to disable the feature. -#ifndef USE_STATIC_IP_CONFIG_IN_CP - #define USE_STATIC_IP_CONFIG_IN_CP true -#endif - -///////////////////////////////////////////////////////////////////////////// - -class WiFiResult -{ - public: - bool duplicate; - String SSID; - uint8_t encryptionType; - int32_t RSSI; - uint8_t* BSSID; - int32_t channel; - bool isHidden; - - WiFiResult() - { - } -}; - -///////////////////////////////////////////////////////////////////////////// - -class ESPAsync_WiFiManager -{ - public: - - ESPAsync_WiFiManager(AsyncWebServer * webserver, DNSServer *dnsserver, const char *iHostname = ""); - - ~ESPAsync_WiFiManager(); - - //Scan for WiFiNetworks in range and sort by signal strength - void scan(); - - String scanModal(); - void loop(); - void safeLoop(); - void criticalLoop(); - String infoAsString(); - - // Can use with STA staticIP now - bool autoConnect(); - bool autoConnect(char const *apName, char const *apPassword = NULL); - ////// - - // If you want to start the config portal - bool startConfigPortal(); - bool startConfigPortal(char const *apName, char const *apPassword = NULL); - void startConfigPortalModeless(char const *apName, char const *apPassword, bool shouldConnectWiFi = true); - - - // get the AP name of the config portal, so it can be used in the callback - String getConfigPortalSSID(); - // get the AP password of the config portal, so it can be used in the callback - String getConfigPortalPW(); - - void resetSettings(); - - //sets timeout before webserver loop ends and exits even if there has been no setup. - //usefully for devices that failed to connect at some point and got stuck in a webserver loop - //in seconds setConfigPortalTimeout is a new name for setTimeout - void setConfigPortalTimeout(unsigned long seconds); - void setTimeout(unsigned long seconds); - - //sets timeout for which to attempt connecting, usefull if you get a lot of failed connects - void setConnectTimeout(unsigned long seconds); - - - void setDebugOutput(bool debug); - //defaults to not showing anything under 8% signal quality if called - void setMinimumSignalQuality(int quality = 8); - - // To enable dynamic/random channel - int setConfigPortalChannel(int channel = 1); - ////// - - //sets a custom ip /gateway /subnet configuration - void setAPStaticIPConfig(const IPAddress& ip, const IPAddress& gw, const IPAddress& sn); - - // KH, new using struct - void setAPStaticIPConfig(const WiFi_AP_IPConfig& WM_AP_IPconfig); - void getAPStaticIPConfig(WiFi_AP_IPConfig &WM_AP_IPconfig); - ////// - - //sets config for a static IP - void setSTAStaticIPConfig(const IPAddress& ip, const IPAddress& gw, const IPAddress& sn); - - // KH, new using struct - void setSTAStaticIPConfig(const WiFi_STA_IPConfig& WM_STA_IPconfig); - void getSTAStaticIPConfig(WiFi_STA_IPConfig &WM_STA_IPconfig); - ////// - -#if USE_CONFIGURABLE_DNS - void setSTAStaticIPConfig(const IPAddress& ip, const IPAddress& gw, const IPAddress& sn, - const IPAddress& dns_address_1, const IPAddress& dns_address_2); -#endif - - //called when AP mode and config portal is started - void setAPCallback(void(*func)(ESPAsync_WiFiManager*)); - //called when settings have been changed and connection was successful - void setSaveConfigCallback(void(*func)()); - -#if USE_DYNAMIC_PARAMS - //adds a custom parameter - bool addParameter(ESPAsync_WMParameter *p); -#else - //adds a custom parameter - void addParameter(ESPAsync_WMParameter *p); -#endif - - //if this is set, it will exit after config, even if connection is unsucessful. - void setBreakAfterConfig(bool shouldBreak); - - //if this is set, try WPS setup when starting (this will delay config portal for up to 2 mins) - //TODO - //if this is set, customise style - void setCustomHeadElement(const char* element); - - //if this is true, remove duplicated Access Points - defaut true - void setRemoveDuplicateAPs(bool removeDuplicates); - - // return SSID of router in STA mode got from config portal. NULL if no user's input //KH - String getSSID() - { - return _ssid; - } - - // return password of router in STA mode got from config portal. NULL if no user's input //KH - String getPW() - { - return _pass; - } - - // New from v1.1.0 - // return SSID of router in STA mode got from config portal. NULL if no user's input //KH - String getSSID1() - { - return _ssid1; - } - - // return password of router in STA mode got from config portal. NULL if no user's input //KH - String getPW1() - { - return _pass1; - } - - #define MAX_WIFI_CREDENTIALS 2 - - String getSSID(uint8_t index) - { - if (index == 0) - return _ssid; - else if (index == 1) - return _ssid1; - else - return String(""); - } - - String getPW(uint8_t index) - { - if (index == 0) - return _pass; - else if (index == 1) - return _pass1; - else - return String(""); - } - ////// - - // New from v1.1.1, for configure CORS Header, default to WM_HTTP_CORS_ALLOW_ALL = "*" -#if USING_CORS_FEATURE - void setCORSHeader(const char* CORSHeaders) - { - _CORS_Header = CORSHeaders; - - LOGWARN1(F("Set CORS Header to : "), _CORS_Header); - } - - const char* getCORSHeader() - { - return _CORS_Header; - } -#endif - - //returns the list of Parameters - ESPAsync_WMParameter** getParameters(); - - // returns the Parameters Count - int getParametersCount(); - - const char* getStatus(int status); - -#ifdef ESP32 - String getStoredWiFiSSID(); - String getStoredWiFiPass(); -#endif - - String WiFi_SSID() - { -#ifdef ESP8266 - return WiFi.SSID(); -#else - return getStoredWiFiSSID(); -#endif - } - - String WiFi_Pass() - { -#ifdef ESP8266 - return WiFi.psk(); -#else - return getStoredWiFiPass(); -#endif - } - - void setHostname() - { - if (RFC952_hostname[0] != 0) - { -#if ESP8266 - WiFi.hostname(RFC952_hostname); -#else - - // Check cores/esp32/esp_arduino_version.h and cores/esp32/core_version.h - //#if ( ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(2, 0, 0) ) //(ESP_ARDUINO_VERSION_MAJOR >= 2) - #if ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 2) ) - WiFi.setHostname(RFC952_hostname); - #else - // Still have bug in ESP32_S2 for old core. If using WiFi.setHostname() => WiFi.localIP() always = 255.255.255.255 - if ( String(ARDUINO_BOARD) != "ESP32S2_DEV" ) - { - // See https://github.com/espressif/arduino-esp32/issues/2537 - WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE); - WiFi.setHostname(RFC952_hostname); - } - #endif -#endif - } - } - -#if USE_ESP_WIFIMANAGER_NTP - - String getTimezoneName() - { - return _timezoneName; - } - - void setTimezoneName(const String& inTimezoneName) - { - _timezoneName = inTimezoneName; - } - ////// - - //See: https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html - // EST5EDT,M3.2.0,M11.1.0 (for America/New_York) - // EST5EDT is the name of the time zone - // EST is the abbreviation used when DST is off - // 6 hours is the time difference from GMT - // EDT is the abbreviation used when DST is on - // ,M3 is the third month - // .2 is the second occurrence of the day in the month - // .0 is Sunday - // ,M11 is the eleventh month - // .1 is the first occurrence of the day in the month - // .0 is Sunday - - const char * getTZ(const char * timezoneName) - { - //const char TZ_NAME[][TIMEZONE_MAX_LEN] - for (uint16_t index = 0; index < sizeof(TZ_NAME) / TIMEZONE_MAX_LEN; index++) - { - if ( !strncmp(timezoneName, (TZ_NAME[index]), strlen((TZ_NAME[index])) ) ) - { - yield(); - return (ESP_TZ_NAME[index]); - } - } - - return ""; - } - - - const char * getTZ(const String& timezoneName) - { - return getTZ(timezoneName.c_str()); - } - - -#endif - - - private: - - DNSServer *dnsServer; - - AsyncWebServer *server; - - bool _modeless; - int scannow; - int shouldscan; - bool needInfo = true; - String pager; - wl_status_t wifiStatus; - -#define RFC952_HOSTNAME_MAXLEN 24 - char RFC952_hostname[RFC952_HOSTNAME_MAXLEN + 1]; - - char* getRFC952_hostname(const char* iHostname); - - void setupConfigPortal(); - void startWPS(); - - const char* _apName = "no-net"; - const char* _apPassword = NULL; - - String _ssid = ""; - String _pass = ""; - - // New from v1.1.0 - String _ssid1 = ""; - String _pass1 = ""; - ////// - -#if USE_ESP_WIFIMANAGER_NTP - // Timezone info - String _timezoneName = ""; -#endif - - unsigned long _configPortalTimeout = 0; - - unsigned long _connectTimeout = 0; - unsigned long _configPortalStart = 0; - - int numberOfNetworks; - int *networkIndices; - - WiFiResult *wifiSSIDs; - wifi_ssid_count_t wifiSSIDCount; - bool wifiSSIDscan; - - // To enable dynamic/random channel - // default to channel 1 - #define MIN_WIFI_CHANNEL 1 - #define MAX_WIFI_CHANNEL 11 // Channel 12,13 is flaky, because of bad number 13 ;-) - - int _WiFiAPChannel = 1; - ////// - - WiFi_AP_IPConfig _WiFi_AP_IPconfig; - - WiFi_STA_IPConfig _WiFi_STA_IPconfig = { IPAddress(0, 0, 0, 0), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0), - IPAddress(192, 168, 2, 1), IPAddress(8, 8, 8, 8) }; - - int _paramsCount = 0; - int _minimumQuality = -1; - bool _removeDuplicateAPs = true; - bool _shouldBreakAfterConfig = false; - bool _tryWPS = false; - - const char* _customHeadElement = ""; - - int status = WL_IDLE_STATUS; - - // New from v1.1.0, for configure CORS Header, default to WM_HTTP_CORS_ALLOW_ALL = "*" -#if USING_CORS_FEATURE - const char* _CORS_Header = WM_HTTP_CORS_ALLOW_ALL; //"*"; -#endif - ////// - - void setWifiStaticIP(); - - // New v1.1.0 - int reconnectWifi(); - ////// - - int connectWifi(const String& ssid = "", const String& pass = ""); - - wl_status_t waitForConnectResult(); - - void setInfo(); - String networkListAsString(); - - void handleRoot(AsyncWebServerRequest *request); - void handleWifi(AsyncWebServerRequest *request); - void handleWifiSave(AsyncWebServerRequest *request); - void handleServerClose(AsyncWebServerRequest *request); - void handleInfo(AsyncWebServerRequest *request); - void handleState(AsyncWebServerRequest *request); - void handleScan(AsyncWebServerRequest *request); - void handleReset(AsyncWebServerRequest *request); - void handleNotFound(AsyncWebServerRequest *request); - bool captivePortal(AsyncWebServerRequest *request); - - void reportStatus(String &page); - - // DNS server - const byte DNS_PORT = 53; - - //helpers - int getRSSIasQuality(int RSSI); - bool isIp(const String& str); - String toStringIp(const IPAddress& ip); - - bool connect; - bool stopConfigPortal = false; - - bool _debug = false; //true; - - void(*_apcallback)(ESPAsync_WiFiManager*) = NULL; - void(*_savecallback)() = NULL; - -#if USE_DYNAMIC_PARAMS - int _max_params; - ESPAsync_WMParameter** _params; -#else - ESPAsync_WMParameter* _params[WIFI_MANAGER_MAX_PARAMS]; -#endif - - template - void DEBUG_WM(Generic text); - - template - auto optionalIPFromString(T *obj, const char *s) -> decltype(obj->fromString(s)) - { - return obj->fromString(s); - } - - auto optionalIPFromString(...) -> bool - { - LOGINFO("NO fromString METHOD ON IPAddress, you need ESP8266 core 2.1.0+ for Custom IP configuration to work."); - return false; - } -}; +#include //https://github.com/khoih-prog/ESPAsync_WiFiManager +#include //https://github.com/khoih-prog/ESPAsync_WiFiManager #endif // ESPAsync_WiFiManager_h diff --git a/src/ESPAsync_WiFiManager.hpp b/src/ESPAsync_WiFiManager.hpp new file mode 100644 index 00000000..402274b2 --- /dev/null +++ b/src/ESPAsync_WiFiManager.hpp @@ -0,0 +1,825 @@ +/**************************************************************************************************************************** + ESPAsync_WiFiManager.hpp + For ESP8266 / ESP32 boards + + ESPAsync_WiFiManager is a library for the ESP8266/Arduino platform, using (ESP)AsyncWebServer to enable easy + configuration and reconfiguration of WiFi credentials using a Captive Portal. + + Modified from + 1. Tzapu (https://github.com/tzapu/WiFiManager) + 2. Ken Taylor (https://github.com/kentaylor) + 3. Alan Steremberg (https://github.com/alanswx/ESPAsyncWiFiManager) + 4. Khoi Hoang (https://github.com/khoih-prog/ESP_WiFiManager) + + Built by Khoi Hoang https://github.com/khoih-prog/ESPAsync_WiFiManager + Licensed under MIT license + + Version: 1.11.0 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.11 K Hoang 21/08/2020 Initial coding to use (ESP)AsyncWebServer instead of (ESP8266)WebServer. Bump up to v1.0.11 + to sync with ESP_WiFiManager v1.0.11 + 1.1.1 K Hoang 29/08/2020 Add MultiWiFi feature to autoconnect to best WiFi at runtime to sync with + ESP_WiFiManager v1.1.1. Add setCORSHeader function to allow flexible CORS + 1.1.2 K Hoang 17/09/2020 Fix bug in examples. + 1.2.0 K Hoang 15/10/2020 Restore cpp code besides Impl.h code to use if linker error. Fix bug. + 1.3.0 K Hoang 04/12/2020 Add LittleFS support to ESP32 using LITTLEFS Library + 1.4.0 K Hoang 18/12/2020 Fix staticIP not saved. Add functions. Add complex examples. + 1.4.1 K Hoang 21/12/2020 Fix bug and compiler warnings. + 1.4.2 K Hoang 21/12/2020 Fix examples' bug not using saved WiFi Credentials after losing all WiFi connections. + 1.4.3 K Hoang 23/12/2020 Fix examples' bug not saving Static IP in certain cases. + 1.5.0 K Hoang 13/02/2021 Add support to new ESP32-S2. Optimize code. + 1.6.0 K Hoang 25/02/2021 Fix WiFi Scanning bug. + 1.6.1 K Hoang 26/03/2021 Modify multiWiFi-related timings to work better with latest esp32 core v1.0.6 + 1.6.2 K Hoang 08/04/2021 Fix example misleading messages. + 1.6.3 K Hoang 13/04/2021 Allow captive portal to run more than once by closing dnsServer. + 1.7.0 K Hoang 20/04/2021 Add support to new ESP32-C3 using SPIFFS or EEPROM + 1.7.1 K Hoang 25/04/2021 Fix MultiWiFi bug. Fix captive-portal bug if CP AP address is not default 192.168.4.1 + 1.8.0 K Hoang 30/04/2021 Set _timezoneName. Add support to new ESP32-S2 (METRO_ESP32S2, FUNHOUSE_ESP32S2, etc.) + 1.8.1 K Hoang 06/05/2021 Fix bug. Don't display invalid time when not synch yet. + 1.9.0 K Hoang 08/05/2021 Add WiFi /scan page. Fix timezoneName not displayed in Info page. Clean up. + 1.9.1 K Hoang 18/05/2021 Fix warnings with ESP8266 core v3.0.0 + 1.9.2 K Hoang 02/08/2021 Fix Mbed TLS compile error and MultiWiFi connection issue with ESP32 core v2.0.0-rc1+ + 1.9.3 K Hoang 13/08/2021 Add WiFi scanning of hidden SSIDs + 1.9.4 K Hoang 10/10/2021 Update `platform.ini` and `library.json` + 1.9.5 K Hoang 26/11/2021 Auto detect ESP32 core and use either built-in LittleFS or LITTLEFS library + 1.9.6 K Hoang 26/11/2021 Fix compile error for ESP32 core v1.0.5- + 1.9.7 K Hoang 30/11/2021 Fix bug to permit using HTTP port different from 80 + 1.9.8 K Hoang 01/12/2021 Fix bug returning IP `255.255.255.255` in core v2.0.0+ when using `hostname` + 1.10.0 K Hoang 29/12/2021 Fix `multiple-definitions` linker error and weird bug related to src_cpp + 1.11.0 K Hoang 17/01/2022 Enable compatibility with old code to include only ESP_WiFiManager.h + *****************************************************************************************************************************/ + +#pragma once + +#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 ) + #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 + #define USING_ESP32_S2 true +#elif defined( ARDUINO_ESP32C3_DEV ) + #warning Using ESP32_C3. To follow library instructions to install esp32-c3 core. Only SPIFFS and EEPROM OK. + #warning You have to select Flash size 2MB and Minimal APP (1.3MB + 700KB) for some boards + #define USING_ESP32_C3 true +#endif + +#define ESP_ASYNC_WIFIMANAGER_VERSION "ESPAsync_WiFiManager v1.11.0" + +#define ESP_ASYNC_WIFIMANAGER_VERSION_MAJOR 1 +#define ESP_ASYNC_WIFIMANAGER_VERSION_MINOR 11 +#define ESP_ASYNC_WIFIMANAGER_VERSION_PATCH 0 + +#define ESP_ASYNC_WIFIMANAGER_VERSION_INT 1011000 + +#if ESP8266 + #if (ARDUINO_ESP8266_GIT_VER == 0xcf6ff4c4) + #define USING_ESP8266_CORE_VERSION 30002 + #define ESP8266_CORE_VERSION "ESP8266 core v3.0.2" + #warning USING_ESP8266_CORE_VERSION "3.0.2" + #elif (ARDUINO_ESP8266_GIT_VER == 0xcbf44fb3) + #define USING_ESP8266_CORE_VERSION 30001 + #define ESP8266_CORE_VERSION "ESP8266 core v3.0.1" + #warning USING_ESP8266_CORE_VERSION "3.0.1" + #elif (ARDUINO_ESP8266_GIT_VER == 0xefb0341a) + #define USING_ESP8266_CORE_VERSION 30000 + #define ESP8266_CORE_VERSION "ESP8266 core v3.0.0" + #warning USING_ESP8266_CORE_VERSION "3.0.0" + #elif (ARDUINO_ESP8266_GIT_VER == 0x2843a5ac) + #define USING_ESP8266_CORE_VERSION 20704 + #define ESP8266_CORE_VERSION "ESP8266 core v2.7.4" + #warning USING_ESP8266_CORE_VERSION "2.7.4" + #elif (ARDUINO_ESP8266_GIT_VER == 0x5d3af165) + #define USING_ESP8266_CORE_VERSION 20703 + #define ESP8266_CORE_VERSION "ESP8266 core v2.7.3" + #warning USING_ESP8266_CORE_VERSION "2.7.3" + #elif (ARDUINO_ESP8266_GIT_VER == 0x39c79d9b) + #define USING_ESP8266_CORE_VERSION 20702 + #define ESP8266_CORE_VERSION "ESP8266 core v2.7.2" + #warning USING_ESP8266_CORE_VERSION "2.7.2" + #elif (ARDUINO_ESP8266_GIT_VER == 0xa5432625) + #define USING_ESP8266_CORE_VERSION 20701 + #define ESP8266_CORE_VERSION "ESP8266 core v2.7.1" + #warning USING_ESP8266_CORE_VERSION "2.7.1" + #elif (ARDUINO_ESP8266_GIT_VER == 0x3d128e5c) + #define USING_ESP8266_CORE_VERSION 20603 + #define ESP8266_CORE_VERSION "ESP8266 core v2.6.3" + #warning USING_ESP8266_CORE_VERSION "2.6.3" + #elif (ARDUINO_ESP8266_GIT_VER == 0x482516e3) + #define USING_ESP8266_CORE_VERSION 20602 + #define ESP8266_CORE_VERSION "ESP8266 core v2.6.2" + #warning USING_ESP8266_CORE_VERSION "2.6.2" + #elif (ARDUINO_ESP8266_GIT_VER == 0x482516e3) + #define USING_ESP8266_CORE_VERSION 20601 + #define ESP8266_CORE_VERSION "ESP8266 core v2.6.1" + #warning USING_ESP8266_CORE_VERSION "2.6.1" + #elif (ARDUINO_ESP8266_GIT_VER == 0x643ec203) + #define USING_ESP8266_CORE_VERSION 20600 + #define ESP8266_CORE_VERSION "ESP8266 core v2.6.0" + #warning USING_ESP8266_CORE_VERSION "2.6.0" + #elif (ARDUINO_ESP8266_GIT_VER == 0x8b899c12) + #define USING_ESP8266_CORE_VERSION 20502 + #define ESP8266_CORE_VERSION "ESP8266 core v2.5.2" + #warning USING_ESP8266_CORE_VERSION "2.5.2" + #elif (ARDUINO_ESP8266_GIT_VER == 0x00000000) + #define USING_ESP8266_CORE_VERSION 20402 + #define ESP8266_CORE_VERSION "ESP8266 core v2.4.2" + #warning USING_ESP8266_CORE_VERSION "2.4.2" + #elif (ARDUINO_ESP8266_GIT_VER == 0x643ec203) + #define USING_ESP8266_CORE_VERSION 0 + #define ESP8266_CORE_VERSION "ESP8266 core too old" + #warning USING_ESP8266_CORE_VERSION "0.0.0" + #else + #define USING_ESP8266_CORE_VERSION 999999 + #define ESP8266_CORE_VERSION "ESP8266 core unknown" + #warning USING_ESP8266_CORE_VERSION "x.y.z" + #endif +#endif + +#include "ESPAsync_WiFiManager_Debug.h" + +//KH, for ESP32 +#ifdef ESP8266 + #include + #include +#else //ESP32 + #include + #include +#endif + +#include +#include +#undef min +#undef max +#include + +// fix crash on ESP32 (see https://github.com/alanswx/ESPAsyncWiFiManager/issues/44) +#if defined(ESP8266) + typedef int wifi_ssid_count_t; +#else + typedef int16_t wifi_ssid_count_t; +#endif + +//KH, for ESP32 +#ifdef ESP8266 + extern "C" + { + #include "user_interface.h" + } + + #define ESP_getChipId() (ESP.getChipId()) +#else //ESP32 + #include + #define ESP_getChipId() ((uint32_t)ESP.getEfuseMac()) +#endif + +typedef struct +{ + IPAddress _ap_static_ip; + IPAddress _ap_static_gw; + IPAddress _ap_static_sn; + +} 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 +#if !defined(USE_CONFIGURABLE_DNS) + #define USE_CONFIGURABLE_DNS false +#endif + +typedef struct +{ + IPAddress _sta_static_ip; + IPAddress _sta_static_gw; + IPAddress _sta_static_sn; + IPAddress _sta_static_dns1; + IPAddress _sta_static_dns2; +} WiFi_STA_IPConfig; + +#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) +#ifndef USING_CORS_FEATURE + // Contributed by AlesSt (https://github.com/AlesSt) to solve AJAX CORS protection problem of API redirects on client side + // See more in https://github.com/khoih-prog/ESP_WiFiManager/issues/27 and https://en.wikipedia.org/wiki/Cross-origin_resource_sharing + #define USING_CORS_FEATURE false +#endif + +#ifndef TIME_BETWEEN_MODAL_SCANS + // Default to 30s + #define TIME_BETWEEN_MODAL_SCANS 120000UL +#endif + +#ifndef TIME_BETWEEN_MODELESS_SCANS + // Default to 60s + #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 + // To enable NTP config + #define USE_ESP_WIFIMANAGER_NTP true +#endif + +#if USE_ESP_WIFIMANAGER_NTP + +#include "utils/TZ.h" + +const char WM_HTTP_SCRIPT_NTP_MSG[] PROGMEM = "

Your Timezone is :

"; +const char WM_HTTP_SCRIPT_NTP_HIDDEN[] PROGMEM = "

"; + +#if ESP8266 + #if !(USE_CLOUDFLARE_NTP) + #undef USE_CLOUDFLARE_NTP + #define USE_CLOUDFLARE_NTP true + #warning Forcing USE_CLOUDFLARE_NTP for ESP8266 as low memory can cause blank page + #endif +#endif + +// To permit disable or configure NTP from sketch +#ifndef USE_CLOUDFLARE_NTP + #define USE_CLOUDFLARE_NTP false +#endif + +#if USE_CLOUDFLARE_NTP +const char WM_HTTP_SCRIPT_NTP[] PROGMEM = ""; +#else +const char WM_HTTP_SCRIPT_NTP[] PROGMEM = ""; +#endif + +#else + const char WM_HTTP_SCRIPT_NTP_MSG[] PROGMEM = ""; + const char WM_HTTP_SCRIPT_NTP_HIDDEN[] PROGMEM = ""; + const char WM_HTTP_SCRIPT_NTP[] PROGMEM = ""; +#endif + +const char WM_HTTP_HEAD_END[] PROGMEM = "
"; + +const char WM_FLDSET_START[] PROGMEM = "
"; +const char WM_FLDSET_END[] PROGMEM = "
"; + +const char WM_HTTP_PORTAL_OPTIONS[] PROGMEM = "



"; +const char WM_HTTP_ITEM[] PROGMEM = "
{v} {r}%
"; +const char JSON_ITEM[] PROGMEM = "{\"SSID\":\"{v}\", \"Encryption\":{i}, \"Quality\":\"{r}\"}"; + + +// KH, update from v1.1.0 +const char WM_HTTP_FORM_START[] PROGMEM = "
"; +////// + +const char WM_HTTP_FORM_LABEL_BEFORE[] PROGMEM = "
"; +const char WM_HTTP_FORM_LABEL_AFTER[] PROGMEM = "
"; + +const char WM_HTTP_FORM_LABEL[] PROGMEM = ""; +const char WM_HTTP_FORM_PARAM[] PROGMEM = ""; + +const char WM_HTTP_FORM_END[] PROGMEM = "
"; + +// KH, update from v1.1.0 +const char WM_HTTP_SAVED[] PROGMEM = "
Credentials Saved
Try connecting ESP to the {x}/{x1} network. Wait around 10 seconds then check if it's OK.

The {v} AP will run on the same WiFi channel of the {x}/{x1} AP. You may have to manually reconnect to the {v} AP.

"; +////// + +const char WM_HTTP_END[] PROGMEM = "
"; + +const char WM_HTTP_HEAD_CL[] = "Content-Length"; +const char WM_HTTP_HEAD_CT[] = "text/html"; +const char WM_HTTP_HEAD_CT2[] = "text/plain"; + +const char WM_HTTP_HEAD_JSON[] ="application/json"; + +//KH Add repeatedly used const +const char WM_HTTP_CACHE_CONTROL[] = "Cache-Control"; +const char WM_HTTP_NO_STORE[] = "no-cache, no-store, must-revalidate"; +const char WM_HTTP_PRAGMA[] = "Pragma"; +const char WM_HTTP_NO_CACHE[] = "no-cache"; +const char WM_HTTP_EXPIRES[] = "Expires"; +const char WM_HTTP_CORS[] = "Access-Control-Allow-Origin"; +const char WM_HTTP_CORS_ALLOW_ALL[] = "*"; + +#if USE_AVAILABLE_PAGES +const char WM_HTTP_AVAILABLE_PAGES[] PROGMEM = "

Available Pages

PageFunction
/Menu page.
/wifiEnter WiFi Config Page with scan results.
/wifisaveSave Config. Portal Info with supplied variables.
/closeClose the Config Portal.
/iThis Info page.
/rDelete WiFi configuration and reboot. ESP device will not reconnect to a network until new WiFi configuration data is entered.
/stateCurrent device state in JSON format. Interface for programmatic WiFi configuration.
/scanRun a WiFi scan and return results in JSON format. Interface for programmatic WiFi configuration.
"; +#else + const char WM_HTTP_AVAILABLE_PAGES[] PROGMEM = ""; +#endif + +#define WIFI_MANAGER_MAX_PARAMS 20 + +// To permit autoConnect() to use STA static IP or DHCP IP. +#ifndef AUTOCONNECT_NO_INVALIDATE + #define AUTOCONNECT_NO_INVALIDATE true +#endif + +///////////////////////////////////////////////////////////////////////////// + +typedef struct +{ + const char *_id; + const char *_placeholder; + char *_value; + int _length; + int _labelPlacement; + +} WMParam_Data; + + +class ESPAsync_WMParameter +{ + public: + + ESPAsync_WMParameter(const char *custom); + ESPAsync_WMParameter(const char *id, const char *placeholder, const char *defaultValue, int length, + const char *custom = "", int labelPlacement = WFM_LABEL_BEFORE); + + // KH, using struct + ESPAsync_WMParameter(const WMParam_Data& WMParam_data); + ////// + + ~ESPAsync_WMParameter(); + + // Using Struct + void setWMParam_Data(const WMParam_Data& WMParam_data); + void getWMParam_Data(WMParam_Data &WMParam_data); + ////// + + const char *getID(); + const char *getValue(); + const char *getPlaceholder(); + int getValueLength(); + int getLabelPlacement(); + const char *getCustomHTML(); + + private: + + WMParam_Data _WMParam_data; + + const char *_customHTML; + + void init(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom, int labelPlacement); + + friend class ESPAsync_WiFiManager; +}; + +#define USE_DYNAMIC_PARAMS true +#define DEFAULT_PORTAL_TIMEOUT 60000L + +// To permit disable/enable StaticIP configuration in Config Portal from sketch. Valid only if DHCP is used. +// You have to explicitly specify false to disable the feature. +#ifndef USE_STATIC_IP_CONFIG_IN_CP + #define USE_STATIC_IP_CONFIG_IN_CP true +#endif + +///////////////////////////////////////////////////////////////////////////// + +class WiFiResult +{ + public: + bool duplicate; + String SSID; + uint8_t encryptionType; + int32_t RSSI; + uint8_t* BSSID; + int32_t channel; + bool isHidden; + + WiFiResult() + { + } +}; + +///////////////////////////////////////////////////////////////////////////// + +class ESPAsync_WiFiManager +{ + public: + + ESPAsync_WiFiManager(AsyncWebServer * webserver, DNSServer *dnsserver, const char *iHostname = ""); + + ~ESPAsync_WiFiManager(); + + //Scan for WiFiNetworks in range and sort by signal strength + void scan(); + + String scanModal(); + void loop(); + void safeLoop(); + void criticalLoop(); + String infoAsString(); + + // Can use with STA staticIP now + bool autoConnect(); + bool autoConnect(char const *apName, char const *apPassword = NULL); + ////// + + // If you want to start the config portal + bool startConfigPortal(); + bool startConfigPortal(char const *apName, char const *apPassword = NULL); + void startConfigPortalModeless(char const *apName, char const *apPassword, bool shouldConnectWiFi = true); + + + // get the AP name of the config portal, so it can be used in the callback + String getConfigPortalSSID(); + // get the AP password of the config portal, so it can be used in the callback + String getConfigPortalPW(); + + void resetSettings(); + + //sets timeout before webserver loop ends and exits even if there has been no setup. + //usefully for devices that failed to connect at some point and got stuck in a webserver loop + //in seconds setConfigPortalTimeout is a new name for setTimeout + void setConfigPortalTimeout(unsigned long seconds); + void setTimeout(unsigned long seconds); + + //sets timeout for which to attempt connecting, usefull if you get a lot of failed connects + void setConnectTimeout(unsigned long seconds); + + + void setDebugOutput(bool debug); + //defaults to not showing anything under 8% signal quality if called + void setMinimumSignalQuality(int quality = 8); + + // To enable dynamic/random channel + int setConfigPortalChannel(int channel = 1); + ////// + + //sets a custom ip /gateway /subnet configuration + void setAPStaticIPConfig(const IPAddress& ip, const IPAddress& gw, const IPAddress& sn); + + // KH, new using struct + void setAPStaticIPConfig(const WiFi_AP_IPConfig& WM_AP_IPconfig); + void getAPStaticIPConfig(WiFi_AP_IPConfig &WM_AP_IPconfig); + ////// + + //sets config for a static IP + void setSTAStaticIPConfig(const IPAddress& ip, const IPAddress& gw, const IPAddress& sn); + + // KH, new using struct + void setSTAStaticIPConfig(const WiFi_STA_IPConfig& WM_STA_IPconfig); + void getSTAStaticIPConfig(WiFi_STA_IPConfig &WM_STA_IPconfig); + ////// + +#if USE_CONFIGURABLE_DNS + void setSTAStaticIPConfig(const IPAddress& ip, const IPAddress& gw, const IPAddress& sn, + const IPAddress& dns_address_1, const IPAddress& dns_address_2); +#endif + + //called when AP mode and config portal is started + void setAPCallback(void(*func)(ESPAsync_WiFiManager*)); + //called when settings have been changed and connection was successful + void setSaveConfigCallback(void(*func)()); + +#if USE_DYNAMIC_PARAMS + //adds a custom parameter + bool addParameter(ESPAsync_WMParameter *p); +#else + //adds a custom parameter + void addParameter(ESPAsync_WMParameter *p); +#endif + + //if this is set, it will exit after config, even if connection is unsucessful. + void setBreakAfterConfig(bool shouldBreak); + + //if this is set, try WPS setup when starting (this will delay config portal for up to 2 mins) + //TODO + //if this is set, customise style + void setCustomHeadElement(const char* element); + + //if this is true, remove duplicated Access Points - defaut true + void setRemoveDuplicateAPs(bool removeDuplicates); + + // return SSID of router in STA mode got from config portal. NULL if no user's input //KH + String getSSID() + { + return _ssid; + } + + // return password of router in STA mode got from config portal. NULL if no user's input //KH + String getPW() + { + return _pass; + } + + // New from v1.1.0 + // return SSID of router in STA mode got from config portal. NULL if no user's input //KH + String getSSID1() + { + return _ssid1; + } + + // return password of router in STA mode got from config portal. NULL if no user's input //KH + String getPW1() + { + return _pass1; + } + + #define MAX_WIFI_CREDENTIALS 2 + + String getSSID(uint8_t index) + { + if (index == 0) + return _ssid; + else if (index == 1) + return _ssid1; + else + return String(""); + } + + String getPW(uint8_t index) + { + if (index == 0) + return _pass; + else if (index == 1) + return _pass1; + else + return String(""); + } + ////// + + // New from v1.1.1, for configure CORS Header, default to WM_HTTP_CORS_ALLOW_ALL = "*" +#if USING_CORS_FEATURE + void setCORSHeader(const char* CORSHeaders) + { + _CORS_Header = CORSHeaders; + + LOGWARN1(F("Set CORS Header to : "), _CORS_Header); + } + + const char* getCORSHeader() + { + return _CORS_Header; + } +#endif + + //returns the list of Parameters + ESPAsync_WMParameter** getParameters(); + + // returns the Parameters Count + int getParametersCount(); + + const char* getStatus(int status); + +#ifdef ESP32 + String getStoredWiFiSSID(); + String getStoredWiFiPass(); +#endif + + String WiFi_SSID() + { +#ifdef ESP8266 + return WiFi.SSID(); +#else + return getStoredWiFiSSID(); +#endif + } + + String WiFi_Pass() + { +#ifdef ESP8266 + return WiFi.psk(); +#else + return getStoredWiFiPass(); +#endif + } + + void setHostname() + { + if (RFC952_hostname[0] != 0) + { +#if ESP8266 + WiFi.hostname(RFC952_hostname); +#else + + // Check cores/esp32/esp_arduino_version.h and cores/esp32/core_version.h + //#if ( ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(2, 0, 0) ) //(ESP_ARDUINO_VERSION_MAJOR >= 2) + #if ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 2) ) + WiFi.setHostname(RFC952_hostname); + #else + // Still have bug in ESP32_S2 for old core. If using WiFi.setHostname() => WiFi.localIP() always = 255.255.255.255 + if ( String(ARDUINO_BOARD) != "ESP32S2_DEV" ) + { + // See https://github.com/espressif/arduino-esp32/issues/2537 + WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE); + WiFi.setHostname(RFC952_hostname); + } + #endif +#endif + } + } + +#if USE_ESP_WIFIMANAGER_NTP + + String getTimezoneName() + { + return _timezoneName; + } + + void setTimezoneName(const String& inTimezoneName) + { + _timezoneName = inTimezoneName; + } + ////// + + //See: https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html + // EST5EDT,M3.2.0,M11.1.0 (for America/New_York) + // EST5EDT is the name of the time zone + // EST is the abbreviation used when DST is off + // 6 hours is the time difference from GMT + // EDT is the abbreviation used when DST is on + // ,M3 is the third month + // .2 is the second occurrence of the day in the month + // .0 is Sunday + // ,M11 is the eleventh month + // .1 is the first occurrence of the day in the month + // .0 is Sunday + + const char * getTZ(const char * timezoneName) + { + //const char TZ_NAME[][TIMEZONE_MAX_LEN] + for (uint16_t index = 0; index < sizeof(TZ_NAME) / TIMEZONE_MAX_LEN; index++) + { + if ( !strncmp(timezoneName, (TZ_NAME[index]), strlen((TZ_NAME[index])) ) ) + { + yield(); + return (ESP_TZ_NAME[index]); + } + } + + return ""; + } + + + const char * getTZ(const String& timezoneName) + { + return getTZ(timezoneName.c_str()); + } + + +#endif + + + private: + + DNSServer *dnsServer; + + AsyncWebServer *server; + + bool _modeless; + int scannow; + int shouldscan; + bool needInfo = true; + String pager; + wl_status_t wifiStatus; + +#define RFC952_HOSTNAME_MAXLEN 24 + char RFC952_hostname[RFC952_HOSTNAME_MAXLEN + 1]; + + char* getRFC952_hostname(const char* iHostname); + + void setupConfigPortal(); + void startWPS(); + + const char* _apName = "no-net"; + const char* _apPassword = NULL; + + String _ssid = ""; + String _pass = ""; + + // New from v1.1.0 + String _ssid1 = ""; + String _pass1 = ""; + ////// + +#if USE_ESP_WIFIMANAGER_NTP + // Timezone info + String _timezoneName = ""; +#endif + + unsigned long _configPortalTimeout = 0; + + unsigned long _connectTimeout = 0; + unsigned long _configPortalStart = 0; + + int numberOfNetworks; + int *networkIndices; + + WiFiResult *wifiSSIDs; + wifi_ssid_count_t wifiSSIDCount; + bool wifiSSIDscan; + + // To enable dynamic/random channel + // default to channel 1 + #define MIN_WIFI_CHANNEL 1 + #define MAX_WIFI_CHANNEL 11 // Channel 12,13 is flaky, because of bad number 13 ;-) + + int _WiFiAPChannel = 1; + ////// + + WiFi_AP_IPConfig _WiFi_AP_IPconfig; + + WiFi_STA_IPConfig _WiFi_STA_IPconfig = { IPAddress(0, 0, 0, 0), IPAddress(192, 168, 2, 1), IPAddress(255, 255, 255, 0), + IPAddress(192, 168, 2, 1), IPAddress(8, 8, 8, 8) }; + + int _paramsCount = 0; + int _minimumQuality = -1; + bool _removeDuplicateAPs = true; + bool _shouldBreakAfterConfig = false; + bool _tryWPS = false; + + const char* _customHeadElement = ""; + + int status = WL_IDLE_STATUS; + + // New from v1.1.0, for configure CORS Header, default to WM_HTTP_CORS_ALLOW_ALL = "*" +#if USING_CORS_FEATURE + const char* _CORS_Header = WM_HTTP_CORS_ALLOW_ALL; //"*"; +#endif + ////// + + void setWifiStaticIP(); + + // New v1.1.0 + int reconnectWifi(); + ////// + + int connectWifi(const String& ssid = "", const String& pass = ""); + + wl_status_t waitForConnectResult(); + + void setInfo(); + String networkListAsString(); + + void handleRoot(AsyncWebServerRequest *request); + void handleWifi(AsyncWebServerRequest *request); + void handleWifiSave(AsyncWebServerRequest *request); + void handleServerClose(AsyncWebServerRequest *request); + void handleInfo(AsyncWebServerRequest *request); + void handleState(AsyncWebServerRequest *request); + void handleScan(AsyncWebServerRequest *request); + void handleReset(AsyncWebServerRequest *request); + void handleNotFound(AsyncWebServerRequest *request); + bool captivePortal(AsyncWebServerRequest *request); + + void reportStatus(String &page); + + // DNS server + const byte DNS_PORT = 53; + + //helpers + int getRSSIasQuality(int RSSI); + bool isIp(const String& str); + String toStringIp(const IPAddress& ip); + + bool connect; + bool stopConfigPortal = false; + + bool _debug = false; //true; + + void(*_apcallback)(ESPAsync_WiFiManager*) = NULL; + void(*_savecallback)() = NULL; + +#if USE_DYNAMIC_PARAMS + int _max_params; + ESPAsync_WMParameter** _params; +#else + ESPAsync_WMParameter* _params[WIFI_MANAGER_MAX_PARAMS]; +#endif + + template + void DEBUG_WM(Generic text); + + template + auto optionalIPFromString(T *obj, const char *s) -> decltype(obj->fromString(s)) + { + return obj->fromString(s); + } + + auto optionalIPFromString(...) -> bool + { + LOGINFO("NO fromString METHOD ON IPAddress, you need ESP8266 core 2.1.0+ for Custom IP configuration to work."); + return false; + } +}; + +#endif // ESPAsync_WiFiManager_hpp + diff --git a/src/ESPAsync_WiFiManager_Debug.h b/src/ESPAsync_WiFiManager_Debug.h index 6558e682..b640b41f 100644 --- a/src/ESPAsync_WiFiManager_Debug.h +++ b/src/ESPAsync_WiFiManager_Debug.h @@ -14,7 +14,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/ESPAsync_WiFiManager Licensed under MIT license - Version: 1.10.0 + Version: 1.11.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -48,6 +48,7 @@ 1.9.7 K Hoang 30/11/2021 Fix bug to permit using HTTP port different from 80 1.9.8 K Hoang 01/12/2021 Fix bug returning IP `255.255.255.255` in core v2.0.0+ when using `hostname` 1.10.0 K Hoang 29/12/2021 Fix `multiple-definitions` linker error and weird bug related to src_cpp + 1.11.0 K Hoang 17/01/2022 Enable compatibility with old code to include only ESP_WiFiManager.h *****************************************************************************************************************************/ #pragma once