deCONZ C++ API v2.6.1
Loading...
Searching...
No Matches
deCONZ::ApsDataRequest Class Reference

APSDE-DATA.request primitive. More...

#include <aps.h>

Public Member Functions

 ApsDataRequest ()
 Constructor.
 
 ApsDataRequest (const ApsDataRequest &other)
 Copy constructor.
 
 ApsDataRequest (ApsDataRequest &&other) noexcept
 Move constructor.
 
ApsDataRequestoperator= (const ApsDataRequest &other)
 Copy assignment operator.
 
ApsDataRequestoperator= (ApsDataRequest &&other) noexcept
 Move assignment operator.
 
 ~ApsDataRequest ()
 Deconstructor.
 
uint8_t id () const
 Returns the uniqe id for this request.
 
AddressdstAddress ()
 Returns the modifiable destination address.
 
const AddressdstAddress () const
 Returns the const destination address.
 
deCONZ::ApsAddressMode dstAddressMode () const
 Returns the destination address mode.
 
void setDstAddressMode (ApsAddressMode mode)
 Sets the destination address mode.
 
uint8_t srcEndpoint () const
 Returns the source endpoint.
 
void setSrcEndpoint (uint8_t ep)
 Sets the source endpoint.
 
uint8_t dstEndpoint () const
 Returns the destination endpoint.
 
void setDstEndpoint (uint8_t ep)
 Sets the destination endpoint.
 
uint16_t profileId () const
 Returns the profile identifier.
 
void setProfileId (uint16_t profileId)
 Sets the profile identifier.
 
uint16_t clusterId () const
 Returns the cluster identifier.
 
void setClusterId (uint16_t clusterId)
 Sets the cluster identifier.
 
uint16_t responseClusterId () const
 Returns the response cluster identifier.
 
void setResponseClusterId (uint16_t clusterId)
 Sets the response cluster identifier.
 
const QByteArray & asdu () const
 Returns the const ASDU payload.
 
QByteArray & asdu ()
 Returns the writeable ASDU payload.
 
void setAsdu (const QByteArray &asdu)
 Sets the ASDU payload.
 
uint8_t radius () const
 Returns the send radius.
 
void setRadius (uint8_t radius)
 Sets the send radius.
 
ApsTxOptions txOptions () const
 Returns the transmit options.
 
void setTxOptions (ApsTxOptions txOptions)
 Sets the transmit options.
 
int writeToStream (QDataStream &stream) const
 Writes the request to the stream in a ZigBee standard conform format.
 
void readFromStream (QDataStream &stream)
 Reads a request from the stream which must be in a ZigBee standard conform format.
 
void clear ()
 Resets the request parameters.
 

Detailed Description

APSDE-DATA.request primitive.

The ApsDataRequest class can be used so send arbitrary messages via ZigBee APS layer.

The destination can be a single node (unicast) or a group of nodes (groupcast, broadcast).

The following code creates and sends a ZigBee Device Profile (ZDP) Match Descriptor Request via broadcast
to search the network for ZigBee Light Link (ZLL) devices like Philips Hue which provide a OnOff cluster.

// set destination addressing
req.setDstEndpoint(ZDO_ENDPOINT);
req.setSrcEndpoint(ZDO_ENDPOINT);
req.setProfileId(ZDP_PROFILE_ID);
req.setClusterId(ZDP_MATCH_DESCRIPTOR_CLID);
// prepare payload
QDataStream stream(&req.asdu(), QIODevice::WriteOnly);
stream.setByteOrder(QDataStream::LittleEndian);
// write payload according to ZigBee specification (section 2.4.3.1.7, Match_Descr_req)
stream << static_cast<quint8>(qrand()); // ZDP transaction sequence number
stream << static_cast<quint16>(deCONZ::BroadcastRxOnWhenIdle); // NWKAddrOfInterest
stream << static_cast<quint16>(ZLL_PROFILE_ID); // ProfileID
stream << static_cast<quint8>(0x01); // NumInClusters
stream << static_cast<quint16>(0x0006); // OnOff ClusterID
stream << static_cast<quint8>(0x00); // NumOutClusters
if (deCONZ::ApsController::instance()->apsdeDataRequest(req) == deCONZ::Success))
{
...
}
void setNwk(uint16_t addr)
Sets the 16-bit network address which might be a unicast or broadcast address.
Definition aps.cpp:1258
static ApsController * instance()
Get the singleton instance of the ApsController.
APSDE-DATA.request primitive.
Definition aps.h:227
void setClusterId(uint16_t clusterId)
Sets the cluster identifier.
Definition aps.cpp:251
void setProfileId(uint16_t profileId)
Sets the profile identifier.
Definition aps.cpp:241
void setDstAddressMode(ApsAddressMode mode)
Sets the destination address mode.
Definition aps.cpp:211
void setSrcEndpoint(uint8_t ep)
Sets the source endpoint.
Definition aps.cpp:221
const QByteArray & asdu() const
Returns the const ASDU payload.
Definition aps.cpp:266
void setDstEndpoint(uint8_t ep)
Sets the destination endpoint.
Definition aps.cpp:231
Address & dstAddress()
Returns the modifiable destination address.
Definition aps.cpp:196
@ BroadcastRxOnWhenIdle
Broadcast to all nodes which have the RxOnWhenIdle flag set.
Definition types.h:74
@ ApsNwkAddress
16-bit network address mode
Definition aps.h:86
@ Success
Success.
Definition types.h:59

Member Function Documentation

◆ id()

uint8_t deCONZ::ApsDataRequest::id ( ) const

Returns the uniqe id for this request.

The id is set in the constructor. It allows to match a ApsDataConfirm to the request.

◆ readFromStream()

void deCONZ::ApsDataRequest::readFromStream ( QDataStream &  stream)

Reads a request from the stream which must be in a ZigBee standard conform format.

QByteArray arr; // buffer which contains the plain request
QDataStream stream(&arr, QIODevice::ReadOnly);
stream.setByteOrder(QDataStream::LittleEndian); // everything in ZigBee is little endian
// deserialize request from buffer
req.readFromStream(stream);
void readFromStream(QDataStream &stream)
Reads a request from the stream which must be in a ZigBee standard conform format.
Definition aps.cpp:395

◆ setRadius()

void deCONZ::ApsDataRequest::setRadius ( uint8_t  radius)

Sets the send radius.

A value of 0 means the stack will use the default value.

◆ setTxOptions()

void deCONZ::ApsDataRequest::setTxOptions ( ApsTxOptions  txOptions)

Sets the transmit options.

Parameters
txOptionsa logical OR combined value of deCONZ::ApsTxOption flags

◆ txOptions()

ApsTxOptions deCONZ::ApsDataRequest::txOptions ( ) const

Returns the transmit options.

Returns
a a logical OR combined value of deCONZ::ApsTxOption flags

◆ writeToStream()

int deCONZ::ApsDataRequest::writeToStream ( QDataStream &  stream) const

Writes the request to the stream in a ZigBee standard conform format.

Returns
1 on success
// ... setup request
QByteArray arr; // buffer into which the plain request will be written
QDataStream stream(&arr, QIODevice::WriteOnly);
stream.setByteOrder(QDataStream::LittleEndian); // everything in ZigBee is little endian
// serialize request to buffer
if (req.writeToStream(stream))
{ }
int writeToStream(QDataStream &stream) const
Writes the request to the stream in a ZigBee standard conform format.
Definition aps.cpp:301

The documentation for this class was generated from the following files: