feat: abstract MQTT network transport
This commit is contained in:
1 parent
f8fc35a11a
commit
03c0ad81fe
19 files changed
+731
-306
No files matched your search
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
enum class NetworkTransition : uint8_t {
|
||||
None,
|
||||
Up,
|
||||
Down,
|
||||
};
|
||||
|
||||
namespace NetworkPolicy {
|
||||
|
||||
struct MQTTTransitionActions {
|
||||
bool disconnect_slots;
|
||||
bool retry_disconnected_slots_now;
|
||||
};
|
||||
|
||||
static constexpr MQTTTransitionActions mqttActions(NetworkTransition transition) {
|
||||
return {
|
||||
transition == NetworkTransition::Down,
|
||||
transition == NetworkTransition::Up,
|
||||
};
|
||||
}
|
||||
|
||||
// `start ota` uses the selected LAN only when reachable and not explicitly
|
||||
// forced to SoftAP. Manifest OTA has no fallback and checks connectivity itself.
|
||||
static constexpr bool startOtaUsesSelectedNetwork(bool force_ap,
|
||||
bool network_connected) {
|
||||
return !force_ap && network_connected;
|
||||
}
|
||||
|
||||
} // namespace NetworkPolicy
|
||||
Reference in new issue
Block a user