mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-14 23:21:31 +10:00
feat(callback): add config portal timeout callback for handle config portal timeout (#1497)
This commit is contained in:
@@ -786,6 +786,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;
|
||||
}
|
||||
|
||||
@@ -830,6 +836,12 @@ boolean WiFiManager::process(){
|
||||
#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;
|
||||
}
|
||||
|
||||
@@ -2788,6 +2800,15 @@ void WiFiManager::setPreOtaUpdateCallback( std::function<void()> func ) {
|
||||
_preotaupdatecallback = func;
|
||||
}
|
||||
|
||||
/**
|
||||
* setConfigPortalTimeoutCallback, set a callback to config portal is timeout
|
||||
* @access public
|
||||
* @param {[type]} void (*func)(void)
|
||||
*/
|
||||
void WiFiManager::setConfigPortalTimeoutCallback( std::function<void()> func ) {
|
||||
_configportaltimeoutcallback = func;
|
||||
}
|
||||
|
||||
/**
|
||||
* set custom head html
|
||||
* custom element will be added to head, eg. new meta,style,script tag etc.
|
||||
|
||||
@@ -276,6 +276,9 @@ class WiFiManager
|
||||
//called just before doing OTA update
|
||||
void setPreOtaUpdateCallback( std::function<void()> func );
|
||||
|
||||
//called when config portal is timeout
|
||||
void setConfigPortalTimeoutCallback( std::function<void()> 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
|
||||
@@ -771,6 +774,7 @@ class WiFiManager
|
||||
std::function<void()> _saveparamscallback;
|
||||
std::function<void()> _resetcallback;
|
||||
std::function<void()> _preotaupdatecallback;
|
||||
std::function<void()> _configportaltimeoutcallback;
|
||||
|
||||
template <class T>
|
||||
auto optionalIPFromString(T *obj, const char *s) -> decltype( obj->fromString(s) ) {
|
||||
|
||||
Reference in New Issue
Block a user