Developing with ZBOSS for Zigbee
ZCL common types and definitions

Modules

 ZCL common types
 

Data Structures

struct  zb_zcl_command_send_status_s
 
struct  zb_zcl_set_attr_value_param_s
 Declare for change attribute for User Application. More...
 

Macros

#define ZB_ZCL_FIX_ENDIAN(data_ptr, data_type)
 Fix data endian, if needed, and store it in the same buffer. More...
 
#define ZB_ZCL_PROCESS_COMMAND_FINISH(buffer, pcmd_info, status)   zb_zcl_process_command_finish(buffer, pcmd_info, status)
 
#define ZB_ZCL_PROCESS_COMMAND_FINISH_NEW(buffer, pcmd_info, status)   zb_zcl_process_command_finish_new(buffer, pcmd_info, status)
 

Typedefs

typedef struct zb_zcl_command_send_status_s zb_zcl_command_send_status_t
 
typedef void(* zb_zcl_set_default_value_attr_cb_t) (zb_uint8_t ep)
 Set default value attribute callback. More...
 
typedef zb_ret_t(* zb_zcl_app_check_attr_value_cb_t) (zb_uint16_t cluster_id, zb_uint8_t cluster_role, zb_uint8_t endpoint, zb_uint16_t attr_id, zb_uint8_t *value)
 Check attribute value callback. More...
 
typedef struct zb_zcl_set_attr_value_param_s zb_zcl_set_attr_value_param_t
 Declare for change attribute for User Application. More...
 

Functions

zb_zcl_attr_tzb_zcl_get_attr_desc (zb_zcl_cluster_desc_t *cluster_desc, zb_uint16_t attr_id)
 Get registered attribute description by cluster descriptor. More...
 
zb_uint8_t zb_zcl_check_attribute_writable (zb_zcl_attr_t *attr_desc, zb_uint8_t endpoint, zb_uint16_t cluster_id, zb_uint8_t cluster_role, zb_uint8_t *new_value, zb_bool_t check_access)
 Check registered attribute is writable one. More...
 
void zb_zcl_write_attr_hook (zb_uint8_t endpoint, zb_uint16_t cluster_id, zb_uint8_t cluster_role, zb_uint16_t attr_id, zb_uint8_t *new_value)
 
zb_uint8_t zb_zcl_get_attribute_size (zb_uint8_t attr_type, zb_uint8_t *attr_value)
 Get size of value of given attribute type. More...
 
zb_uint8_t zb_zcl_get_analog_attribute_size (zb_uint8_t attr_type)
 Get size of analog data type. More...
 
zb_bool_t zb_zcl_is_analog_data_type (zb_uint8_t attr_type)
 Check whether type of ZCL attrbiute is analog. More...
 
zb_ret_t zb_zcl_check_attr_value (zb_uint16_t cluster_id, zb_uint8_t cluster_role, zb_uint8_t endpoint, zb_uint16_t attr_id, zb_uint8_t *value)
 Check if attribute value is valid or not. More...
 
zb_bool_t zb_zcl_is_target_endpoint (zb_af_endpoint_desc_t *ep_desc, zb_uint16_t profile_id)
 
zb_uint8_t zb_zcl_get_next_target_endpoint (zb_uint8_t start_from_ep, zb_uint16_t cluster_id, zb_uint8_t cluster_role, zb_uint16_t profile_id)
 
zb_zcl_cluster_desc_tget_cluster_desc (const zb_af_endpoint_desc_t *ep_desc, zb_uint16_t cluster_id, zb_uint8_t cluster_role)
 Search endpoint for cluster with given id. More...
 
zb_uint8_t get_endpoint_by_cluster (zb_uint16_t cluster_id, zb_uint8_t cluster_role)
 Find endpoint which has cluster with given ID. More...
 
zb_bool_t is_cluster_present (zb_uint16_t cluster_id)
 Find if device has cluster with given ID. More...
 
zb_uint16_t get_profile_id_by_endpoint (zb_uint8_t endpoint_id)
 
zb_af_endpoint_desc_tget_endpoint_by_cluster_with_role (zb_uint16_t cluster_id, zb_uint8_t cluster_role)
 Find endpoint which has cluster with given ID and role. More...
 
zb_zcl_attr_tzb_zcl_get_attr_desc_a (zb_uint8_t ep, zb_uint16_t cluster_id, zb_uint8_t cluster_role, zb_uint16_t attr_id)
 
zb_uint8_tzb_zcl_put_value_to_packet (zb_uint8_t *cmd_ptr, zb_uint8_t attr_type, zb_uint8_t *attr_value)
 
zb_zcl_status_t zb_zcl_set_attr_val (zb_uint8_t ep, zb_uint16_t cluster_id, zb_uint8_t cluster_role, zb_uint16_t attr_id, zb_uint8_t *value, zb_bool_t check_access)
 Sets attribute value, perform all needed checks before and after setting new value. More...
 
zb_ret_t zb_zcl_register_cb (zb_uint8_t param, zb_callback_t cb)
 Register callback that should be called when APS acknowledge is received for ZCL command. More...
 
zb_ret_t zb_zcl_ack_callback (zb_uint8_t param)
 Call callback on receiving APS acknowledge for ZCL command. More...
 
zb_uint8_t zb_zcl_check_accept_command (zb_uint8_t param)
 
void zb_zcl_process_command_finish (zb_bufid_t buffer, zb_zcl_parsed_hdr_t *pcmd_info, zb_uint8_t status)
 Common continue command. More...
 
void zb_zcl_process_command_finish_new (zb_bufid_t buffer, zb_zcl_parsed_hdr_t *pcmd_info, zb_uint8_t status)
 

Detailed Description

Macro Definition Documentation

◆ ZB_ZCL_FIX_ENDIAN

#define ZB_ZCL_FIX_ENDIAN (   data_ptr,
  data_type 
)

Fix data endian, if needed, and store it in the same buffer.

Parameters
data_ptr- pointer to data value
data_type- ZCL data type

Typedef Documentation

◆ zb_zcl_app_check_attr_value_cb_t

typedef zb_ret_t(* zb_zcl_app_check_attr_value_cb_t) (zb_uint16_t cluster_id, zb_uint8_t cluster_role, zb_uint8_t endpoint, zb_uint16_t attr_id, zb_uint8_t *value)

Check attribute value callback.

Parameters
cluster_id- Cluster ID
cluster_role- cluster role (zcl_cluster_role)
endpoint- endpoint number
attr_id- attribute ID
value- new attribute value
Returns
RET_OK - if new value is valid, RET_ERROR - if new value is wrong or RET_IGNORE - if use default Check attribute functions

◆ zb_zcl_command_send_status_t

Command send status structure

◆ zb_zcl_set_attr_value_param_t

Declare for change attribute for User Application.

Note
Size of values must be twice as large as maximum size of a possible attribute

◆ zb_zcl_set_default_value_attr_cb_t

typedef void(* zb_zcl_set_default_value_attr_cb_t) (zb_uint8_t ep)

Set default value attribute callback.

Parameters
ep- endpoint number

Function Documentation

◆ get_cluster_desc()

zb_zcl_cluster_desc_t* get_cluster_desc ( const zb_af_endpoint_desc_t ep_desc,
zb_uint16_t  cluster_id,
zb_uint8_t  cluster_role 
)

Search endpoint for cluster with given id.

Parameters
ep_desc- application endpoint description
cluster_id- cluster ID (see zcl_cluster_id)
cluster_role- role (see zcl_cluster_role)
Returns
cluster descriptor or NULL if not present

◆ get_endpoint_by_cluster()

zb_uint8_t get_endpoint_by_cluster ( zb_uint16_t  cluster_id,
zb_uint8_t  cluster_role 
)

Find endpoint which has cluster with given ID.

Parameters
cluster_id- cluster ID (see zcl_cluster_id)
cluster_role- role (see zcl_cluster_role)
Returns
endpoint number or 0 if not found

◆ get_endpoint_by_cluster_with_role()

zb_af_endpoint_desc_t* get_endpoint_by_cluster_with_role ( zb_uint16_t  cluster_id,
zb_uint8_t  cluster_role 
)

Find endpoint which has cluster with given ID and role.

Parameters
cluster_id- cluster ID (see zcl_cluster_id)
cluster_role- role (see zcl_cluster_role)
Returns
endpoint number or 0 if not found

◆ is_cluster_present()

zb_bool_t is_cluster_present ( zb_uint16_t  cluster_id)

Find if device has cluster with given ID.

Parameters
cluster_id- cluster ID (see zcl_cluster_id)
Returns
ZB_TRUE if cluster found

◆ zb_zcl_ack_callback()

zb_ret_t zb_zcl_ack_callback ( zb_uint8_t  param)

Call callback on receiving APS acknowledge for ZCL command.

Parameters
param- buffer with ZCL command
Returns
RET_OK if callback was found and called RET_NOT_FOUND if no callback was registered

◆ zb_zcl_check_accept_command()

zb_uint8_t zb_zcl_check_accept_command ( zb_uint8_t  param)

Check whether ZCL command should be handled by stack

Parameters
param- reference to buffer with parsed ZCL command
Returns
ZB_ZCL_STATUS_SUCCESS if command should be handled ZB_ZCL_STATUS_UNSUP_MANUF_CLUST_CMD if manufacturer specific command is not supported ZB_ZCL_STATUS_UNSUP_CLUST_CMD if general command is not supported ZB_ZCL_STATUS_UNSUP_CLUST if cluster with role specified in ZCL header is not supported

◆ zb_zcl_check_attr_value()

zb_ret_t zb_zcl_check_attr_value ( zb_uint16_t  cluster_id,
zb_uint8_t  cluster_role,
zb_uint8_t  endpoint,
zb_uint16_t  attr_id,
zb_uint8_t value 
)

Check if attribute value is valid or not.

Parameters
cluster_id- cluster ID
cluster_role- cluster role (zcl_cluster_role)
endpoint- endpoint
attr_id- attribute ID
value- pointer to attribute data
Returns
ZB_TRUE if data value is valid, ZB_FALSE otherwise

◆ zb_zcl_check_attribute_writable()

zb_uint8_t zb_zcl_check_attribute_writable ( zb_zcl_attr_t attr_desc,
zb_uint8_t  endpoint,
zb_uint16_t  cluster_id,
zb_uint8_t  cluster_role,
zb_uint8_t new_value,
zb_bool_t  check_access 
)

Check registered attribute is writable one.

Parameters
attr_desc- attribute descriptor
endpoint- endpoint
cluster_id- cluster identifier
cluster_role- cluster role (zcl_cluster_role)
new_value- new value for an attribute
check_access- check READ_ONLY access or not
Returns
ZB_ZCL_STATUS_SUCCESS on success, error status otherwise

◆ zb_zcl_get_analog_attribute_size()

zb_uint8_t zb_zcl_get_analog_attribute_size ( zb_uint8_t  attr_type)

Get size of analog data type.

Parameters
attr_type- attribute type in question (see zcl_attr_type)
Returns
size in bytes of 0xFF in type is not analog or invalid

◆ zb_zcl_get_attr_desc()

zb_zcl_attr_t* zb_zcl_get_attr_desc ( zb_zcl_cluster_desc_t cluster_desc,
zb_uint16_t  attr_id 
)

Get registered attribute description by cluster descriptor.

Parameters
cluster_desc- cluster descriptor
attr_id- attribute identifier
Returns
Pointer to attribute description, or NULL if no attribute description found.

◆ zb_zcl_get_attr_desc_a()

zb_zcl_attr_t* zb_zcl_get_attr_desc_a ( zb_uint8_t  ep,
zb_uint16_t  cluster_id,
zb_uint8_t  cluster_role,
zb_uint16_t  attr_id 
)

Find attribute descriptor by given endpoint number, cluster ID and attribute ID

Parameters
ep- endpoint number (must exist)
cluster_id- cluster ID (must exist on given ep, see zb_zcl_cluster_id_t)
cluster_role- role (see zcl_cluster_role)
attr_id- attribute ID
Returns
attribute descriptor

◆ zb_zcl_get_attribute_size()

zb_uint8_t zb_zcl_get_attribute_size ( zb_uint8_t  attr_type,
zb_uint8_t attr_value 
)

Get size of value of given attribute type.

Parameters
attr_type- attribute type in question (see zcl_attr_type)
attr_value- pointer to value in question (needed for variable sized types)
Returns
size in bytes or 0xFF if type is invalid

◆ zb_zcl_is_analog_data_type()

zb_bool_t zb_zcl_is_analog_data_type ( zb_uint8_t  attr_type)

Check whether type of ZCL attrbiute is analog.

Parameters
attr_type- attribute type in question (see zcl_attr_type)
Returns
ZB_TRUE if type is analog, ZB_FALSE otherwise

◆ zb_zcl_process_command_finish()

void zb_zcl_process_command_finish ( zb_bufid_t  buffer,
zb_zcl_parsed_hdr_t pcmd_info,
zb_uint8_t  status 
)

Common continue command.

Usually use after invoke User App. If invoke User App finished with error (status!=RET_OK), send error response, else if not disabled default response send it or free buffer

Parameters
buffer- buffer for send response
pcmd_info- pointer of cmd_info (see zb_zcl_parsed_hdr_s)
status- status of operation (see zb_zcl_status_t)

◆ zb_zcl_put_value_to_packet()

zb_uint8_t* zb_zcl_put_value_to_packet ( zb_uint8_t cmd_ptr,
zb_uint8_t  attr_type,
zb_uint8_t attr_value 
)

Put attribute value to command packet, fix endian if needed.

Parameters
cmd_ptr- pointer to destination
attr_type- type of attribute being written (see zcl_attr_type)
attr_value- pointer to value to be put into packet
Returns
command pointer adjusted to point at the tail of written value

◆ zb_zcl_register_cb()

zb_ret_t zb_zcl_register_cb ( zb_uint8_t  param,
zb_callback_t  cb 
)

Register callback that should be called when APS acknowledge is received for ZCL command.

Parameters
param- pointer to buffer with ZCL command
cb- pointer to callback function

◆ zb_zcl_set_attr_val()

zb_zcl_status_t zb_zcl_set_attr_val ( zb_uint8_t  ep,
zb_uint16_t  cluster_id,
zb_uint8_t  cluster_role,
zb_uint16_t  attr_id,
zb_uint8_t value,
zb_bool_t  check_access 
)

Sets attribute value, perform all needed checks before and after setting new value.

Parameters
ep- endpoint number
cluster_id- cluster ID (see zb_zcl_cluster_id_t)
cluster_role- role (see zcl_cluster_role)
attr_id- ID of the attribute being set
value- pointer to new value
check_access- whether read-only check should be performed
Returns
ZB_ZCL_STATUS_SUCCESS if value was written
ZB_ZCL_STATUS_READ_ONLY if attribute is read only and check_access is false ZB_ZCL_STATUS_UNSUP_ATTRIB if attribute is not supported by cluster ZB_ZCL_STATUS_INVALID_VALUE if current value of attribute is invalid
Note
given endpoint with given cluster ID should exist

◆ zb_zcl_write_attr_hook()

void zb_zcl_write_attr_hook ( zb_uint8_t  endpoint,
zb_uint16_t  cluster_id,
zb_uint8_t  cluster_role,
zb_uint16_t  attr_id,
zb_uint8_t new_value 
)

Hook on Write Attribute command

Parameters
endpoint- endpoint
cluster_id- cluster ID
cluster_role- cluster role (zcl_cluster_role)
attr_id- attribute ID
new_value- pointer to newly assigned value