diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0c58385..c23ae49 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,7 +15,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p Please ensure to specify the following: * Arduino IDE version (e.g. 1.8.19) or Platform.io version -* `ESP8266` or `ESP32` Core Version (e.g. ESP8266 core v3.0.2 or ESP32 v2.0.2) +* Board Core Version (e.g. ESP8266 core v3.0.2, ESP32 core v2.0.2) * Contextual information (e.g. what you were trying to achieve) * Simplest possible steps to reproduce * Anything that might be relevant in your opinion, such as: @@ -27,9 +27,10 @@ Please ensure to specify the following: ``` Arduino IDE version: 1.8.19 -ESP8266 Core Version 3.0.2 +ESP32_DEV board +ESP32 core v2.0.2 OS: Ubuntu 20.04 LTS -Linux xy-Inspiron-3593 5.4.0-99-generic #112-Ubuntu SMP Thu Feb 3 13:50:55 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux +Linux xy-Inspiron-3593 5.4.0-100-generic #113-Ubuntu SMP Thu Feb 3 18:43:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux Context: The board couldn't autoreconnect to Local Blynk Server after router power recycling. diff --git a/README.md b/README.md index 2881634..39a478f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing) [![GitHub issues](https://img.shields.io/github/issues/khoih-prog/ESP_WiFiManager_Lite.svg)](http://github.com/khoih-prog/ESP_WiFiManager_Lite/issues) -Buy Me A Coffee +Donate to my libraries using BuyMeACoffee + --- --- @@ -49,6 +50,7 @@ * [13. To avoid blocking in loop when WiFi is lost](#13-To-avoid-blocking-in-loop-when-wifi-is-lost) * [13.1 Max times to try WiFi per loop](#131-max-times-to-try-wifi-per-loop) * [13.2 Interval between reconnection WiFi if lost](#132-interval-between-reconnection-wifi-if-lost) + * [14. Not using Board_Name on Config_Portal](#14-Not-using-Board_Name-on-Config_Portal) * [Examples](#examples) * [ 1. ESP_WiFi](examples/ESP_WiFi) * [ 2. ESP_WiFi_MQTT](examples/ESP_WiFi_MQTT) @@ -508,6 +510,19 @@ Check [retries block the main loop #18](https://github.com/khoih-prog/WiFiManage #define WIFI_RECON_INTERVAL 30000 // 30s ``` +#### 14. Not using Board_Name on Config_Portal + +Default is `true`. Just change to `false` to Not using `Board_Name` on Config_Portal + +``` +///////////////////////////////////////////// + +// Optional, to use Board Name in Menu +#define USING_BOARD_NAME false + +///////////////////////////////////////////// +``` + --- --- @@ -791,14 +806,21 @@ Please take a look at other examples, as well. #include "Credentials.h" #include "dynamicParams.h" +ESP_WiFiManager_Lite* ESP_WiFiManager; + void heartBeatPrint() { static int num = 1; if (WiFi.status() == WL_CONNECTED) - Serial.print(F("H")); // H means connected to WiFi + Serial.print("H"); // H means connected to WiFi else - Serial.print(F("F")); // F means not connected to WiFi + { + if (ESP_WiFiManager->isConfigMode()) + Serial.print("C"); // C means in Config Mode + else + Serial.print("F"); // F means not connected to WiFi + } if (num == 80) { @@ -825,9 +847,6 @@ void check_status() } } -ESP_WiFiManager_Lite* ESP_WiFiManager; - - #if USING_CUSTOMS_STYLE const char NewCustomsStyle[] /*PROGMEM*/ = ""; @@ -853,6 +872,12 @@ void setup() ESP_WiFiManager = new ESP_WiFiManager_Lite(); + String AP_SSID = "your_customized_ssid"; + String AP_PWD = "your_customized_pwd"; + + // Set customized AP SSID and PWD + ESP_WiFiManager->setConfigPortal(AP_SSID, AP_PWD); + // Optional to change default AP IP(192.168.4.1) and channel(10) //ESP_WiFiManager->setConfigPortalIP(IPAddress(192, 168, 120, 1)); ESP_WiFiManager->setConfigPortalChannel(0); @@ -1041,6 +1066,11 @@ void loop() ///////////////////////////////////////////// +// Optional, to use Board Name in Menu +#define USING_BOARD_NAME true + +///////////////////////////////////////////// + #include #if ESP8266 @@ -1233,7 +1263,7 @@ This is the terminal output when running [**ESP_WiFi**](examples/ESP_WiFi) examp ``` Starting ESP_WiFi using LittleFS on ESP32_DEV -ESP_WiFiManager_Lite v1.8.1 +ESP_WiFiManager_Lite v1.8.2 ESP_MultiResetDetector v1.3.0 LittleFS Flag read = 0xFFFC0003 multiResetDetectorFlag = 0xFFFC0003 @@ -1289,7 +1319,7 @@ Saving config file OK stConf:SSID=ESP_9ABF498,PW=MyESP_9ABF498 [WML] IP=192.168.4.1,ch=10 [WML] s:millis() = 1014, configTimeout = 121014 -F +C Your stored Credentials : Blynk Server1 = new.duckdns.org Token1 = token1 @@ -1297,14 +1327,14 @@ Blynk Server2 = new.ddns.net Token2 = token2 Port = 8080 MQTT Server = mqtt.duckdns.org -FFFFFFFFF +CCCCCCCCC ``` #### 1.2. Got valid Credentials from Config Portal then connected to WiFi ``` Starting ESP_WiFi using LittleFS on ESP32_DEV -ESP_WiFiManager_Lite v1.8.1 +ESP_WiFiManager_Lite v1.8.2 ESP_MultiResetDetector v1.3.0 LittleFS Flag read = 0xFFFE0001 multiResetDetectorFlag = 0xFFFE0001 @@ -1376,7 +1406,7 @@ This is the terminal output when running [**ESP_WiFi_MQTT**](examples/ESP_WiFi_M ``` Starting ESP_WiFi_MQTT using LittleFS on ESP8266_NODEMCU -ESP_WiFiManager_Lite v1.8.1 +ESP_WiFiManager_Lite v1.8.2 ESP_MultiResetDetector v1.3.0 LittleFS Flag read = 0xFFFE0001 multiResetDetectorFlag = 0xFFFE0001 @@ -1419,7 +1449,7 @@ Saving config file OK [WML] OK [WML] SaveBkUpCPFile [WML] OK -N +C Your stored Credentials : AIO_SERVER = blank AIO_SERVERPORT = blank @@ -1430,7 +1460,7 @@ AIO_SUB_TOPIC = blank NStop multiResetDetecting Saving config file... Saving config file OK -NNN +CCC ``` #### 2.2. Got valid Credentials from Config Portal then connected to WiFi @@ -1451,7 +1481,7 @@ NNN Starting ESP_WiFi_MQTT using LittleFS on ESP8266_NODEMCU -ESP_WiFiManager_Lite v1.8.1 +ESP_WiFiManager_Lite v1.8.2 ESP_MultiResetDetector v1.3.0 LittleFS Flag read = 0xFFFE0001 multiResetDetectorFlag = 0xFFFE0001 @@ -1543,7 +1573,7 @@ This is the terminal output when running [**ESP_WiFi_MQTT**](examples/ESP_WiFi_M ``` Starting ESP_WiFi_MQTT using LittleFS on ESP32S2_DEV -ESP_WiFiManager_Lite v1.8.1 +ESP_WiFiManager_Lite v1.8.2 ESP_MultiResetDetector v1.3.0 LittleFS Flag read = 0xFFFE0001 multiResetDetectorFlag = 0xFFFE0001 @@ -1567,7 +1597,7 @@ Saving config file OK stConf:SSID=ESP_8A1DF7C,PW=MyESP_8A1DF7C [WML] IP=192.168.4.1,ch=1 [WML] s:configTimeout = 0 -N +C Your stored Credentials : AIO_SERVER = io.adafruit.com AIO_SERVERPORT = 1883 @@ -1578,7 +1608,7 @@ AIO_SUB_TOPIC = /feeds/LED_Control NStop multiResetDetecting Saving config file... Saving config file OK -NNN N +CCC C ``` #### 3.2. Got valid Credentials from Config Portal then connected to WiFi @@ -1656,7 +1686,7 @@ entry 0x4004c190 Starting ESP_WiFi_MQTT using LittleFS on ESP32S2_DEV -ESP_WiFiManager_Lite v1.8.1 +ESP_WiFiManager_Lite v1.8.2 ESP_MultiResetDetector v1.3.0 LittleFS Flag read = 0xFFFE0001 multiResetDetectorFlag = 0xFFFE0001 @@ -1758,7 +1788,7 @@ This is the terminal output when running [**ESP_WiFi_MQTT**](examples/ESP_WiFi_M ``` Starting ESP_WiFi_MQTT using LittleFS on ESP32S2_DEV -ESP_WiFiManager_Lite v1.8.1 +ESP_WiFiManager_Lite v1.8.2 ESP_MultiResetDetector v1.3.0 LittleFS Flag read = 0xFFFC0003 multiResetDetectorFlag = 0xFFFC0003 @@ -1769,7 +1799,7 @@ Saving config file OK [WML] stConf:SSID=ESP_8A1DF7C,PW=MyESP_8A1DF7C [WML] IP=192.168.4.1,ch=3 -N +C Your stored Credentials : AIO_SERVER = io.adafruit.com AIO_SERVERPORT = 1883 @@ -1786,7 +1816,7 @@ NNNN NNNNN NNNNN NNNNN NN[WML] h:UpdLittleFS ``` Starting ESP_WiFi_MQTT using LittleFS on ESP32S2_DEV -ESP_WiFiManager_Lite v1.8.1 +ESP_WiFiManager_Lite v1.8.2 ESP_MultiResetDetector v1.3.0 LittleFS Flag read = 0xFFFE0001 multiResetDetectorFlag = 0xFFFE0001 @@ -1842,7 +1872,7 @@ This is the terminal output when running [**ESP_WiFi**](examples/ESP_WiFi) examp ``` Starting ESP_WiFi_MQTT using LittleFS on ESP32_DEV -ESP_WiFiManager_Lite v1.8.1 +ESP_WiFiManager_Lite v1.8.2 ESP_MultiResetDetector v1.3.0 LittleFS Flag read = 0xFFFC0003 multiResetDetectorFlag = 0xFFFC0003 @@ -1871,7 +1901,7 @@ Saving config file OK [WML] stConf:SSID=ESP_9ABF498,PW=MyESP_9ABF498 [WML] IP=192.168.4.1,ch=11 -N +C Your stored Credentials : AIO_SERVER = io.adafruit.com AIO_SERVERPORT = 1883 @@ -1879,14 +1909,14 @@ AIO_USERNAME = private AIO_KEY = private AIO_PUB_TOPIC = /feeds/Temperature AIO_SUB_TOPIC = /feeds/LED_Control -N +CCC ``` ### 5.2 Config Data Saved => Connection to Adafruit MQTT ``` Starting ESP_WiFi_MQTT using LittleFS on ESP32_DEV -ESP_WiFiManager_Lite v1.8.1 +ESP_WiFiManager_Lite v1.8.2 ESP_MultiResetDetector v1.3.0 LittleFS Flag read = 0xFFFE0001 multiResetDetectorFlag = 0xFFFE0001 @@ -1934,7 +1964,7 @@ This is the terminal output when running [**ESP_WiFi**](examples/ESP_WiFi) examp ``` Starting ESP_WiFi using LittleFS on ESP32S3_DEV -ESP_WiFiManager_Lite v1.8.1 +ESP_WiFiManager_Lite v1.8.2 ESP_MultiResetDetector v1.3.0 LittleFS Flag read = 0xFFFE0001 multiResetDetectorFlag = 0xFFFE0001 @@ -1976,7 +2006,7 @@ This is the terminal output when running [**ESP_WiFi**](examples/ESP_WiFi) examp ``` Starting ESP_WiFi using LittleFS on ESP32C3_DEV -ESP_WiFiManager_Lite v1.8.1 +ESP_WiFiManager_Lite v1.8.2 ESP_MultiResetDetector v1.3.0 LittleFS Flag read = 0xFFFE0001 multiResetDetectorFlag = 0xFFFE0001 @@ -2086,6 +2116,9 @@ Submit issues to: [ESP_WiFiManager_Lite issues](https://github.com/khoih-prog/ES 28. Add support to **ESP32-S3 (ESP32S3_DEV, ESP32_S3_BOX, UM TINYS3, UM PROS3, UM FEATHERS3, etc.) using EEPROM, SPIFFS or LittleFS** 29. Add `LittleFS` support to **ESP32-C3** 30. Use `ESP32-core's LittleFS` library instead of `Lorol's LITTLEFS` library for ESP32 core v2.0.0+ +31. Optimize code by passing by `reference` instead of `value` +32. Optional `Board_Name` in Config Portal +33. Add function `isConfigMode()` to signal system is in Config Portal mode --- --- diff --git a/changelog.md b/changelog.md index 8281313..47e3dc3 100644 --- a/changelog.md +++ b/changelog.md @@ -12,6 +12,7 @@ ## Table of Contents * [Changelog](#changelog) + * [Release v1.8.2](#release-v182) * [Release v1.8.1](#release-v181) * [Release v1.8.0](#release-v180) * [Release v1.7.0](#release-v170) @@ -29,6 +30,12 @@ ## Changelog +### Release v1.8.2 + +1. Optimize code by using passing by `reference` instead of by `value` +2. Optional `Board_Name` in Menu. Check [option to remove board name from web page #25](https://github.com/khoih-prog/WiFiManager_NINA_Lite/issues/25) +3. Add function `isConfigMode()` to signal system is in Config Portal mode. + ### Release v1.8.1 1. Add LittleFS support to `ESP32-C3`. diff --git a/examples/ESP_WiFi/ESP_WiFi.ino b/examples/ESP_WiFi/ESP_WiFi.ino index cf39a04..0ad8771 100644 --- a/examples/ESP_WiFi/ESP_WiFi.ino +++ b/examples/ESP_WiFi/ESP_WiFi.ino @@ -14,14 +14,21 @@ #include "Credentials.h" #include "dynamicParams.h" +ESP_WiFiManager_Lite* ESP_WiFiManager; + void heartBeatPrint() { static int num = 1; if (WiFi.status() == WL_CONNECTED) - Serial.print(F("H")); // H means connected to WiFi + Serial.print("H"); // H means connected to WiFi else - Serial.print(F("F")); // F means not connected to WiFi + { + if (ESP_WiFiManager->isConfigMode()) + Serial.print("C"); // C means in Config Mode + else + Serial.print("F"); // F means not connected to WiFi + } if (num == 80) { @@ -48,9 +55,6 @@ void check_status() } } -ESP_WiFiManager_Lite* ESP_WiFiManager; - - #if USING_CUSTOMS_STYLE const char NewCustomsStyle[] /*PROGMEM*/ = ""; diff --git a/examples/ESP_WiFi/defines.h b/examples/ESP_WiFi/defines.h index 1955e02..4e9a6e5 100644 --- a/examples/ESP_WiFi/defines.h +++ b/examples/ESP_WiFi/defines.h @@ -124,6 +124,11 @@ ///////////////////////////////////////////// +// Optional, to use Board Name in Menu +#define USING_BOARD_NAME true + +///////////////////////////////////////////// + #include #if ESP8266 diff --git a/examples/ESP_WiFi_MQTT/ESP_WiFi_MQTT.ino b/examples/ESP_WiFi_MQTT/ESP_WiFi_MQTT.ino index f116f98..61ff771 100644 --- a/examples/ESP_WiFi_MQTT/ESP_WiFi_MQTT.ino +++ b/examples/ESP_WiFi_MQTT/ESP_WiFi_MQTT.ino @@ -52,9 +52,14 @@ void heartBeatPrint() static int num = 1; if (WiFi.status() == WL_CONNECTED) - Serial.print("W"); // W means connected to WiFi + Serial.print("H"); // H means connected to WiFi else - Serial.print("N"); // N means not connected to WiFi + { + if (ESP_WiFiManager->isConfigMode()) + Serial.print("C"); // C means in Config Mode + else + Serial.print("F"); // F means not connected to WiFi + } if (num == 40) { diff --git a/examples/ESP_WiFi_MQTT/defines.h b/examples/ESP_WiFi_MQTT/defines.h index 1cd4ed6..1cc3ff6 100644 --- a/examples/ESP_WiFi_MQTT/defines.h +++ b/examples/ESP_WiFi_MQTT/defines.h @@ -118,6 +118,11 @@ ///////////////////////////////////////////// +// Optional, to use Board Name in Menu +#define USING_BOARD_NAME true + +///////////////////////////////////////////// + #include #if ESP8266 diff --git a/keywords.txt b/keywords.txt index fd88ad2..6fa0998 100644 --- a/keywords.txt +++ b/keywords.txt @@ -31,6 +31,7 @@ getFullConfigData KEYWORD2 localIP KEYWORD2 clearConfigData KEYWORD2 isConfigDataValid KEYWORD2 +isConfigMode KEYWORD2 resetFunc KEYWORD2 resetAndEnterConfigPortal KEYWORD2 resetAndEnterConfigPortalPersistent KEYWORD2 @@ -80,3 +81,12 @@ WM_HTTP_NO_CACHE LITERAL1 WM_HTTP_EXPIRES LITERAL1 WM_HTTP_CORS LITERAL1 WM_HTTP_CORS_ALLOW_ALL LITERAL1 + +LED_ON LITERAL1 +LED_OFF LITERAL1 + +USING_BOARD_NAME LITERAL1 + +FORCED_CONFIG_PORTAL_FLAG_DATA LITERAL1 +FORCED_PERS_CONFIG_PORTAL_FLAG_DATA LITERAL1 +FORCED_CONFIG_PORTAL_FLAG_DATA_SIZE LITERAL1 diff --git a/library.json b/library.json index 1455121..35f0ca3 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ESP_WiFiManager_Lite", - "version": "1.8.1", + "version": "1.8.2", "keywords": "wifi, wi-fi, MultiWiFi, multi-wifi, WiFiManager, esp8266, esp32, esp32-s2, esp32-s3, esp32-c3, Communication, iot, credentials, persistent, config-portal, DoubleReset, MultiReset, DoubleResetDetector, littlefs, spiffs, eeprom, light-weight", "description": "Library to configure MultiWiFi/Credentials at runtime for ESP32 (including ESP32-S2, ESP32-S3 and ESP32-C3) and ESP8266 boards. You can also specify DHCP HostName, static AP and STA IP. Use much less memory compared to full-fledge WiFiManager. Config Portal will be auto-adjusted to match the number of dynamic custom parameters. Optional default Credentials to be autoloaded into Config Portal to use or change instead of manually input. Credentials are saved in LittleFS, SPIFFS or EEPROM. New powerful-yet-simple-to-use feature to enable adding dynamic custom parameters from sketch and input using the same Config Portal. Double or MultiDetectDetector as well as Virtual Switches feature permits entering Config Portal as requested. Configurable Customs HTML Headers, including Customs Style, Customs Head Elements, CORS Header", "authors": diff --git a/library.properties b/library.properties index 6f28f7b..00aed5b 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=ESP_WiFiManager_Lite -version=1.8.1 +version=1.8.2 author=Khoi Hoang maintainer=Khoi Hoang license=MIT diff --git a/src/ESP_WiFiManager_Lite.h b/src/ESP_WiFiManager_Lite.h index 54954c5..ad2d0ba 100644 --- a/src/ESP_WiFiManager_Lite.h +++ b/src/ESP_WiFiManager_Lite.h @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/ESP_WiFiManager_Lite Licensed under MIT license - Version: 1.8.1 + Version: 1.8.2 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -23,7 +23,8 @@ 1.6.0 K Hoang 26/11/2021 Auto detect ESP32 core and use either built-in LittleFS or LITTLEFS library. Fix bug. 1.7.0 K Hoang 08/01/2022 Fix the blocking issue in loop() with configurable WIFI_RECON_INTERVAL 1.8.0 K Hoang 10/02/2022 Add support to new ESP32-S3 - 1.8.1 K Hoang 11/02/2022 Add LittleFS support to ESP32-C3. Use core LittleFS instead of Lorol's LITTLEFS for v2.0.0+ + 1.8.1 K Hoang 11/02/2022 Add LittleFS support to ESP32-C3. Use core LittleFS instead of Lorol's LITTLEFS for v2.0.0+ + 1.8.2 K Hoang 21/02/2022 Optional Board_Name in Menu. Optimize code by using passing by reference *****************************************************************************************************************************/ #pragma once @@ -54,13 +55,13 @@ #endif #ifndef ESP_WIFI_MANAGER_LITE_VERSION - #define ESP_WIFI_MANAGER_LITE_VERSION "ESP_WiFiManager_Lite v1.8.1" + #define ESP_WIFI_MANAGER_LITE_VERSION "ESP_WiFiManager_Lite v1.8.2" #define ESP_WIFI_MANAGER_LITE_VERSION_MAJOR 1 #define ESP_WIFI_MANAGER_LITE_VERSION_MINOR 8 - #define ESP_WIFI_MANAGER_LITE_VERSION_PATCH 1 + #define ESP_WIFI_MANAGER_LITE_VERSION_PATCH 2 - #define ESP_WIFI_MANAGER_LITE_VERSION_INT 1008001 + #define ESP_WIFI_MANAGER_LITE_VERSION_INT 1008002 #endif #ifdef ESP8266 @@ -357,8 +358,14 @@ typedef struct #define NUM_WIFI_CREDENTIALS 2 -// Configurable items besides fixed Header, just add board_name -#define NUM_CONFIGURABLE_ITEMS ( ( 2 * NUM_WIFI_CREDENTIALS ) + 1 ) +#if USING_BOARD_NAME + // Configurable items besides fixed Header, just add board_name + #define NUM_CONFIGURABLE_ITEMS ( ( 2 * NUM_WIFI_CREDENTIALS ) + 1 ) +#else + // Configurable items besides fixed Header, just add board_name + #define NUM_CONFIGURABLE_ITEMS ( ( 2 * NUM_WIFI_CREDENTIALS )) +#endif + //////////////// #define HEADER_MAX_LEN 16 @@ -385,12 +392,20 @@ const char ESP_WM_LITE_HTML_HEAD_START[] /*PROGMEM*/ = "div,input{padding:5px;font-size:1em;}input{width:95%;}body{text-align: center;}button{background-color:#16A1E7;color:#fff;line-height:2.4rem;font-size:1.2rem;width:100%;}fieldset{border-radius:0.3rem;margin:0px;}"; +#if USING_BOARD_NAME const char ESP_WM_LITE_HTML_HEAD_END[] /*PROGMEM*/ = "
\
[[input_id]]
\
\
[[input_id1]]
\
\
"; // DO NOT CHANGE THIS STRING EVER!!!! +#else +const char ESP_WM_LITE_HTML_HEAD_END[] /*PROGMEM*/ = "
\ +
[[input_id]]
\ +
\ +
[[input_id1]]
\ +
"; // DO NOT CHANGE THIS STRING EVER!!!! +#endif const char ESP_WM_LITE_HTML_INPUT_ID[] /*PROGMEM*/ = ""; const char ESP_WM_LITE_HTML_INPUT_ID1[] /*PROGMEM*/ = ""; @@ -399,12 +414,21 @@ const char ESP_WM_LITE_FLDSET_START[] /*PROGMEM*/ = "
"; const char ESP_WM_LITE_FLDSET_END[] /*PROGMEM*/ = "
"; const char ESP_WM_LITE_HTML_PARAM[] /*PROGMEM*/ = "
"; const char ESP_WM_LITE_HTML_BUTTON[] /*PROGMEM*/ = "
"; + +#if USING_BOARD_NAME const char ESP_WM_LITE_HTML_SCRIPT[] /*PROGMEM*/ = ""; @@ -438,7 +462,7 @@ const char WM_HTTP_CORS_ALLOW_ALL[] /*PROGMEM*/ = "*"; ////////////////////////////////////////// -String IPAddressToString(IPAddress _address) +String IPAddressToString(const IPAddress& _address) { String str = String(_address[0]); str += "."; @@ -889,14 +913,14 @@ class ESP_WiFiManager_Lite ////////////////////////////////////////////// - void setConfigPortalIP(IPAddress portalIP = IPAddress(192, 168, 4, 1)) + void setConfigPortalIP(const IPAddress& portalIP = IPAddress(192, 168, 4, 1)) { portal_apIP = portalIP; } ////////////////////////////////////////////// - void setConfigPortal(String ssid = "", String pass = "") + void setConfigPortal(const String& ssid = "", const String& pass = "") { portal_ssid = ssid; portal_pass = pass; @@ -907,7 +931,7 @@ class ESP_WiFiManager_Lite #define MIN_WIFI_CHANNEL 1 #define MAX_WIFI_CHANNEL 11 // Channel 13 is flaky, because of bad number 13 ;-) - int setConfigPortalChannel(int channel = 1) + int setConfigPortalChannel(const int& channel = 1) { // If channel < MIN_WIFI_CHANNEL - 1 or channel > MAX_WIFI_CHANNEL => channel = 1 // If channel == 0 => will use random channel from MIN_WIFI_CHANNEL to MAX_WIFI_CHANNEL @@ -922,9 +946,10 @@ class ESP_WiFiManager_Lite ////////////////////////////////////////////// - void setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn = IPAddress(255, 255, 255, 0), - IPAddress dns_address_1 = IPAddress(0, 0, 0, 0), - IPAddress dns_address_2 = IPAddress(0, 0, 0, 0)) + void setSTAStaticIPConfig(const IPAddress& ip, const IPAddress& gw, + const IPAddress& sn = IPAddress(255, 255, 255, 0), + const IPAddress& dns_address_1 = IPAddress(0, 0, 0, 0), + const IPAddress& dns_address_2 = IPAddress(0, 0, 0, 0)) { static_IP = ip; static_GW = gw; @@ -945,7 +970,7 @@ class ESP_WiFiManager_Lite ////////////////////////////////////////////// - String getWiFiSSID(uint8_t index) + String getWiFiSSID(const uint8_t& index) { if (index >= NUM_WIFI_CREDENTIALS) return String(""); @@ -958,7 +983,7 @@ class ESP_WiFiManager_Lite ////////////////////////////////////////////// - String getWiFiPW(uint8_t index) + String getWiFiPW(const uint8_t& index) { if (index >= NUM_WIFI_CREDENTIALS) return String(""); @@ -1035,6 +1060,13 @@ class ESP_WiFiManager_Lite ////////////////////////////////////////////// + bool isConfigMode() + { + return configuration_mode; + } + + ////////////////////////////////////////////// + // Forced CP => Flag = 0xBEEFBEEF. Else => No forced CP // Flag to be stored at (EEPROM_START + DRD_FLAG_DATA_SIZE + CONFIG_DATA_SIZE) // to avoid corruption to current data @@ -1245,7 +1277,7 @@ class ESP_WiFiManager_Lite ////////////////////////////////////// - void displayConfigData(ESP_WM_LITE_Configuration configData) + void displayConfigData(const ESP_WM_LITE_Configuration& configData) { ESP_WML_LOGERROR5(F("Hdr="), configData.header, F(",SSID="), configData.WiFi_Creds[0].wifi_ssid, F(",PW="), configData.WiFi_Creds[0].wifi_pw); @@ -1338,7 +1370,7 @@ class ESP_WiFiManager_Lite ////////////////////////////////////////////// - void saveForcedCP(uint32_t value) + void saveForcedCP(const uint32_t& value) { File file = FileFS.open(CONFIG_PORTAL_FILENAME, "w"); @@ -1374,7 +1406,7 @@ class ESP_WiFiManager_Lite ////////////////////////////////////////////// - void setForcedCP(bool isPersistent) + void setForcedCP(const bool& isPersistent) { uint32_t readForcedConfigPortalFlag = isPersistent? FORCED_PERS_CONFIG_PORTAL_FLAG_DATA : FORCED_CONFIG_PORTAL_FLAG_DATA; @@ -1476,6 +1508,7 @@ class ESP_WiFiManager_Lite // We dont like to destroy myMenuItems[i].pdata with invalid data uint16_t maxBufferLength = 0; + for (uint16_t i = 0; i < NUM_MENU_ITEMS; i++) { if (myMenuItems[i].maxlen > maxBufferLength) @@ -1976,7 +2009,7 @@ class ESP_WiFiManager_Lite ////////////////////////////////////////////// - void setForcedCP(bool isPersistent) + void setForcedCP(const bool& isPersistent) { uint32_t readForcedConfigPortalFlag = isPersistent? FORCED_PERS_CONFIG_PORTAL_FLAG_DATA : FORCED_CONFIG_PORTAL_FLAG_DATA; @@ -2573,7 +2606,10 @@ class ESP_WiFiManager_Lite result.replace("[[pw]]", ESP_WM_LITE_config.WiFi_Creds[0].wifi_pw); result.replace("[[id1]]", ESP_WM_LITE_config.WiFi_Creds[1].wifi_ssid); result.replace("[[pw1]]", ESP_WM_LITE_config.WiFi_Creds[1].wifi_pw); + +#if USING_BOARD_NAME result.replace("[[nm]]", ESP_WM_LITE_config.board_name); +#endif } else { @@ -2581,7 +2617,10 @@ class ESP_WiFiManager_Lite result.replace("[[pw]]", ""); result.replace("[[id1]]", ""); result.replace("[[pw1]]", ""); + +#if USING_BOARD_NAME result.replace("[[nm]]", ""); +#endif } #if USE_DYNAMIC_PARAMETERS @@ -2633,7 +2672,10 @@ class ESP_WiFiManager_Lite static bool pw_Updated = false; static bool id1_Updated = false; static bool pw1_Updated = false; + +#if USING_BOARD_NAME static bool nm_Updated = false; +#endif if (!id_Updated && (key == String("id"))) { @@ -2683,18 +2725,19 @@ class ESP_WiFiManager_Lite else strncpy(ESP_WM_LITE_config.WiFi_Creds[1].wifi_pw, value.c_str(), sizeof(ESP_WM_LITE_config.WiFi_Creds[1].wifi_pw) - 1); } +#if USING_BOARD_NAME else if (!nm_Updated && (key == String("nm"))) { ESP_WML_LOGDEBUG(F("h:repl nm")); nm_Updated = true; number_items_Updated++; - if (strlen(value.c_str()) < sizeof(ESP_WM_LITE_config.board_name) - 1) strcpy(ESP_WM_LITE_config.board_name, value.c_str()); else strncpy(ESP_WM_LITE_config.board_name, value.c_str(), sizeof(ESP_WM_LITE_config.board_name) - 1); - } + } +#endif #if USE_DYNAMIC_PARAMETERS else @@ -2870,7 +2913,7 @@ class ESP_WiFiManager_Lite ////////////////////////////////////////// - void setMinimumSignalQuality(int quality) + void setMinimumSignalQuality(const int& quality) { _minimumQuality = quality; } @@ -2878,7 +2921,7 @@ class ESP_WiFiManager_Lite ////////////////////////////////////////// //if this is true, remove duplicate Access Points - default true - void setRemoveDuplicateAPs(bool removeDuplicates) + void setRemoveDuplicateAPs(const bool& removeDuplicates) { _removeDuplicateAPs = removeDuplicates; } @@ -2998,7 +3041,7 @@ class ESP_WiFiManager_Lite ////////////////////////////////////////// - int getRSSIasQuality(int RSSI) + int getRSSIasQuality(const int& RSSI) { int quality = 0; diff --git a/src/ESP_WiFiManager_Lite_Debug.h b/src/ESP_WiFiManager_Lite_Debug.h index bf85255..63dd316 100644 --- a/src/ESP_WiFiManager_Lite_Debug.h +++ b/src/ESP_WiFiManager_Lite_Debug.h @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/ESP_WiFiManager_Lite Licensed under MIT license - Version: 1.8.1 + Version: 1.8.2 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -23,7 +23,8 @@ 1.6.0 K Hoang 26/11/2021 Auto detect ESP32 core and use either built-in LittleFS or LITTLEFS library. Fix bug. 1.7.0 K Hoang 08/01/2022 Fix the blocking issue in loop() with configurable WIFI_RECON_INTERVAL 1.8.0 K Hoang 10/02/2022 Add support to new ESP32-S3 - 1.8.1 K Hoang 11/02/2022 Add LittleFS support to ESP32-C3. Use core LittleFS instead of Lorol's LITTLEFS for v2.0.0+ + 1.8.1 K Hoang 11/02/2022 Add LittleFS support to ESP32-C3. Use core LittleFS instead of Lorol's LITTLEFS for v2.0.0+ + 1.8.2 K Hoang 21/02/2022 Optional Board_Name in Menu. Optimize code by using passing by reference *****************************************************************************************************************************/ #ifndef ESP_WiFiManager_Lite_Debug_h