deCONZ C++ API v2.6.1
Loading...
Searching...
No Matches
aps.h
1#ifndef DECONZ_APS_H
2#define DECONZ_APS_H
3
4/*
5 * Copyright (c) 2012-2023 dresden elektronik ingenieurtechnik gmbh.
6 * All rights reserved.
7 *
8 * The software in this package is published under the terms of the BSD
9 * style license a copy of which has been included with this distribution in
10 * the LICENSE.txt file.
11 *
12 */
13
68#include <array>
69#include <QByteArray>
70#include <QFlags>
71#include <QString>
72#include <QMetaType>
73
74#include "deconz/types.h"
75#include "deconz/timeref.h"
76#include "deconz/declspec.h"
77
78namespace deCONZ
79{
80
82enum ApsAddressMode : unsigned char
83{
88 ApsNwkExtAddress = 0x4
89};
90
92enum ApsTxOption : unsigned char
93{
95 ApsTxUseNwk = 0x02,
98};
99
100Q_DECLARE_FLAGS(ApsTxOptions, ApsTxOption)
101Q_DECLARE_OPERATORS_FOR_FLAGS(deCONZ::ApsTxOptions)
102
103class AddressPrivate;
104
110class DECONZ_DLLSPEC Address
111{
112public:
114 Address() = default;
116 Address(const Address &other);
118 Address &operator= (const Address &other);
120 ~Address() = default;
122 bool isNwkUnicast() const;
124 bool isNwkBroadcast() const;
126 bool hasNwk() const;
128 bool hasExt() const;
130 bool hasGroup() const;
132 uint16_t nwk() const;
134 uint64_t ext() const;
136 uint16_t group() const;
140 void setNwk(uint16_t addr);
144 void setExt(uint64_t addr);
148 void setGroup(uint16_t addr);
150 void clear();
152 API_DEPRECATED QString toStringExt() const;
154 API_DEPRECATED QString toStringNwk() const;
156 API_DEPRECATED QString toStringGroup() const;
160 API_DEPRECATED bool fromStringExt(const QString &str);
164 API_DEPRECATED bool fromStringNwk(const QString &str);
168 bool operator==(const Address &other) const;
172 bool operator !=(const Address &other) const;
173
174private:
175 uint64_t m_ext{0};
176 uint16_t m_nwk{0};
177 uint16_t m_group{0};
178 uint8_t m_addrModes{deCONZ::NoAddress};
179 uint8_t _pad[3];
180};
181
182class ApsDataRequestPrivate;
183
226class DECONZ_DLLSPEC ApsDataRequest
227{
228public:
232 ApsDataRequest(const ApsDataRequest &other);
234 ApsDataRequest(ApsDataRequest &&other) noexcept;
236 ApsDataRequest& operator=(const ApsDataRequest &other);
238 ApsDataRequest& operator=(ApsDataRequest &&other) noexcept;
245 uint8_t id() const;
247 Address &dstAddress();
249 const Address &dstAddress() const;
251 deCONZ::ApsAddressMode dstAddressMode() const;
253 void setDstAddressMode(ApsAddressMode mode);
255 uint8_t srcEndpoint() const;
257 void setSrcEndpoint(uint8_t ep);
259 uint8_t dstEndpoint() const;
261 void setDstEndpoint(uint8_t ep);
263 uint16_t profileId() const;
265 void setProfileId(uint16_t profileId);
267 uint16_t clusterId() const;
269 void setClusterId(uint16_t clusterId);
271 uint16_t responseClusterId() const;
273 void setResponseClusterId(uint16_t clusterId);
275 const QByteArray &asdu() const;
277 QByteArray &asdu();
279 void setAsdu(const QByteArray &asdu);
281 uint8_t radius() const;
283 void setRadius(uint8_t radius);
287 ApsTxOptions txOptions() const;
291 void setTxOptions(ApsTxOptions txOptions);
306 int writeToStream(QDataStream &stream) const;
318 void readFromStream(QDataStream &stream);
320 void clear();
321
322 /* \cond INTERNAL_SYMBOLS */
323 void setSendAfter(deCONZ::SteadyTimeRef t);
324 deCONZ::SteadyTimeRef sendAfter() const;
325 uint8_t version() const;
326 void setVersion(uint8_t version) const;
327 uint16_t nodeId() const;
328 void setNodeId(uint16_t id) const;
329 deCONZ::SteadyTimeRef timeout() const;
330 void setTimeout(deCONZ::SteadyTimeRef timeout);
331 CommonState state() const;
332 void setState(CommonState state);
333 int sendDelay() const;
334 void setSendDelay(int delayMs);
335 bool confirmed() const;
336 void setConfirmed(bool confirmed);
337 void setSourceRoute(const std::array<quint16, 9> &relays, size_t size, const uint srHash);
338 uint sourceRouteUuidHash() const;
339 /* \endcond */
340
341private:
342 ApsDataRequestPrivate *d_ptr = nullptr;
343 Q_DECLARE_PRIVATE(ApsDataRequest)
344};
345
351class DECONZ_DLLSPEC ApsDataConfirm
352{
353public:
355 ApsDataConfirm() = default;
357 ApsDataConfirm(uint8_t reqId, uint8_t status);
359 ApsDataConfirm(const ApsDataRequest &req, uint8_t status);
361 ApsDataConfirm(const ApsDataConfirm &other) = default;
363 ApsDataConfirm &operator=(const ApsDataConfirm &other) = default;
365 ~ApsDataConfirm() = default;
367 uint8_t id() const;
369 void setId(uint8_t id);
371 Address &dstAddress();
373 const Address &dstAddress() const;
375 ApsAddressMode dstAddressMode() const;
377 void setDstAddressMode(ApsAddressMode mode);
379 uint8_t dstEndpoint() const;
381 uint8_t srcEndpoint() const;
385 uint8_t status() const;
387 uint32_t txTime() const;
389 void readFromStream(QDataStream &stream);
390
391private:
392 Address m_dstAddr{};
393 ApsAddressMode m_dstAddrMode = deCONZ::ApsNoAddress;
394 uint8_t m_id = 0;
395 uint8_t m_dstEndpoint = 0xFF;
396 uint8_t m_srcEndpoint = 0xFF;
397 uint8_t m_status = 0xFF;
398};
399
400class ApsDataIndicationPrivate;
401
407class DECONZ_DLLSPEC ApsDataIndication
408{
409public:
415 ApsDataIndication &operator=(const ApsDataIndication &other);
419 ApsAddressMode dstAddressMode() const;
421 void setDstAddressMode(ApsAddressMode mode);
423 Address &dstAddress();
425 const Address &dstAddress() const;
427 uint8_t dstEndpoint() const;
429 void setDstEndpoint(uint8_t ep);
431 ApsAddressMode srcAddressMode() const;
433 void setSrcAddressMode(ApsAddressMode mode);
435 Address &srcAddress();
437 const Address &srcAddress() const;
439 uint8_t srcEndpoint() const;
441 void setSrcEndpoint(uint8_t ep);
443 uint16_t profileId() const;
445 void setProfileId(uint16_t profileId);
447 uint16_t clusterId() const;
449 void setClusterId(uint16_t clusterId);
451 const QByteArray &asdu() const;
453 QByteArray &asdu();
455 void setAsdu(const QByteArray &asdu);
457 uint8_t status() const;
459 void setStatus(uint8_t status);
461 uint8_t securityStatus() const;
463 void setSecurityStatus(uint8_t status);
465 uint8_t linkQuality() const;
467 void setLinkQuality(uint8_t lqi);
469 uint32_t rxTime() const;
471 void setRxTime(uint32_t time);
473 int8_t rssi() const;
475 void setRssi(int8_t rssi);
477 quint16 previousHop() const;
479 void readFromStream(QDataStream &stream);
481 void writeToStream(QDataStream &stream) const;
482 /* \cond INTERNAL_SYMBOLS */
483 int version() const;
484 void setVersion(int version) const;
485 /* \endcond */
487 void reset();
488
489private:
490 ApsDataIndicationPrivate *d_ptr = nullptr;
491 Q_DECLARE_PRIVATE(ApsDataIndication)
492};
493
494class ApsMemoryPrivate;
495
496class DECONZ_DLLSPEC ApsMemory
497{
498public:
499 ApsMemory();
500 ~ApsMemory();
501
502 /* \cond INTERNAL_SYMBOLS */
503 ApsMemoryPrivate *d = nullptr; // opaque pointer only used internally
504 /* \endcond */
505};
506
507} // namespace deCONZ
508
509uint8_t DECONZ_DLLSPEC APS_NextApsRequestId();
510
511Q_DECLARE_METATYPE(deCONZ::ApsDataRequest)
512Q_DECLARE_METATYPE(deCONZ::ApsDataConfirm)
513Q_DECLARE_METATYPE(deCONZ::ApsDataIndication)
514
515#endif // DECONZ_APS_H
Convenience class to work with network, extended and group addresses.
Definition aps.h:111
Address()=default
Constructor.
~Address()=default
Deconstructor.
APSDE-DATA.confirm primitive.
Definition aps.h:352
ApsDataConfirm()=default
Constructor.
ApsDataConfirm & operator=(const ApsDataConfirm &other)=default
Copy assignment constructor.
ApsDataConfirm(const ApsDataConfirm &other)=default
Copy constructor.
~ApsDataConfirm()=default
Deconstructor.
Definition aps.cpp:699
APSDE-DATA.indication primitive.
Definition aps.h:408
Definition aps.cpp:55
APSDE-DATA.request primitive.
Definition aps.h:227
Definition aps.cpp:92
Definition aps.h:497
The deCONZ namespace.
Definition aps.cpp:19
ApsAddressMode
Address modes used to specify source and destination addresses.
Definition aps.h:83
@ ApsGroupAddress
16-bit group address mode
Definition aps.h:85
@ ApsNwkExtAddress
16-bit network address mode and 64-bit extended IEEE address mode (since protocol version 0x010B)
Definition aps.h:88
@ ApsExtAddress
64-bit extended IEEE address mode
Definition aps.h:87
@ ApsNoAddress
No addressing specified.
Definition aps.h:84
@ ApsNwkAddress
16-bit network address mode
Definition aps.h:86
ApsTxOption
Flags used in the ApsDataRequest.
Definition aps.h:93
@ ApsTxSecurityEnabledTransmission
APS layer security enabled transmission.
Definition aps.h:94
@ ApsTxAcknowledgedTransmission
Enable APS acknowledged transmission.
Definition aps.h:96
@ ApsTxUseNwk
Use network key security.
Definition aps.h:95
@ ApsTxFragmentationPermitted
Allow fragmentation.
Definition aps.h:97
CommonState
Common states for various purposes.
Definition types.h:400
Definition timeref.h:22
Declaration of the most common deCONZ library types.