Developing with ZBOSS for Zigbee
Default response command sending and parsing.

Data Structures

struct  zb_zcl_default_resp_payload_s
 Default response payload structure. More...
 

Macros

#define ZB_ZCL_SEND_DEFAULT_RESP_DIRECTION(buffer, addr, addr_mode, dst_ep, ep, prof_id, cluster_id, seq_num, cmd, status_code, direction)
 Send default response command with custom Direction. More...
 
#define ZB_ZCL_SEND_DEFAULT_RESP_WITH_CB(buffer, addr, addr_mode, dst_ep, ep, prof_id, cluster_id, seq_num, cmd, status_code, callback)
 Send default response command and execute callback when it is acknowledged or expired. More...
 
#define ZB_ZCL_SEND_DEFAULT_RESP_WITH_CB_NEW(buffer, addr, addr_mode, dst_ep, ep, prof_id, cluster_id, seq_num, cmd, status_code, callback, aps_secured)
 
#define ZB_ZCL_SEND_DEFAULT_RESP_MANUF_WITH_CB(buffer, addr, addr_mode, dst_ep, ep, prof_id, cluster_id, seq_num, cmd, status_code, manuf_code, direction, callback)
 Send default response command and execute callback when it's acknowledged or expired. More...
 
#define ZB_ZCL_CHECK_IF_SEND_DEFAULT_RESP_EXT( _is_broadcast, _delivery_mode, _disable_def_resp, _status, _is_def_resp_frame)
 check whether command requires default response to be sent More...
 
#define ZB_ZCL_CHECK_IF_SEND_DEFAULT_RESP(_cmd_info, _status)
 API call that is used to check if it is needed to send Default response for the command. More...
 
#define ZB_ZCL_SEND_DEFAULT_RESP_EXT(_buffer, _dst_addr, _dst_addr_mode, _dst_ep, _src_ep, _prof_id, _cluster_id, _seq_num, _cmd, _status_code, _direction, _is_manuf_specific, _manuf_code, _callback)
 General API for sending Default response command. More...
 
#define ZB_ZCL_SEND_DEFAULT_RESP(buffer, addr, addr_mode, dst_ep, ep, prof_id, cluster_id, seq_num, cmd, status_code)
 Send default response command. More...
 
#define ZB_ZCL_SEND_DEFAULT_RESP_NEW(buffer, addr, addr_mode, dst_ep, ep, prof_id, cluster_id, seq_num, cmd, status_code, aps_secured)
 
#define ZB_ZCL_SEND_DEFAULT_RESP_MANUF( buffer, addr, addr_mode, dst_ep, ep, prof_id, cluster_id, seq_num, cmd, status_code, manuf_code, direction)
 Send default response command. More...
 
#define ZB_ZCL_READ_DEFAULT_RESP(buffer)
 Default response structured reading. More...
 

Typedefs

typedef struct zb_zcl_default_resp_payload_s zb_zcl_default_resp_payload_t
 Default response payload structure.
 

Detailed Description

Default response command is defined in ZCL spec, subclause 2.4.12.

Example
Command can be sent like in the following snippet:
buf,
ZB_ZCL_PARSED_HDR_SHORT_DATA(cmd_info).source.u.short_addr,
ZB_ZCL_PARSED_HDR_SHORT_DATA(cmd_info).src_endpoint,
ZB_ZCL_PARSED_HDR_SHORT_DATA(cmd_info).dst_endpoint,
cmd_info->profile_id,
ZB_ZCL_CLUSTER_ID_CUSTOM,
cmd_info->seq_number,
cmd_info->cmd_id,
status);
Incoming default response can be parsed as following:

Macro Definition Documentation

◆ ZB_ZCL_CHECK_IF_SEND_DEFAULT_RESP

#define ZB_ZCL_CHECK_IF_SEND_DEFAULT_RESP (   _cmd_info,
  _status 
)
Value:
ZB_NWK_IS_ADDRESS_BROADCAST((_cmd_info).addr_data.common_data.dst_addr), \
ZB_APS_FC_GET_DELIVERY_MODE((_cmd_info).addr_data.common_data.fc), \
(_cmd_info).disable_default_response, _status, \
((_cmd_info).is_common_command && (_cmd_info).cmd_id == ZB_ZCL_CMD_DEFAULT_RESP))

API call that is used to check if it is needed to send Default response for the command.

Parameters
_cmd_info- variable of zb_zcl_parsed_hdr_t type, containing received command header data
_status- status of the handled command

◆ ZB_ZCL_CHECK_IF_SEND_DEFAULT_RESP_EXT

#define ZB_ZCL_CHECK_IF_SEND_DEFAULT_RESP_EXT (   _is_broadcast,
  _delivery_mode,
  _disable_def_resp,
  _status,
  _is_def_resp_frame 
)
Value:
(!(_is_broadcast) && ((_delivery_mode) == ZB_APS_DELIVERY_UNICAST) && \
(!(_disable_def_resp) || (_status) != ZB_ZCL_STATUS_SUCCESS) \
&& !(_is_def_resp_frame))

check whether command requires default response to be sent

Default response is sent if:

  • particular response is not sent yet
  • original command is NOT broadcast
  • disable_default_response is set to FALSE or command status is not Success
  • command itself is NOT default response

This is a helper method, use ZB_ZCL_CHECK_IF_SEND_DEFAULT_RESP instead

Parameters
_is_broadcast- broadcast bit from NWK header
_delivery_mode- delivery mode from APS header
_disable_def_resp- Disable Default Response bit from ZCL header
_status- status of the handled command
_is_def_resp_frame- check for command type

◆ ZB_ZCL_READ_DEFAULT_RESP

#define ZB_ZCL_READ_DEFAULT_RESP (   buffer)
Value:
( (zb_buf_len((buffer)) != sizeof(zb_zcl_default_resp_payload_t)) ? \
NULL : \

Default response structured reading.

Parameters
buffer- pointer to the message buffer (of type zb_bufid_t) containing payload
Returns
pointer to zb_zcl_default_resp_payload_s structure
Attention
returned pointer will point to the same data in the buffer thus being valid until buffer data will be overwritten.

◆ ZB_ZCL_SEND_DEFAULT_RESP

#define ZB_ZCL_SEND_DEFAULT_RESP (   buffer,
  addr,
  addr_mode,
  dst_ep,
  ep,
  prof_id,
  cluster_id,
  seq_num,
  cmd,
  status_code 
)
Value:
ZB_ZCL_SEND_DEFAULT_RESP_WITH_CB(buffer, addr, addr_mode, dst_ep, ep, prof_id, cluster_id, \
seq_num, cmd, status_code, NULL)

Send default response command.

Parameters
buffer- ID zb_bufid_t of a buffer with payload
addr- short destination address
addr_mode- address mode, only ZB_APS_ADDR_MODE_16_GROUP_ENDP_NOT_PRESENT and ZB_APS_ADDR_MODE_16_ENDP_PRESENT are supported
dst_ep- destination end point
ep- our end point
prof_id- profile identifier
cluster_id- cluster identifier
seq_num- sequence number
cmd- identifier of the command the response is dedicated to
status_code- status field for received command

◆ ZB_ZCL_SEND_DEFAULT_RESP_DIRECTION

#define ZB_ZCL_SEND_DEFAULT_RESP_DIRECTION (   buffer,
  addr,
  addr_mode,
  dst_ep,
  ep,
  prof_id,
  cluster_id,
  seq_num,
  cmd,
  status_code,
  direction 
)
Value:
{ \
zb_uint8_t *ptr; \
ptr = ZB_ZCL_START_PACKET(buffer); \
ZB_ZCL_CONSTRUCT_GENERAL_COMMAND_RESP_FRAME_CONTROL_A( \
ptr, (direction), ZB_U2B(ZB_ZCL_NOT_MANUFACTURER_SPECIFIC)); \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER(ptr, (seq_num), ZB_ZCL_CMD_DEFAULT_RESP); \
*(ptr++) = (cmd); \
*(ptr++) = (status_code); \
ZB_ZCL_FINISH_PACKET((buffer), ptr) \
ZB_ZCL_SEND_COMMAND_SHORT((buffer), (addr), (addr_mode), (dst_ep), (ep), (prof_id), \
(cluster_id), NULL); \
}

Send default response command with custom Direction.

If you don't want to specify direction explicitly, use ZB_ZCL_SEND_DEFAULT_RESP()

Parameters
buffer- ID zb_bufid_t of a buffer with payload
addr- short destination address
addr_mode- address mode, only ZB_APS_ADDR_MODE_16_GROUP_ENDP_NOT_PRESENT and ZB_APS_ADDR_MODE_16_ENDP_PRESENT are supported
dst_ep- destination end point
ep- our end point
prof_id- profile identifier
cluster_id- cluster identifier
seq_num- sequence number
cmd- identifier of the command the response is dedicated to
status_code- status field for received command
direction- direction of the command (see zcl_frame_direction)

◆ ZB_ZCL_SEND_DEFAULT_RESP_EXT

#define ZB_ZCL_SEND_DEFAULT_RESP_EXT (   _buffer,
  _dst_addr,
  _dst_addr_mode,
  _dst_ep,
  _src_ep,
  _prof_id,
  _cluster_id,
  _seq_num,
  _cmd,
  _status_code,
  _direction,
  _is_manuf_specific,
  _manuf_code,
  _callback 
)
Value:
{ \
zb_uint8_t *_ptr; \
_ptr = ZB_ZCL_START_PACKET(_buffer); \
ZB_ZCL_CONSTRUCT_GENERAL_COMMAND_RESP_FRAME_CONTROL_A(_ptr, (_direction), \
(_is_manuf_specific)); \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_EXT(_ptr, (_seq_num), (_is_manuf_specific), (_manuf_code), \
*(_ptr++) = (_cmd); \
*(_ptr++) = (_status_code); \
ZB_ZCL_FINISH_PACKET((_buffer), _ptr) \
ZB_ZCL_SEND_COMMAND_SHORT((_buffer), (_dst_addr), (_dst_addr_mode), (_dst_ep), (_src_ep), \
(_prof_id), (_cluster_id), (_callback)); \
}

General API for sending Default response command.

Parameters
_buffer- zb_bufid_t buffer
_dst_addr- 16-bit destination address
_dst_addr_mode- destination address mode. Possible values ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT, ZB_APS_ADDR_MODE_16_GROUP_ENDP_NOT_PRESENT, ZB_APS_ADDR_MODE_16_ENDP_PRESENT
_dst_ep- destination Endpoint number
_src_ep- source Endpoint number
_prof_id- profile ID
_cluster_id- cluster ID
_seq_num- transaction sequence number
_cmd- command ID
_status_code- command status (see zcl_status)
_direction- direction of command (see zcl_frame_direction)
_is_manuf_specific- flag, equal to 1 if command is manufacturer specific
_manuf_code- manufacturer specific code, is taken unto account only if _is_manuf_specific is equal to 1
_callback- pointer to the callback function that will be called when the command is sent

◆ ZB_ZCL_SEND_DEFAULT_RESP_MANUF

#define ZB_ZCL_SEND_DEFAULT_RESP_MANUF (   buffer,
  addr,
  addr_mode,
  dst_ep,
  ep,
  prof_id,
  cluster_id,
  seq_num,
  cmd,
  status_code,
  manuf_code,
  direction 
)
Value:
ZB_ZCL_SEND_DEFAULT_RESP_MANUF_WITH_CB(buffer, addr, addr_mode, dst_ep, ep, prof_id, cluster_id, \
seq_num, cmd, status_code, manuf_code, direction, NULL)

Send default response command.

Parameters
buffer- ID zb_bufid_t of a buffer with payload
addr- short destination address
addr_mode- address mode, only ZB_APS_ADDR_MODE_16_GROUP_ENDP_NOT_PRESENT and ZB_APS_ADDR_MODE_16_ENDP_PRESENT are supported
dst_ep- destination end point
ep- our end point
prof_id- profile identifier
cluster_id- cluster identifier
seq_num- sequence number
cmd- identifier of the command the response is dedicated to
status_code- status field for received command
manuf_code- manufacturer code
direction- direction of command (see zcl_frame_direction)

◆ ZB_ZCL_SEND_DEFAULT_RESP_MANUF_WITH_CB

#define ZB_ZCL_SEND_DEFAULT_RESP_MANUF_WITH_CB (   buffer,
  addr,
  addr_mode,
  dst_ep,
  ep,
  prof_id,
  cluster_id,
  seq_num,
  cmd,
  status_code,
  manuf_code,
  direction,
  callback 
)
Value:
{ \
zb_uint8_t * ptr = NULL; \
ptr = ZB_ZCL_START_PACKET(buffer); \
ZB_ZCL_CONSTRUCT_GENERAL_COMMAND_RESP_FRAME_CONTROL_EXT(ptr, ZB_TRUE, direction); \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_EXT(ptr, seq_num, ZB_TRUE, manuf_code, ZB_ZCL_CMD_DEFAULT_RESP); \
*(ptr++) = cmd; \
*(ptr++) = status_code; \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT(buffer, addr, addr_mode, dst_ep, ep, prof_id, cluster_id, (callback)); \
}

Send default response command and execute callback when it's acknowledged or expired.

If no callback is needed, use ZB_ZCL_SEND_DEFAULT_RESP()

Parameters
buffer- ID zb_bufid_t of a buffer with payload
addr- short destination address
addr_mode- address mode, only ZB_APS_ADDR_MODE_16_GROUP_ENDP_NOT_PRESENT and ZB_APS_ADDR_MODE_16_ENDP_PRESENT are supported
dst_ep- destination end point
ep- our end point
prof_id- profile identifier
cluster_id- cluster identifier
seq_num- sequence number
cmd- identifier of the command the response is dedicated to
status_code- status field for received command
manuf_code- manufacturer code
direction- direction of the command (see zcl_frame_direction)
callback- callback to be executed when command is acknowledged or expired (of type zb_callback_t)

◆ ZB_ZCL_SEND_DEFAULT_RESP_NEW

#define ZB_ZCL_SEND_DEFAULT_RESP_NEW (   buffer,
  addr,
  addr_mode,
  dst_ep,
  ep,
  prof_id,
  cluster_id,
  seq_num,
  cmd,
  status_code,
  aps_secured 
)
Value:
ZB_ZCL_SEND_DEFAULT_RESP_WITH_CB_NEW(buffer, addr, addr_mode, dst_ep, ep, prof_id, cluster_id, \
seq_num, cmd, status_code, NULL, aps_secured)

◆ ZB_ZCL_SEND_DEFAULT_RESP_WITH_CB

#define ZB_ZCL_SEND_DEFAULT_RESP_WITH_CB (   buffer,
  addr,
  addr_mode,
  dst_ep,
  ep,
  prof_id,
  cluster_id,
  seq_num,
  cmd,
  status_code,
  callback 
)
Value:
{ \
zb_uint8_t *ptr; \
ptr = ZB_ZCL_START_PACKET(buffer); \
ZB_ZCL_CONSTRUCT_GENERAL_COMMAND_RESP_FRAME_CONTROL(ptr); \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER(ptr, (seq_num), ZB_ZCL_CMD_DEFAULT_RESP); \
*(ptr++) = (cmd); \
*(ptr++) = (status_code); \
ZB_ZCL_FINISH_PACKET((buffer), ptr) \
ZB_ZCL_SEND_COMMAND_SHORT((buffer), (addr), (addr_mode), (dst_ep), (ep), (prof_id), \
(cluster_id), (callback)); \
}

Send default response command and execute callback when it is acknowledged or expired.

If no callback is needed, use ZB_ZCL_SEND_DEFAULT_RESP()

Parameters
buffer- ID zb_bufid_t of a buffer with payload
addr- short destination address
addr_mode- address mode, only ZB_APS_ADDR_MODE_16_GROUP_ENDP_NOT_PRESENT and ZB_APS_ADDR_MODE_16_ENDP_PRESENT are supported
dst_ep- destination end point
ep- our end point
prof_id- profile identifier
cluster_id- cluster identifier
seq_num- sequence number
cmd- identifier of the command the response is dedicated to
status_code- status field for received command
callback- callback to be executed when command is acknowledged or expired (of type zb_callback_t)

◆ ZB_ZCL_SEND_DEFAULT_RESP_WITH_CB_NEW

#define ZB_ZCL_SEND_DEFAULT_RESP_WITH_CB_NEW (   buffer,
  addr,
  addr_mode,
  dst_ep,
  ep,
  prof_id,
  cluster_id,
  seq_num,
  cmd,
  status_code,
  callback,
  aps_secured 
)
Value:
{ \
zb_uint8_t *ptr; \
ptr = ZB_ZCL_START_PACKET(buffer); \
ZB_ZCL_CONSTRUCT_GENERAL_COMMAND_RESP_FRAME_CONTROL(ptr); \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER(ptr, (seq_num), ZB_ZCL_CMD_DEFAULT_RESP); \
*(ptr++) = (cmd); \
*(ptr++) = (status_code); \
ZB_ZCL_FINISH_N_SEND_PACKET_NEW((buffer), ptr, (addr), (addr_mode), (dst_ep), (ep), (prof_id), \
(cluster_id), (callback), (aps_secured), ZB_FALSE, 0); \
}
zb_zcl_default_resp_payload_t
struct zb_zcl_default_resp_payload_s zb_zcl_default_resp_payload_t
Default response payload structure.
ZB_ZCL_START_PACKET
#define ZB_ZCL_START_PACKET(zbbuf)
Initializes zb_buf_t buffer and returns pointer to the beginning of array.
Definition: zb_zcl_common.h:1431
ZB_ZCL_SEND_DEFAULT_RESP_WITH_CB
#define ZB_ZCL_SEND_DEFAULT_RESP_WITH_CB(buffer, addr, addr_mode, dst_ep, ep, prof_id, cluster_id, seq_num, cmd, status_code, callback)
Send default response command and execute callback when it is acknowledged or expired.
Definition: zb_zcl_commands.h:343
ZB_ZCL_SEND_DEFAULT_RESP
#define ZB_ZCL_SEND_DEFAULT_RESP(buffer, addr, addr_mode, dst_ep, ep, prof_id, cluster_id, seq_num, cmd, status_code)
Send default response command.
Definition: zb_zcl_commands.h:496
ZB_ZCL_NOT_MANUFACTURER_SPECIFIC
#define ZB_ZCL_NOT_MANUFACTURER_SPECIFIC
Definition: zb_zcl_common.h:912
ZB_TRUE
#define ZB_TRUE
Definition: zb_types.h:371
ZB_ZCL_READ_DEFAULT_RESP
#define ZB_ZCL_READ_DEFAULT_RESP(buffer)
Default response structured reading.
Definition: zb_zcl_commands.h:544
ZB_ZCL_PARSED_HDR_SHORT_DATA
#define ZB_ZCL_PARSED_HDR_SHORT_DATA(header)
Extract common addressing data from parsed ZCL structure.
Definition: zb_zcl_common.h:1105
zb_buf_begin
#define zb_buf_begin(buf)
Definition: zboss_api_buf.h:344
ZB_NWK_IS_ADDRESS_BROADCAST
#define ZB_NWK_IS_ADDRESS_BROADCAST(addr)
Check that address is broadcast.
Definition: zboss_api_nwk.h:57
ZB_ZCL_SEND_DEFAULT_RESP_MANUF_WITH_CB
#define ZB_ZCL_SEND_DEFAULT_RESP_MANUF_WITH_CB(buffer, addr, addr_mode, dst_ep, ep, prof_id, cluster_id, seq_num, cmd, status_code, manuf_code, direction, callback)
Send default response command and execute callback when it's acknowledged or expired.
Definition: zb_zcl_commands.h:391
ZB_APS_ADDR_MODE_16_ENDP_PRESENT
#define ZB_APS_ADDR_MODE_16_ENDP_PRESENT
Definition: zboss_api_aps.h:107
zb_zcl_default_resp_payload_s
Default response payload structure.
Definition: zb_zcl_commands.h:531
ZB_ZCL_CMD_DEFAULT_RESP
#define ZB_ZCL_CMD_DEFAULT_RESP
Definition: zb_zcl_commands.h:77
ZB_ZCL_CHECK_IF_SEND_DEFAULT_RESP_EXT
#define ZB_ZCL_CHECK_IF_SEND_DEFAULT_RESP_EXT( _is_broadcast, _delivery_mode, _disable_def_resp, _status, _is_def_resp_frame)
check whether command requires default response to be sent
Definition: zb_zcl_commands.h:421
ZB_ZCL_STATUS_SUCCESS
#define ZB_ZCL_STATUS_SUCCESS
Definition: zb_zcl_common.h:346
ZB_FALSE
#define ZB_FALSE
Definition: zb_types.h:370
zb_buf_len
#define zb_buf_len(buf)
Definition: zboss_api_buf.h:362