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,
int channelNumber = -1);
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 hasChannelConfigSummary(uint8_t)
const {
return false; }
133 virtual bool setAndSaveFunction(uint32_t channelFunction);
134 virtual bool loadFunctionFromConfig();
135 virtual bool shouldProcessChannelFunctionFromConfig()
const;
136 bool setAndSaveConfigChangeFlag(
bool value);
137 virtual bool saveConfigChangeFlag()
const;
138 virtual bool loadConfigChangeFlag();
139 void clearChannelConfigChangedFlag();
140 void markChannelConfigReceived(
int configType);
141 void markAllChannelConfigsReceived();
142 bool isChannelConfigFinishedReceived()
const;
143 bool isLocalChannelConfigChangePending(
int configType)
const;
144 bool iterateConfigExchange();
151 int getNextLocalConfigType()
const;
152 bool setLocalConfigChange(
int configType,
bool value =
true);
153 void clearLocalConfigChanges(
int configType,
int secondConfigType = -1);
154 uint8_t getUsedLocalConfigTypes()
const;
155 ChannelConfigState getChannelConfigState()
const {
156 return static_cast<ChannelConfigState
>(channelConfigState);
158 void setChannelConfigState(ChannelConfigState state) {
159 channelConfigState =
static_cast<uint8_t
>(state);
163 uint8_t channelConfigState : 4;
164 uint8_t setChannelConfigAttempts : 2;
165 uint8_t configFinishedReceived : 1;
166 uint8_t reserved : 1;
168 uint8_t weeklyConfigFailures : 2;
169 uint8_t altWeeklyConfigFailures : 2;
170 uint8_t sentWeeklyConfigType : 2;
175 uint8_t finishChannelConfig(
180 uint8_t getWeeklyConfigFailures(
int configType)
const;
181 void resetWeeklyConfigFailures(
int configType);
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:728
void onRegistered(Supla::Protocol::SuplaSrpc *suplaSrpc) override
Method called each time when device successfully registers to Supla server.
Definition element_with_channel_actions.cpp:446
uint8_t handleChannelConfig(TSD_ChannelConfig *result, bool local=false) override
Handles "set channel config" request from server.
Definition element_with_channel_actions.cpp:523
bool isAnyUpdatePending() const override
Returns true if any update is pending.
Definition element_with_channel_actions.cpp:383
void handleSetChannelConfigResult(TSDS_SetChannelConfigResult *result) override
Handles "set channel config" reply from server.
Definition element_with_channel_actions.cpp:652
int getNextConfigType() const
Returns the next config type to be sent.
Definition element_with_channel_actions.cpp:977
void handleChannelConfigFinished() override
Handles "channel config finished" message from server.
Definition element_with_channel_actions.cpp:479
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:511
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:569
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