4#ifndef SRC_SUPLA_ELEMENT_WITH_CHANNEL_ACTIONS_H_
5#define SRC_SUPLA_ELEMENT_WITH_CHANNEL_ACTIONS_H_
8#include <supla-common/proto.h>
9#include <supla/apply_config_result.h>
10#include <supla/element.h>
11#include <supla/local_action.h>
15enum class ChannelConfigState : uint8_t {
17 LocalChangePending = 1,
18 SetChannelConfigSend = 2,
19 SetChannelConfigFailed = 3,
20 WaitForConfigFinished = 4,
26static_assert(
static_cast<uint8_t
>(ChannelConfigState::LAST_STATE_MAX) <= 16,
27 "ChannelConfigState does not fit in 4 bits");
38 bool isSet(
int configType)
const;
39 void clear(
int configType);
41 void setAll(uint8_t values);
42 uint8_t getAll()
const;
43 void set(
int configType,
bool value =
true);
49 "ConfigTypesBitmap must remain one byte");
59 ElementMode mode = ElementMode::Registered);
63 void addAction(uint16_t action,
66 bool alwaysEnabled =
false)
override;
67 void addAction(uint16_t action,
ActionHandler *client, uint16_t event,
68 bool alwaysEnabled =
false)
override;
76 virtual void addAction(uint16_t action,
80 bool alwaysEnabled =
false);
84 virtual void addAction(uint16_t action,
ActionHandler *client,
87 bool alwaysEnabled =
false);
88 virtual void addAction(uint16_t action,
91 bool alwaysEnabled =
false);
92 virtual void addAction(uint16_t action,
ActionHandler *client,
94 bool alwaysEnabled =
false);
96 bool isEventAlreadyUsed(uint16_t event,
bool ignoreAlwaysEnabled)
override;
104 bool local =
false)
override;
106 bool altSchedule =
false,
107 bool local =
false)
override;
113 void runAction(uint16_t event)
const override;
123 virtual void fillChannelConfig(
void *channelConfig,
int *size, uint8_t index);
125 void triggerSetChannelConfig(
126 int configType = SUPLA_CONFIG_TYPE_DEFAULT,
127 bool localChange =
false);
131 virtual bool setAndSaveFunction(uint32_t channelFunction);
132 virtual bool loadFunctionFromConfig();
133 virtual bool shouldProcessChannelFunctionFromConfig()
const;
134 bool setAndSaveConfigChangeFlag(
bool value);
135 virtual bool saveConfigChangeFlag()
const;
136 virtual bool loadConfigChangeFlag();
137 void clearChannelConfigChangedFlag();
138 void markChannelConfigReceived(
int configType);
139 void markAllChannelConfigsReceived();
140 bool isChannelConfigFinishedReceived()
const;
141 bool isLocalChannelConfigChangePending(
int configType)
const;
142 bool iterateConfigExchange();
149 int getNextLocalConfigType()
const;
150 bool setLocalConfigChange(
int configType,
bool value =
true);
151 void clearLocalConfigChanges(
int configType,
int secondConfigType = -1);
152 uint8_t getUsedLocalConfigTypes()
const;
154 ChannelConfigState channelConfigState : 4;
155 uint8_t setChannelConfigAttempts : 2;
156 uint8_t configFinishedReceived : 1;
157 uint8_t reserved : 1;
163 uint8_t finishChannelConfig(
Definition local_action.h:15
Definition action_handler.h:8
Definition condition.h:14
Definition element_with_channel_actions.h:56
void purgeConfig() override
Removes all configration data related to the element from Storage::Config.
Definition element_with_channel_actions.cpp:697
void onRegistered(Supla::Protocol::SuplaSrpc *suplaSrpc) override
Method called each time when device successfully registers to Supla server.
Definition element_with_channel_actions.cpp:438
uint8_t handleChannelConfig(TSD_ChannelConfig *result, bool local=false) override
Handles "set channel config" request from server.
Definition element_with_channel_actions.cpp:514
bool isAnyUpdatePending() const override
Returns true if any update is pending.
Definition element_with_channel_actions.cpp:375
void handleSetChannelConfigResult(TSDS_SetChannelConfigResult *result) override
Handles "set channel config" reply from server.
Definition element_with_channel_actions.cpp:643
int getNextConfigType() const
Returns the next config type to be sent.
Definition element_with_channel_actions.cpp:914
void handleChannelConfigFinished() override
Handles "channel config finished" message from server.
Definition element_with_channel_actions.cpp:472
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:502
uint8_t handleWeeklySchedule(TSD_ChannelConfig *result, bool altSchedule=false, bool local=false) override
Handles "set channel config" with "weekly schedule" type request from server.
Definition element_with_channel_actions.cpp:568
Base class for all elements of SuplaDevice.
Definition element.h:30
virtual bool iterateConnected()
Method called on each SuplaDevice iteration when device is connected and registered to Supla server o...
Definition element.cpp:143
Definition local_action.h:87
Definition supla_srpc.h:47
Definition element_with_channel_actions.h:30