Update WiFiManager to 2.0.17

This commit is contained in:
iranl
2024-05-03 16:31:48 +02:00
parent 9b1097159d
commit 2a22ae015d
11 changed files with 690 additions and 377 deletions

View File

@@ -51,10 +51,10 @@
// #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
// #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.
@@ -222,24 +222,32 @@ class WiFiManagerParameter {
protected:
void init(const char *id, const char *label, const char *defaultValue, int length, const char *custom, int labelPlacement);
private:
WiFiManagerParameter& operator=(const WiFiManagerParameter&);
const char *_id;
const char *_label;
char *_value;
int _length;
int _labelPlacement;
protected:
const char *_customHTML;
friend class WiFiManager;
};
// debugging
typedef enum {
WM_DEBUG_SILENT = 0, // debug OFF but still compiled for runtime
WM_DEBUG_ERROR = 1, // error only
WM_DEBUG_NOTIFY = 2, // default stable,INFO
WM_DEBUG_VERBOSE = 3, // move verbose info
WM_DEBUG_DEV = 4, // development useful debugging info
WM_DEBUG_MAX = 5 // MAX extra dev auditing, var dumps etc (MAX+1 will print timing,mem and frag info)
} wm_debuglevel_t;
class WiFiManager
{
public:
WiFiManager(Print& consolePort);
WiFiManager(const char* user, const char* password);
WiFiManager();
~WiFiManager();
void WiFiManagerInit();
@@ -340,6 +348,7 @@ class WiFiManager
// toggle debug output
void setDebugOutput(boolean debug);
void setDebugOutput(boolean debug, String prefix); // log line prefix, default "*wm:"
void setDebugOutput(boolean debug, wm_debuglevel_t level ); // log line prefix, default "*wm:"
//set min quality percentage to include in scan, defaults to 8% if not specified
void setMinimumSignalQuality(int quality = 8);
@@ -499,7 +508,7 @@ class WiFiManager
std::unique_ptr<WM_WebServer> server;
private:
protected:
// vars
std::vector<uint8_t> _menuIds;
std::vector<const char *> _menuIdsParams = {"wifi","param","info","exit"};
@@ -550,7 +559,7 @@ 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 = true; // use an agrressive reconnect strategy, WILL delay conxs
bool _aggresiveReconn = false; // 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
// https://github.com/tzapu/WiFiManager/issues/1067
bool _allowExit = true; // allow exit in nonblocking, else user exit/abort calls will be ignored including cptimeout
@@ -608,9 +617,15 @@ class WiFiManager
// 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
//
// preload scanning causes AP to delay showing for users, but also caches and lets the cp load faster once its open
// my scan takes 7-10 seconds
public:
boolean _preloadwifiscan = false; // preload wifiscan if true
unsigned int _scancachetime = 30000; // ms cache time for preload scans
boolean _asyncScan = true; // perform wifi network scan async
boolean _asyncScan = false; // perform wifi network scan async
protected:
boolean _autoforcerescan = false; // automatically force rescan if scan networks is 0, ignoring cache
@@ -647,13 +662,16 @@ class WiFiManager
void updateConxResult(uint8_t status);
// webserver handlers
void HTTPSend(String content);
public:
void handleNotFound();
protected:
void HTTPSend(const String &content);
void handleRoot();
void handleWifi(boolean scan);
void handleWifiSave();
void handleInfo();
void handleReset();
void handleNotFound();
void handleExit();
void handleClose();
// void handleErase();
@@ -748,8 +766,15 @@ class WiFiManager
boolean abort = false;
boolean reset = false;
boolean configPortalActive = false;
// these are state flags for portal mode, we are either in webportal mode(STA) or configportal mode(AP)
// these are mutually exclusive as STA+AP mode is not supported due to channel restrictions and stability
// if we decide to support this, these checks will need to be replaced with something client aware to check if client origin is ap or web
// These state checks are critical and used for internal function checks
boolean webPortalActive = false;
boolean portalTimeoutResult = false;
boolean portalAbortResult = false;
boolean storeSTAmode = true; // option store persistent STA mode in connectwifi
int timer = 0; // timer for debug throttle for numclients, and portal timeout messages
@@ -759,26 +784,17 @@ class WiFiManager
int _max_params;
WiFiManagerParameter** _params = NULL;
// debugging
typedef enum {
DEBUG_ERROR = 0,
DEBUG_NOTIFY = 1, // default stable
DEBUG_VERBOSE = 2,
DEBUG_DEV = 3, // default dev
DEBUG_MAX = 4
} wm_debuglevel_t;
boolean _debug = true;
String _debugPrefix = FPSTR(S_debugPrefix);
wm_debuglevel_t debugLvlShow = DEBUG_VERBOSE; // at which level start showing [n] level tags
wm_debuglevel_t debugLvlShow = WM_DEBUG_VERBOSE; // at which level start showing [n] level tags
// build debuglevel support
// @todo use DEBUG_ESP_x?
// Set default debug level
#ifndef WM_DEBUG_LEVEL
#define WM_DEBUG_LEVEL DEBUG_NOTIFY
#define WM_DEBUG_LEVEL WM_DEBUG_NOTIFY
#endif
// override debug level OFF
@@ -821,10 +837,6 @@ class WiFiManager
std::function<void()> _preotaupdatecallback;
std::function<void()> _configportaltimeoutcallback;
bool _hasCredentials = false;
char _credUser[31] = {0};
char _credPassword[31] = {0};
template <class T>
auto optionalIPFromString(T *obj, const char *s) -> decltype( obj->fromString(s) ) {
return obj->fromString(s);