mirror of
https://github.com/Laxilef/OTGateway.git
synced 2026-11-30 18:23:03 +05:00
refactor: simplify task configuration and registration
This commit is contained in:
1 parent
d19f6aaa52
commit
4004927ecd
9 files changed
+38
-55
No files matched your search
+6
-5
@@ -1852,15 +1852,16 @@ Task mqttConfigureTask("Configure MQTT", Task::Type::ONCE, [](void*) {
|
||||
});
|
||||
|
||||
void initMqtt() {
|
||||
onNetworkEvent([](NetworkEvent event) {
|
||||
if (event == NetworkEvent::CONNECTED || event == NetworkEvent::DISCONNECTED || event == NetworkEvent::EVENTS_OVERFLOW) {
|
||||
requestReconfigureMqtt();
|
||||
}
|
||||
});
|
||||
|
||||
// Keep only the configuration dispatcher when MQTT publications are disabled.
|
||||
mqttConfigureTask.pause().setEnabledWhen([] {
|
||||
return !upgrading && !restartTask.scheduled() && !restartTask.active();
|
||||
});
|
||||
|
||||
appTaskManager.addTask(mqttConfigureTask);
|
||||
onNetworkEvent([](NetworkEvent event) {
|
||||
if (event == NetworkEvent::CONNECTED || event == NetworkEvent::DISCONNECTED || event == NetworkEvent::EVENTS_OVERFLOW) {
|
||||
requestReconfigureMqtt();
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user