diff --git a/CMakeLists.txt b/CMakeLists.txt index 70400c4..a824e99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,8 @@ file(GLOB SRCFILES Logger.cpp # include/RTOS.h lib/WiFiManager/WiFiManager.cpp + lib/WiFiManager/wm_consts_en.h + lib/WiFiManager/wm_strings_en.h lib/Crc16/Crc16.h lib/nuki_ble/src/NukiBle.cpp lib/nuki_ble/src/NukiBle.hpp diff --git a/lib/WiFiManager/.travis.yml b/lib/WiFiManager/.travis.yml deleted file mode 100644 index 17dd5e3..0000000 --- a/lib/WiFiManager/.travis.yml +++ /dev/null @@ -1,42 +0,0 @@ -language: c -sudo: false - -before_install: - - "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16" - - sleep 3 - - export DISPLAY=:1.0 - - wget http://downloads.arduino.cc/arduino-1.8.10-linux64.tar.xz - - tar xf arduino-1.8.10-linux64.tar.xz - - sudo mv arduino-1.8.10 /usr/local/share/arduino - - sudo ln -s /usr/local/share/arduino/arduino /usr/local/bin/arduino - -install: - - ln -s $PWD /usr/local/share/arduino/libraries/WiFiManager - - arduino --pref "boardsmanager.additional.urls=http://arduino.esp8266.com/stable/package_esp8266com_index.json,http://dl.espressif.com/dl/package_esp32_index.json" --save-prefs - - arduino --install-library "ArduinoJson:6.18.0" - - arduino --install-boards esp8266:esp8266 - - arduino --pref "compiler.warning_level=all" --save-prefs -# install esp32 - - arduino --install-boards esp32:esp32 - -script: - - "echo $PWD" - - "echo $HOME" - - "ls $PWD" - - source $TRAVIS_BUILD_DIR/travis/common.sh - - arduino --board esp8266:esp8266:generic:xtal=80,eesz=4M1M,FlashMode=qio,FlashFreq=80,dbg=Serial,lvl=CORE --save-prefs - - build_examples - - arduino --board esp32:esp32:esp32:FlashFreq=80,FlashSize=4M,DebugLevel=info --save-prefs -# some examples fail (SPIFFS defines differ esp32 vs esp8266) so we exclude them - - build_examples -# - arduino -v --verbose-build --verify $PWD/examples/AutoConnect/AutoConnect.ino - -# no coverage generated, no need to run -# -#after_success: -# - bash <(curl -s https://codecov.io/bash) - -notifications: - email: - on_success: change - on_failure: change diff --git a/lib/WiFiManager/CMakeLists.txt b/lib/WiFiManager/CMakeLists.txt new file mode 100644 index 0000000..7bd408a --- /dev/null +++ b/lib/WiFiManager/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.5) + +idf_component_register( + SRCS "WiFiManager.cpp" + INCLUDE_DIRS "." + REQUIRES arduino +) + +project(WiFiManager) diff --git a/lib/WiFiManager/README.md b/lib/WiFiManager/README.md index 2d6ab65..75c82c3 100644 --- a/lib/WiFiManager/README.md +++ b/lib/WiFiManager/README.md @@ -1,6 +1,5 @@ # WiFiManager -## DEVELOPMENT Version Espressif ESPx WiFi Connection manager with fallback web configuration portal @@ -8,26 +7,25 @@ Espressif ESPx WiFi Connection manager with fallback web configuration portal ![Release](https://img.shields.io/github/v/release/tzapu/WiFiManager?include_prereleases) -![Build CI Status](https://github.com/tzapu/WiFiManager/actions/workflows/compile_library.yml/badge.svg) +[![Build CI Status](https://github.com/tzapu/WiFiManager/actions/workflows/compile_library.yml/badge.svg)](https://github.com/tzapu/WiFiManager/actions/workflows/compile_library.yml) -![Build CI Status Examples](https://github.com/tzapu/WiFiManager/actions/workflows/compile_examples.yaml/badge.svg) +[![Build CI Status Examples](https://github.com/tzapu/WiFiManager/actions/workflows/compile_examples.yaml/badge.svg)](https://github.com/tzapu/WiFiManager/actions/workflows/compile_examples.yaml) [![arduino-library-badge](https://www.ardu-badge.com/badge/WiFiManager.svg?)](https://www.ardu-badge.com/WiFiManager) [![Build with PlatformIO](https://img.shields.io/badge/PlatformIO-Library-orange?)](https://platformio.org/lib/show/567/WiFiManager/installation) -![ESP8266](https://img.shields.io/badge/ESP-8266-000000.svg?longCache=true&style=flat&colorA=CC101F) +[![ESP8266](https://img.shields.io/badge/ESP-8266-000000.svg?longCache=true&style=flat&colorA=CC101F)](https://www.espressif.com/en/products/socs/esp8266) -![ESP32](https://img.shields.io/badge/ESP-32-000000.svg?longCache=true&style=flat&colorA=CC101F) -![ESP32](https://img.shields.io/badge/ESP-32S2-000000.svg?longCache=true&style=flat&colorA=CC101F) -![ESP32](https://img.shields.io/badge/ESP-32C3-000000.svg?longCache=true&style=flat&colorA=CC101F) +[![ESP32](https://img.shields.io/badge/ESP-32-000000.svg?longCache=true&style=flat&colorA=CC101F)](https://www.espressif.com/en/products/socs/esp32) +[![ESP32](https://img.shields.io/badge/ESP-32S2-000000.svg?longCache=true&style=flat&colorA=CC101F)](https://www.espressif.com/en/products/socs/esp32-s2) +[![ESP32](https://img.shields.io/badge/ESP-32C3-000000.svg?longCache=true&style=flat&colorA=CC101F)](https://www.espressif.com/en/products/socs/esp32-c3) Member to Member Support / Chat [![Join the chat at https://gitter.im/tablatronix/WiFiManager](https://badges.gitter.im/tablatronix/WiFiManager.svg)](https://gitter.im/tablatronix/WiFiManager?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![Discord](https://img.shields.io/badge/Discord-WiFiManager-%237289da.svg?logo=discord)](https://discord.gg/dkjJbHwC) - +[![Discord](https://img.shields.io/badge/Discord-WiFiManager-%237289da.svg?logo=discord)](https://discord.gg/nS5WGkaQH5) The configuration portal is of the captive variety, so on various devices it will present the configuration dialogue as soon as you connect to the created access point. **This works with the ESP8266 Arduino platform** @@ -171,8 +169,8 @@ Also see [examples](https://github.com/tzapu/WiFiManager/tree/master/examples). [PlatformIO](https://platformio.org/) is an emerging ecosystem for IoT development, and is an alternative to using the Arduino IDE. Install `WiFiManager` -using the platformio [library manager](https://docs.platformio.org/en/latest/librarymanager/index.htm) in your editor, -or using the [PlatformIO Core CLI](https://docs.platformio.org/en/latest/userguide/demo.html#library-manager), +using the platformio [library manager](https://docs.platformio.org/en/latest/librarymanager/index.html#librarymanager) in your editor, +or using the [PlatformIO Core CLI](https://docs.platformio.org/en/latest/core/index.html), or by adding it to your `platformio.ini` as shown below (recommended approach). The simplest way is to open the `platformio.ini` file at the root of your project, and `WifiManager` to the common top-level env @@ -229,7 +227,7 @@ IF YOU NEED TO SAVE PARAMETERS EVEN ON WIFI FAIL OR EMPTY, you must set `setBrea void setBreakAfterConfig(boolean shouldBreak); ``` -See [AutoConnectWithFSParameters Example](https://github.com/tzapu/WiFiManager/tree/master/examples/AutoConnectWithFSParameters). +See [AutoConnectWithFSParameters Example](https://github.com/tzapu/WiFiManager/tree/master/examples/Parameters/SPIFFS/AutoConnectWithFSParameters). ```cpp wifiManager.setSaveConfigCallback(saveConfigCallback); ``` @@ -269,7 +267,7 @@ void loop() { } } ``` -See example for a more complex version. [OnDemandConfigPortal](https://github.com/tzapu/WiFiManager/tree/master/examples/OnDemandConfigPortal) +See example for a more complex version. [OnDemandConfigPortal](https://github.com/tzapu/WiFiManager/tree/master/examples/OnDemand/OnDemandConfigPortal) #### Exiting from the Configuration Portal Normally, once entered, the configuration portal will continue to loop until WiFi credentials have been successfully entered or a timeout is reached. @@ -291,7 +289,7 @@ Usage scenario would be: ``` - if connection to AP fails, configuration portal starts and you can set /change the values (or use on demand configuration portal) -- once configuration is done and connection is established [save config callback]() is called +- once configuration is done and connection is established save config callback() is called - once WiFiManager returns control to your application, read and save the new values using the `WiFiManagerParameter` object. ```cpp mqtt_server = custom_mqtt_server.getValue(); @@ -299,7 +297,7 @@ Usage scenario would be: This feature is a lot more involved than all the others, so here are some examples to fully show how it is done. You should also take a look at adding custom HTML to your form. -- Save and load custom parameters to file system in json form [AutoConnectWithFSParameters](https://github.com/tzapu/WiFiManager/tree/master/examples/AutoConnectWithFSParameters) +- Save and load custom parameters to file system in json form [AutoConnectWithFSParameters](https://github.com/tzapu/WiFiManager/tree/master/examples/Parameters/SPIFFS/AutoConnectWithFSParameters) - *Save and load custom parameters to EEPROM* (not done yet) #### Custom IP Configuration diff --git a/lib/WiFiManager/WiFiManager.cpp b/lib/WiFiManager/WiFiManager.cpp index 90fdfb1..6d28256 100644 --- a/lib/WiFiManager/WiFiManager.cpp +++ b/lib/WiFiManager/WiFiManager.cpp @@ -33,7 +33,7 @@ WiFiManagerParameter::WiFiManagerParameter(const char *custom) { _id = NULL; _label = NULL; _length = 1; - _value = NULL; + _value = nullptr; _labelPlacement = WFM_LABEL_DEFAULT; _customHTML = custom; } @@ -59,6 +59,8 @@ void WiFiManagerParameter::init(const char *id, const char *label, const char *d _label = label; _labelPlacement = labelPlacement; _customHTML = custom; + _length = 1; + _value = nullptr; setValue(defaultValue,length); } @@ -87,8 +89,14 @@ void WiFiManagerParameter::setValue(const char *defaultValue, int length) { // // return false; //@todo bail // } - _length = length; - _value = new char[_length + 1]; + if(_length != length || _value == nullptr){ + _length = length; + if( _value != nullptr){ + delete[] _value; + } + _value = new char[_length + 1]; + } + memset(_value, 0, _length + 1); // explicit null if (defaultValue != NULL) { @@ -200,7 +208,7 @@ int WiFiManager::getParametersCount() { **/ // constructors -WiFiManager::WiFiManager(Stream& consolePort):_debugPort(consolePort){ +WiFiManager::WiFiManager(Print& consolePort):_debugPort(consolePort){ WiFiManagerInit(); } @@ -227,7 +235,7 @@ WiFiManager::~WiFiManager() { _params = NULL; } - // @todo remove event + // remove event // WiFi.onEvent(std::bind(&WiFiManager::WiFiEvent,this,_1,_2)); #ifdef ESP32 WiFi.removeEvent(wm_event_id); @@ -272,7 +280,28 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) { #ifdef WM_DEBUG_LEVEL DEBUG_WM(F("AutoConnect")); #endif - if(getWiFiIsSaved()){ + + // bool wifiIsSaved = getWiFiIsSaved(); + + #ifdef ESP32 + setupHostname(true); + + if(_hostname != ""){ + // disable wifi if already on + if(WiFi.getMode() & WIFI_STA){ + WiFi.mode(WIFI_OFF); + int timeout = millis()+1200; + // async loop for mode change + while(WiFi.getMode()!= WIFI_OFF && millis()= DEBUG_DEV) debugSoftAPConfig(); - // @todo add softAP retry here + // @todo add softAP retry here to dela with unknown failures delay(500); // slight delay to make sure we get an AP IP #ifdef WM_DEBUG_LEVEL @@ -595,29 +634,29 @@ void WiFiManager::setupHTTPServer(){ #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_VERBOSE,F("[CB] _webservercallback calling")); #endif - _webservercallback(); + _webservercallback(); // @CALLBACK } // @todo add a new callback maybe, after webserver started, callback cannot override handlers, but can grab them first /* Setup httpd callbacks, web pages: root, wifi config pages, SO captive portal detectors and not found. */ // G macro workaround for Uri() bug https://github.com/esp8266/Arduino/issues/7102 - server->on(G(R_root), std::bind(&WiFiManager::handleRoot, this)); - server->on(G(R_wifi), std::bind(&WiFiManager::handleWifi, this, true)); - server->on(G(R_wifinoscan), std::bind(&WiFiManager::handleWifi, this, false)); - server->on(G(R_wifisave), std::bind(&WiFiManager::handleWifiSave, this)); - server->on(G(R_info), std::bind(&WiFiManager::handleInfo, this)); - server->on(G(R_param), std::bind(&WiFiManager::handleParam, this)); - server->on(G(R_paramsave), std::bind(&WiFiManager::handleParamSave, this)); - server->on(G(R_restart), std::bind(&WiFiManager::handleReset, this)); - server->on(G(R_exit), std::bind(&WiFiManager::handleExit, this)); - server->on(G(R_close), std::bind(&WiFiManager::handleClose, this)); - server->on(G(R_erase), std::bind(&WiFiManager::handleErase, this, false)); - server->on(G(R_status), std::bind(&WiFiManager::handleWiFiStatus, this)); + server->on(WM_G(R_root), std::bind(&WiFiManager::handleRoot, this)); + server->on(WM_G(R_wifi), std::bind(&WiFiManager::handleWifi, this, true)); + server->on(WM_G(R_wifinoscan), std::bind(&WiFiManager::handleWifi, this, false)); + server->on(WM_G(R_wifisave), std::bind(&WiFiManager::handleWifiSave, this)); + server->on(WM_G(R_info), std::bind(&WiFiManager::handleInfo, this)); + server->on(WM_G(R_param), std::bind(&WiFiManager::handleParam, this)); + server->on(WM_G(R_paramsave), std::bind(&WiFiManager::handleParamSave, this)); + server->on(WM_G(R_restart), std::bind(&WiFiManager::handleReset, this)); + server->on(WM_G(R_exit), std::bind(&WiFiManager::handleExit, this)); + server->on(WM_G(R_close), std::bind(&WiFiManager::handleClose, this)); + server->on(WM_G(R_erase), std::bind(&WiFiManager::handleErase, this, false)); + server->on(WM_G(R_status), std::bind(&WiFiManager::handleWiFiStatus, this)); server->onNotFound (std::bind(&WiFiManager::handleNotFound, this)); - server->on(G(R_update), std::bind(&WiFiManager::handleUpdate, this)); - server->on(G(R_updatedone), HTTP_POST, std::bind(&WiFiManager::handleUpdateDone, this), std::bind(&WiFiManager::handleUpdating, this)); + server->on(WM_G(R_update), std::bind(&WiFiManager::handleUpdate, this)); + server->on(WM_G(R_updatedone), HTTP_POST, std::bind(&WiFiManager::handleUpdateDone, this), std::bind(&WiFiManager::handleUpdating, this)); server->begin(); // Web server start #ifdef WM_DEBUG_LEVEL @@ -678,9 +717,11 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo if(!validApPassword()) return false; // HANDLE issues with STA connections, shutdown sta if not connected, or else this will hang channel scanning and softap will not respond - // @todo sometimes still cannot connect to AP for no known reason, no events in log either if(_disableSTA || (!WiFi.isConnected() && _disableSTAConn)){ // this fixes most ap problems, however, simply doing mode(WIFI_AP) does not work if sta connection is hanging, must `wifi_station_disconnect` + #ifdef WM_DISCONWORKAROUND + WiFi.mode(WIFI_AP_STA); + #endif WiFi_Disconnect(); WiFi_enableSTA(false); #ifdef WM_DEBUG_LEVEL @@ -688,8 +729,7 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo #endif } else { - // @todo even if sta is connected, it is possible that softap connections will fail, IOS says "invalid password", windows says "cannot connect to this network" researching - WiFi_enableSTA(true); + // WiFi_enableSTA(true); } // init configportal globals to known states @@ -750,6 +790,12 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo #endif shutdownConfigPortal(); result = abort ? portalAbortResult : portalTimeoutResult; // false, false + if (_configportaltimeoutcallback != NULL) { + #ifdef WM_DEBUG_LEVEL + DEBUG_WM(DEBUG_VERBOSE,F("[CB] config portal timeout callback")); + #endif + _configportaltimeoutcallback(); // @CALLBACK + } break; } @@ -757,6 +803,7 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo // status change, break // @todo what is this for, should be moved inside the processor + // I think.. this is to detect autoconnect by esp in background, there are also many open issues about autoreconnect not working if(state != WL_IDLE_STATUS){ result = (state == WL_CONNECTED); // true if connected DEBUG_WM(DEBUG_DEV,F("configportal loop break")); @@ -785,28 +832,36 @@ boolean WiFiManager::process(){ MDNS.update(); #endif - if(configPortalActive && !_configPortalIsBlocking){ - if(configPortalHasTimeout()) shutdownConfigPortal(); - } - if(webPortalActive || (configPortalActive && !_configPortalIsBlocking)){ - // if timed out or abort, break if(_allowExit && (configPortalHasTimeout() || abort)){ #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_DEV,F("process loop abort")); #endif + webPortalActive = false; shutdownConfigPortal(); + if (_configportaltimeoutcallback != NULL) { + #ifdef WM_DEBUG_LEVEL + DEBUG_WM(DEBUG_VERBOSE,F("[CB] config portal timeout callback")); + #endif + _configportaltimeoutcallback(); // @CALLBACK + } return false; } - uint8_t state = processConfigPortal(); + uint8_t state = processConfigPortal(); // state is WL_IDLE or WL_CONNECTED/FAILED return state == WL_CONNECTED; } return false; } -//using esp wl_status enums as returns for now, should be fine +/** + * [processConfigPortal description] + * using esp wl_status enums as returns for now, should be fine + * returns WL_IDLE_STATUS or WL_CONNECTED/WL_CONNECT_FAILED upon connect/save flag + * + * @return {[type]} [description] + */ uint8_t WiFiManager::processConfigPortal(){ if(configPortalActive){ //DNS handler @@ -848,7 +903,7 @@ uint8_t WiFiManager::processConfigPortal(){ #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_VERBOSE,F("[CB] _savewificallback calling")); #endif - _savewificallback(); + _savewificallback(); // @CALLBACK } if(!_connectonsave) return WL_IDLE_STATUS; if(_disableConfigPortal) shutdownConfigPortal(); @@ -868,7 +923,7 @@ uint8_t WiFiManager::processConfigPortal(){ #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_VERBOSE,F("[CB] WiFi/Param save callback")); #endif - _savewificallback(); + _savewificallback(); // @CALLBACK } if(_disableConfigPortal) shutdownConfigPortal(); return WL_CONNECT_FAILED; // CONNECT FAIL @@ -915,6 +970,7 @@ bool WiFiManager::shutdownConfigPortal(){ server->handleClient(); // @todo what is the proper way to shutdown and free the server up + // debug - many open issues aobut port not clearing for use with other servers server->stop(); server.reset(); @@ -972,7 +1028,7 @@ uint8_t WiFiManager::connectWifi(String ssid, String pass, bool connect) { // make sure sta is on before `begin` so it does not call enablesta->mode while persistent is ON ( which would save WM AP state to eeprom !) // WiFi.setAutoReconnect(false); if(_cleanConnect) WiFi_Disconnect(); // disconnect before begin, in case anything is hung, this causes a 2 seconds delay for connect - // @todo find out what status is when this is needed, can we detect it and handle it, say in between states or idle_status + // @todo find out what status is when this is needed, can we detect it and handle it, say in between states or idle_status to avoid these // if retry without delay (via begin()), the IDF is still busy even after returning status // E (5130) wifi:sta is connecting, return error @@ -1423,11 +1479,20 @@ bool WiFiManager::WiFi_scanNetworks(bool force,bool async){ // DEBUG_WM(DEBUG_DEV,_numNetworks,(millis()-_lastscan )); // DEBUG_WM(DEBUG_DEV,"scanNetworks force:",force == true); #endif - if(_numNetworks == 0){ + + // if 0 networks, rescan @note this was a kludge, now disabling to test real cause ( maybe wifi not init etc) + // enable only if preload failed? + if(_numNetworks == 0 && _autoforcerescan){ DEBUG_WM(DEBUG_DEV,"NO APs found forcing new scan"); force = true; } - if(force || (_lastscan>0 && (millis()-_lastscan > 60000))){ + + // if scan is empty or stale (last scantime > _scancachetime), this avoids fast reloading wifi page and constant scan delayed page loads appearing to freeze. + if(!_lastscan || (_lastscan>0 && (millis()-_lastscan > _scancachetime))){ + force = true; + } + + if(force){ int8_t res; _startscan = millis(); if(async && _asyncScan){ @@ -1668,7 +1733,7 @@ String WiFiManager::getParamOut(){ char valLength[5]; for (int i = 0; i < _paramsCount; i++) { - Serial.println((String)_params[i]->_length); + //Serial.println((String)_params[i]->_length); if (_params[i] == NULL || _params[i]->_length == 0 || _params[i]->_length > 99999) { // try to detect param scope issues, doesnt always catch but works ok #ifdef WM_DEBUG_LEVEL @@ -1744,17 +1809,11 @@ void WiFiManager::handleWifiSave() { #endif handleRequest(); - // @todo use new callback for before paramsaves - if (!_paramsInWifi && _presavecallback != NULL) { - _presavecallback(); - } - //SAVE/connect here _ssid = server->arg(F("s")).c_str(); _pass = server->arg(F("p")).c_str(); - if(_paramsInWifi) doParamSave(); - + // set static ips from server args if (server->arg(FPSTR(S_ip)) != "") { //_sta_static_ip.fromString(server->arg(FPSTR(S_ip)); String ip = server->arg(FPSTR(S_ip)); @@ -1785,6 +1844,12 @@ void WiFiManager::handleWifiSave() { #endif } + if (_presavewificallback != NULL) { + _presavewificallback(); // @CALLBACK + } + + if(_paramsInWifi) doParamSave(); + String page; if(_ssid == ""){ @@ -1795,6 +1860,8 @@ void WiFiManager::handleWifiSave() { page = getHTTPHead(FPSTR(S_titlewifisaved)); // @token titlewifisaved page += FPSTR(HTTP_SAVED); } + + if(_showBack) page += FPSTR(HTTP_BACKBTN); page += FPSTR(HTTP_END); server->sendHeader(FPSTR(HTTP_HEAD_CORS), FPSTR(HTTP_HEAD_CORS_ALLOW_ALL)); // @HTTPHEAD send cors @@ -1821,6 +1888,7 @@ void WiFiManager::handleParamSave() { String page = getHTTPHead(FPSTR(S_titleparamsaved)); // @token titleparamsaved page += FPSTR(HTTP_PARAMSAVED); + if(_showBack) page += FPSTR(HTTP_BACKBTN); page += FPSTR(HTTP_END); HTTPSend(page); @@ -1832,8 +1900,8 @@ void WiFiManager::handleParamSave() { void WiFiManager::doParamSave(){ // @todo use new callback for before paramsaves, is this really needed? - if ( _presavecallback != NULL) { - _presavecallback(); + if ( _presaveparamscallback != NULL) { + _presaveparamscallback(); // @CALLBACK } //parameters @@ -1871,7 +1939,7 @@ void WiFiManager::doParamSave(){ } if ( _saveparamscallback != NULL) { - _saveparamscallback(); + _saveparamscallback(); // @CALLBACK } } @@ -1926,7 +1994,7 @@ void WiFiManager::handleInfo() { #elif defined(ESP32) // add esp_chip_info ? - infos = 26; + infos = 27; String infoids[] = { F("esphead"), F("uptime"), @@ -1939,6 +2007,8 @@ void WiFiManager::handleInfo() { F("memsketch"), F("memsmeter"), F("lastreset"), + F("temp"), + // F("hall"), F("wifihead"), F("conx"), F("stassid"), @@ -1954,7 +2024,6 @@ void WiFiManager::handleInfo() { F("apmac"), F("aphost"), F("apbssid") - // F("temp") }; #endif @@ -1989,9 +2058,16 @@ void WiFiManager::handleInfo() { String WiFiManager::getInfoData(String id){ String p; - // @todo add WM versioning - if(id==F("esphead"))p = FPSTR(HTTP_INFO_esphead); - else if(id==F("wifihead"))p = FPSTR(HTTP_INFO_wifihead); + if(id==F("esphead")){ + p = FPSTR(HTTP_INFO_esphead); + #ifdef ESP32 + p.replace(FPSTR(T_1), (String)ESP.getChipModel()); + #endif + } + else if(id==F("wifihead")){ + p = FPSTR(HTTP_INFO_wifihead); + p.replace(FPSTR(T_1),getModeString(WiFi.getMode())); + } else if(id==F("uptime")){ // subject to rollover! p = FPSTR(HTTP_INFO_uptime); @@ -2044,7 +2120,7 @@ String WiFiManager::getInfoData(String id){ p = FPSTR(HTTP_INFO_bootver); p.replace(FPSTR(T_1),(String)system_get_boot_version()); } - #endif + #endif else if(id==F("cpufreq")){ p = FPSTR(HTTP_INFO_cpufreq); p.replace(FPSTR(T_1),(String)ESP.getCpuFreqMHz()); @@ -2169,15 +2245,17 @@ String WiFiManager::getInfoData(String id){ p.replace(FPSTR(T_1),WiFi.getAutoConnect() ? FPSTR(S_enable) : FPSTR(S_disable)); } #endif - #ifdef ESP32 + #if defined(ESP32) && !defined(WM_NOTEMP) else if(id==F("temp")){ // temperature is not calibrated, varying large offsets are present, use for relative temp changes only p = FPSTR(HTTP_INFO_temp); p.replace(FPSTR(T_1),(String)temperatureRead()); p.replace(FPSTR(T_2),(String)((temperatureRead()+32)*1.8)); - // p.replace(FPSTR(T_3),(String)hallRead()); - p.replace(FPSTR(T_3),"NA"); } + // else if(id==F("hall")){ + // p = FPSTR(HTTP_INFO_hall); + // p.replace(FPSTR(T_1),(String)hallRead()); // hall sensor reads can cause issues with adcs + // } #endif else if(id==F("aboutver")){ p = FPSTR(HTTP_INFO_aboutver); @@ -2206,7 +2284,7 @@ String WiFiManager::getInfoData(String id){ } else if(id==F("aboutdate")){ p = FPSTR(HTTP_INFO_aboutdate); - p.replace(FPSTR(T_1),String(__DATE__) + " " + String(__TIME__)); + p.replace(FPSTR(T_1),String(__DATE__ " " __TIME__)); } return p; } @@ -2316,11 +2394,11 @@ void WiFiManager::handleNotFound() { */ boolean WiFiManager::captivePortal() { #ifdef WM_DEBUG_LEVEL - DEBUG_WM(DEBUG_DEV,"-> " + server->hostHeader()); + DEBUG_WM(DEBUG_MAX,"-> " + server->hostHeader()); #endif if(!_enableCaptivePortal) return false; // skip redirections, @todo maybe allow redirection even when no cp ? might be useful - + String serverLoc = toStringIp(server->client()->localIP()); if(_httpPort != 80) serverLoc += ":" + (String)_httpPort; // add port if not default bool doredirect = serverLoc != server->hostHeader(); // redirect if hostheader not server ip, prevent redirect loops @@ -2517,7 +2595,7 @@ void WiFiManager::resetSettings() { WiFi_enableSTA(true,true); // must be sta to disconnect erase delay(500); // ensure sta is enabled if (_resetcallback != NULL){ - _resetcallback(); + _resetcallback(); // @CALLBACK } #ifdef ESP32 @@ -2700,6 +2778,15 @@ void WiFiManager::setSaveConfigCallback( std::function func ) { _savewificallback = func; } +/** + * setPreSaveConfigCallback, set a callback to fire before saving wifi or params + * @access public + * @param {[type]} void (*func)(void) + */ +void WiFiManager::setPreSaveConfigCallback( std::function func ) { + _presavewificallback = func; +} + /** * setConfigResetCallback, set a callback to occur when a resetSettings() occurs * @access public @@ -2719,12 +2806,12 @@ void WiFiManager::setSaveParamsCallback( std::function func ) { } /** - * setPreSaveConfigCallback, set a callback to fire before saving wifi or params + * setPreSaveParamsCallback, set a pre save params callback on params save prior to anything else * @access public * @param {[type]} void (*func)(void) */ -void WiFiManager::setPreSaveConfigCallback( std::function func ) { - _presavecallback = func; +void WiFiManager::setPreSaveParamsCallback( std::function func ) { + _presaveparamscallback = func; } /** @@ -2737,12 +2824,12 @@ void WiFiManager::setPreOtaUpdateCallback( std::function func ) { } /** - * setDisconnectedCallback, set a callback to fire when WiFi is disconnected + * setConfigPortalTimeoutCallback, set a callback to config portal is timeout * @access public * @param {[type]} void (*func)(void) */ -void WiFiManager::setDisconnectedCallback( std::function func ) { - _disconnectedcallback = func; +void WiFiManager::setConfigPortalTimeoutCallback( std::function func ) { + _configportaltimeoutcallback = func; } /** @@ -3287,26 +3374,25 @@ void WiFiManager::debugPlatformInfo(){ #ifdef ESP8266 system_print_meminfo(); #ifdef WM_DEBUG_LEVEL - DEBUG_WM(F("getCoreVersion(): "),ESP.getCoreVersion()); - DEBUG_WM(F("system_get_sdk_version(): "),system_get_sdk_version()); - DEBUG_WM(F("system_get_boot_version():"),system_get_boot_version()); - DEBUG_WM(F("getFreeHeap(): "),(String)ESP.getFreeHeap()); + DEBUG_WM(F("[SYS] getCoreVersion(): "),ESP.getCoreVersion()); + DEBUG_WM(F("[SYS] system_get_sdk_version(): "),system_get_sdk_version()); + DEBUG_WM(F("[SYS] system_get_boot_version():"),system_get_boot_version()); + DEBUG_WM(F("[SYS] getFreeHeap(): "),(String)ESP.getFreeHeap()); #endif #elif defined(ESP32) #ifdef WM_DEBUG_LEVEL - DEBUG_WM(F("Free heap: "), ESP.getFreeHeap()); - DEBUG_WM(F("ESP SDK version: "), ESP.getSdkVersion()); + DEBUG_WM(F("[SYS] WM version: "), WM_VERSION_STR); + DEBUG_WM(F("[SYS] Arduino version: "), VER_ARDUINO_STR); + DEBUG_WM(F("[SYS] ESP SDK version: "), ESP.getSdkVersion()); + DEBUG_WM(F("[SYS] Free heap: "), ESP.getFreeHeap()); #endif - // esp_chip_info_t chipInfo; - // esp_chip_info(&chipInfo); + #ifdef WM_DEBUG_LEVEL - // DEBUG_WM("Chip Info: Model: ",chipInfo.model); - // DEBUG_WM("Chip Info: Cores: ",chipInfo.cores); - // DEBUG_WM("Chip Info: Rev: ",chipInfo.revision); - // DEBUG_WM(printf("Chip Info: Model: %d, cores: %d, revision: %d", chipInfo.model.c_str(), chipInfo.cores, chipInfo.revision)); - // DEBUG_WM("Chip Rev: ",(String)ESP.getChipRevision()); + DEBUG_WM(F("[SYS] Chip ID:"),WIFI_getChipId()); + DEBUG_WM(F("[SYS] Chip Model:"), ESP.getChipModel()); + DEBUG_WM(F("[SYS] Chip Cores:"), ESP.getChipCores()); + DEBUG_WM(F("[SYS] Chip Rev:"), ESP.getChipRevision()); #endif - // core version is not avail #endif } @@ -3353,7 +3439,7 @@ boolean WiFiManager::validApPassword(){ DEBUG_WM(F("AccessPoint set password is INVALID or <8 chars")); #endif _apPassword = ""; - return false; // @todo FATAL or fallback to empty ? + return false; // @todo FATAL or fallback to empty , currently fatal, fail secure. } #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_VERBOSE,F("AccessPoint set password is VALID")); @@ -3373,6 +3459,7 @@ String WiFiManager::htmlEntities(String str, bool whitespace) { str.replace("&","&"); str.replace("<","<"); str.replace(">",">"); + str.replace("'","'"); if(whitespace) str.replace(" "," "); // str.replace("-","–"); // str.replace("\"","""); @@ -3432,20 +3519,29 @@ bool WiFiManager::WiFiSetCountry(){ // ret = esp_wifi_set_bandwidth(WIFI_IF_AP,WIFI_BW_HT20); // WIFI_BW_HT40 #ifdef ESP32 esp_err_t err = ESP_OK; - // @todo check if wifi is init, no idea how, doesnt seem to be exposed atm ( might be now! ) + // @todo check if wifi is init, no idea how, doesnt seem to be exposed atm ( check again it might be now! ) if(WiFi.getMode() == WIFI_MODE_NULL){ DEBUG_WM(DEBUG_ERROR,"[ERROR] cannot set country, wifi not init"); } // exception if wifi not init! - else if(_wificountry == "US") err = esp_wifi_set_country(&WM_COUNTRY_US); - else if(_wificountry == "JP") err = esp_wifi_set_country(&WM_COUNTRY_JP); - else if(_wificountry == "CN") err = esp_wifi_set_country(&WM_COUNTRY_CN); + // Assumes that _wificountry is set to one of the supported country codes : "01"(world safe mode) "AT","AU","BE","BG","BR", + // "CA","CH","CN","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GR","HK","HR","HU", + // "IE","IN","IS","IT","JP","KR","LI","LT","LU","LV","MT","MX","NL","NO","NZ","PL","PT", + // "RO","SE","SI","SK","TW","US" + // If an invalid country code is passed, ESP_ERR_WIFI_ARG will be returned + // This also uses 802.11d mode, which matches the STA to the country code of the AP it connects to (meaning + // that the country code will be overridden if connecting to a "foreign" AP) + else { + #ifndef WM_NOCOUNTRY + err = esp_wifi_set_country_code(_wificountry.c_str(), true); + #else + DEBUG_WM(DEBUG_ERROR,"[ERROR] esp wifi set country is not available"); + err = true; + #endif + } #ifdef WM_DEBUG_LEVEL - else{ - DEBUG_WM(DEBUG_ERROR,"[ERROR] country code not found"); - } if(err){ if(err == ESP_ERR_WIFI_NOT_INIT) DEBUG_WM(DEBUG_ERROR,"[ERROR] ESP_ERR_WIFI_NOT_INIT"); - else if(err == ESP_ERR_INVALID_ARG) DEBUG_WM(DEBUG_ERROR,"[ERROR] ESP_ERR_WIFI_ARG"); + else if(err == ESP_ERR_INVALID_ARG) DEBUG_WM(DEBUG_ERROR,"[ERROR] ESP_ERR_WIFI_ARG (invalid country code)"); else if(err != ESP_OK)DEBUG_WM(DEBUG_ERROR,"[ERROR] unknown error",(String)err); } #endif @@ -3482,7 +3578,7 @@ bool WiFiManager::WiFi_Mode(WiFiMode_t m,bool persistent) { return ret; #elif defined(ESP32) if(persistent && esp32persistent) WiFi.persistent(true); - ret = WiFi.mode(m); // @todo persistent check persistant mode , NI + ret = WiFi.mode(m); // @todo persistent check persistant mode, was eventually added to esp lib, but have to add version checking probably if(persistent && esp32persistent) WiFi.persistent(false); return ret; #endif @@ -3499,7 +3595,7 @@ bool WiFiManager::WiFi_Disconnect() { #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_DEV,F("WiFi station disconnect")); #endif - ETS_UART_INTR_DISABLE(); // @todo probably not needed + ETS_UART_INTR_DISABLE(); // @todo possibly not needed ret = wifi_station_disconnect(); ETS_UART_INTR_ENABLE(); return ret; @@ -3577,7 +3673,7 @@ bool WiFiManager::WiFi_eraseConfig() { bool ret; WiFi.mode(WIFI_AP_STA); // cannot erase if not in STA mode ! WiFi.persistent(true); - ret = WiFi.disconnect(true,true); + ret = WiFi.disconnect(true,true); // disconnect(bool wifioff, bool eraseap) delay(500); WiFi.persistent(false); return ret; @@ -3672,12 +3768,6 @@ String WiFiManager::WiFi_psk(bool persistent) const { // DEBUG_WM(DEBUG_VERBOSE,"[EVENT]",event); #endif if(event == ARDUINO_EVENT_WIFI_STA_DISCONNECTED){ - - if(_disconnectedcallback != nullptr) - { - _disconnectedcallback(); - } - #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_VERBOSE,F("[EVENT] WIFI_REASON: "),info.wifi_sta_disconnected.reason); #endif @@ -3698,7 +3788,7 @@ String WiFiManager::WiFi_psk(bool persistent) const { WiFi.reconnect(); #endif } - else if(event == ARDUINO_EVENT_WIFI_SCAN_DONE){ + else if(event == ARDUINO_EVENT_WIFI_SCAN_DONE && _asyncScan){ uint16_t scans = WiFi.scanComplete(); WiFi_scanComplete(scans); } @@ -3751,7 +3841,8 @@ void WiFiManager::handleUpdating(){ // combine route handlers into one callback and use argument or post checking instead of mutiple functions maybe, if POST process else server upload page? // [x] add upload checking, do we need too check file? // convert output to debugger if not moving to example - if (captivePortal()) return; // If captive portal redirect instead of displaying the page + + // if (captivePortal()) return; // If captive portal redirect instead of displaying the page bool error = false; unsigned long _configPortalTimeoutSAV = _configPortalTimeout; // store cp timeout _configPortalTimeout = 0; // disable timeout @@ -3762,12 +3853,12 @@ void WiFiManager::handleUpdating(){ // UPLOAD START if (upload.status == UPLOAD_FILE_START) { - if(_debug) Serial.setDebugOutput(true); + // if(_debug) Serial.setDebugOutput(true); uint32_t maxSketchSpace; // Use new callback for before OTA update if (_preotaupdatecallback != NULL) { - _preotaupdatecallback(); + _preotaupdatecallback(); // @CALLBACK } #ifdef ESP8266 WiFiUDP::stopAll(); @@ -3780,9 +3871,14 @@ void WiFiManager::handleUpdating(){ #endif #ifdef WM_DEBUG_LEVEL - DEBUG_WM(DEBUG_VERBOSE,"Update file: ", upload.filename.c_str()); + DEBUG_WM(DEBUG_VERBOSE,"[OTA] Update file: ", upload.filename.c_str()); #endif + // Update.onProgress(THandlerFunction_Progress fn); + // Update.onProgress([](unsigned int progress, unsigned int total) { + // Serial.printf("Progress: %u%%\r", (progress / (total / 100))); + // }); + if (!Update.begin(maxSketchSpace)) { // start with max available size #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_ERROR,F("[ERROR] OTA Update ERROR"), Update.getError()); @@ -3793,7 +3889,7 @@ void WiFiManager::handleUpdating(){ } // UPLOAD WRITE else if (upload.status == UPLOAD_FILE_WRITE) { - Serial.print("."); + // Serial.print("."); if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) { #ifdef WM_DEBUG_LEVEL DEBUG_WM(DEBUG_ERROR,F("[ERROR] OTA Update WRITE ERROR"), Update.getError()); @@ -3811,7 +3907,7 @@ void WiFiManager::handleUpdating(){ #endif } else { - Update.printError(Serial); + // Update.printError(Serial); error = true; } } @@ -3828,7 +3924,7 @@ void WiFiManager::handleUpdating(){ // upload and ota done, show status void WiFiManager::handleUpdateDone() { DEBUG_WM(DEBUG_VERBOSE, F("<- Handle update done")); - if (captivePortal()) return; // If captive portal redirect instead of displaying the page + // if (captivePortal()) return; // If captive portal redirect instead of displaying the page String page = getHTTPHead(FPSTR(S_options)); // @token options String str = FPSTR(HTTP_ROOT_MAIN); diff --git a/lib/WiFiManager/WiFiManager.h b/lib/WiFiManager/WiFiManager.h index 3f493e5..36fe039 100644 --- a/lib/WiFiManager/WiFiManager.h +++ b/lib/WiFiManager/WiFiManager.h @@ -39,6 +39,23 @@ #define WM_NOSOFTAPSSID // no softapssid() @todo shim #endif +// #ifdef CONFIG_IDF_TARGET_ESP32S2 +// #warning ESP32S2 +// #endif + +// #ifdef CONFIG_IDF_TARGET_ESP32C3 +// #warning ESP32C3 +// #endif + +// #ifdef CONFIG_IDF_TARGET_ESP32S3 +// #warning ESP32S3 +// #endif + +#if defined(ARDUINO_ESP32S3_DEV) || defined(CONFIG_IDF_TARGET_ESP32S3) +#warning "WM_NOTEMP" +#define WM_NOTEMP // disabled temp sensor, have to determine which chip we are on +#endif + // #include "soc/efuse_reg.h" // include to add efuse chip rev to info, getChipRevision() is almost always the same though, so not sure why it matters. // #define esp32autoreconnect // implement esp32 autoreconnect event listener kludge, @DEPRECATED @@ -46,32 +63,7 @@ #define WM_WEBSERVERSHIM // use webserver shim lib -#define G(string_literal) (String(FPSTR(string_literal)).c_str()) - -#define STRING2(x) #x -#define STRING(x) STRING2(x) - -// #include -#ifdef ESP_IDF_VERSION - // #pragma message "ESP_IDF_VERSION_MAJOR = " STRING(ESP_IDF_VERSION_MAJOR) - // #pragma message "ESP_IDF_VERSION_MINOR = " STRING(ESP_IDF_VERSION_MINOR) - // #pragma message "ESP_IDF_VERSION_PATCH = " STRING(ESP_IDF_VERSION_PATCH) - #define VER_IDF_STR STRING(ESP_IDF_VERSION_MAJOR) "." STRING(ESP_IDF_VERSION_MINOR) "." STRING(ESP_IDF_VERSION_PATCH) -#endif - -// #include "esp_arduino_version.h" -#ifdef ESP_ARDUINO_VERSION - // #pragma message "ESP_ARDUINO_VERSION_MAJOR = " STRING(ESP_ARDUINO_VERSION_MAJOR) - // #pragma message "ESP_ARDUINO_VERSION_MINOR = " STRING(ESP_ARDUINO_VERSION_MINOR) - // #pragma message "ESP_ARDUINO_VERSION_PATCH = " STRING(ESP_ARDUINO_VERSION_PATCH) - #define VER_ARDUINO_STR STRING(ESP_ARDUINO_VERSION_MAJOR) "." STRING(ESP_ARDUINO_VERSION_MINOR) "." STRING(ESP_ARDUINO_VERSION_PATCH) -#else - // #include - // #pragma message "ESP_ARDUINO_VERSION_GIT = " STRING(ARDUINO_ESP32_GIT_VER)// 0x46d5afb1 - // #pragma message "ESP_ARDUINO_VERSION_DESC = " STRING(ARDUINO_ESP32_GIT_DESC) // 1.0.6 - #define VER_ARDUINO_STR "Unknown" - // #pragma message "ESP_ARDUINO_VERSION_REL = " STRING(ARDUINO_ESP32_RELEASE) //"1_0_6" -#endif +#define WM_G(string_literal) (String(FPSTR(string_literal)).c_str()) #ifdef ESP8266 @@ -117,7 +109,21 @@ #endif #ifdef WM_RTC - #include + #ifdef ESP_IDF_VERSION_MAJOR // IDF 4+ + #if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4 + #include "esp32/rom/rtc.h" + #elif CONFIG_IDF_TARGET_ESP32S2 + #include "esp32s2/rom/rtc.h" + #elif CONFIG_IDF_TARGET_ESP32C3 + #include "esp32c3/rom/rtc.h" + #elif CONFIG_IDF_TARGET_ESP32S3 + #include "esp32s3/rom/rtc.h" + #else + #error Target CONFIG_IDF_TARGET is not supported + #endif + #else // ESP32 Before IDF 4.0 + #include "rom/rtc.h" + #endif #endif #else @@ -125,7 +131,60 @@ #include #include -#include "strings_en.h" + + +// Include wm strings vars +// Pass in strings env override via WM_STRINGS_FILE +#ifndef WM_STRINGS_FILE +#define WM_STRINGS_FILE "wm_strings_en.h" // this includes constants as dependency +#endif +#include WM_STRINGS_FILE + +// prep string concat vars +#define WM_STRING2(x) #x +#define WM_STRING(x) WM_STRING2(x) + +// #include +#ifdef ESP_IDF_VERSION + // #pragma message "ESP_IDF_VERSION_MAJOR = " WM_STRING(ESP_IDF_VERSION_MAJOR) + // #pragma message "ESP_IDF_VERSION_MINOR = " WM_STRING(ESP_IDF_VERSION_MINOR) + // #pragma message "ESP_IDF_VERSION_PATCH = " WM_STRING(ESP_IDF_VERSION_PATCH) + #define VER_IDF_STR WM_STRING(ESP_IDF_VERSION_MAJOR) "." WM_STRING(ESP_IDF_VERSION_MINOR) "." WM_STRING(ESP_IDF_VERSION_PATCH) +#else + #define VER_IDF_STR "Unknown" +#endif + +#ifdef Arduino_h + #ifdef ESP32 + // #include "esp_arduino_version.h" // esp32 arduino > 2.x + #endif + // esp_get_idf_version + #ifdef ESP_ARDUINO_VERSION + // #pragma message "ESP_ARDUINO_VERSION_MAJOR = " WM_STRING(ESP_ARDUINO_VERSION_MAJOR) + // #pragma message "ESP_ARDUINO_VERSION_MINOR = " WM_STRING(ESP_ARDUINO_VERSION_MINOR) + // #pragma message "ESP_ARDUINO_VERSION_PATCH = " WM_STRING(ESP_ARDUINO_VERSION_PATCH) + #ifdef ESP_ARDUINO_VERSION_MAJOR + #define VER_ARDUINO_STR WM_STRING(ESP_ARDUINO_VERSION_MAJOR) "." WM_STRING(ESP_ARDUINO_VERSION_MINOR) "." WM_STRING(ESP_ARDUINO_VERSION_PATCH) + #else + #define VER_ARDUINO_STR "Unknown" + #endif + #else + #include + // #pragma message "ESP_ARDUINO_VERSION_GIT = " WM_STRING(ARDUINO_ESP32_GIT_VER)// 0x46d5afb1 + // #pragma message "ESP_ARDUINO_VERSION_DESC = " WM_STRING(ARDUINO_ESP32_GIT_DESC) // 1.0.6 + // #pragma message "ESP_ARDUINO_VERSION_REL = " WM_STRING(ARDUINO_ESP32_RELEASE) //"1_0_6" + #ifdef ESP_ARDUINO_VERSION_MAJOR + #define VER_ARDUINO_STR WM_STRING(ESP_ARDUINO_VERSION_MAJOR) "." WM_STRING(ESP_ARDUINO_VERSION_MINOR) "." WM_STRING(ESP_ARDUINO_VERSION_PATCH) + #else + #define VER_ARDUINO_STR "Unknown" + #endif + #endif +#else +#define VER_ARDUINO_STR "Unknown" +#endif + +// #pragma message "VER_IDF_STR = " WM_STRING(VER_IDF_STR) +// #pragma message "VER_ARDUINO_STR = " WM_STRING(VER_ARDUINO_STR) #ifndef WIFI_MANAGER_MAX_PARAMS #define WIFI_MANAGER_MAX_PARAMS 5 // params will autoincrement and realloc by this amount when max is reached @@ -179,7 +238,7 @@ class WiFiManagerParameter { class WiFiManager { public: - WiFiManager(Stream& consolePort); + WiFiManager(Print& consolePort); WiFiManager(); ~WiFiManager(); void WiFiManagerInit(); @@ -244,17 +303,20 @@ class WiFiManager //called when wifi settings have been changed and connection was successful ( or setBreakAfterConfig(true) ) void setSaveConfigCallback( std::function func ); - //called when saving either params-in-wifi or params page - void setSaveParamsCallback( std::function func ); - //called when saving params-in-wifi or params before anything else happens (eg wifi) void setPreSaveConfigCallback( std::function func ); + //called when saving params before anything else happens + void setPreSaveParamsCallback( std::function func ); + + //called when saving either params-in-wifi or params page + void setSaveParamsCallback( std::function func ); + //called just before doing OTA update void setPreOtaUpdateCallback( std::function func ); - //called when WiFi has disconnected - void setDisconnectedCallback( std::function func ); + //called when config portal is timeout + void setConfigPortalTimeoutCallback( std::function func ); //sets timeout before AP,webserver loop ends and exits even if there has been no setup. //useful for devices that failed to connect at some point and got stuck in a webserver loop @@ -487,9 +549,10 @@ class WiFiManager uint16_t _httpPort = 80; // port for webserver // uint8_t _retryCount = 0; // counter for retries, probably not needed if synchronous uint8_t _connectRetries = 1; // number of sta connect retries, force reconnect, wait loop (connectimeout) does not always work and first disconnect bails - bool _aggresiveReconn = false; // use an agrressive reconnect strategy, WILL delay conxs + bool _aggresiveReconn = true; // use an agrressive reconnect strategy, WILL delay conxs // on some conn failure modes will add delays and many retries to work around esp and ap bugs, ie, anti de-auth protections - bool _allowExit = true; // allow exit non blocking + // https://github.com/tzapu/WiFiManager/issues/1067 + bool _allowExit = true; // allow exit in nonblocking, else user exit/abort calls will be ignored including cptimeout #ifdef ESP32 wifi_event_id_t wm_event_id = 0; @@ -530,6 +593,7 @@ class WiFiManager // internal options // wifiscan notes + // currently disabled due to issues with caching, sometimes first scan is empty esp32 wifi not init yet race, or portals hit server nonstop flood // The following are background wifi scanning optimizations // experimental to make scans faster, preload scans after starting cp, and visiting home page, so when you click wifi its already has your list // ideally we would add async and xhr here but I am holding off on js requirements atm @@ -538,10 +602,17 @@ class WiFiManager // async enables asyncronous scans, so they do not block anything // the refresh button bypasses cache // no aps found is problematic as scans are always going to want to run, leading to page load delays - boolean _preloadwifiscan = false; // preload wifiscan if true - boolean _asyncScan = false; // perform wifi network scan async - unsigned int _scancachetime = 30000; // ms cache time for background scans + // + // These settings really only make sense with _preloadwifiscan true + // but not limited to, we could run continuous background scans on various page hits, or xhr hits + // which would be better coupled with asyncscan + // atm preload is only done on root hit and startcp + boolean _preloadwifiscan = true; // preload wifiscan if true + unsigned int _scancachetime = 30000; // ms cache time for preload scans + boolean _asyncScan = true; // perform wifi network scan async + boolean _autoforcerescan = false; // automatically force rescan if scan networks is 0, ignoring cache + boolean _disableIpFields = false; // modify function of setShow_X_Fields(false), forces ip fields off instead of default show if set, eg. _staShowStaticFields=-1 String _wificountry = ""; // country code, @todo define in strings lang @@ -627,15 +698,28 @@ class WiFiManager #if defined(ESP_ARDUINO_VERSION) && defined(ESP_ARDUINO_VERSION_VAL) #define WM_ARDUINOVERCHECK ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(2, 0, 0) + #define WM_ARDUINOVERCHECK_204 ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 5) #ifdef WM_ARDUINOVERCHECK #define WM_ARDUINOEVENTS #else #define WM_NOSOFTAPSSID + #define WM_NOCOUNTRY #endif + #ifdef WM_ARDUINOVERCHECK_204 + #define WM_DISCONWORKAROUND + #endif + + #else + #define WM_NOCOUNTRY #endif + #ifdef WM_NOCOUNTRY + #warning "ESP32 set country unavailable" + #endif + + #ifdef WM_ARDUINOEVENTS void WiFiEvent(WiFiEvent_t event, arduino_event_info_t info); #else @@ -693,7 +777,7 @@ class WiFiManager // Set default debug level #ifndef WM_DEBUG_LEVEL - #define WM_DEBUG_LEVEL DEBUG_VERBOSE // development default, not release + #define WM_DEBUG_LEVEL DEBUG_NOTIFY #endif // override debug level OFF @@ -704,14 +788,14 @@ class WiFiManager #ifdef WM_DEBUG_LEVEL uint8_t _debugLevel = (uint8_t)WM_DEBUG_LEVEL; #else - uint8_t _debugLevel = DEBUG_VERBOSE; // default debug level + uint8_t _debugLevel = 0; // default debug level #endif // @todo use DEBUG_ESP_PORT ? #ifdef WM_DEBUG_PORT - Stream& _debugPort = WM_DEBUG_PORT; + Print& _debugPort = WM_DEBUG_PORT; #else - Stream& _debugPort = Serial; // debug output stream ref + Print& _debugPort = Serial; // debug output stream ref #endif template @@ -729,11 +813,12 @@ class WiFiManager std::function _apcallback; std::function _webservercallback; std::function _savewificallback; - std::function _presavecallback; + std::function _presavewificallback; + std::function _presaveparamscallback; std::function _saveparamscallback; std::function _resetcallback; std::function _preotaupdatecallback; - std::function _disconnectedcallback = nullptr; + std::function _configportaltimeoutcallback; template auto optionalIPFromString(T *obj, const char *s) -> decltype( obj->fromString(s) ) { diff --git a/lib/WiFiManager/examples/Basic/Basic.ino b/lib/WiFiManager/examples/Basic/Basic.ino index 59c95d9..bf1e263 100644 --- a/lib/WiFiManager/examples/Basic/Basic.ino +++ b/lib/WiFiManager/examples/Basic/Basic.ino @@ -2,7 +2,7 @@ void setup() { - WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP + // WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP // it is a good practice to make sure your code sets wifi mode how you want it. // put your setup code here, to run once: @@ -13,7 +13,7 @@ void setup() { // reset settings - wipe stored credentials for testing // these are stored by the esp library - wm.resetSettings(); + // wm.resetSettings(); // Automatically connect using saved credentials, // if connection fails, it starts an access point with the specified name ( "AutoConnectAP"), diff --git a/lib/WiFiManager/examples/Parameters/LittleFS/LittleFSParameters.ino b/lib/WiFiManager/examples/Parameters/LittleFS/LittleFSParameters.ino new file mode 100644 index 0000000..188b3c1 --- /dev/null +++ b/lib/WiFiManager/examples/Parameters/LittleFS/LittleFSParameters.ino @@ -0,0 +1,79 @@ +/** + * Basic example using LittleFS to store data + */ + +#include +#include +#include + +String readFile(fs::FS &fs, const char * path){ + Serial.printf("Reading file: %s\r\n", path); + File file = fs.open(path, "r"); + if(!file || file.isDirectory()){ + Serial.println("- empty file or failed to open file"); + return String(); + } + Serial.println("- read from file:"); + String fileContent; + while(file.available()){ + fileContent+=String((char)file.read()); + } + file.close(); + Serial.println(fileContent); + return fileContent; +} +void writeFile(fs::FS &fs, const char * path, const char * message){ + Serial.printf("Writing file: %s\r\n", path); + File file = fs.open(path, "w"); + if(!file){ + Serial.println("- failed to open file for writing"); + return; + } + if(file.print(message)){ + Serial.println("- file written"); + } else { + Serial.println("- write failed"); + } + file.close(); +} + +int data = 4; + +#include +#define TRIGGER_PIN 2 +int timeout = 120; // seconds to run for + +void setup() { +if (!LittleFS.begin()) { //to start littlefs +Serial.println("LittleFS mount failed"); +return; +} +data = readFile(LittleFS, "/data.txt").toInt(); +WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP + // put your setup code here, to run once: + pinMode(TRIGGER_PIN, INPUT_PULLUP); + WiFiManager wm; + //wm.resetSettings(); + bool res; + res = wm.autoConnect("Setup"); + if(!res) { + Serial.println("Failed to connect"); + // ESP.restart(); + } + +} + +void loop() { +if ( digitalRead(TRIGGER_PIN) == LOW) { + WiFiManager wm; + //wm.resetSettings(); + wm.setConfigPortalTimeout(timeout); + if (!wm.startConfigPortal("Sharmander")) { + Serial.println("failed to connect and hit timeout"); + delay(3000); + ESP.restart(); + delay(5000); + } + Serial.println("connected...yeey :)"); +} +} \ No newline at end of file diff --git a/lib/WiFiManager/examples/Parameters/SPIFFS/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino b/lib/WiFiManager/examples/Parameters/SPIFFS/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino index 0e1cd0c..a9c7b79 100644 --- a/lib/WiFiManager/examples/Parameters/SPIFFS/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino +++ b/lib/WiFiManager/examples/Parameters/SPIFFS/AutoConnectWithFSParameters/AutoConnectWithFSParameters.ino @@ -46,7 +46,7 @@ void setup() { configFile.readBytes(buf.get(), size); -#ifdef ARDUINOJSON_VERSION_MAJOR >= 6 + #if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6 DynamicJsonDocument json(1024); auto deserializeError = deserializeJson(json, buf.get()); serializeJson(json, Serial); @@ -133,7 +133,7 @@ void setup() { //save the custom parameters to FS if (shouldSaveConfig) { Serial.println("saving config"); -#ifdef ARDUINOJSON_VERSION_MAJOR >= 6 + #if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6 DynamicJsonDocument json(1024); #else DynamicJsonBuffer jsonBuffer; @@ -148,7 +148,7 @@ void setup() { Serial.println("failed to open config file for writing"); } -#ifdef ARDUINOJSON_VERSION_MAJOR >= 6 +#if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6 serializeJson(json, Serial); serializeJson(json, configFile); #else diff --git a/lib/WiFiManager/examples/Parameters/SPIFFS/AutoConnectWithFSParametersAndCustomIP/AutoConnectWithFSParametersAndCustomIP.ino b/lib/WiFiManager/examples/Parameters/SPIFFS/AutoConnectWithFSParametersAndCustomIP/AutoConnectWithFSParametersAndCustomIP.ino index 27b9da9..63523e9 100644 --- a/lib/WiFiManager/examples/Parameters/SPIFFS/AutoConnectWithFSParametersAndCustomIP/AutoConnectWithFSParametersAndCustomIP.ino +++ b/lib/WiFiManager/examples/Parameters/SPIFFS/AutoConnectWithFSParametersAndCustomIP/AutoConnectWithFSParametersAndCustomIP.ino @@ -51,7 +51,7 @@ void setup() { std::unique_ptr buf(new char[size]); configFile.readBytes(buf.get(), size); -#ifdef ARDUINOJSON_VERSION_MAJOR >= 6 + #if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6 DynamicJsonDocument json(1024); auto deserializeError = deserializeJson(json, buf.get()); serializeJson(json, Serial); @@ -153,7 +153,7 @@ void setup() { //save the custom parameters to FS if (shouldSaveConfig) { Serial.println("saving config"); -#ifdef ARDUINOJSON_VERSION_MAJOR >= 6 + #if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6 DynamicJsonDocument json(1024); #else DynamicJsonBuffer jsonBuffer; @@ -172,7 +172,7 @@ void setup() { Serial.println("failed to open config file for writing"); } -#ifdef ARDUINOJSON_VERSION_MAJOR >= 6 + #if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6 serializeJson(json, Serial); serializeJson(json, configFile); #else diff --git a/lib/WiFiManager/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino b/lib/WiFiManager/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino index fc8ec32..2546c6a 100644 --- a/lib/WiFiManager/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino +++ b/lib/WiFiManager/examples/Super/OnDemandConfigPortal/OnDemandConfigPortal.ino @@ -23,7 +23,7 @@ WiFiManager wm; // TEST OPTION FLAGS -bool TEST_CP = true; // always start the configportal, even if ap found +bool TEST_CP = false; // always start the configportal, even if ap found int TESP_CP_TIMEOUT = 90; // test cp timeout bool TEST_NET = true; // do a network test after connect, (gets ntp time) @@ -34,6 +34,23 @@ bool WMISBLOCKING = true; // use blocking or non blocking mode, non global pa // char ssid[] = "*************"; // your network SSID (name) // char pass[] = "********"; // your network password + +//callbacks + // called after AP mode and config portal has started + // setAPCallback( std::function func ); + // called after webserver has started + // setWebServerCallback( std::function func ); + // called when settings reset have been triggered + // setConfigResetCallback( std::function func ); + // called when wifi settings have been changed and connection was successful ( or setBreakAfterConfig(true) ) + // setSaveConfigCallback( std::function func ); + // called when saving either params-in-wifi or params page + // setSaveParamsCallback( std::function func ); + // called when saving params-in-wifi or params before anything else happens (eg wifi) + // setPreSaveConfigCallback( std::function func ); + // called just before doing OTA update + // setPreOtaUpdateCallback( std::function func ); + void saveWifiCallback(){ Serial.println("[CALLBACK] saveCallback fired"); } @@ -64,15 +81,19 @@ void handleRoute(){ wm.server->send(200, "text/plain", "hello from user code"); } +void handlePreOtaUpdateCallback(){ + Update.onProgress([](unsigned int progress, unsigned int total) { + Serial.printf("CUSTOM Progress: %u%%\r", (progress / (total / 100))); + }); +} + void setup() { - // WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP + // WiFi.mode(WIFI_STA); // explicitly set mode, esp can default to STA+AP // put your setup code here, to run once: Serial.begin(115200); - // Serial1.begin(115200); - // Serial.setDebugOutput(true); - delay(1000); + // Serial.setDebugOutput(true); Serial.println("\n Starting"); // WiFi.setSleepMode(WIFI_NONE_SLEEP); // disable sleep, can improve ap stability @@ -83,20 +104,27 @@ void setup() { Serial.println("[ERROR] TEST"); Serial.println("[INFORMATION] TEST"); + + // WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN); // wifi_scan_method_t scanMethod + // WiFi.setSortMethod(WIFI_CONNECT_AP_BY_SIGNAL); // wifi_sort_method_t sortMethod - WIFI_CONNECT_AP_BY_SIGNAL,WIFI_CONNECT_AP_BY_SECURITY + // WiFi.setMinSecurity(WIFI_AUTH_WPA2_PSK); + + wm.setDebugOutput(true); wm.debugPlatformInfo(); //reset settings - for testing // wm.resetSettings(); - // wm.erase(); + // wm.erase(); // setup some parameters - + WiFiManagerParameter custom_html("

This Is Custom HTML

"); // only custom html WiFiManagerParameter custom_mqtt_server("server", "mqtt server", "", 40); WiFiManagerParameter custom_mqtt_port("port", "mqtt port", "", 6); WiFiManagerParameter custom_token("api_token", "api token", "", 16); WiFiManagerParameter custom_tokenb("invalid token", "invalid token", "", 0); // id is invalid, cannot contain spaces WiFiManagerParameter custom_ipaddress("input_ip", "input IP", "", 15,"pattern='\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}'"); // custom input attrs (ip mask) + WiFiManagerParameter custom_input_type("input_pwd", "input pass", "", 15,"type='password'"); // custom input attrs (ip mask) const char _customHtml_checkbox[] = "type=\"checkbox\""; WiFiManagerParameter custom_checkbox("my_checkbox", "My Checkbox", "T", 2, _customHtml_checkbox,WFM_LABEL_AFTER); @@ -128,6 +156,7 @@ void setup() { wm.setWebServerCallback(bindServerCallback); wm.setSaveConfigCallback(saveWifiCallback); wm.setSaveParamsCallback(saveParamCallback); + wm.setPreOtaUpdateCallback(handlePreOtaUpdateCallback); // add all your parameters here wm.addParameter(&custom_html); @@ -137,6 +166,7 @@ void setup() { wm.addParameter(&custom_tokenb); wm.addParameter(&custom_ipaddress); wm.addParameter(&custom_checkbox); + wm.addParameter(&custom_input_type); wm.addParameter(&custom_html_inputs); @@ -144,11 +174,21 @@ void setup() { custom_html.setValue("test",4); custom_token.setValue("test",4); - // set custom html head content , inside - const char* headhtml = ""; - wm.setCustomHeadElement(headhtml); + // const char* icon = " + // "; - // set custom html menu content , inside + + // set custom html head content , inside + // examples of favicon, or meta tags etc + // const char* headhtml = ""; + // const char* headhtml = ""; + // wm.setCustomHeadElement(headhtml); + + // set custom html menu content , inside menu item "custom", see setMenu() const char* menuhtml = "

\n"; wm.setCustomMenuHTML(menuhtml); @@ -186,7 +226,8 @@ void setup() { // set Hostname - wm.setHostname(("WM_"+wm.getDefaultAPName()).c_str()); + wm.setHostname(("WM_"+wm.getDefaultAPName()).c_str()); + // wm.setHostname("WM_RANDO_1234"); // set custom channel // wm.setWiFiAPChannel(13); @@ -271,11 +312,13 @@ void setup() { } void wifiInfo(){ + // can contain gargbage on esp32 if wifi is not ready yet Serial.println("[WIFI] WIFI INFO DEBUG"); // WiFi.printDiag(Serial); Serial.println("[WIFI] SAVED: " + (String)(wm.getWiFiIsSaved() ? "YES" : "NO")); Serial.println("[WIFI] SSID: " + (String)wm.getWiFiSSID()); Serial.println("[WIFI] PASS: " + (String)wm.getWiFiPass()); + Serial.println("[WIFI] HOSTNAME: " + (String)WiFi.getHostname()); } void loop() { @@ -348,7 +391,7 @@ void getTime() { } Serial.println(""); struct tm timeinfo; - gmtime_r(&now, &timeinfo); // @NOTE doesnt work in esp2.3.0 + gmtime_r(&now, &timeinfo); Serial.print("Current time: "); Serial.print(asctime(&timeinfo)); } diff --git a/lib/WiFiManager/examples/Tests/wifi_softap/wifi_softap.ino b/lib/WiFiManager/examples/Tests/wifi_softap/wifi_softap.ino new file mode 100644 index 0000000..aa3e45c --- /dev/null +++ b/lib/WiFiManager/examples/Tests/wifi_softap/wifi_softap.ino @@ -0,0 +1,51 @@ +// wifi_basic.ino + +#include +#include + +// #define NVSERASE +#ifdef NVSERASE +#include +#include +#endif + +void setup(){ + Serial.begin(115200); + delay(2000); + Serial.println("Startup...."); + + #ifdef NVSERASE + esp_err_t err; + err = nvs_flash_init(); + err = nvs_flash_erase(); + #endif + + Serial.setDebugOutput(true); + + WiFi.begin("hellowifi","noonehere"); + + while (WiFi.status() != WL_CONNECTED && millis()<15000) { + delay(500); + Serial.print("."); + } + + if(WiFi.status() == WL_CONNECTED){ + Serial.println(""); + Serial.println("WiFi connected."); + Serial.println("IP address: "); + // Serial.println(WiFi.localIP()); + } + else { + Serial.println("WiFi NOT CONNECTED, starting ap"); + /////////////// + /// BUG + // WiFi.enableSTA(false); // BREAKS softap start, says ok BUT no ap found + + delay(2000); + WiFi.softAP("espsoftap","12345678"); + } +} + +void loop(){ + +} \ No newline at end of file diff --git a/lib/WiFiManager/extras/WiFiManager.template.html b/lib/WiFiManager/extras/WiFiManager.template.html index e0643ec..20787e1 100644 --- a/lib/WiFiManager/extras/WiFiManager.template.html +++ b/lib/WiFiManager/extras/WiFiManager.template.html @@ -192,9 +192,8 @@ button:hover{ /*opacity: 80%;*/ } -input:disabled { +:disabled { opacity: 0.5; - /* not working in cp ?? */ } @@ -204,6 +203,7 @@ input:disabled { p = l.nextElementSibling.classList.contains('l'); document.getElementById('p').disabled = !p; if(p)document.getElementById('p').focus()}; + function f() {var x = document.getElementById('p');x.type==='password'?x.type='text':x.type='password';} @@ -251,7 +251,7 @@ input:disabled { -



+

Show Password

custom parameter


@@ -302,7 +302,11 @@ input:disabled {

H4 Color Header S

content
-

/info


+

Heading 1

+

Heading 2

+

Heading 3

+

Heading 4

+

WIFI HEAD (WIFI_OFF)


Chip ID
123456
Flash Chip ID
1234556
diff --git a/lib/WiFiManager/library.json b/lib/WiFiManager/library.json index dfff70b..6b92d24 100644 --- a/lib/WiFiManager/library.json +++ b/lib/WiFiManager/library.json @@ -1,6 +1,6 @@ { "name": "WiFiManager", - "version": "2.0.11-beta", + "version": "2.0.15-rc.1", "keywords": "wifi,wi-fi,esp,esp8266,esp32,espressif8266,espressif32,nodemcu,wemos,arduino", "description": "WiFi Configuration manager with web configuration portal for ESP boards", "authors": diff --git a/lib/WiFiManager/library.properties b/lib/WiFiManager/library.properties index 1c3a8ad..d358823 100644 --- a/lib/WiFiManager/library.properties +++ b/lib/WiFiManager/library.properties @@ -1,5 +1,5 @@ name=WiFiManager -version=2.0.11-beta +version=2.0.15-rc.1 author=tzapu maintainer=tablatronix sentence=WiFi Configuration manager with web configuration portal for Espressif ESPx boards, by tzapu diff --git a/lib/WiFiManager/strings_en.h b/lib/WiFiManager/strings_en.h index 771ef2b..cabeb58 100644 --- a/lib/WiFiManager/strings_en.h +++ b/lib/WiFiManager/strings_en.h @@ -1,499 +1,15 @@ /** - * strings_en.h - * engligh strings for - * WiFiManager, a library for the ESP8266/Arduino platform - * for configuration of WiFi credentials using a Captive Portal - * - * @author Creator tzapu - * @author tablatronix - * @version 0.0.0 - * @license MIT + * Contents of this file have moved to 2 new locations + * wm_strings_nn.h + * wm_consts_nn.h */ -#ifndef _WM_STRINGS_H_ -#define _WM_STRINGS_H_ +#warning "This file is deprecated" +#ifndef _STRINGS_EN_H_ +#define _STRINGS_EN_H_ -#ifndef WIFI_MANAGER_OVERRIDE_STRINGS -// !!! ABOVE WILL NOT WORK if you define in your sketch, must be build flag, if anyone one knows how to order includes to be able to do this it would be neat.. I have seen it done.. +// strings files must include a consts file! +#include "wm_strings_en.h" // include constants, tokens, routes -const char WM_VERSION_STR[] PROGMEM = "v1.0.11-beta"; - -const char HTTP_HEAD_START[] PROGMEM = "" -"" -"" -"" -"" -"{v}"; - -const char HTTP_SCRIPT[] PROGMEM = ""; // @todo add button states, disable on click , show ack , spinner etc - -const char HTTP_HEAD_END[] PROGMEM = "
"; // {c} = _bodyclass -// example of embedded logo, base64 encoded inline, No styling here -// const char HTTP_ROOT_MAIN[] PROGMEM = "

{v}

WiFiManager

"; -const char HTTP_ROOT_MAIN[] PROGMEM = "

{t}

{v}

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

\n", // MENU_WIFINOSCAN -"

\n", // MENU_INFO -"

\n",//MENU_PARAM -"

\n", // MENU_CLOSE -"

\n",// MENU_RESTART -"

\n", // MENU_EXIT -"

\n", // MENU_ERASE -"

\n",// MENU_UPDATE -"

" // MENU_SEP -}; - -// const char HTTP_PORTAL_OPTIONS[] PROGMEM = strcat(HTTP_PORTAL_MENU[0] , HTTP_PORTAL_MENU[3] , HTTP_PORTAL_MENU[7]); -const char HTTP_PORTAL_OPTIONS[] PROGMEM = ""; -const char HTTP_ITEM_QI[] PROGMEM = ""; // rssi icons -const char HTTP_ITEM_QP[] PROGMEM = "
{r}%
"; // rssi percentage {h} = hidden showperc pref -const char HTTP_ITEM[] PROGMEM = "
{v}{qi}{qp}
"; // {q} = HTTP_ITEM_QI, {r} = HTTP_ITEM_QP -// const char HTTP_ITEM[] PROGMEM = "
{v} {R} {r}% {q} {e}
"; // test all tokens - -const char HTTP_FORM_START[] PROGMEM = "
"; -const char HTTP_FORM_WIFI[] PROGMEM = "
"; -const char HTTP_FORM_WIFI_END[] PROGMEM = ""; -const char HTTP_FORM_STATIC_HEAD[] PROGMEM = "

"; -const char HTTP_FORM_END[] PROGMEM = "

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

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

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

Available Pages


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

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

* May not function inside captive portal, Open in browser http://192.168.4.1"; -const char HTTP_UPDATE_FAIL[] PROGMEM = "
Update Failed!
Reboot device and try again
"; -const char HTTP_UPDATE_SUCCESS[] PROGMEM = "
Update Successful.
Device Rebooting now...
"; - -#ifdef WM_JSTEST -const char HTTP_JS[] PROGMEM = -""; -#endif - -// Info html -// @todo remove html elements from progmem, repetetive strings -#ifdef ESP32 - const char HTTP_INFO_esphead[] PROGMEM = "

esp32


"; - const char HTTP_INFO_chiprev[] PROGMEM = "
Chip Rev
{1}
"; - const char HTTP_INFO_lastreset[] PROGMEM = "
Last reset reason
CPU0: {1}
CPU1: {2}
"; - const char HTTP_INFO_aphost[] PROGMEM = "
Access Point Hostname
{1}
"; - const char HTTP_INFO_psrsize[] PROGMEM = "
PSRAM Size
{1} bytes
"; - const char HTTP_INFO_temp[] PROGMEM = "
Temperature
{1} C° / {2} F°
Hall
{3}
"; -#else - const char HTTP_INFO_esphead[] PROGMEM = "

esp8266


"; - const char HTTP_INFO_fchipid[] PROGMEM = "
Flash Chip ID
{1}
"; - const char HTTP_INFO_corever[] PROGMEM = "
Core Version
{1}
"; - const char HTTP_INFO_bootver[] PROGMEM = "
Boot Version
{1}
"; - const char HTTP_INFO_lastreset[] PROGMEM = "
Last reset reason
{1}
"; - const char HTTP_INFO_flashsize[] PROGMEM = "
Real Flash Size
{1} bytes
"; -#endif - -const char HTTP_INFO_memsmeter[] PROGMEM = "
"; -const char HTTP_INFO_memsketch[] PROGMEM = "
Memory - Sketch Size
Used / Total bytes
{1} / {2}"; -const char HTTP_INFO_freeheap[] PROGMEM = "
Memory - Free Heap
{1} bytes available
"; -const char HTTP_INFO_wifihead[] PROGMEM = "

WiFi


"; -const char HTTP_INFO_uptime[] PROGMEM = "
Uptime
{1} Mins {2} Secs
"; -const char HTTP_INFO_chipid[] PROGMEM = "
Chip ID
{1}
"; -const char HTTP_INFO_idesize[] PROGMEM = "
Flash Size
{1} bytes
"; -const char HTTP_INFO_sdkver[] PROGMEM = "
SDK Version
{1}
"; -const char HTTP_INFO_cpufreq[] PROGMEM = "
CPU Frequency
{1}MHz
"; -const char HTTP_INFO_apip[] PROGMEM = "
Access Point IP
{1}
"; -const char HTTP_INFO_apmac[] PROGMEM = "
Access Point MAC
{1}
"; -const char HTTP_INFO_apssid[] PROGMEM = "
Access Point SSID
{1}
"; -const char HTTP_INFO_apbssid[] PROGMEM = "
BSSID
{1}
"; -const char HTTP_INFO_stassid[] PROGMEM = "
Station SSID
{1}
"; -const char HTTP_INFO_staip[] PROGMEM = "
Station IP
{1}
"; -const char HTTP_INFO_stagw[] PROGMEM = "
Station Gateway
{1}
"; -const char HTTP_INFO_stasub[] PROGMEM = "
Station Subnet
{1}
"; -const char HTTP_INFO_dnss[] PROGMEM = "
DNS Server
{1}
"; -const char HTTP_INFO_host[] PROGMEM = "
Hostname
{1}
"; -const char HTTP_INFO_stamac[] PROGMEM = "
Station MAC
{1}
"; -const char HTTP_INFO_conx[] PROGMEM = "
Connected
{1}
"; -const char HTTP_INFO_autoconx[] PROGMEM = "
Autoconnect
{1}
"; - -const char HTTP_INFO_aboutver[] PROGMEM = "
WiFiManager
{1}
"; -const char HTTP_INFO_aboutarduino[] PROGMEM = "
Arduino
{1}
"; -const char HTTP_INFO_aboutsdk[] PROGMEM = "
ESP-SDK/IDF
{1}
"; -const char HTTP_INFO_aboutdate[] PROGMEM = "
Build Date
{1}
"; - -const char S_brand[] PROGMEM = "WiFiManager"; -const char S_debugPrefix[] PROGMEM = "*wm:"; -const char S_y[] PROGMEM = "Yes"; -const char S_n[] PROGMEM = "No"; -const char S_enable[] PROGMEM = "Enabled"; -const char S_disable[] PROGMEM = "Disabled"; -const char S_GET[] PROGMEM = "GET"; -const char S_POST[] PROGMEM = "POST"; -const char S_NA[] PROGMEM = "Unknown"; -const char S_passph[] PROGMEM = "********"; -const char S_titlewifisaved[] PROGMEM = "Credentials Saved"; -const char S_titlewifisettings[] PROGMEM = "Settings Saved"; -const char S_titlewifi[] PROGMEM = "Config ESP"; -const char S_titleinfo[] PROGMEM = "Info"; -const char S_titleparam[] PROGMEM = "Setup"; -const char S_titleparamsaved[] PROGMEM = "Setup Saved"; -const char S_titleexit[] PROGMEM = "Exit"; -const char S_titlereset[] PROGMEM = "Reset"; -const char S_titleerase[] PROGMEM = "Erase"; -const char S_titleclose[] PROGMEM = "Close"; -const char S_options[] PROGMEM = "options"; -const char S_nonetworks[] PROGMEM = "No networks found. Refresh to scan again."; -const char S_staticip[] PROGMEM = "Static IP"; -const char S_staticgw[] PROGMEM = "Static Gateway"; -const char S_staticdns[] PROGMEM = "Static DNS"; -const char S_subnet[] PROGMEM = "Subnet"; -const char S_exiting[] PROGMEM = "Exiting"; -const char S_resetting[] PROGMEM = "Module will reset in a few seconds."; -const char S_closing[] PROGMEM = "You can close the page, portal will continue to run"; -const char S_error[] PROGMEM = "An Error Occured"; -const char S_notfound[] PROGMEM = "File Not Found\n\n"; -const char S_uri[] PROGMEM = "URI: "; -const char S_method[] PROGMEM = "\nMethod: "; -const char S_args[] PROGMEM = "\nArguments: "; -const char S_parampre[] PROGMEM = "param_"; - -// debug strings -const char D_HR[] PROGMEM = "--------------------"; - -// END WIFI_MANAGER_OVERRIDE_STRINGS -#endif - -// ----------------------------------------------------------------------------------------------- -// DO NOT EDIT BELOW THIS LINE - -const uint8_t _nummenutokens = 11; -const char * const _menutokens[_nummenutokens] PROGMEM = { - "wifi", - "wifinoscan", - "info", - "param", - "close", - "restart", - "exit", - "erase", - "update", - "sep", - "custom" -}; - -const char R_root[] PROGMEM = "/"; -const char R_wifi[] PROGMEM = "/wifi"; -const char R_wifinoscan[] PROGMEM = "/0wifi"; -const char R_wifisave[] PROGMEM = "/wifisave"; -const char R_info[] PROGMEM = "/info"; -const char R_param[] PROGMEM = "/param"; -const char R_paramsave[] PROGMEM = "/paramsave"; -const char R_restart[] PROGMEM = "/restart"; -const char R_exit[] PROGMEM = "/exit"; -const char R_close[] PROGMEM = "/close"; -const char R_erase[] PROGMEM = "/erase"; -const char R_status[] PROGMEM = "/status"; -const char R_update[] PROGMEM = "/update"; -const char R_updatedone[] PROGMEM = "/u"; - - -//Strings -const char S_ip[] PROGMEM = "ip"; -const char S_gw[] PROGMEM = "gw"; -const char S_sn[] PROGMEM = "sn"; -const char S_dns[] PROGMEM = "dns"; - -// softap ssid default prefix -#ifdef ESP8266 - const char S_ssidpre[] PROGMEM = "ESP"; -#elif defined(ESP32) - const char S_ssidpre[] PROGMEM = "ESP32"; -#else - const char S_ssidpre[] PROGMEM = "WM"; -#endif - -//Tokens -//@todo consolidate and reduce -const char T_ss[] PROGMEM = "{"; // token start sentinel -const char T_es[] PROGMEM = "}"; // token end sentinel -const char T_1[] PROGMEM = "{1}"; // @token 1 -const char T_2[] PROGMEM = "{2}"; // @token 2 -const char T_3[] PROGMEM = "{3}"; // @token 2 -const char T_v[] PROGMEM = "{v}"; // @token v -const char T_V[] PROGMEM = "{V}"; // @token v -const char T_I[] PROGMEM = "{I}"; // @token I -const char T_i[] PROGMEM = "{i}"; // @token i -const char T_n[] PROGMEM = "{n}"; // @token n -const char T_p[] PROGMEM = "{p}"; // @token p -const char T_t[] PROGMEM = "{t}"; // @token t -const char T_l[] PROGMEM = "{l}"; // @token l -const char T_c[] PROGMEM = "{c}"; // @token c -const char T_e[] PROGMEM = "{e}"; // @token e -const char T_q[] PROGMEM = "{q}"; // @token q -const char T_r[] PROGMEM = "{r}"; // @token r -const char T_R[] PROGMEM = "{R}"; // @token R -const char T_h[] PROGMEM = "{h}"; // @token h - -// http -const char HTTP_HEAD_CL[] PROGMEM = "Content-Length"; -const char HTTP_HEAD_CT[] PROGMEM = "text/html"; -const char HTTP_HEAD_CT2[] PROGMEM = "text/plain"; -const char HTTP_HEAD_CORS[] PROGMEM = "Access-Control-Allow-Origin"; -const char HTTP_HEAD_CORS_ALLOW_ALL[] PROGMEM = "*"; - -const char * const WIFI_STA_STATUS[] PROGMEM -{ - "WL_IDLE_STATUS", // 0 STATION_IDLE - "WL_NO_SSID_AVAIL", // 1 STATION_NO_AP_FOUND - "WL_SCAN_COMPLETED", // 2 - "WL_CONNECTED", // 3 STATION_GOT_IP - "WL_CONNECT_FAILED", // 4 STATION_CONNECT_FAIL, STATION_WRONG_PASSWORD(NI) - "WL_CONNECTION_LOST", // 5 - "WL_DISCONNECTED", // 6 - "WL_STATION_WRONG_PASSWORD" // 7 KLUDGE -}; - -#ifdef ESP32 -const char * const AUTH_MODE_NAMES[] PROGMEM -{ - "OPEN", - "WEP", - "WPA_PSK", - "WPA2_PSK", - "WPA_WPA2_PSK", - "WPA2_ENTERPRISE", - "MAX" -}; -#elif defined(ESP8266) -const char * const AUTH_MODE_NAMES[] PROGMEM -{ - "", - "", - "WPA_PSK", // 2 ENC_TYPE_TKIP - "", - "WPA2_PSK", // 4 ENC_TYPE_CCMP - "WEP", // 5 ENC_TYPE_WEP - "", - "OPEN", //7 ENC_TYPE_NONE - "WPA_WPA2_PSK", // 8 ENC_TYPE_AUTO -}; -#endif - -const char* const WIFI_MODES[] PROGMEM = { "NULL", "STA", "AP", "STA+AP" }; - - -#ifdef ESP32 -// as 2.5.2 -// typedef struct { -// char cc[3]; /**< country code string */ -// uint8_t schan; /**< start channel */ -// uint8_t nchan; /**< total channel number */ -// int8_t max_tx_power; /**< This field is used for getting WiFi maximum transmitting power, call esp_wifi_set_max_tx_power to set the maximum transmitting power. */ -// wifi_country_policy_t policy; /**< country policy */ -// } wifi_country_t; -const wifi_country_t WM_COUNTRY_US{"US",1,11,CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER,WIFI_COUNTRY_POLICY_AUTO}; -const wifi_country_t WM_COUNTRY_CN{"CN",1,13,CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER,WIFI_COUNTRY_POLICY_AUTO}; -const wifi_country_t WM_COUNTRY_JP{"JP",1,14,CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER,WIFI_COUNTRY_POLICY_AUTO}; -#elif defined(ESP8266) && !defined(WM_NOCOUNTRY) -// typedef struct { -// char cc[3]; /**< country code string */ -// uint8_t schan; /**< start channel */ -// uint8_t nchan; /**< total channel number */ -// uint8_t policy; /**< country policy */ -// } wifi_country_t; -const wifi_country_t WM_COUNTRY_US{"US",1,11,WIFI_COUNTRY_POLICY_AUTO}; -const wifi_country_t WM_COUNTRY_CN{"CN",1,13,WIFI_COUNTRY_POLICY_AUTO}; -const wifi_country_t WM_COUNTRY_JP{"JP",1,14,WIFI_COUNTRY_POLICY_AUTO}; -#endif - - -/* -* ESP32 WiFi Events - -0 SYSTEM_EVENT_WIFI_READY < ESP32 WiFi ready -1 SYSTEM_EVENT_SCAN_DONE < ESP32 finish scanning AP -2 SYSTEM_EVENT_STA_START < ESP32 station start -3 SYSTEM_EVENT_STA_STOP < ESP32 station stop -4 SYSTEM_EVENT_STA_CONNECTED < ESP32 station connected to AP -5 SYSTEM_EVENT_STA_DISCONNECTED < ESP32 station disconnected from AP -6 SYSTEM_EVENT_STA_AUTHMODE_CHANGE < the auth mode of AP connected by ESP32 station changed -7 SYSTEM_EVENT_STA_GOT_IP < ESP32 station got IP from connected AP -8 SYSTEM_EVENT_STA_LOST_IP < ESP32 station lost IP and the IP is reset to 0 -9 SYSTEM_EVENT_STA_WPS_ER_SUCCESS < ESP32 station wps succeeds in enrollee mode -10 SYSTEM_EVENT_STA_WPS_ER_FAILED < ESP32 station wps fails in enrollee mode -11 SYSTEM_EVENT_STA_WPS_ER_TIMEOUT < ESP32 station wps timeout in enrollee mode -12 SYSTEM_EVENT_STA_WPS_ER_PIN < ESP32 station wps pin code in enrollee mode -13 SYSTEM_EVENT_AP_START < ESP32 soft-AP start -14 SYSTEM_EVENT_AP_STOP < ESP32 soft-AP stop -15 SYSTEM_EVENT_AP_STACONNECTED < a station connected to ESP32 soft-AP -16 SYSTEM_EVENT_AP_STADISCONNECTED < a station disconnected from ESP32 soft-AP -17 SYSTEM_EVENT_AP_STAIPASSIGNED < ESP32 soft-AP assign an IP to a connected station -18 SYSTEM_EVENT_AP_PROBEREQRECVED < Receive probe request packet in soft-AP interface -19 SYSTEM_EVENT_GOT_IP6 < ESP32 station or ap or ethernet interface v6IP addr is preferred -20 SYSTEM_EVENT_ETH_START < ESP32 ethernet start -21 SYSTEM_EVENT_ETH_STOP < ESP32 ethernet stop -22 SYSTEM_EVENT_ETH_CONNECTED < ESP32 ethernet phy link up -23 SYSTEM_EVENT_ETH_DISCONNECTED < ESP32 ethernet phy link down -24 SYSTEM_EVENT_ETH_GOT_IP < ESP32 ethernet got IP from connected AP -25 SYSTEM_EVENT_MAX - - -typedef enum { - ARDUINO_EVENT_WIFI_READY = 0, - ARDUINO_EVENT_WIFI_SCAN_DONE, - ARDUINO_EVENT_WIFI_STA_START, - ARDUINO_EVENT_WIFI_STA_STOP, - ARDUINO_EVENT_WIFI_STA_CONNECTED, - ARDUINO_EVENT_WIFI_STA_DISCONNECTED, - ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE, - ARDUINO_EVENT_WIFI_STA_GOT_IP, - ARDUINO_EVENT_WIFI_STA_GOT_IP6, - ARDUINO_EVENT_WIFI_STA_LOST_IP, - ARDUINO_EVENT_WIFI_AP_START, - ARDUINO_EVENT_WIFI_AP_STOP, - ARDUINO_EVENT_WIFI_AP_STACONNECTED, - ARDUINO_EVENT_WIFI_AP_STADISCONNECTED, - ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED, - ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED, - ARDUINO_EVENT_WIFI_AP_GOT_IP6, - ARDUINO_EVENT_WIFI_FTM_REPORT, - ARDUINO_EVENT_ETH_START, - ARDUINO_EVENT_ETH_STOP, - ARDUINO_EVENT_ETH_CONNECTED, - ARDUINO_EVENT_ETH_DISCONNECTED, - ARDUINO_EVENT_ETH_GOT_IP, - ARDUINO_EVENT_ETH_GOT_IP6, - ARDUINO_EVENT_WPS_ER_SUCCESS, - ARDUINO_EVENT_WPS_ER_FAILED, - ARDUINO_EVENT_WPS_ER_TIMEOUT, - ARDUINO_EVENT_WPS_ER_PIN, - ARDUINO_EVENT_WPS_ER_PBC_OVERLAP, - ARDUINO_EVENT_SC_SCAN_DONE, - ARDUINO_EVENT_SC_FOUND_CHANNEL, - ARDUINO_EVENT_SC_GOT_SSID_PSWD, - ARDUINO_EVENT_SC_SEND_ACK_DONE, - ARDUINO_EVENT_PROV_INIT, - ARDUINO_EVENT_PROV_DEINIT, - ARDUINO_EVENT_PROV_START, - ARDUINO_EVENT_PROV_END, - ARDUINO_EVENT_PROV_CRED_RECV, - ARDUINO_EVENT_PROV_CRED_FAIL, - ARDUINO_EVENT_PROV_CRED_SUCCESS, - ARDUINO_EVENT_MAX -} arduino_event_id_t; - -typedef union { - wifi_event_sta_scan_done_t wifi_scan_done; - wifi_event_sta_authmode_change_t wifi_sta_authmode_change; - wifi_event_sta_connected_t wifi_sta_connected; - wifi_event_sta_disconnected_t wifi_sta_disconnected; - wifi_event_sta_wps_er_pin_t wps_er_pin; - wifi_event_sta_wps_fail_reason_t wps_fail_reason; - wifi_event_ap_probe_req_rx_t wifi_ap_probereqrecved; - wifi_event_ap_staconnected_t wifi_ap_staconnected; - wifi_event_ap_stadisconnected_t wifi_ap_stadisconnected; - wifi_event_ftm_report_t wifi_ftm_report; - ip_event_ap_staipassigned_t wifi_ap_staipassigned; - ip_event_got_ip_t got_ip; - ip_event_got_ip6_t got_ip6; - smartconfig_event_got_ssid_pswd_t sc_got_ssid_pswd; - esp_eth_handle_t eth_connected; - wifi_sta_config_t prov_cred_recv; - wifi_prov_sta_fail_reason_t prov_fail_reason; -} arduino_event_info_t; - -*/ -#endif +#endif \ No newline at end of file diff --git a/lib/WiFiManager/wm_consts_en.h b/lib/WiFiManager/wm_consts_en.h new file mode 100644 index 0000000..fc21b42 --- /dev/null +++ b/lib/WiFiManager/wm_consts_en.h @@ -0,0 +1,253 @@ +/** + * wm_consts.h + * internal const strings/tokens + * WiFiManager, a library for the ESP8266/Arduino platform + * for configuration of WiFi credentials using a Captive Portal + * + * @author Creator tzapu + * @author tablatronix + * @version 0.0.0 + * @license MIT + */ + +#ifndef _WM_CONSTS_H +#define _WM_CONSTS_H + + +// ----------------------------------------------------------------------------------------------- +// TOKENS + +const char WM_VERSION_STR[] PROGMEM = "v2.0.15-rc.1"; + +const uint8_t _nummenutokens = 11; +const char * const _menutokens[_nummenutokens] PROGMEM = { + "wifi", + "wifinoscan", + "info", + "param", + "close", + "restart", + "exit", + "erase", + "update", + "sep", + "custom" +}; + +const char R_root[] PROGMEM = "/"; +const char R_wifi[] PROGMEM = "/wifi"; +const char R_wifinoscan[] PROGMEM = "/0wifi"; +const char R_wifisave[] PROGMEM = "/wifisave"; +const char R_info[] PROGMEM = "/info"; +const char R_param[] PROGMEM = "/param"; +const char R_paramsave[] PROGMEM = "/paramsave"; +const char R_restart[] PROGMEM = "/restart"; +const char R_exit[] PROGMEM = "/exit"; +const char R_close[] PROGMEM = "/close"; +const char R_erase[] PROGMEM = "/erase"; +const char R_status[] PROGMEM = "/status"; +const char R_update[] PROGMEM = "/update"; +const char R_updatedone[] PROGMEM = "/u"; + + +//Strings +const char S_ip[] PROGMEM = "ip"; +const char S_gw[] PROGMEM = "gw"; +const char S_sn[] PROGMEM = "sn"; +const char S_dns[] PROGMEM = "dns"; + + + +//Tokens +//@todo consolidate and reduce +const char T_ss[] PROGMEM = "{"; // token start sentinel +const char T_es[] PROGMEM = "}"; // token end sentinel +const char T_1[] PROGMEM = "{1}"; // @token 1 +const char T_2[] PROGMEM = "{2}"; // @token 2 +const char T_3[] PROGMEM = "{3}"; // @token 2 +const char T_v[] PROGMEM = "{v}"; // @token v +const char T_V[] PROGMEM = "{V}"; // @token v +const char T_I[] PROGMEM = "{I}"; // @token I +const char T_i[] PROGMEM = "{i}"; // @token i +const char T_n[] PROGMEM = "{n}"; // @token n +const char T_p[] PROGMEM = "{p}"; // @token p +const char T_t[] PROGMEM = "{t}"; // @token t +const char T_l[] PROGMEM = "{l}"; // @token l +const char T_c[] PROGMEM = "{c}"; // @token c +const char T_e[] PROGMEM = "{e}"; // @token e +const char T_q[] PROGMEM = "{q}"; // @token q +const char T_r[] PROGMEM = "{r}"; // @token r +const char T_R[] PROGMEM = "{R}"; // @token R +const char T_h[] PROGMEM = "{h}"; // @token h + +// http +const char HTTP_HEAD_CL[] PROGMEM = "Content-Length"; +const char HTTP_HEAD_CT[] PROGMEM = "text/html"; +const char HTTP_HEAD_CT2[] PROGMEM = "text/plain"; +const char HTTP_HEAD_CORS[] PROGMEM = "Access-Control-Allow-Origin"; +const char HTTP_HEAD_CORS_ALLOW_ALL[] PROGMEM = "*"; + +const char * const WIFI_STA_STATUS[] PROGMEM +{ + "WL_IDLE_STATUS", // 0 STATION_IDLE + "WL_NO_SSID_AVAIL", // 1 STATION_NO_AP_FOUND + "WL_SCAN_COMPLETED", // 2 + "WL_CONNECTED", // 3 STATION_GOT_IP + "WL_CONNECT_FAILED", // 4 STATION_CONNECT_FAIL, STATION_WRONG_PASSWORD(NI) + "WL_CONNECTION_LOST", // 5 + "WL_DISCONNECTED", // 6 + "WL_STATION_WRONG_PASSWORD" // 7 KLUDGE +}; + +#ifdef ESP32 +const char * const AUTH_MODE_NAMES[] PROGMEM +{ + "OPEN", + "WEP", + "WPA_PSK", + "WPA2_PSK", + "WPA_WPA2_PSK", + "WPA2_ENTERPRISE", + "MAX" +}; +#elif defined(ESP8266) +const char * const AUTH_MODE_NAMES[] PROGMEM +{ + "", + "", + "WPA_PSK", // 2 ENC_TYPE_TKIP + "", + "WPA2_PSK", // 4 ENC_TYPE_CCMP + "WEP", // 5 ENC_TYPE_WEP + "", + "OPEN", //7 ENC_TYPE_NONE + "WPA_WPA2_PSK", // 8 ENC_TYPE_AUTO +}; +#endif + +const char* const WIFI_MODES[] PROGMEM = { "NULL", "STA", "AP", "STA+AP" }; + + +#ifdef ESP32 +// as 2.5.2 +// typedef struct { +// char cc[3]; /**< country code string */ +// uint8_t schan; /**< start channel */ +// uint8_t nchan; /**< total channel number */ +// int8_t max_tx_power; /**< This field is used for getting WiFi maximum transmitting power, call esp_wifi_set_max_tx_power to set the maximum transmitting power. */ +// wifi_country_policy_t policy; /**< country policy */ +// } wifi_country_t; +const wifi_country_t WM_COUNTRY_US{"US",1,11,CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER,WIFI_COUNTRY_POLICY_AUTO}; +const wifi_country_t WM_COUNTRY_CN{"CN",1,13,CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER,WIFI_COUNTRY_POLICY_AUTO}; +const wifi_country_t WM_COUNTRY_JP{"JP",1,14,CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER,WIFI_COUNTRY_POLICY_AUTO}; +#elif defined(ESP8266) && !defined(WM_NOCOUNTRY) +// typedef struct { +// char cc[3]; /**< country code string */ +// uint8_t schan; /**< start channel */ +// uint8_t nchan; /**< total channel number */ +// uint8_t policy; /**< country policy */ +// } wifi_country_t; +const wifi_country_t WM_COUNTRY_US{"US",1,11,WIFI_COUNTRY_POLICY_AUTO}; +const wifi_country_t WM_COUNTRY_CN{"CN",1,13,WIFI_COUNTRY_POLICY_AUTO}; +const wifi_country_t WM_COUNTRY_JP{"JP",1,14,WIFI_COUNTRY_POLICY_AUTO}; +#endif + + +/* +* ESP32 WiFi Events + +0 SYSTEM_EVENT_WIFI_READY < ESP32 WiFi ready +1 SYSTEM_EVENT_SCAN_DONE < ESP32 finish scanning AP +2 SYSTEM_EVENT_STA_START < ESP32 station start +3 SYSTEM_EVENT_STA_STOP < ESP32 station stop +4 SYSTEM_EVENT_STA_CONNECTED < ESP32 station connected to AP +5 SYSTEM_EVENT_STA_DISCONNECTED < ESP32 station disconnected from AP +6 SYSTEM_EVENT_STA_AUTHMODE_CHANGE < the auth mode of AP connected by ESP32 station changed +7 SYSTEM_EVENT_STA_GOT_IP < ESP32 station got IP from connected AP +8 SYSTEM_EVENT_STA_LOST_IP < ESP32 station lost IP and the IP is reset to 0 +9 SYSTEM_EVENT_STA_WPS_ER_SUCCESS < ESP32 station wps succeeds in enrollee mode +10 SYSTEM_EVENT_STA_WPS_ER_FAILED < ESP32 station wps fails in enrollee mode +11 SYSTEM_EVENT_STA_WPS_ER_TIMEOUT < ESP32 station wps timeout in enrollee mode +12 SYSTEM_EVENT_STA_WPS_ER_PIN < ESP32 station wps pin code in enrollee mode +13 SYSTEM_EVENT_AP_START < ESP32 soft-AP start +14 SYSTEM_EVENT_AP_STOP < ESP32 soft-AP stop +15 SYSTEM_EVENT_AP_STACONNECTED < a station connected to ESP32 soft-AP +16 SYSTEM_EVENT_AP_STADISCONNECTED < a station disconnected from ESP32 soft-AP +17 SYSTEM_EVENT_AP_STAIPASSIGNED < ESP32 soft-AP assign an IP to a connected station +18 SYSTEM_EVENT_AP_PROBEREQRECVED < Receive probe request packet in soft-AP interface +19 SYSTEM_EVENT_GOT_IP6 < ESP32 station or ap or ethernet interface v6IP addr is preferred +20 SYSTEM_EVENT_ETH_START < ESP32 ethernet start +21 SYSTEM_EVENT_ETH_STOP < ESP32 ethernet stop +22 SYSTEM_EVENT_ETH_CONNECTED < ESP32 ethernet phy link up +23 SYSTEM_EVENT_ETH_DISCONNECTED < ESP32 ethernet phy link down +24 SYSTEM_EVENT_ETH_GOT_IP < ESP32 ethernet got IP from connected AP +25 SYSTEM_EVENT_MAX + + +typedef enum { + ARDUINO_EVENT_WIFI_READY = 0, + ARDUINO_EVENT_WIFI_SCAN_DONE, + ARDUINO_EVENT_WIFI_STA_START, + ARDUINO_EVENT_WIFI_STA_STOP, + ARDUINO_EVENT_WIFI_STA_CONNECTED, + ARDUINO_EVENT_WIFI_STA_DISCONNECTED, + ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE, + ARDUINO_EVENT_WIFI_STA_GOT_IP, + ARDUINO_EVENT_WIFI_STA_GOT_IP6, + ARDUINO_EVENT_WIFI_STA_LOST_IP, + ARDUINO_EVENT_WIFI_AP_START, + ARDUINO_EVENT_WIFI_AP_STOP, + ARDUINO_EVENT_WIFI_AP_STACONNECTED, + ARDUINO_EVENT_WIFI_AP_STADISCONNECTED, + ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED, + ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED, + ARDUINO_EVENT_WIFI_AP_GOT_IP6, + ARDUINO_EVENT_WIFI_FTM_REPORT, + ARDUINO_EVENT_ETH_START, + ARDUINO_EVENT_ETH_STOP, + ARDUINO_EVENT_ETH_CONNECTED, + ARDUINO_EVENT_ETH_DISCONNECTED, + ARDUINO_EVENT_ETH_GOT_IP, + ARDUINO_EVENT_ETH_GOT_IP6, + ARDUINO_EVENT_WPS_ER_SUCCESS, + ARDUINO_EVENT_WPS_ER_FAILED, + ARDUINO_EVENT_WPS_ER_TIMEOUT, + ARDUINO_EVENT_WPS_ER_PIN, + ARDUINO_EVENT_WPS_ER_PBC_OVERLAP, + ARDUINO_EVENT_SC_SCAN_DONE, + ARDUINO_EVENT_SC_FOUND_CHANNEL, + ARDUINO_EVENT_SC_GOT_SSID_PSWD, + ARDUINO_EVENT_SC_SEND_ACK_DONE, + ARDUINO_EVENT_PROV_INIT, + ARDUINO_EVENT_PROV_DEINIT, + ARDUINO_EVENT_PROV_START, + ARDUINO_EVENT_PROV_END, + ARDUINO_EVENT_PROV_CRED_RECV, + ARDUINO_EVENT_PROV_CRED_FAIL, + ARDUINO_EVENT_PROV_CRED_SUCCESS, + ARDUINO_EVENT_MAX +} arduino_event_id_t; + +typedef union { + wifi_event_sta_scan_done_t wifi_scan_done; + wifi_event_sta_authmode_change_t wifi_sta_authmode_change; + wifi_event_sta_connected_t wifi_sta_connected; + wifi_event_sta_disconnected_t wifi_sta_disconnected; + wifi_event_sta_wps_er_pin_t wps_er_pin; + wifi_event_sta_wps_fail_reason_t wps_fail_reason; + wifi_event_ap_probe_req_rx_t wifi_ap_probereqrecved; + wifi_event_ap_staconnected_t wifi_ap_staconnected; + wifi_event_ap_stadisconnected_t wifi_ap_stadisconnected; + wifi_event_ftm_report_t wifi_ftm_report; + ip_event_ap_staipassigned_t wifi_ap_staipassigned; + ip_event_got_ip_t got_ip; + ip_event_got_ip6_t got_ip6; + smartconfig_event_got_ssid_pswd_t sc_got_ssid_pswd; + esp_eth_handle_t eth_connected; + wifi_sta_config_t prov_cred_recv; + wifi_prov_sta_fail_reason_t prov_fail_reason; +} arduino_event_info_t; + +*/ + +#endif \ No newline at end of file diff --git a/lib/WiFiManager/wm_strings_en.h b/lib/WiFiManager/wm_strings_en.h new file mode 100644 index 0000000..73ba6c1 --- /dev/null +++ b/lib/WiFiManager/wm_strings_en.h @@ -0,0 +1,275 @@ +/** + * wm_strings_en.h + * engligh strings for + * WiFiManager, a library for the ESP8266/Arduino platform + * for configuration of WiFi credentials using a Captive Portal + * + * @author Creator tzapu + * @author tablatronix + * @version 0.0.0 + * @license MIT + */ + +#ifndef _WM_STRINGS_EN_H_ +#define _WM_STRINGS_EN_H_ + + +#ifndef WIFI_MANAGER_OVERRIDE_STRINGS +// !!! ABOVE WILL NOT WORK if you define in your sketch, must be build flag, if anyone one knows how to order includes to be able to do this it would be neat.. I have seen it done.. + +// strings files must include a consts file! +#include "wm_consts_en.h" // include constants, tokens, routes + +const char WM_LANGUAGE[] PROGMEM = "en-US"; // i18n lang code + +const char HTTP_HEAD_START[] PROGMEM = "" +"" +"" +"" +"" +"{v}"; + +const char HTTP_SCRIPT[] PROGMEM = ""; // @todo add button states, disable on click , show ack , spinner etc + +const char HTTP_HEAD_END[] PROGMEM = "
"; // {c} = _bodyclass +// example of embedded logo, base64 encoded inline, No styling here +// const char HTTP_ROOT_MAIN[] PROGMEM = "

{v}

WiFiManager

"; +const char HTTP_ROOT_MAIN[] PROGMEM = "

{t}

{v}

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

\n", // MENU_WIFI +"

\n", // MENU_WIFINOSCAN +"

\n", // MENU_INFO +"

\n",//MENU_PARAM +"

\n", // MENU_CLOSE +"

\n",// MENU_RESTART +"

\n", // MENU_EXIT +"

\n", // MENU_ERASE +"

\n",// MENU_UPDATE +"

" // MENU_SEP +}; + +// const char HTTP_PORTAL_OPTIONS[] PROGMEM = strcat(HTTP_PORTAL_MENU[0] , HTTP_PORTAL_MENU[3] , HTTP_PORTAL_MENU[7]); +const char HTTP_PORTAL_OPTIONS[] PROGMEM = ""; +const char HTTP_ITEM_QI[] PROGMEM = ""; // rssi icons +const char HTTP_ITEM_QP[] PROGMEM = "
{r}%
"; // rssi percentage {h} = hidden showperc pref +const char HTTP_ITEM[] PROGMEM = "
{v}{qi}{qp}
"; // {q} = HTTP_ITEM_QI, {r} = HTTP_ITEM_QP +// const char HTTP_ITEM[] PROGMEM = "
{v} {R} {r}% {q} {e}
"; // test all tokens + +const char HTTP_FORM_START[] PROGMEM = "
"; +const char HTTP_FORM_WIFI[] PROGMEM = "
Show Password"; +const char HTTP_FORM_WIFI_END[] PROGMEM = ""; +const char HTTP_FORM_STATIC_HEAD[] PROGMEM = "

"; +const char HTTP_FORM_END[] PROGMEM = "

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

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

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

Available pages


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

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

* May not function inside captive portal, open in browser http://192.168.4.1"; +const char HTTP_UPDATE_FAIL[] PROGMEM = "
Update failed!
Reboot device and try again
"; +const char HTTP_UPDATE_SUCCESS[] PROGMEM = "
Update successful.
Device rebooting now...
"; + +#ifdef WM_JSTEST +const char HTTP_JS[] PROGMEM = +""; +#endif + +// Info html +// @todo remove html elements from progmem, repetetive strings +#ifdef ESP32 + const char HTTP_INFO_esphead[] PROGMEM = "

esp32


"; + const char HTTP_INFO_chiprev[] PROGMEM = "
Chip rev
{1}
"; + const char HTTP_INFO_lastreset[] PROGMEM = "
Last reset reason
CPU0: {1}
CPU1: {2}
"; + const char HTTP_INFO_aphost[] PROGMEM = "
Access point hostname
{1}
"; + const char HTTP_INFO_psrsize[] PROGMEM = "
PSRAM Size
{1} bytes
"; + const char HTTP_INFO_temp[] PROGMEM = "
Temperature
{1} C° / {2} F°
"; + const char HTTP_INFO_hall[] PROGMEM = "
Hall
{1}
"; +#else + const char HTTP_INFO_esphead[] PROGMEM = "

esp8266


"; + const char HTTP_INFO_fchipid[] PROGMEM = "
Flash chip ID
{1}
"; + const char HTTP_INFO_corever[] PROGMEM = "
Core version
{1}
"; + const char HTTP_INFO_bootver[] PROGMEM = "
Boot version
{1}
"; + const char HTTP_INFO_lastreset[] PROGMEM = "
Last reset reason
{1}
"; + const char HTTP_INFO_flashsize[] PROGMEM = "
Real flash size
{1} bytes
"; +#endif + +const char HTTP_INFO_memsmeter[] PROGMEM = "
"; +const char HTTP_INFO_memsketch[] PROGMEM = "
Memory - Sketch size
Used / Total bytes
{1} / {2}"; +const char HTTP_INFO_freeheap[] PROGMEM = "
Memory - Free heap
{1} bytes available
"; +const char HTTP_INFO_wifihead[] PROGMEM = "

WiFi


"; +const char HTTP_INFO_uptime[] PROGMEM = "
Uptime
{1} mins {2} secs
"; +const char HTTP_INFO_chipid[] PROGMEM = "
Chip ID
{1}
"; +const char HTTP_INFO_idesize[] PROGMEM = "
Flash size
{1} bytes
"; +const char HTTP_INFO_sdkver[] PROGMEM = "
SDK version
{1}
"; +const char HTTP_INFO_cpufreq[] PROGMEM = "
CPU frequency
{1}MHz
"; +const char HTTP_INFO_apip[] PROGMEM = "
Access point IP
{1}
"; +const char HTTP_INFO_apmac[] PROGMEM = "
Access point MAC
{1}
"; +const char HTTP_INFO_apssid[] PROGMEM = "
Access point SSID
{1}
"; +const char HTTP_INFO_apbssid[] PROGMEM = "
BSSID
{1}
"; +const char HTTP_INFO_stassid[] PROGMEM = "
Station SSID
{1}
"; +const char HTTP_INFO_staip[] PROGMEM = "
Station IP
{1}
"; +const char HTTP_INFO_stagw[] PROGMEM = "
Station gateway
{1}
"; +const char HTTP_INFO_stasub[] PROGMEM = "
Station subnet
{1}
"; +const char HTTP_INFO_dnss[] PROGMEM = "
DNS Server
{1}
"; +const char HTTP_INFO_host[] PROGMEM = "
Hostname
{1}
"; +const char HTTP_INFO_stamac[] PROGMEM = "
Station MAC
{1}
"; +const char HTTP_INFO_conx[] PROGMEM = "
Connected
{1}
"; +const char HTTP_INFO_autoconx[] PROGMEM = "
Autoconnect
{1}
"; + +const char HTTP_INFO_aboutver[] PROGMEM = "
WiFiManager
{1}
"; +const char HTTP_INFO_aboutarduino[] PROGMEM = "
Arduino
{1}
"; +const char HTTP_INFO_aboutsdk[] PROGMEM = "
ESP-SDK/IDF
{1}
"; +const char HTTP_INFO_aboutdate[] PROGMEM = "
Build date
{1}
"; + +const char S_brand[] PROGMEM = "WiFiManager"; +const char S_debugPrefix[] PROGMEM = "*wm:"; +const char S_y[] PROGMEM = "Yes"; +const char S_n[] PROGMEM = "No"; +const char S_enable[] PROGMEM = "Enabled"; +const char S_disable[] PROGMEM = "Disabled"; +const char S_GET[] PROGMEM = "GET"; +const char S_POST[] PROGMEM = "POST"; +const char S_NA[] PROGMEM = "Unknown"; +const char S_passph[] PROGMEM = "********"; +const char S_titlewifisaved[] PROGMEM = "Credentials saved"; +const char S_titlewifisettings[] PROGMEM = "Settings saved"; +const char S_titlewifi[] PROGMEM = "Config ESP"; +const char S_titleinfo[] PROGMEM = "Info"; +const char S_titleparam[] PROGMEM = "Setup"; +const char S_titleparamsaved[] PROGMEM = "Setup saved"; +const char S_titleexit[] PROGMEM = "Exit"; +const char S_titlereset[] PROGMEM = "Reset"; +const char S_titleerase[] PROGMEM = "Erase"; +const char S_titleclose[] PROGMEM = "Close"; +const char S_options[] PROGMEM = "options"; +const char S_nonetworks[] PROGMEM = "No networks found. Refresh to scan again."; +const char S_staticip[] PROGMEM = "Static IP"; +const char S_staticgw[] PROGMEM = "Static gateway"; +const char S_staticdns[] PROGMEM = "Static DNS"; +const char S_subnet[] PROGMEM = "Subnet"; +const char S_exiting[] PROGMEM = "Exiting"; +const char S_resetting[] PROGMEM = "Module will reset in a few seconds."; +const char S_closing[] PROGMEM = "You can close the page, portal will continue to run"; +const char S_error[] PROGMEM = "An error occured"; +const char S_notfound[] PROGMEM = "File not found\n\n"; +const char S_uri[] PROGMEM = "URI: "; +const char S_method[] PROGMEM = "\nMethod: "; +const char S_args[] PROGMEM = "\nArguments: "; +const char S_parampre[] PROGMEM = "param_"; + +// debug strings +const char D_HR[] PROGMEM = "--------------------"; + + +// softap ssid default prefix +#ifdef ESP8266 + const char S_ssidpre[] PROGMEM = "ESP"; +#elif defined(ESP32) + const char S_ssidpre[] PROGMEM = "ESP32"; +#else + const char S_ssidpre[] PROGMEM = "WM"; +#endif + +// END WIFI_MANAGER_OVERRIDE_STRINGS +#endif + +#endif diff --git a/networkDevices/WifiDevice.cpp b/networkDevices/WifiDevice.cpp index 844b7f5..f62dbdc 100644 --- a/networkDevices/WifiDevice.cpp +++ b/networkDevices/WifiDevice.cpp @@ -93,9 +93,12 @@ void WifiDevice::initialize() if(_restartOnDisconnect) { - _wm.setDisconnectedCallback([&]() + WiFi.onEvent([&](WiFiEvent_t event, WiFiEventInfo_t info) { - onDisconnected(); + if(event == ARDUINO_EVENT_WIFI_STA_DISCONNECTED) + { + onDisconnected(); + } }); } }