add option to restart ESP when disconnected

This commit is contained in:
technyon
2022-06-30 20:25:37 +02:00
parent 2ef59fc0b6
commit d693e8a065
6 changed files with 47 additions and 0 deletions

View File

@@ -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