From ec1d474d7b5ab3e0bdf7ca37c29aa43ae19e4900 Mon Sep 17 00:00:00 2001 From: tablatronix Date: Fri, 5 Oct 2018 14:29:11 -0500 Subject: [PATCH] readme and comments --- README.md | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++ WiFiManager.h | 38 ++++++++++-------- 2 files changed, 130 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index e4c3857..a032860 100644 --- a/README.md +++ b/README.md @@ -431,3 +431,112 @@ And countless others * https://github.com/chriscook8/esp-arduino-apboot * https://github.com/esp8266/Arduino/tree/master/libraries/DNSServer/examples/CaptivePortalAdvanced * Built by AlexT https://github.com/tzapu + +#### THIS BRANCH - Development +## Development Overview + +### Added Public Methods +`setConfigPortalBlocking` + +`setShowStaticFields` + +`setCaptivePortalEnable` + +`setRestorePersistent` + +`setCaptivePortalClientCheck` + +`setWebPortalClientCheck` + +`startWebPortal` + +`stopWebPortal` + +`process` + +`disconnect` + +`erase` + +` debugSoftAPConfig` + +` debugPlatformInfo` + +`setScanDispPerc` + +`setHostname` + +`setMenu(menu_page_t[])` + +`setWiFiAutoReconnect` + +` setSTAStaticIPConfig(..,dns)` + +`setShowDnsFields` + +`getLastConxResult` + +`getWLStatusString` + +`getModeString` + +`getWiFiIsSaved` + +`setShowInfoErase` + +`setEnableConfigPortal` + +`setCountry` + +`setClass` + +`htmleEtities` + + +### WiFiManagerParameter +`WiFiManagerParameter(id,label)` + +`WiFiManagerParameter.setValue(value,length)` + +`getParameters` + +`getParametersCount` + + +### Constructors +`WiFiManager(Stream& consolePort)` + +## define flags +❗️ **Defines cannot be set in user sketches** +`#define WM_MDNS // use MDNS` +`#define WM_FIXERASECONFIG // use erase flash fix, esp8266 2.4.0` +`#define WM_ERASE_NVS // esp32 erase(true) will erase NVS` +`#include // esp32 info page will show last reset reasons if this file is included` + +## Changes +- ESP32 support ( fairly stable ) +- complete refactor of strings `strings_en.h` +- adds new tokens for wifiscan, and some classes (left , invert icons, MSG color) +- adds status callout panel default, primary, special colors +- adds tons of info on info page, and erase capability +- adds signal icons, replaces percentage ( has hover titles ) +- adds labels to all inputs (replaces placeholders) +- all html ( and eventually all strings except debug) moved to `strings_en.h` +- added additional debugging, compressed debug lines, debuglevels +- persistent disabled, and restored via de/con-stuctor (uses `setRestorePersistent`) +- should retain all user modes including AP, should not overwrite or persist user modes or configs,even STA (`storeSTAmode`) (BUGGY) +- ⚠️ return values may have changed depending on portal abort, or timeout ( `portalTimeoutResult`,`portalAbortResult`) +- params memory is auto allocated by increment of `WIFI_MANAGER_MAX_PARAMS(5)` when exceeded, user no longer needs to specify this at all. +- addparameter now returns bool, and it returns false if param ID is not alphanum [0-9,A-Z,a-z,_] +- param field ids allow {I} token to use param_n instead of string in case someones wants to change this due to i18n or character issues +- provides `#DEFINE FIXERASECONFIG` to help deal with https://github.com/esp8266/Arduino/pull/3635 +- failure reason reporting on portal +- set esp8266 sta hostname, esp32 sta+ap hostname ( DHCP client id) +- pass in debug stream in constructor WiFiManager(Stream& consolePort) +- you can force ip fields off with showxfields(false) if you set _disableIpFields=true +- param menu/page (setup) added to separate params from wifi page, handled automatically by setMenu +- set custom root menu +- disable configportal on autoconnect +- wm parameters init is now protected, allowing child classes, example included +- wifiscans are precached and async for faster page loads, refresh forces rescan +- adds esp32 gettemperature ( currently commented out, useful for relative measurement only ) \ No newline at end of file diff --git a/WiFiManager.h b/WiFiManager.h index 97d3103..b591f50 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -31,8 +31,8 @@ // #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 -// autoreconnect status WORKING https://github.com/espressif/arduino-esp32/issues/653#issuecomment-405604766 +// #define esp32autoreconnect // implement esp32 autoreconnect event listener kludge, deprecated +// autoreconnect is WORKING https://github.com/espressif/arduino-esp32/issues/653#issuecomment-405604766 #define WM_WEBSERVERSHIM // use webserver shim lib @@ -174,6 +174,24 @@ class WiFiManager bool erase(); bool erase(bool opt); + //adds a custom parameter, returns false on failure + bool addParameter(WiFiManagerParameter *p); + //returns the list of Parameters + WiFiManagerParameter** getParameters(); + // returns the Parameters Count + int getParametersCount(); + + + //called when AP mode and config portal is started + void setAPCallback( std::function func ); + //called when settings reset have been triggered + void setConfigResetCallback(void(*func)(void)); + //called when settings have been changed and connection was successful + void setSaveConfigCallback( std::function func ); + //called when settings before have been changed and connection was successful + void setPreSaveConfigCallback( 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 //in seconds setConfigPortalTimeout is a new name for setTimeout, ! not used if setConfigPortalBlocking @@ -194,20 +212,6 @@ class WiFiManager void setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn); //sets config for a static IP with DNS void setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn, IPAddress dns); - //called when AP mode and config portal is started - void setAPCallback( std::function func ); - //called when settings reset have been triggered - void setConfigResetCallback(void(*func)(void)); - //called when settings have been changed and connection was successful - void setSaveConfigCallback( std::function func ); - //called when settings before have been changed and connection was successful - void setPreSaveConfigCallback( std::function func ); - //adds a custom parameter, returns false on failure - bool addParameter(WiFiManagerParameter *p); - //returns the list of Parameters - WiFiManagerParameter** getParameters(); - // returns the Parameters Count - int getParametersCount(); //if this is set, it will exit after config, even if connection is unsuccessful. void setBreakAfterConfig(boolean shouldBreak); // if this is set, portal will be blocking and wait until save or exit, @@ -465,7 +469,7 @@ class WiFiManager template void DEBUG_WM(Generic text); - template + template void DEBUG_WM(wm_debuglevel_t level,Generic text); template void DEBUG_WM(Generic text,Genericb textb);