19#ifndef SRC_SUPLA_ELEMENT_WITH_CHANNEL_ACTIONS_H_
20#define SRC_SUPLA_ELEMENT_WITH_CHANNEL_ACTIONS_H_
23#include <supla-common/proto.h>
24#include <supla/element.h>
25#include <supla/local_action.h>
29enum class ChannelConfigState : uint8_t {
31 LocalChangePending = 1,
32 SetChannelConfigSend = 2,
33 SetChannelConfigFailed = 3,
34 WaitForConfigFinished = 4,
39enum class ApplyConfigResult : uint8_t {
43 SetChannelConfigNeeded,
51 uint8_t configFinishedReceived: 1;
52 uint8_t defaultConfig: 1;
53 uint8_t weeklySchedule: 1;
54 uint8_t altWeeklySchedule: 1;
56 uint8_t extendedDefaultConfig: 1;
62 bool isSet(
int configType)
const;
63 void clear(
int configType);
65 void setAll(uint8_t values);
66 uint8_t getAll()
const;
67 void setConfigFinishedReceived();
68 void clearConfigFinishedReceived();
69 bool isConfigFinishedReceived()
const;
70 void set(
int configType,
bool value =
true);
81class ElementWithChannelActions :
public Element,
public LocalAction {
83 explicit ElementWithChannelActions(
84 ElementMode mode = ElementMode::Registered);
87 void addAction(uint16_t action,
90 bool alwaysEnabled =
false)
override;
91 void addAction(uint16_t action,
ActionHandler *client, uint16_t event,
92 bool alwaysEnabled =
false)
override;
100 virtual void addAction(uint16_t action,
104 bool alwaysEnabled =
false);
108 virtual void addAction(uint16_t action,
ActionHandler *client,
111 bool alwaysEnabled =
false);
112 virtual void addAction(uint16_t action,
115 bool alwaysEnabled =
false);
116 virtual void addAction(uint16_t action,
ActionHandler *client,
118 bool alwaysEnabled =
false);
120 bool isEventAlreadyUsed(uint16_t event,
bool ignoreAlwaysEnabled)
override;
130 void runAction(uint16_t event)
const override;
137 virtual void fillChannelConfig(
void *channelConfig,
int *size, uint8_t index);
139 void triggerSetChannelConfig(
int configType = SUPLA_CONFIG_TYPE_DEFAULT);
143 virtual bool setAndSaveFunction(uint32_t channelFunction);
144 virtual bool loadFunctionFromConfig();
145 virtual bool saveConfigChangeFlag()
const;
146 virtual bool loadConfigChangeFlag();
147 void clearChannelConfigChangedFlag();
148 bool iterateConfigExchange();
155 Supla::ChannelConfigState channelConfigState =
156 Supla::ChannelConfigState::None;
158 uint8_t setChannelConfigAttempts = 0;
Definition action_handler.h:21
Definition condition.h:27
void purgeConfig() override
Removes all configration data related to the element from Storage::Config.
Definition element_with_channel_actions.cpp:502
void onRegistered(Supla::Protocol::SuplaSrpc *suplaSrpc) override
Method called each time when device successfully registers to Supla server.
Definition element_with_channel_actions.cpp:317
bool isAnyUpdatePending() const override
Returns true if any update is pending.
Definition element_with_channel_actions.cpp:288
void handleSetChannelConfigResult(TSDS_SetChannelConfigResult *result) override
Handles "set channel config" reply from server.
Definition element_with_channel_actions.cpp:465
int getNextConfigType() const
Returns the next config type to be sent.
Definition element_with_channel_actions.cpp:605
uint8_t handleChannelConfig(TSD_ChannelConfig *result, bool local) override
Handles "set channel config" request from server.
Definition element_with_channel_actions.cpp:367
void handleChannelConfigFinished() override
Handles "channel config finished" message from server.
Definition element_with_channel_actions.cpp:338
bool iterateConnected() override
Method called on each SuplaDevice iteration when device is connected and registered to Supla server o...
Definition element_with_channel_actions.cpp:355
Definition local_action.h:52
Definition supla_srpc.h:61
Definition element_with_channel_actions.h:47