nRF5 SDK for Thread and Zigbee v3.2.0
Modules | Data Structures | Macros | Typedefs | Functions
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)
 Common continue command. More...
 

Typedefs

typedef struct
zb_zcl_command_send_status_s 
zb_zcl_command_send_status_t
 
typedef zb_void_t(* 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...
 
zb_void_t 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_bool_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 (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_uint16_t cluster_role)
 Find endpoint which 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)
 

Detailed Description

Macro Definition Documentation

#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
#define ZB_ZCL_PROCESS_COMMAND_FINISH (   buffer,
  pcmd_info,
  status 
)
Value:
{ \
if (ZB_ZCL_CHECK_IF_SEND_DEFAULT_RESP(*(pcmd_info), status)) \
{ \
(buffer), \
ZB_ZCL_PARSED_HDR_SHORT_DATA((pcmd_info)).source.u.short_addr, \
ZB_ZCL_PARSED_HDR_SHORT_DATA((pcmd_info)).src_endpoint, \
ZB_ZCL_PARSED_HDR_SHORT_DATA((pcmd_info)).dst_endpoint, \
(pcmd_info)->profile_id, \
(pcmd_info)->cluster_id, \
(pcmd_info)->seq_number, \
(pcmd_info)->cmd_id, \
(status)); \
} \
else \
{ \
TRACE_MSG( TRACE_ZCL3, "Default response disabled", (FMT__0)); \
zb_free_buf((buffer)); \
} \
}
#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:453
void zb_free_buf(zb_buf_t *buf)
Free packet buffer and put it into freelist.
Definition: zboss_api_aps.h:165
#define TRACE_MSG(lm, fmts, args)
Put trace output.
Definition: zb_trace.h:210
#define ZB_ZCL_PARSED_HDR_SHORT_DATA(header)
Extract common addresing data from parsed ZCL structure.
Definition: zb_zcl_common.h:1015
#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.
Definition: zb_zcl_commands.h:390

Common continue command.

Usualy use after invoke User App. If invoke User App finished with error (status!=RET_OK), send error responce, 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)

Typedef Documentation

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 (zb_zcl_cluster_role_e)
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

Command send status structure

Declare for change attribute for User Application.

Note
Size of values must be twice as large as maximum size of a possible attribute
typedef zb_void_t(* zb_zcl_set_default_value_attr_cb_t)(zb_uint8_t ep)

Set default value attribute callback.

Parameters
ep- endpoint number

Function Documentation

zb_zcl_cluster_desc_t* get_cluster_desc ( 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 zb_zcl_cluster_id_e)
cluster_role- role (see zb_zcl_cluster_role_e)
Returns
cluster descriptor or NULL if not present
zb_uint8_t get_endpoint_by_cluster ( zb_uint16_t  cluster_id,
zb_uint16_t  cluster_role 
)

Find endpoint which has cluster with given ID.

Parameters
cluster_id- cluster ID (see zb_zcl_cluster_id_e)
cluster_role- role (see zb_zcl_cluster_role_e)
Returns
endpoint number or 0 if not found
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 zb_zcl_cluster_id_e)
cluster_role- role (see zb_zcl_cluster_role_e)
Returns
endpoint number or 0 if not found
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_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_bool_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 (zb_zcl_cluster_role_e)
endpoint- endpoint
attr_id- attribute ID
value- pointer to attribute data
Returns
ZB_TRUE if data value is valid, ZB_FALSE otherwise
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 (zb_zcl_cluster_role_e)
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_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 zb_zcl_attr_type_t)
Returns
size in bytes of 0xFF in type is not analog or invalid
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_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 zb_zcl_cluster_role_e)
attr_id- attribute ID
Returns
attribute descriptor
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 zb_zcl_attr_type_t)
attr_value- pointer to value in question (needed for variable sized types)
Returns
size in bytes or 0xFF if type is invalid
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 zb_zcl_attr_type_t)
Returns
ZB_TRUE if type is analog, ZB_FALSE otherwith
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 zb_zcl_attr_type_t)
attr_value- pointer to value to be put into packet
Returns
command pointer adjusted to point at the tail of written value
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_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 zb_zcl_cluster_role_e)
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_void_t 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 (zb_zcl_cluster_role_e)
attr_id- attribute ID
new_value- pointer to newly assigned value

Documentation feedback | Developer Zone | Subscribe | Updated