add option to restart ESP when disconnected
This commit is contained in:
@@ -2705,6 +2705,15 @@ void WiFiManager::setPreOtaUpdateCallback( std::function<void()> func ) {
|
||||
_preotaupdatecallback = func;
|
||||
}
|
||||
|
||||
/**
|
||||
* setDisconnectedCallback, set a callback to fire when WiFi is disconnected
|
||||
* @access public
|
||||
* @param {[type]} void (*func)(void)
|
||||
*/
|
||||
void WiFiManager::setDisconnectedCallback( std::function<void()> func ) {
|
||||
_disconnectedcallback = func;
|
||||
}
|
||||
|
||||
/**
|
||||
* set custom head html
|
||||
* custom element will be added to head, eg. new style tag etc.
|
||||
@@ -3611,6 +3620,12 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user