nRF5 SDK for Thread and Zigbee v3.2.0
Macros | Functions
Fill ZCL packet low-level API

Macros

#define ZB_ZCL_START_PACKET(zbbuf)
 Initializes zb_buf_t buffer and returns pointer to the beginning of array.
 
#define ZB_ZCL_GET_BYTES_WRITTEN(zbbuf, ptr)
 Return number of bytes written to the buffer.
 
#define ZB_ZCL_GET_BYTES_AVAILABLE(zbbuf, ptr)
 Return number of bytes available in a packet.
 
#define ZB_ZCL_PACKET_PUT_DATA8(ptr, val)
 Put 8-bit value to packet.
 
#define ZB_ZCL_PACKET_PUT_DATA16(ptr, val)
 
#define ZB_ZCL_PACKET_PUT_DATA16_VAL(ptr, val)   ZB_PUT_NEXT_HTOLE16(ptr, val)
 
#define ZB_ZCL_PACKET_PUT_2DATA16_VAL(ptr, val1, val2)   (ptr) = zb_put_next_2_htole16((ptr),(val1),(val2))
 
#define ZB_ZCL_PACKET_PUT_2DATA16_VAL(ptr, val1, val2)   (ptr) = zb_put_next_2_htole16((ptr),(val1),(val2))
 
#define ZB_ZCL_PACKET_PUT_2DATA32_VAL(ptr, val1, val2)   (ptr) = zb_put_next_2_htole32((ptr),(val1),(val2))
 
#define ZB_ZCL_PACKET_PUT_2DATA32_VAL(ptr, val1, val2)   (ptr) = zb_put_next_2_htole32((ptr),(val1),(val2))
 
#define ZB_ZCL_PACKET_PUT_DATA32_VAL(ptr, val)
 Put 32-bit value to packet. More...
 
#define ZB_ZCL_PACKET_PUT_DATA32(ptr, val)
 Put 32-bit value to packet. More...
 
#define ZB_ZCL_PACKET_PUT_DATA48_VAL(ptr, val)
 Put 48-bit value to packet. More...
 
#define ZB_ZCL_PACKET_PUT_DATA48(ptr, val)
 Put 48-bit value to packet. More...
 
#define ZB_ZCL_PACKET_PUT_DATA24_VAL(ptr, val)
 Put 24-bit value to packet. More...
 
#define ZB_ZCL_PACKET_PUT_DATA24(ptr, val)
 Put 24-bit value to packet. More...
 
#define ZB_ZCL_PACKET_PUT_DATA64(ptr, val)
 Put 64-bit value to packet. More...
 
#define ZB_ZCL_PACKET_GET_DATA8(dst_ptr, src_ptr)
 Get 8-bit value from packet. More...
 
#define ZB_ZCL_PACKET_PUT_DATA_N(ptr, val, n)   (ZB_MEMCPY(ptr, val, n), (ptr) += (n))
 Put N byte data to packet. More...
 
#define ZB_ZCL_PACKET_PUT_DATA_N(ptr, val, n)   (ZB_MEMCPY(ptr, val, n), (ptr) += (n))
 Put N byte data to packet. More...
 
#define ZB_ZCL_PACKET_GET_DATA16(dst_ptr, src_ptr)
 Get 16-bit value from packet. More...
 
#define ZB_ZCL_PACKET_GET_DATA24(dst_ptr, src_ptr)
 Get 24-bit value from packet. More...
 
#define ZB_ZCL_PACKET_GET_DATA48(dst_ptr, src_ptr)
 Get 48-bit value from packet. More...
 
#define ZB_ZCL_PACKET_GET_DATA32(dst_ptr, src_ptr)
 Get 32-bit value from packet. More...
 
#define ZB_ZCL_PACKET_GET_DATA64(dst_ptr, src_ptr)
 Get 64-bit value from packet. More...
 
#define ZB_ZCL_PACKET_GET_DATA_IEEE(dst_ptr, src_ptr)
 Get IEEE address from packet. More...
 
#define ZB_ZCL_PACKET_PUT_DATA_IEEE(dst_ptr, src_ptr)
 Put IEEE address into packet. More...
 
#define ZB_ZCL_PACKET_PUT_STRING(_ptr, _val)
 
#define ZB_ZCL_PACKET_PUT_STRING(_ptr, _val)
 
#define ZB_ZCL_PACKET_GET_STRING(_zcl_str, data, _zcl_str_max_size)
 
#define ZB_ZCL_PACKET_GET_STRING(_zcl_str, data, _zcl_str_max_size)
 
#define ZB_ZCL_PACKET_GET_STATIC_STRING(_zcl_str, data)   ZB_ZCL_PACKET_GET_STRING(_zcl_str, data, sizeof(_zcl_str))
 
#define ZB_ZCL_PACKET_GET_STATIC_STRING(_zcl_str, data)   ZB_ZCL_PACKET_GET_STRING(_zcl_str, data, sizeof(_zcl_str))
 
#define ZB_ZCL_PACKET_GET_DATA_N(dst_ptr, src_ptr, n)
 Get N-byte value from packet. More...
 
#define ZB_ZCL_FINISH_PACKET(zbbuf, ptr)   (void) zb_zcl_finish_and_send_packet((zbbuf), (ptr),
 
#define ZB_ZCL_SEND_COMMAND_SHORT(buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, cluster_id, cb)   (zb_addr_u *)(&(addr)), dst_addr_mode, dst_ep, ep, prof_id, cluster_id, cb)
 
#define ZB_ZCL_FINISH_PACKET_O(zbbuf, ptr)   ZB_BUF_ALLOC_LEFT(zbbuf, ZB_ZCL_GET_BYTES_WRITTEN(zbbuf, ptr), ptr);
 

Functions

zb_ret_t zb_zcl_finish_and_send_packet (zb_buf_t *buffer, zb_uint8_t *ptr, zb_addr_u *dst_addr, zb_uint8_t dst_addr_mode, zb_uint8_t dst_ep, zb_uint8_t ep, zb_uint16_t prof_id, zb_uint16_t cluster_id, zb_callback_t cb)
 ZCL finish and send packet. More...
 
zb_ret_t zb_zcl_finish_and_send_packet_frag (zb_buf_t *buffer, zb_uint8_t *ptr, zb_addr_u *dst_addr, zb_uint8_t dst_addr_mode, zb_uint8_t dst_ep, zb_uint8_t ep, zb_uint16_t prof_id, zb_uint16_t cluster_id, zb_callback_t cb, zb_bool_t frag)
 

Detailed Description

Types and macros shared fill Fill ZCL packet.

Example
zb_uint8_t *cmd_payload;
cmd_payload = ZB_ZCL_START_PACKET(data_buf);
// Form command payload
/* Add Attribute reporting configuration record (correct one) */
ZB_ZCL_PACKET_PUT_DATA16_VAL(cmd_payload, ZB_ZCL_ATTR_OO_ON_OFF_ID); // attr id
ZB_ZCL_PACKET_PUT_DATA8(cmd_payload, ZB_ZCL_ATTR_TYPE_BOOL); // attr type
ZB_ZCL_PACKET_PUT_DATA16_VAL(cmd_payload, min_interval); // minimum interval
ZB_ZCL_PACKET_PUT_DATA16_VAL(cmd_payload, max_interval); // maximum interval
/* Reportable change is omitted for discrete data type */
/* Add Attribute reporting configuration record (with error - invalid attribute id) */
ZB_ZCL_PACKET_PUT_DATA16_VAL(cmd_payload, ZB_ZCL_ATTR_B_APPLICATION_VERSION_ID); // attr id
ZB_ZCL_PACKET_PUT_DATA8(cmd_payload, ZB_ZCL_ATTR_TYPE_U8); // attr type
ZB_ZCL_PACKET_PUT_DATA16_VAL(cmd_payload, min_interval); // minimum interval
ZB_ZCL_PACKET_PUT_DATA16_VAL(cmd_payload, max_interval); // maximum interval
ZB_ZCL_PACKET_PUT_DATA8(cmd_payload, VERSION_DELTA_VALUE); // Reportable change
ZB_ZCL_FINISH_PACKET(data_buf, cmd_payload);
ZB_ZCL_SEND_WRITE_ATTRS_CMD(data_buf, dst_addr, ZB_APS_ADDR_MODE_16_ENDP_PRESENT,

For more information see any HA sample

Macro Definition Documentation

#define ZB_ZCL_FINISH_PACKET (   zbbuf,
  ptr 
)    (void) zb_zcl_finish_and_send_packet((zbbuf), (ptr),

Finish ZCL packet filling. Used bytes number are marked in a buffer.

Parameters
zbbuf- pointer to zb_buf_t buffer.
ptr- pointer to the byte after the last written byte in the buffer.
Attention
After ZB_ZCL_FINISH_PACKET() call, pointer ptr is set to the beginning of the buffer data.
#define ZB_ZCL_PACKET_GET_DATA16 (   dst_ptr,
  src_ptr 
)
Value:
{ \
ZB_LETOH16((dst_ptr), (src_ptr)); \
(src_ptr) += sizeof(zb_uint16_t); \
}
unsigned short zb_uint16_t
Project-local 2-byte unsigned int type.
Definition: zb_types.h:120
#define ZB_LETOH16
Definition: zb_types.h:673

Get 16-bit value from packet.

Parameters
dst_ptr- pointer to the memory to store value (pinter value preserved).
src_ptr- pointer to the memory to get value from (will be incremented by value size).
#define ZB_ZCL_PACKET_GET_DATA24 (   dst_ptr,
  src_ptr 
)
Value:
{ \
ZB_LETOH24(dst_ptr, src_ptr); \
(src_ptr) += ZB_24BIT_SIZE; \
}

Get 24-bit value from packet.

Parameters
dst_ptr- pointer to the memory to store value (pinter value preserved).
src_ptr- pointer to the memory to get value from (will be incremented by value size).
#define ZB_ZCL_PACKET_GET_DATA32 (   dst_ptr,
  src_ptr 
)
Value:
{ \
ZB_LETOH32((dst_ptr), (src_ptr)); \
(src_ptr) += sizeof(zb_uint32_t); \
}
unsigned int zb_uint32_t
Project-local 4-byte unsigned int type.
Definition: zb_types.h:144

Get 32-bit value from packet.

Parameters
dst_ptr- pointer to the memory to store value (pinter value preserved).
src_ptr- pointer to the memory to get value from (will be incremented by value size).
#define ZB_ZCL_PACKET_GET_DATA48 (   dst_ptr,
  src_ptr 
)
Value:
{ \
ZB_LETOH48(dst_ptr, src_ptr); \
(src_ptr) += ZB_48BIT_SIZE; \
}

Get 48-bit value from packet.

Parameters
dst_ptr- pointer to the memory to store value (pinter value preserved).
src_ptr- pointer to the memory to get value from (will be incremented by value size).
#define ZB_ZCL_PACKET_GET_DATA64 (   dst_ptr,
  src_ptr 
)
Value:
{ \
ZB_LETOH64((dst_ptr), (src_ptr)); \
(src_ptr) += 8; \
}

Get 64-bit value from packet.

Parameters
dst_ptr- pointer to the memory to store value (pinter value preserved).
src_ptr- pointer to the memory to get value from (will be incremented by value size).
#define ZB_ZCL_PACKET_GET_DATA8 (   dst_ptr,
  src_ptr 
)
Value:
{ \
*(dst_ptr) = *((src_ptr)++); \
}

Get 8-bit value from packet.

Parameters
dst_ptr- pointer to the memory to store value (pinter value preserved).
src_ptr- pointer to the memory to get value from (will be incremented).
#define ZB_ZCL_PACKET_GET_DATA_IEEE (   dst_ptr,
  src_ptr 
)
Value:
{ \
ZB_IEEE_ADDR_COPY((dst_ptr), (src_ptr)); \
(src_ptr) += sizeof(zb_ieee_addr_t); \
}
zb_64bit_addr_t zb_ieee_addr_t
Long (64-bit) device address.
Definition: zb_types.h:438

Get IEEE address from packet.

Parameters
dst_ptr- pointer to the memory to store value (pinter value preserved).
src_ptr- pointer to the memory to get value from (will be incremented by value size).
#define ZB_ZCL_PACKET_GET_DATA_N (   dst_ptr,
  src_ptr,
 
)
Value:
{ \
ZB_MEMCPY((dst_ptr), (src_ptr), (n)); \
(src_ptr) += (n); \
}

Get N-byte value from packet.

Parameters
dst_ptr- pointer to the memory to store value (will be incremented by value size).
src_ptr- pointer to the memory to get value from (pinter value preserved).
n- data length.
#define ZB_ZCL_PACKET_GET_STATIC_STRING (   _zcl_str,
  data 
)    ZB_ZCL_PACKET_GET_STRING(_zcl_str, data, sizeof(_zcl_str))

Get ZCL String from packet and put it into array with fixed size.

#define ZB_ZCL_PACKET_GET_STATIC_STRING (   _zcl_str,
  data 
)    ZB_ZCL_PACKET_GET_STRING(_zcl_str, data, sizeof(_zcl_str))

Get ZCL String from packet and put it into array with fixed size.

#define ZB_ZCL_PACKET_GET_STRING (   _zcl_str,
  data,
  _zcl_str_max_size 
)
Value:
{ \
ZB_ZCL_PACKET_GET_DATA8(&_zcl_str[0], data); \
if (_zcl_str_max_size > ZB_ZCL_GET_STRING_LENGTH(_zcl_str)) \
{ \
data, \
} \
else \
{ \
data = NULL; \
} \
}
#define ZB_ZCL_GET_STRING_LENGTH(str)
Get ZCL string length.
Definition: zb_zcl_common.h:419
#define ZB_ZCL_PACKET_GET_DATA8(dst_ptr, src_ptr)
Get 8-bit value from packet.
Definition: zb_zcl_common.h:1444
#define ZB_ZCL_PACKET_GET_DATA_N(dst_ptr, src_ptr, n)
Get N-byte value from packet.
Definition: zb_zcl_common.h:1617
#define ZB_ZCL_GET_STRING_BEGIN(_str)
Definition: zb_zcl_common.h:427

Get ZCL String from packet.

Note
If string is invalid (cannot be stored in buffer) this macro sets data to NULL.
Parameters
_zcl_str- Destination buffer.
data- Pointer to incomming data.
_zcl_str_max_size- Size of destination buffer.
#define ZB_ZCL_PACKET_GET_STRING (   _zcl_str,
  data,
  _zcl_str_max_size 
)
Value:
{ \
ZB_ZCL_PACKET_GET_DATA8(&_zcl_str[0], data); \
if (_zcl_str_max_size > ZB_ZCL_GET_STRING_LENGTH(_zcl_str)) \
{ \
data, \
} \
else \
{ \
data = NULL; \
} \
}
#define ZB_ZCL_GET_STRING_LENGTH(str)
Get ZCL string length.
Definition: zb_zcl_common.h:419
#define ZB_ZCL_PACKET_GET_DATA8(dst_ptr, src_ptr)
Get 8-bit value from packet.
Definition: zb_zcl_common.h:1444
#define ZB_ZCL_PACKET_GET_DATA_N(dst_ptr, src_ptr, n)
Get N-byte value from packet.
Definition: zb_zcl_common.h:1617
#define ZB_ZCL_GET_STRING_BEGIN(_str)
Definition: zb_zcl_common.h:427

Get ZCL String from packet.

Note
If string is invalid (cannot be stored in buffer) this macro sets data to NULL.
Parameters
_zcl_str- Destination buffer.
data- Pointer to incomming data.
_zcl_str_max_size- Size of destination buffer.
#define ZB_ZCL_PACKET_PUT_DATA16 (   ptr,
  val 
)
Value:
{ \
ZB_HTOLE16((ptr), (val)); \
(ptr) += 2; \
}

Put 16-bit value to packet

Parameters
ptr- pointer to the place to put value to
val- pointer to the value to put into packet
#define ZB_ZCL_PACKET_PUT_DATA16_VAL (   ptr,
  val 
)    ZB_PUT_NEXT_HTOLE16(ptr, val)

Put 16-bit value to packet

Parameters
ptr- pointer to the place to put value to
val- value to put into packet
#define ZB_ZCL_PACKET_PUT_DATA24 (   ptr,
  val 
)

Put 24-bit value to packet.

Parameters
ptr- pointer to the place to put value to
val- pointer to the value to put into packet
#define ZB_ZCL_PACKET_PUT_DATA24_VAL (   ptr,
  val 
)

Put 24-bit value to packet.

Parameters
ptr- pointer to the place to put value to
val- value to put into packet
#define ZB_ZCL_PACKET_PUT_DATA32 (   ptr,
  val 
)

Put 32-bit value to packet.

Parameters
ptr- pointer to the place to put value to
val- pointer to the value to put into packet
#define ZB_ZCL_PACKET_PUT_DATA32_VAL (   ptr,
  val 
)

Put 32-bit value to packet.

Parameters
ptr- pointer to the place to put value to
val- pointer to the value to put into packet
#define ZB_ZCL_PACKET_PUT_DATA48 (   ptr,
  val 
)

Put 48-bit value to packet.

Parameters
ptr- pointer to the place to put value to
val- pointer to the value to put into packet
#define ZB_ZCL_PACKET_PUT_DATA48_VAL (   ptr,
  val 
)

Put 48-bit value to packet.

Parameters
ptr- pointer to the place to put value to
val- value to put into packet
#define ZB_ZCL_PACKET_PUT_DATA64 (   ptr,
  val 
)

Put 64-bit value to packet.

Parameters
ptr- pointer to the place to put value to
val- pointer to the value to put into packet
#define ZB_ZCL_PACKET_PUT_DATA_IEEE (   dst_ptr,
  src_ptr 
)
Value:
{ \
ZB_IEEE_ADDR_COPY((dst_ptr), (src_ptr)); \
(dst_ptr) += sizeof(zb_ieee_addr_t); \
}
zb_64bit_addr_t zb_ieee_addr_t
Long (64-bit) device address.
Definition: zb_types.h:438

Put IEEE address into packet.

Parameters
dst_ptr- pointer to the memory to store value (will be incremented by value size).
src_ptr- pointer to the memory to get value from (pinter value preserved).
#define ZB_ZCL_PACKET_PUT_DATA_N (   ptr,
  val,
 
)    (ZB_MEMCPY(ptr, val, n), (ptr) += (n))

Put N byte data to packet.

Parameters
ptr- pointer to the place to put value to.
val- pointer to the value to put into packet.
n- number of bytes to be copied.

Put N byte data to packet

#define ZB_ZCL_PACKET_PUT_DATA_N (   ptr,
  val,
 
)    (ZB_MEMCPY(ptr, val, n), (ptr) += (n))

Put N byte data to packet.

Parameters
ptr- pointer to the place to put value to.
val- pointer to the value to put into packet.
n- number of bytes to be copied.

Put N byte data to packet

#define ZB_ZCL_PACKET_PUT_STRING (   _ptr,
  _val 
)
Value:
{ \
}
#define ZB_ZCL_PACKET_PUT_DATA8(ptr, val)
Put 8-bit value to packet.
Definition: zb_zcl_common.h:1353
#define ZB_ZCL_PACKET_PUT_DATA_N(ptr, val, n)
Put N byte data to packet.
Definition: zb_zcl_common.h:1537
#define ZB_ZCL_GET_STRING_LENGTH(str)
Get ZCL string length.
Definition: zb_zcl_common.h:419
#define ZB_ZCL_GET_STRING_BEGIN(_str)
Definition: zb_zcl_common.h:427

Put ZCL Octet String to packet

#define ZB_ZCL_PACKET_PUT_STRING (   _ptr,
  _val 
)
Value:
{ \
}
#define ZB_ZCL_PACKET_PUT_DATA8(ptr, val)
Put 8-bit value to packet.
Definition: zb_zcl_common.h:1353
#define ZB_ZCL_PACKET_PUT_DATA_N(ptr, val, n)
Put N byte data to packet.
Definition: zb_zcl_common.h:1537
#define ZB_ZCL_GET_STRING_LENGTH(str)
Get ZCL string length.
Definition: zb_zcl_common.h:419
#define ZB_ZCL_GET_STRING_BEGIN(_str)
Definition: zb_zcl_common.h:427

Put ZCL Octet String to packet

Function Documentation

zb_ret_t zb_zcl_finish_and_send_packet ( zb_buf_t buffer,
zb_uint8_t ptr,
zb_addr_u dst_addr,
zb_uint8_t  dst_addr_mode,
zb_uint8_t  dst_ep,
zb_uint8_t  ep,
zb_uint16_t  prof_id,
zb_uint16_t  cluster_id,
zb_callback_t  cb 
)

ZCL finish and send packet.

Parameters
bufferpointer to the buffer where ZCL cmd is stored
ptrpointer to the end of ZCL cmd in buffer
dst_addrdestination address (see zb_addr_u)
dst_addr_modedestination address mode (only ZB_APS_ADDR_MODE_16_GROUP_ENDP_NOT_PRESENT and ZB_APS_ADDR_MODE_16_ENDP_PRESENT are supported)
dst_epdestination endpoint
epsource endpoint
prof_idprofile the command belongs to
cluster_idcluster identifier
cbcommand send status callback

Documentation feedback | Developer Zone | Subscribe | Updated