supla-device
Loading...
Searching...
No Matches
protocol_layer.h
1/*
2 * Copyright (C) AC SOFTWARE SP. Z O.O
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#ifndef SRC_SUPLA_PROTOCOL_PROTOCOL_LAYER_H_
20#define SRC_SUPLA_PROTOCOL_PROTOCOL_LAYER_H_
21
22#include <stdint.h>
23#include <supla-common/proto.h>
24
26
27namespace Supla {
28
29namespace Protocol {
30
31class ProtocolLayer {
32 public:
33 explicit ProtocolLayer(SuplaDeviceClass *sdc);
34 virtual ~ProtocolLayer();
35 static ProtocolLayer *first();
36 static ProtocolLayer *last();
37 static bool IsAnyUpdatePending();
38 ProtocolLayer *next();
39 SuplaDeviceClass *getSdc();
40
41 void setVerboseLog(bool value);
42 virtual void onInit() = 0;
43 virtual bool onLoadConfig() = 0;
44 virtual bool verifyConfig() = 0;
45 virtual bool isEnabled() = 0;
46 virtual void disconnect() = 0;
47 virtual bool isConfigEmpty();
48 // Return value indicates if specific protocol is ready to handle data
49 // from other elements and if call to Element::iterateConnected should be
50 // done.
51 virtual bool iterate(uint32_t _millis) = 0;
52 virtual bool isNetworkRestartRequested() = 0;
53 virtual uint32_t getConnectionFailTime() = 0;
54 virtual bool isConnectionError();
55 virtual bool isConnecting();
56 virtual bool isUpdatePending();
57 virtual bool isRegisteredAndReady() = 0;
58 virtual void sendActionTrigger(uint8_t channelNumber, uint32_t actionId) = 0;
59 virtual void sendRemainingTimeValue(uint8_t channelNumber,
60 uint32_t timeMs,
61 uint8_t state,
62 int32_t senderId);
63 virtual void sendRemainingTimeValue(uint8_t channelNumber,
64 uint32_t remainingTime,
65 uint8_t* state,
66 int32_t senderId,
67 bool useSecondsInsteadOfMs);
68 virtual void getUserLocaltime();
69 virtual void sendChannelValueChanged(uint8_t channelNumber, int8_t *value,
70 uint8_t offline, uint32_t validityTimeSec) = 0;
71 virtual void sendExtendedChannelValueChanged(uint8_t channelNumber,
73
74 virtual void getChannelConfig(uint8_t channelNumber,
75 uint8_t configType = SUPLA_CONFIG_TYPE_DEFAULT);
76 virtual bool setChannelConfig(uint8_t channelNumber,
77 _supla_int_t channelFunction, void *channelConfig, int size,
78 uint8_t configType = SUPLA_CONFIG_TYPE_DEFAULT);
79 virtual void notifyConfigChange(int channelNumber);
80
81 virtual bool setDeviceConfig(TSDS_SetDeviceConfig *deviceConfig);
82 virtual bool setInitialCaption(uint8_t channelNumber, const char *caption);
83
84 virtual void sendRegisterNotification(
85 TDS_RegisterPushNotification *notification);
86 virtual bool sendNotification(int context,
87 const char *title,
88 const char *message,
89 int soundId);
90 virtual void sendSubdeviceDetails(TDS_SubdeviceDetails *subdeviceDetails);
91 virtual void sendChannelStateResult(int32_t receiverId, uint8_t channelNo);
92
93 protected:
94 static ProtocolLayer *firstPtr;
95 ProtocolLayer *nextPtr = nullptr;
96 SuplaDeviceClass *sdc = nullptr;
97 bool configEmpty = true;
98 bool verboseLog = true;
99};
100
101} // namespace Protocol
102} // namespace Supla
103
104#endif // SRC_SUPLA_PROTOCOL_PROTOCOL_LAYER_H_
Definition SuplaDevice.h:93
Definition proto.h:3624
Definition proto.h:3650
Definition proto.h:2755
Definition proto.h:749