Commit 8ce6984 1 parent 8984863 commit 8ce6984 Copy full SHA for 8ce6984
File tree 2 files changed +16
-0
lines changed
2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -2629,6 +2629,15 @@ void WiFiManager::setPreSaveConfigCallback( std::function<void()> func ) {
2629
2629
_presavecallback = func;
2630
2630
}
2631
2631
2632
+ /* *
2633
+ * setPreOtaUpdateCallback, set a callback to fire before OTA update
2634
+ * @access public
2635
+ * @param {[type]} void (*func)(void)
2636
+ */
2637
+ void WiFiManager::setPreOtaUpdateCallback ( std::function<void ()> func ) {
2638
+ _preotaupdatecallback = func;
2639
+ }
2640
+
2632
2641
/* *
2633
2642
* set custom head html
2634
2643
* custom element will be added to head, eg. new style tag etc.
@@ -3587,6 +3596,10 @@ void WiFiManager::handleUpdating(){
3587
3596
if (_debug) Serial.setDebugOutput (true );
3588
3597
uint32_t maxSketchSpace;
3589
3598
3599
+ // Use new callback for before OTA update
3600
+ if (_preotaupdatecallback != NULL ) {
3601
+ _preotaupdatecallback ();
3602
+ }
3590
3603
#ifdef ESP8266
3591
3604
WiFiUDP::stopAll ();
3592
3605
maxSketchSpace = (ESP.getFreeSketchSpace () - 0x1000 ) & 0xFFFFF000 ;
Original file line number Diff line number Diff line change @@ -220,6 +220,8 @@ class WiFiManager
220
220
// called when saving params-in-wifi or params before anything else happens (eg wifi)
221
221
void setPreSaveConfigCallback ( std::function<void ()> func );
222
222
223
+ // called just before doing OTA update
224
+ void setPreOtaUpdateCallback ( std::function<void ()> func );
223
225
224
226
// sets timeout before AP,webserver loop ends and exits even if there has been no setup.
225
227
// useful for devices that failed to connect at some point and got stuck in a webserver loop
@@ -661,6 +663,7 @@ class WiFiManager
661
663
std::function<void ()> _presavecallback;
662
664
std::function<void ()> _saveparamscallback;
663
665
std::function<void ()> _resetcallback;
666
+ std::function<void ()> _preotaupdatecallback;
664
667
665
668
template <class T >
666
669
auto optionalIPFromString (T *obj, const char *s) -> decltype( obj->fromString (s) ) {
You can’t perform that action at this time.
0 commit comments