mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-04 02:48:13 +10:00
Add callback for OTA update (#1286)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -220,6 +220,8 @@ class WiFiManager
|
||||
//called when saving params-in-wifi or params before anything else happens (eg wifi)
|
||||
void setPreSaveConfigCallback( std::function<void()> func );
|
||||
|
||||
//called just before doing OTA update
|
||||
void setPreOtaUpdateCallback( 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
|
||||
@@ -661,6 +663,7 @@ class WiFiManager
|
||||
std::function<void()> _presavecallback;
|
||||
std::function<void()> _saveparamscallback;
|
||||
std::function<void()> _resetcallback;
|
||||
std::function<void()> _preotaupdatecallback;
|
||||
|
||||
template <class T>
|
||||
auto optionalIPFromString(T *obj, const char *s) -> decltype( obj->fromString(s) ) {
|
||||
|
||||
Reference in New Issue
Block a user