mirror of
https://github.com/Laxilef/OTGateway.git
synced 2025-12-12 11:14:28 +05:00
disable tasks before ota update
This commit is contained in:
@@ -37,9 +37,15 @@ class WifiManagerTask : public Task {
|
|||||||
public:
|
public:
|
||||||
WifiManagerTask(bool _enabled = false, unsigned long _interval = 0) : Task(_enabled, _interval) {}
|
WifiManagerTask(bool _enabled = false, unsigned long _interval = 0) : Task(_enabled, _interval) {}
|
||||||
|
|
||||||
|
WifiManagerTask* addTaskForDisable(Task* task) {
|
||||||
|
this->tasksForDisable.push_back(task);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool connected = false;
|
bool connected = false;
|
||||||
unsigned long lastArpGratuitous = 0;
|
unsigned long lastArpGratuitous = 0;
|
||||||
|
std::vector<Task*> tasksForDisable;
|
||||||
|
|
||||||
const char* getTaskName() {
|
const char* getTaskName() {
|
||||||
return "WifiManager";
|
return "WifiManager";
|
||||||
@@ -142,6 +148,14 @@ protected:
|
|||||||
wm.setAPClientCheck(true);
|
wm.setAPClientCheck(true);
|
||||||
wm.setConfigPortalBlocking(false);
|
wm.setConfigPortalBlocking(false);
|
||||||
wm.setSaveParamsCallback(saveParamsCallback);
|
wm.setSaveParamsCallback(saveParamsCallback);
|
||||||
|
wm.setPreOtaUpdateCallback([this] {
|
||||||
|
for (Task* task : this->tasksForDisable) {
|
||||||
|
if (task->isEnabled()) {
|
||||||
|
task->disable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this->delay(10);
|
||||||
|
});
|
||||||
wm.setConfigPortalTimeout(wm.getWiFiIsSaved() ? 180 : 0);
|
wm.setConfigPortalTimeout(wm.getWiFiIsSaved() ? 180 : 0);
|
||||||
wm.setDisableConfigPortal(false);
|
wm.setDisableConfigPortal(false);
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,13 @@ void setup() {
|
|||||||
tMain = new MainTask(true, 100);
|
tMain = new MainTask(true, 100);
|
||||||
Scheduler.start(tMain);
|
Scheduler.start(tMain);
|
||||||
|
|
||||||
|
tWm
|
||||||
|
->addTaskForDisable(tMain)
|
||||||
|
->addTaskForDisable(tMqtt)
|
||||||
|
->addTaskForDisable(tOt)
|
||||||
|
->addTaskForDisable(tSensors)
|
||||||
|
->addTaskForDisable(tRegulator);
|
||||||
|
|
||||||
Scheduler.begin();
|
Scheduler.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user