SensESP 3.4.1-alpha
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
system_status_controller.h
Go to the documentation of this file.
1#ifndef _SYSTEM_STATUS_CONTROLLER_H_
2#define _SYSTEM_STATUS_CONTROLLER_H_
3
8
9namespace sensesp {
10
20
28class SystemStatusController : public ValueProducer<SystemStatus> {
29 public:
31
35
39
40 protected:
58
60 switch (new_value) {
62 if (current_state_ != SystemStatus::kWifiDisconnected &&
63 current_state_ != SystemStatus::kWifiNoAP &&
64 current_state_ != SystemStatus::kWifiManagerActivated) {
65 // Wifi disconnection states override the higher level protocol state
67 }
68 break;
71 break;
74 break;
77 break;
79 // No distinct status-LED pattern: treat like a disconnect for the LED.
80 // The certificate-specific message is surfaced on the web Status page
81 // via get_connection_status().
82 if (current_state_ != SystemStatus::kWifiDisconnected &&
83 current_state_ != SystemStatus::kWifiNoAP &&
84 current_state_ != SystemStatus::kWifiManagerActivated) {
86 }
87 break;
88 }
89 }
90
92 [this](const WiFiState& new_value) { this->set_wifi_state(new_value); }};
97
98 void update_state(const SystemStatus new_state) {
99 current_state_ = new_state;
100 this->emit(new_state);
101 }
102
103 private:
104 SystemStatus current_state_ = SystemStatus::kWifiNoAP;
105};
106
107} // namespace sensesp
108
109#endif
Provides an easy way of calling a function based on the output of any ValueProducer.
Base class for a controller that can react to system status events.
void set_sk_ws_connection_state(const SKWSConnectionState &new_value)
LambdaConsumer< WiFiState > wifi_state_consumer_
LambdaConsumer< SKWSConnectionState > ws_connection_state_consumer_
void update_state(const SystemStatus new_state)
void set_wifi_state(const WiFiState &new_value)
ValueConsumer< SKWSConnectionState > & get_ws_connection_state_consumer()
ValueConsumer< WiFiState > & get_wifi_state_consumer()
A base class for piece of code (like a transform) that accepts data for input. ValueConsumers can acc...
A base class for any sensor or piece of code that outputs a value for consumption elsewhere.
void emit(const SystemStatus &new_value)