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