Add callback for OTA update (#1286)

This commit is contained in:
Mollayo
2021-09-03 21:23:37 -05:00
committed by GitHub
parent 8984863fe6
commit 8ce698427d
2 changed files with 16 additions and 0 deletions
+13
View File
@@ -2629,6 +2629,15 @@ void WiFiManager::setPreSaveConfigCallback( std::function<void()> func ) {
_presavecallback = func;
}
/**
* setPreOtaUpdateCallback, set a callback to fire before OTA update
* @access public
* @param {[type]} void (*func)(void)
*/
void WiFiManager::setPreOtaUpdateCallback( std::function<void()> func ) {
_preotaupdatecallback = func;
}
/**
* set custom head html
* custom element will be added to head, eg. new style tag etc.
@@ -3587,6 +3596,10 @@ void WiFiManager::handleUpdating(){
if(_debug) Serial.setDebugOutput(true);
uint32_t maxSketchSpace;
// Use new callback for before OTA update
if (_preotaupdatecallback != NULL) {
_preotaupdatecallback();
}
#ifdef ESP8266
WiFiUDP::stopAll();
maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;