nRF5 SDK for Thread and Zigbee v3.2.0
Macros
Simple Sensor

Macros

#define ZB_HA_DECLARE_SIMPLE_SENSOR_CLUSTER_LIST(cluster_list_name,basic_attr_list,identify_attr_list,binary_input_attr_list)
 Declare cluster list for Simple Sensor device. More...
 
#define ZB_HA_DECLARE_SIMPLE_SENSOR_EP(ep_name, ep_id, cluster_list)
 Declare endpoint for Simple Sensor device. More...
 
#define ZB_HA_DECLARE_SIMPLE_SENSOR_CTX(device_ctx, ep_name)   ZBOSS_DECLARE_DEVICE_CTX_1_EP(device_ctx, ep_name)
 Declare Simple Sensor device context. More...
 

Detailed Description

Simple Sensor device has 3 clusters (see spec 7.4.13):

Simple Sensor device sample

Example
Declaring clusters
/******************* Declare attributes ************************/
/* Basic cluster attribute variables */
ZB_ZCL_DECLARE_BASIC_ATTRIB_LIST(basic_attr_list, &g_attr_zcl_version, &g_attr_power_source);
/* Identify cluster attribute variables */
zb_uint16_t g_attr_identify_time = 0;
ZB_ZCL_DECLARE_IDENTIFY_ATTRIB_LIST(identify_attr_list, &g_attr_identify_time);
/* Binary input attribute variables */
zb_bool_t g_present_value = ZB_FALSE;
ZB_ZCL_DECLARE_BINARY_INPUT_ATTRIB_LIST(binary_input_attr_list, &g_out_of_service, &g_present_value, &g_status_flag);
/********************* Declare device **************************/
ZB_HA_DECLARE_SIMPLE_SENSOR_CLUSTER_LIST(simple_sensor_clusters, basic_attr_list, identify_attr_list,
binary_input_attr_list);
ZB_HA_DECLARE_SIMPLE_SENSOR_EP(simple_sensor_ep, HA_SIMPLE_SENSOR_ENDPOINT, simple_sensor_clusters);
ZB_HA_DECLARE_SIMPLE_SENSOR_CTX(simple_sensor_ctx, simple_sensor_ep);
Registering device list
ZB_AF_REGISTER_DEVICE_CTX(&simple_sensor_ctx);
ZB_AF_SET_ENDPOINT_HANDLER(HA_SIMPLE_SENSOR_ENDPOINT, zcl_specific_cluster_cmd_handler);
Example of command handler
zb_uint8_t zcl_specific_cluster_cmd_handler(zb_uint8_t param)
{
zb_buf_t *zcl_cmd_buf = (zb_buf_t *)ZB_BUF_FROM_REF(param);
zb_bool_t cmd_processed = ZB_FALSE;
/* Command from client to server */
switch (cmd_info->cluster_id)
{
if (cmd_info->is_common_command)
{
switch (cmd_info->cmd_id)
{
TRACE_MSG(TRACE_ZCL3, "Got response in cluster 0x%04x",
( FMT__D, cmd_info->cluster_id));
/* Process default response */
cmd_processed = ZB_TRUE;
break;
default:
TRACE_MSG(TRACE_ZCL2, "Unsupported general command %hd", (FMT__H, cmd_info->cmd_id));
break;
}
}
else
{
TRACE_MSG(TRACE_ERROR, "Cluster-specific commands not supported for Binary Input cluster", (FMT__0));
}
break;
default:
TRACE_MSG(TRACE_ERROR, "Cluster 0x%d is not supported", (FMT__D, cmd_info->cluster_id));
break;
}
}

The complete set of Simple Sensor device samples can be found in /snippet/ha_simple_sensor_sample.c.

Macro Definition Documentation

#define ZB_HA_DECLARE_SIMPLE_SENSOR_CLUSTER_LIST (   cluster_list_name,
  basic_attr_list,
  identify_attr_list,
  binary_input_attr_list 
)

Declare cluster list for Simple Sensor device.

Parameters
cluster_list_name- cluster list variable name
basic_attr_list- attribute list for Basic cluster
identify_attr_list- attribute list for Identify cluster
binary_input_attr_list- attribute list for Binary Input cluster
#define ZB_HA_DECLARE_SIMPLE_SENSOR_CTX (   device_ctx,
  ep_name 
)    ZBOSS_DECLARE_DEVICE_CTX_1_EP(device_ctx, ep_name)

Declare Simple Sensor device context.

Parameters
device_ctx- device context variable name.
ep_name- endpoint variable name.
#define ZB_HA_DECLARE_SIMPLE_SENSOR_EP (   ep_name,
  ep_id,
  cluster_list 
)
Value:
ZB_ZCL_DECLARE_SIMPLE_SENSOR_SIMPLE_DESC(ep_name, ep_id, \
ZB_HA_SIMPLE_SENSOR_IN_CLUSTER_NUM, ZB_HA_SIMPLE_SENSOR_OUT_CLUSTER_NUM); \
ZBOSS_DEVICE_DECLARE_REPORTING_CTX(reporting_info## device_ctx_name, \
ZB_HA_SIMPLE_SENSOR_REPORT_ATTR_COUNT); \
ZB_ZCL_ARRAY_SIZE(cluster_list, zb_zcl_cluster_desc_t), cluster_list, \
(zb_af_simple_desc_1_1_t*)&simple_desc_##ep_name, \
ZB_HA_SIMPLE_SENSOR_REPORT_ATTR_COUNT, \
reporting_info## device_ctx_name, 0, NULL)
ZCL cluster description.
Definition: zb_zcl_common.h:143
Definition: zboss_api_af.h:287
#define ZBOSS_DEVICE_DECLARE_REPORTING_CTX(rep_ctx, rep_count)
Definition: zboss_api_af.h:579
#define ZB_AF_DECLARE_ENDPOINT_DESC(ep_name,ep_id,profile_id,reserved_length,reserved_ptr,cluster_number,cluster_list,simple_desc,rep_count,rep_ctx,lev_ctrl_count,lev_ctrl_ctx)
Initialize endpoint descriptor.
Definition: zboss_api_af.h:490
Definition: zboss_api_af.h:201

Declare endpoint for Simple Sensor device.

internals_doc

Parameters
ep_name- endpoint variable name
ep_id- endpoint ID
cluster_list- endpoint cluster list

Documentation feedback | Developer Zone | Subscribe | Updated