deCONZ C++ API v2.6.1
Loading...
Searching...
No Matches
zcl_private.h
1/*
2 * Copyright (c) 2012-2023 dresden elektronik ingenieurtechnik gmbh.
3 * All rights reserved.
4 *
5 * The software in this package is published under the terms of the BSD
6 * style license a copy of which has been included with this distribution in
7 * the LICENSE.txt file.
8 *
9 */
10
11#ifndef ZCL_PRIVATE_H
12#define ZCL_PRIVATE_H
13
14#include <QString>
15#include <QIcon>
16#include <cinttypes>
17#include "deconz/declspec.h"
18
19namespace deCONZ
20{
21
23{
24public:
25 Enumeration() :
26 m_id(0xFFFF)
27 {
28 }
29
30 Enumeration(uint id, const QString &name) :
31 m_id(id),
32 m_name(name)
33 {
34 }
35 uint id() const { return m_id; }
36 const QString &name() const { return m_name; }
37 void setValue(uint key, const QString &name) { m_values[key] = name; }
38 QString getValueName(uint key)
39 {
40 if (m_values.contains(key))
41 return m_values[key];
42
43 return QString();
44 }
45 const QHash<uint, QString> &values() const { return m_values; }
46
47private:
48 QHash<uint, QString> m_values;
49 uint m_id;
50 QString m_name;
51};
52
54{
55public:
57
58 static constexpr int PoolSize = 64; // for ZclMemory
59
60 uint16_t m_id = 0xFFFF;
61 uint8_t m_dataType = 0xFF;
62 uint8_t m_subType = 0xFF;
63 QString m_name;
64 QString m_description;
65 ZclAccess m_access = ZclRead;
66 uint8_t m_enumerationId = 0xFF;
67 uint8_t m_numericBase = 10;
68 bool m_required = false;
69 bool m_avail = true;
70 union {
71 int idx;
72 uint64_t bitmap;
73 } m_valueState;
74
80 QVariant m_value;
82 std::vector<int> m_valuePos;
83 QStringList m_valueNames;
84 int64_t m_lastRead = -1;
85
90 uint16_t m_listSizeAttr = 0xFFFF;
91 int m_listSize = 0;
92
93 // reporting
94 uint16_t m_minReportInterval = 0;
95 uint16_t m_maxReportInterval = 0xFFFF;
96 uint16_t m_reportTimeout = 0;
98
100 int m_rangeMin = 0;
101 int m_rangeMax = 0;
102
103 quint16 m_manufacturerCode = 0;
104
105 quint16 m_attrSetId = 0xFFFF;
106 quint16 m_attrSetManufacturerCode = 0;
107};
108
110{
111public:
113 uint16_t id;
114 QString description;
115 quint16 manufacturerCode;
116 std::vector<int> attributeIndexes;
117};
118
120{
121public:
123 uint16_t id;
124 uint16_t oppositeId;
125 uint16_t manufacturerCode;
126 QString name;
127 QString description;
128 bool isZcl;
129 bool isServer;
130 std::vector<ZclAttribute> attributes;
131 std::vector<ZclAttributeSet> attributeSets;
132 std::vector<ZclCommand> commands;
133};
134
136{
137public:
138 static constexpr int PoolSize = 16; // for ZclMemory
139 uint8_t valid = 0;
140 uint8_t frameControl = 0;
141 uint16_t manufacturerCode = 0xFFFF;
142 uint8_t seqNumber = 0;
143 uint8_t commandId = 0;
144 QByteArray payload;
145};
146
148{
149public:
152 {
153 UnknownData,
154 AnalogData,
155 DiscreteData
156 };
158 uint8_t m_id;
159 QString m_name;
160 QString m_shortname;
161 int m_length;
162 DataKind m_analogDiscrete;
163};
164
166{
167public:
169 uint8_t m_id;
170 uint16_t m_manufacturerId;
171 uint8_t m_responseId;
172 QString m_name;
173 bool m_required;
174 bool m_recv;
175 QString m_description;
176 bool m_isProfileWide;
177 bool m_disableDefaultResponse;
178 std::vector<ZclAttribute> m_payload;
179};
180
181// TODO: place in private header and hide in public release
182class DECONZ_DLLSPEC ZclDomain
183{
184public:
185 ZclDomain() : m_useZcl(true) { }
186 ZclDomain(const QString &name, const QString &description) :
187 m_useZcl(true),
188 m_name(name),
189 m_description(description)
190 {
191#ifdef ZCL_LOAD_DBG
192 qDebug("Domain: %s %04X-%04X -- %s", qPrintable(name), qPrintable(description));
193#endif
194 }
195 bool useZcl() const { return m_useZcl; }
196 void setUseZcl(bool useZcl) { m_useZcl = useZcl; }
197 const QString &name() const { return m_name; }
198 void setName(const QString &name) { m_name = name; }
199 const QString &description() const { return m_description; }
200 void setDescription(const QString &description) { m_description = description; }
201 const QHash<uint32_t, ZclCluster> &inClusters() const { return m_inClusters; }
202 const QHash<uint32_t, ZclCluster> &outClusters() const { return m_outClusters; }
203 bool isValid() const { return !m_name.isEmpty(); }
204
205private:
206 friend class ZclDataBase;
207 bool m_useZcl;
208 QString m_name;
209 QString m_description;
210 QHash<uint32_t, ZclCluster> m_inClusters;
211 QHash<uint32_t, ZclCluster> m_outClusters;
212};
213
214class DECONZ_DLLSPEC ZclDevice
215{
216public:
217 ZclDevice() : m_deviceId(0xFFFF), m_profileId(0xFFFF) {}
218 ZclDevice(uint16_t id, const QString &name, const QString &description, const QIcon &icon) :
219 m_deviceId(id),
220 m_profileId(0xFFFF),
221 m_name(name),
222 m_description(description),
223 m_icon(icon)
224 {
225#ifdef ZCL_LOAD_DBG
226 qDebug("ZclDevice: %04X %s -- %s", id, qPrintable(name), qPrintable(description));
227#endif
228 }
229
230 uint16_t id() const { return m_deviceId; }
231 void setId(uint16_t id) { m_deviceId = id; }
232 uint16_t profileId() const { return m_profileId; }
233 void setProfileId(uint16_t id) { m_profileId = id; }
234 const QString &name() const { return m_name; }
235 const QString &description() const { return m_description; }
236 const QIcon &icon() const { return m_icon; }
237
238private:
239 uint16_t m_deviceId;
240 uint16_t m_profileId;
241 QString m_name;
242 QString m_description;
243 QIcon m_icon;
244};
245
246// TODO: place in private header and hide in public release
247class DECONZ_DLLSPEC ZclProfile
248{
249public:
250 ZclProfile() : m_id(0xFFFF) {}
251 ZclProfile(uint16_t id, const QString &name, const QString &description, const QIcon &icon) :
252 m_id(id),
253 m_name(name),
254 m_description(description),
255 m_icon(icon)
256 {
257#ifdef ZCL_LOAD_DBG
258 qDebug("Profile: %04X %s -- %s", id, qPrintable(name), qPrintable(description));
259#endif
260 }
261
262 uint16_t id() const { return m_id; }
263 void setId(uint16_t id) { m_id = id; }
264 const QString &name() const { return m_name; }
265 void setName(const QString &name) { m_name = name; }
266 const QString &description() const { return m_description; }
267 void setDescription(const QString &description) { m_description = description; }
268 const QIcon &icon() const { return m_icon; }
269 void setIcon(const QIcon &icon) { m_icon = icon; }
270 const std::vector<ZclDomain> &domains() const { return m_domains; }
271 void addDomain(const ZclDomain &domain);
272 bool isValid() const { return (m_id != 0xFFFF); }
273
274private:
275 friend class ZclDataBase;
276
277 uint16_t m_id;
278 QString m_name;
279 QString m_description;
280 QIcon m_icon;
281 std::vector<ZclDomain> m_domains;
282};
283
284// TODO: place in private header and hide in public release
285class DECONZ_DLLSPEC ZclDataBase
286{
287public:
288 ZclDataBase();
289 ~ZclDataBase();
290 ZclCluster inCluster(uint16_t profileId, uint16_t clusterId, quint16 mfcode);
291 ZclCluster outCluster(uint16_t profileId, uint16_t clusterId, quint16 mfcode);
292 const ZclDataType &dataType(uint8_t id) const;
293 const ZclDataType &dataType(const QString &shortName) const;
294 ZclProfile profile(uint16_t id);
295 ZclDomain domain(const QString &name);
296 void addDomain(const ZclDomain &domain);
297 void addProfile(const ZclProfile &profile);
298 ZclDevice device(uint16_t profileId, uint16_t deviceId);
299 bool getEnumeration(uint id, deCONZ::Enumeration &out)
300 {
301 for (const auto &e : m_enums)
302 {
303 if (e.id() == id)
304 {
305 out = e;
306 return true;
307 }
308 }
309
310 return false;
311 }
312 void load(const QString &dbfile);
313 void initDbFile(const QString &zclFile);
314 void reloadAll(const QString &zclFile);
315 void clear();
316 bool knownDataType(uint8_t id);
317
318private:
319 std::vector<deCONZ::Enumeration> m_enums;
320 ZclCluster m_unknownCluster;
321 ZclDataType m_unknownDataType;
322 std::vector<ZclDataType> m_dataTypes;
323 std::vector<ZclDomain> m_domains;
324 QHash<uint16_t, ZclProfile> m_profiles;
329 std::vector<ZclDevice> m_devices;
330 QString m_iconPath;
331};
332
333DECONZ_DLLSPEC ZclDataBase * zclDataBase();
334
335} //namespace deCONZ
336
337#endif // ZCL_PRIVATE_H
Definition zcl_private.h:23
Definition zcl_private.h:54
NumericUnion m_reportableChange
Reportable change.
Definition zcl_private.h:97
int m_listSize
Current size of the list.
Definition zcl_private.h:91
bool m_required
True if mandatory.
Definition zcl_private.h:68
uint16_t m_listSizeAttr
If this is a list here is the attribute id wich holds the list size.
Definition zcl_private.h:90
NumericUnion m_numericValue
Numeric data.
Definition zcl_private.h:81
QVariant m_value
May hold a value or the static content like enumeration or bitmap values.
Definition zcl_private.h:80
bool m_avail
Attribute is available in the cluster.
Definition zcl_private.h:69
int idx
index into a list
Definition zcl_private.h:71
uint8_t m_numericBase
For numeric data types.
Definition zcl_private.h:67
uint16_t m_maxReportInterval
Maximum reporting interval.
Definition zcl_private.h:95
uint16_t m_minReportInterval
Minimum reporting interval.
Definition zcl_private.h:94
uint64_t bitmap
bitmap bits set
Definition zcl_private.h:72
uint8_t m_enumerationId
Id of a enumeration repository.
Definition zcl_private.h:66
uint16_t m_reportTimeout
Report timeout period.
Definition zcl_private.h:96
Definition zcl_private.h:110
FormatHint
Used to change the display format in the GUI.
Definition zcl.h:685
@ DefaultFormat
Use the default format for a value.
Definition zcl.h:686
Definition zcl_private.h:120
Represents a ZigBee cluster (ZCL and non-ZCL).
Definition zcl.h:1173
Definition zcl_private.h:166
Definition zcl_private.h:286
Definition zcl_private.h:148
DataKind
Data kind of the data type.
Definition zcl_private.h:152
Represents the data type of a ZigBee cluster attribute.
Definition zcl.h:310
Definition zcl_private.h:215
Definition zcl_private.h:183
Definition zcl_private.h:136
Definition zcl_private.h:248
The deCONZ namespace.
Definition aps.cpp:19
ZclAccess
Allowed access method of a ZclAttribute.
Definition zcl.h:418
Holds various numeric values 8-64 bit, signed and unsigned.
Definition types.h:329