supla-device
Loading...
Searching...
No Matches
protocol_layer.h
1// SPDX-FileCopyrightText: AC SOFTWARE SP. Z O.O.
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#ifndef SRC_SUPLA_PROTOCOL_PROTOCOL_LAYER_H_
5#define SRC_SUPLA_PROTOCOL_PROTOCOL_LAYER_H_
6
7#include <supla/network/connection_error.h>
8
9#include <stdint.h>
10#include <supla-common/proto.h>
11
13
14namespace Supla {
15
16namespace Protocol {
17
19 public:
20 explicit ProtocolLayer(SuplaDeviceClass *sdc);
21 virtual ~ProtocolLayer();
22 static ProtocolLayer *first();
23 static ProtocolLayer *last();
24 static bool IsAnyUpdatePending();
25 ProtocolLayer *next();
26 SuplaDeviceClass *getSdc();
27
28 void setVerboseLog(bool value);
29 virtual void onInit() = 0;
30 virtual bool onLoadConfig() = 0;
31 virtual bool verifyConfig() = 0;
32 virtual bool isEnabled() = 0;
33 virtual void disconnect() = 0;
34 virtual bool isConfigEmpty();
35 // Return value indicates if specific protocol is ready to handle data
36 // from other elements and if call to Element::iterateConnected should be
37 // done.
38 virtual bool iterate(uint32_t _millis) = 0;
39 virtual bool isNetworkRestartRequested() = 0;
40 virtual uint32_t getConnectionFailTime() = 0;
41 virtual bool isConnectionError();
42 virtual Supla::ConnectionError getConnectionError() const;
43 virtual bool isConnecting();
44 virtual bool isMqtt() const;
45 virtual bool isUpdatePending();
46 virtual bool isRegisteredAndReady() = 0;
47 virtual void sendActionTrigger(uint8_t channelNumber, uint32_t actionId) = 0;
48 virtual void sendRemainingTimeValue(uint8_t channelNumber,
49 uint32_t timeMs,
50 uint8_t state,
51 int32_t senderId);
52 virtual void sendRemainingTimeValue(uint8_t channelNumber,
53 uint32_t remainingTime,
54 uint8_t* state,
55 int32_t senderId,
56 bool useSecondsInsteadOfMs);
57 virtual void getUserLocaltime();
58 virtual void sendChannelValueChanged(uint8_t channelNumber, int8_t *value,
59 uint8_t offline, uint32_t validityTimeSec) = 0;
60 virtual void sendExtendedChannelValueChanged(uint8_t channelNumber,
62
63 virtual void getChannelConfig(uint8_t channelNumber,
64 uint8_t configType = SUPLA_CONFIG_TYPE_DEFAULT);
65 virtual bool setChannelConfig(uint8_t channelNumber,
66 _supla_int_t channelFunction, void *channelConfig, int size,
67 uint8_t configType = SUPLA_CONFIG_TYPE_DEFAULT);
68 virtual void notifyConfigChange(int channelNumber);
69
70 virtual bool setDeviceConfig(TSDS_SetDeviceConfig *deviceConfig);
71 virtual bool setInitialCaption(uint8_t channelNumber, const char *caption);
72
73 virtual void sendRegisterNotification(
74 TDS_RegisterPushNotification *notification);
75 virtual bool sendNotification(int context,
76 const char *title,
77 const char *message,
78 int soundId);
79 virtual void sendSubdeviceDetails(TDS_SubdeviceDetails *subdeviceDetails);
80 virtual void sendChannelStateResult(int32_t receiverId, uint8_t channelNo);
81
82 protected:
83 static ProtocolLayer *firstPtr;
84 ProtocolLayer *nextPtr = nullptr;
85 SuplaDeviceClass *sdc = nullptr;
86 bool configEmpty = true;
87 bool verboseLog = false;
88};
89
90} // namespace Protocol
91} // namespace Supla
92
93#endif // SRC_SUPLA_PROTOCOL_PROTOCOL_LAYER_H_
Definition SuplaDevice.h:167
Definition protocol_layer.h:18
Definition proto.h:3904
Definition proto.h:3930
Definition proto.h:2891
Definition proto.h:784