Developing with ZBOSS for Zigbee

Types and macros required for ZCL frame manipulations. More...

Data Structures

struct  zb_zcl_frame_ctrl_s
 ZCL frame control field. More...
 
struct  zb_zcl_frame_hdr_full_s
 ZCL frame header with manufacturer code. More...
 
struct  zb_zcl_frame_hdr_short_s
 ZCL frame header without manufacturer code. More...
 
struct  zb_zcl_addr_s
 Type to represent source address of ZCL message. More...
 
struct  zb_zcl_parsed_hdr_s
 
struct  zb_zcl_attr_addr_info_s
 

Macros

#define ZB_ZCL_MANUFACTURER_WILDCARD_ID   0xffff
 
#define ZB_ZCL_REVERT_DIRECTION(_d)   (((_d) == ZB_ZCL_FRAME_DIRECTION_TO_SRV) ? ZB_ZCL_FRAME_DIRECTION_TO_CLI : ZB_ZCL_FRAME_DIRECTION_TO_SRV)
 Reverts ZCL direction value.
 
#define ZB_ZCL_PARSED_HDR_SHORT_DATA(header)   ((header)->addr_data.common_data)
 Extract common addressing data from parsed ZCL structure. More...
 
#define ZB_ZCL_GET_FRAME_TYPE(v)
 Get ZCL frame type zcl_frame_type.
 
#define ZB_ZCL_GET_MANUF_SPECIFIC(v)
 Check is ZCL frame manufacturer specific zcl_manufacturer_specific.
 
#define ZB_ZCL_IS_MANUF_SPECIFIC(v)   (ZB_ZCL_GET_MANUF_SPECIFIC(v) != 0U)
 
#define ZB_ZCL_GET_DIRECTION(v)
 Get ZCL frame direction zcl_frame_direction.
 
#define ZB_ZCL_GET_DISABLE_DEFAULT_RESPONSE(v)
 Get ZCL disable default response field zcl_disable_default_response.
 
#define ZB_ZCL_SET_FRAME_TYPE(v, val)
 Set ZCL frame type zcl_frame_type.
 
#define ZB_ZCL_SET_MANUF_SPECIFIC(v, val)
 Set ZCL frame manufacturer specific zcl_manufacturer_specific.
 
#define ZB_ZCL_SET_DIRECTION(v, val)
 Set ZCL frame direction zcl_frame_direction.
 
#define ZB_ZCL_SET_DISABLE_DEFAULT_RESPONSE(v, val)
 Set ZCL disable default response field zcl_disable_default_response.
 
#define ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_RES_FRAME_CONTROL(buf_ptr)
 Construct ZCL header frame control value for cluster-specific command response. More...
 
#define ZB_ZCL_CONSTRUCT_COMMAND_HEADER(data_ptr, tsn, cmd_id)
 Construct ZCL header. More...
 
#define ZB_ZCL_CONSTRUCT_COMMAND_HEADER_EXT(_data_ptr, _tsn, _is_manuf_spec, _manuf_specific, _cmd_id)
 Construct ZCL header, Manufacturer specific value is conditionally supported. More...
 
#define ZB_ZCL_GET_SEQ_NUM()
 Return next sequence number for ZCL frame.
 
#define ZB_ZCL_COPY_PARSED_HEADER(buf, dst)
 Copy parsed ZCL header from buffer. More...
 
#define ZB_ZCL_SEND_CMD( buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, dis_default_resp, cluster_id, command_id, cb)
 General macro for sending a command with empty payload. More...
 

Typedefs

typedef zb_uint8_t zb_zcl_frame_type_t
 Type for ZCL frame type. More...
 
typedef zb_uint8_t zb_zcl_manufacturer_specific_t
 Type for return statuses of mathematical operations. More...
 
typedef zb_uint8_t zb_zcl_disable_default_response_t
 Type for possible values of Disable default response subfield of FCF in ZCL frame. More...
 
typedef zb_uint8_t zb_zcl_frame_direction_t
 Type for ZCL frame direction. More...
 
typedef struct zb_zcl_frame_ctrl_s zb_zcl_frame_ctrl_t
 ZCL frame control field. More...
 
typedef struct zb_zcl_frame_hdr_full_s zb_zcl_frame_hdr_full_t
 ZCL frame header with manufacturer code. More...
 
typedef struct zb_zcl_frame_hdr_short_s zb_zcl_frame_hdr_short_t
 ZCL frame header without manufacturer code. More...
 
typedef struct zb_zcl_addr_s zb_zcl_addr_t
 Type to represent source address of ZCL message. More...
 
typedef struct zb_zcl_parsed_hdr_s zb_zcl_parsed_hdr_t
 
typedef struct zb_zcl_attr_addr_info_s zb_zcl_attr_addr_info_t
 

Functions

void * zb_zcl_start_command_header (zb_bufid_t zbbuf, zb_uint8_t frame_ctl, zb_uint16_t manuf_code, zb_uint8_t cmd_id, zb_uint8_t *tsn)
 Construct ZCL command header in the buffer. More...
 

ZCL frame type

Defines Permitted values for Frame Type subfield of Frame Control field in ZCL frame.

#define ZB_ZCL_FRAME_TYPE_COMMON   0x00U
 
#define ZB_ZCL_FRAME_TYPE_CLUSTER_SPECIFIC   0x01U
 

Values for Manufacturer-specific subfield of FCF in ZCL frame

See also
ZCL spec, subclause 2.3.1.1.2
#define ZB_ZCL_NOT_MANUFACTURER_SPECIFIC   0x00U
 
#define ZB_ZCL_MANUFACTURER_SPECIFIC   0x01U
 

Disable default response subfield of FCF in ZCL frame

See also
ZCL spec, subclause 2.3.1.1.3
#define ZB_ZCL_ENABLE_DEFAULT_RESPONSE   0x00U
 
#define ZB_ZCL_DISABLE_DEFAULT_RESPONSE   0x01U
 

ZCL frame direction

See also
ZCL spec, subclause 2.3.1.1.3.
#define ZB_ZCL_FRAME_DIRECTION_TO_SRV   0x00U
 
#define ZB_ZCL_FRAME_DIRECTION_TO_CLI   0x01U
 

ZCL address type

Possible address types of devices from which ZCL message is received.

#define ZB_ZCL_ADDR_TYPE_SHORT   0U
 
#define ZB_ZCL_ADDR_TYPE_IEEE_GPD   1U
 
#define ZB_ZCL_ADDR_TYPE_SRC_ID_GPD   2U
 
#define ZB_ZCL_ADDR_TYPE_IEEE   3U
 

Detailed Description

Types and macros required for ZCL frame manipulations.

Macro Definition Documentation

◆ ZB_ZCL_CONSTRUCT_COMMAND_HEADER

#define ZB_ZCL_CONSTRUCT_COMMAND_HEADER (   data_ptr,
  tsn,
  cmd_id 
)

Construct ZCL header.

Note
To add Manufacturer specific field, use ZB_ZCL_CONSTRUCT_COMMAND_HEADER_EXT(), macro.

◆ ZB_ZCL_CONSTRUCT_COMMAND_HEADER_EXT

#define ZB_ZCL_CONSTRUCT_COMMAND_HEADER_EXT (   _data_ptr,
  _tsn,
  _is_manuf_spec,
  _manuf_specific,
  _cmd_id 
)
Value:
{ \
if ((_is_manuf_spec)) \
{ \
ZB_ZCL_PACKET_PUT_DATA16_VAL((_data_ptr), (_manuf_specific)); \
} \
ZB_ZCL_PACKET_PUT_DATA8((_data_ptr), (_tsn)); \
ZB_ZCL_PACKET_PUT_DATA8((_data_ptr), (_cmd_id)); \
}

Construct ZCL header, Manufacturer specific value is conditionally supported.

◆ ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_RES_FRAME_CONTROL

#define ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_RES_FRAME_CONTROL (   buf_ptr)
Value:

Construct ZCL header frame control value for cluster-specific command response.

◆ ZB_ZCL_COPY_PARSED_HEADER

#define ZB_ZCL_COPY_PARSED_HEADER (   buf,
  dst 
)
Value:
(ZB_MEMCPY( \
(dst), \

Copy parsed ZCL header from buffer.

Parameters
buf- ID zb_bufid_t of buffer containing parsed ZCL header as parameter
dst- pointer to the memory area to copy header to

◆ ZB_ZCL_DISABLE_DEFAULT_RESPONSE

#define ZB_ZCL_DISABLE_DEFAULT_RESPONSE   0x01U

Disable default response

◆ ZB_ZCL_ENABLE_DEFAULT_RESPONSE

#define ZB_ZCL_ENABLE_DEFAULT_RESPONSE   0x00U

Enable default response

◆ ZB_ZCL_FRAME_DIRECTION_TO_CLI

#define ZB_ZCL_FRAME_DIRECTION_TO_CLI   0x01U

Command sent from server to a client

◆ ZB_ZCL_FRAME_DIRECTION_TO_SRV

#define ZB_ZCL_FRAME_DIRECTION_TO_SRV   0x00U

Command sent from client to a server

◆ ZB_ZCL_FRAME_TYPE_CLUSTER_SPECIFIC

#define ZB_ZCL_FRAME_TYPE_CLUSTER_SPECIFIC   0x01U

Command is specific to a cluster

◆ ZB_ZCL_FRAME_TYPE_COMMON

#define ZB_ZCL_FRAME_TYPE_COMMON   0x00U

Command acts across the entire profile

◆ ZB_ZCL_MANUFACTURER_SPECIFIC

#define ZB_ZCL_MANUFACTURER_SPECIFIC   0x01U

Command refers to manufacturer-specific profile extension. Manufacturer code field shall be included into ZCL frame header.

◆ ZB_ZCL_NOT_MANUFACTURER_SPECIFIC

#define ZB_ZCL_NOT_MANUFACTURER_SPECIFIC   0x00U

Standard profile command. Manufacturer code field shall not be included into ZCL frame header.

◆ ZB_ZCL_PARSED_HDR_SHORT_DATA

#define ZB_ZCL_PARSED_HDR_SHORT_DATA (   header)    ((header)->addr_data.common_data)

Extract common addressing data from parsed ZCL structure.

Parameters
header- pointer to the parsed ZCL header structure (see zb_zcl_parsed_hdr_s).

◆ ZB_ZCL_SEND_CMD

#define ZB_ZCL_SEND_CMD (   buffer,
  addr,
  dst_addr_mode,
  dst_ep,
  ep,
  prof_id,
  dis_default_resp,
  cluster_id,
  command_id,
  cb 
)
Value:
{ \
zb_uint8_t* ptr = ZB_ZCL_START_PACKET_REQ(buffer) \
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_REQ_FRAME_CONTROL(ptr, dis_default_resp) \
ZB_ZCL_CONSTRUCT_COMMAND_HEADER_REQ(ptr, ZB_ZCL_GET_SEQ_NUM(), command_id); \
ZB_ZCL_FINISH_PACKET(buffer, ptr) \
ZB_ZCL_SEND_COMMAND_SHORT(buffer, addr, dst_addr_mode, dst_ep, ep, prof_id, cluster_id, cb); \
}

General macro for sending a command with empty payload.

Parameters
bufferto put command payload and headers to
addraddress to send to
dst_addr_modedestination address mode
dst_epdestination endpoint
epsource endpoint
prof_idprofile the command belongs to
dis_default_resp"Disable default response" flag
cluster_idcluster identifier
command_idcommand identifier
cbcommand send status callback
#define ZB_ZCL_DOOR_LOCK_SEND_LOCK_DOOR_REQ(buffer, \
dst_addr, \
dst_addr_mode, \
dst_ep, \
ep, \
dis_default_resp, \
cb) \
ZB_ZCL_SEND_CMD( buffer, \
dst_addr, \
dst_addr_mode, \
dst_ep, \
ep, \
ZB_AF_HA_PROFILE_ID, \
dis_default_resp, \
ZB_ZCL_CLUSTER_ID_DOOR_LOCK, \
ZB_ZCL_CMD_DOOR_LOCK_LOCK_DOOR, \
cb)

Typedef Documentation

◆ zb_zcl_addr_t

typedef struct zb_zcl_addr_s zb_zcl_addr_t

Type to represent source address of ZCL message.

It is needed if ZGP sink is enabled and therefore messages can be received from ZGPD devices which are identified by 32-bit source Id.

◆ zb_zcl_attr_addr_info_t

Attribute address info structure

◆ zb_zcl_disable_default_response_t

Type for possible values of Disable default response subfield of FCF in ZCL frame.

Holds one of zcl_disable_default_response. Kept for backward compatibility as zcl_disable_default_response were declared previously as enum.

◆ zb_zcl_frame_ctrl_t

ZCL frame control field.

See also
ZCL spec, subclause 2.3.1.1

◆ zb_zcl_frame_direction_t

Type for ZCL frame direction.

Holds one of zcl_frame_direction. Kept only for backward compatibility as zcl_frame_direction were declared previously as enum.

◆ zb_zcl_frame_hdr_full_t

ZCL frame header with manufacturer code.

See also
ZCL spec, subclause 2.3.1

◆ zb_zcl_frame_hdr_short_t

ZCL frame header without manufacturer code.

See also
ZCL spec, subclause 2.3.1

◆ zb_zcl_frame_type_t

Type for ZCL frame type.

◆ zb_zcl_manufacturer_specific_t

Type for return statuses of mathematical operations.

◆ zb_zcl_parsed_hdr_t

Parsed ZCL header

Function Documentation

◆ zb_zcl_start_command_header()

void* zb_zcl_start_command_header ( zb_bufid_t  zbbuf,
zb_uint8_t  frame_ctl,
zb_uint16_t  manuf_code,
zb_uint8_t  cmd_id,
zb_uint8_t tsn 
)

Construct ZCL command header in the buffer.

Parameters
zbbufbuffer ID
frame_ctlFrame Control field for ZCL packet
manuf_codemanufacturer code, not used manufacturer-specific flag is not set
cmd_idZCL command id
tsnpointer to variable (may be NULL) for TSN value of ZCL packet (generated by the function)

Returns pointer to the buffer data begin after ZCL header (where command payload can be placed if needed).

ZB_ZCL_FRAME_TYPE_CLUSTER_SPECIFIC
#define ZB_ZCL_FRAME_TYPE_CLUSTER_SPECIFIC
Definition: zb_zcl_common.h:892
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:1428
zb_uint8_t
unsigned char zb_uint8_t
Project-local 1-byte unsigned int type.
Definition: zb_types.h:149
zb_zcl_parsed_hdr_s
Definition: zb_zcl_common.h:1040
ZB_ZCL_FRAME_DIRECTION_TO_CLI
#define ZB_ZCL_FRAME_DIRECTION_TO_CLI
Definition: zb_zcl_common.h:958
ZB_ZCL_GET_SEQ_NUM
#define ZB_ZCL_GET_SEQ_NUM()
Return next sequence number for ZCL frame.
Definition: zb_zcl_common.h:1348
ZB_ZCL_CMD_DOOR_LOCK_OPERATION_EVENT_NOTIFICATION_ID
@ ZB_ZCL_CMD_DOOR_LOCK_OPERATION_EVENT_NOTIFICATION_ID
Definition: zb_zcl_door_lock.h:379
ZB_ZCL_NOT_MANUFACTURER_SPECIFIC
#define ZB_ZCL_NOT_MANUFACTURER_SPECIFIC
Definition: zb_zcl_common.h:911
ZB_ZCL_CONSTRUCT_COMMAND_HEADER
#define ZB_ZCL_CONSTRUCT_COMMAND_HEADER(data_ptr, tsn, cmd_id)
Construct ZCL header.
Definition: zb_zcl_common.h:1305
ZB_BUF_GET_PARAM
#define ZB_BUF_GET_PARAM(buf, type)
Definition: zboss_api_buf.h:455
ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_RES_FRAME_CONTROL
#define ZB_ZCL_CONSTRUCT_SPECIFIC_COMMAND_RES_FRAME_CONTROL(buf_ptr)
Construct ZCL header frame control value for cluster-specific command response.
Definition: zb_zcl_common.h:1292
ZB_ZCL_DISABLE_DEFAULT_RESPONSE
#define ZB_ZCL_DISABLE_DEFAULT_RESPONSE
Definition: zb_zcl_common.h:937