Modified the zigbee template with added temperature cluster

According to
https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.1.2/nrf/ug_zigbee_adding_clusters.html.
This commit is contained in:
rbaron 2022-12-04 17:49:22 +01:00
parent f090b25a2c
commit d8322c9162
2 changed files with 62 additions and 55 deletions

View file

@ -24,7 +24,7 @@
/** @cond internals_doc */ /** @cond internals_doc */
/** Range extender IN (server) clusters number */ /** Range extender IN (server) clusters number */
#define ZB_RANGE_EXTENDER_IN_CLUSTER_NUM 2 #define ZB_RANGE_EXTENDER_IN_CLUSTER_NUM 3
/** Range extender OUT (client) clusters number */ /** Range extender OUT (client) clusters number */
#define ZB_RANGE_EXTENDER_OUT_CLUSTER_NUM 0 #define ZB_RANGE_EXTENDER_OUT_CLUSTER_NUM 0
@ -35,35 +35,31 @@
/** Number of attribute for reporting on Range extender device */ /** Number of attribute for reporting on Range extender device */
#define ZB_RANGE_EXTENDER_REPORT_ATTR_COUNT 0 #define ZB_RANGE_EXTENDER_REPORT_ATTR_COUNT 0
/** @endcond */ /* internals_doc */
/**
* @brief Declare cluster list for Range extender device
* @param cluster_list_name - cluster list variable name
* @param basic_attr_list - attribute list for Basic cluster
* @param identify_attr_list - attribute list for Identify cluster
*/
#define ZB_DECLARE_RANGE_EXTENDER_CLUSTER_LIST( \ #define ZB_DECLARE_RANGE_EXTENDER_CLUSTER_LIST( \
cluster_list_name, \ cluster_list_name, \
basic_attr_list, \ basic_attr_list, \
identify_attr_list) \ identify_attr_list, \
zb_zcl_cluster_desc_t cluster_list_name[] = \ temp_measurement_attr_list) \
{ \ zb_zcl_cluster_desc_t cluster_list_name[] = \
{ \
ZB_ZCL_CLUSTER_DESC( \ ZB_ZCL_CLUSTER_DESC( \
ZB_ZCL_CLUSTER_ID_IDENTIFY, \ ZB_ZCL_CLUSTER_ID_IDENTIFY, \
ZB_ZCL_ARRAY_SIZE(identify_attr_list, zb_zcl_attr_t), \ ZB_ZCL_ARRAY_SIZE(identify_attr_list, zb_zcl_attr_t), \
(identify_attr_list), \ (identify_attr_list), \
ZB_ZCL_CLUSTER_SERVER_ROLE, \ ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_MANUF_CODE_INVALID \ ZB_ZCL_MANUF_CODE_INVALID), \
), \
ZB_ZCL_CLUSTER_DESC( \ ZB_ZCL_CLUSTER_DESC( \
ZB_ZCL_CLUSTER_ID_BASIC, \ ZB_ZCL_CLUSTER_ID_BASIC, \
ZB_ZCL_ARRAY_SIZE(basic_attr_list, zb_zcl_attr_t), \ ZB_ZCL_ARRAY_SIZE(basic_attr_list, zb_zcl_attr_t), \
(basic_attr_list), \ (basic_attr_list), \
ZB_ZCL_CLUSTER_SERVER_ROLE, \ ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_MANUF_CODE_INVALID \ ZB_ZCL_MANUF_CODE_INVALID), \
) \ ZB_ZCL_CLUSTER_DESC( \
} ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT, \
ZB_ZCL_ARRAY_SIZE(temp_measurement_attr_list, zb_zcl_attr_t), \
(temp_measurement_attr_list), \
ZB_ZCL_CLUSTER_SERVER_ROLE, \
ZB_ZCL_MANUF_CODE_INVALID)}
/** @cond internals_doc */ /** @cond internals_doc */
@ -76,7 +72,8 @@ zb_zcl_cluster_desc_t cluster_list_name[] = \
*/ */
#define ZB_ZCL_DECLARE_RANGE_EXTENDER_SIMPLE_DESC(ep_name, ep_id, in_clust_num, out_clust_num) \ #define ZB_ZCL_DECLARE_RANGE_EXTENDER_SIMPLE_DESC(ep_name, ep_id, in_clust_num, out_clust_num) \
ZB_DECLARE_SIMPLE_DESC(in_clust_num, out_clust_num); \ ZB_DECLARE_SIMPLE_DESC(in_clust_num, out_clust_num); \
ZB_AF_SIMPLE_DESC_TYPE(in_clust_num, out_clust_num) simple_desc_##ep_name = \ ZB_AF_SIMPLE_DESC_TYPE(in_clust_num, out_clust_num) \
simple_desc_##ep_name = \
{ \ { \
ep_id, \ ep_id, \
ZB_AF_HA_PROFILE_ID, \ ZB_AF_HA_PROFILE_ID, \
@ -85,11 +82,8 @@ zb_zcl_cluster_desc_t cluster_list_name[] = \
0, \ 0, \
in_clust_num, \ in_clust_num, \
out_clust_num, \ out_clust_num, \
{ \ {ZB_ZCL_CLUSTER_ID_BASIC, \
ZB_ZCL_CLUSTER_ID_BASIC, \ ZB_ZCL_CLUSTER_ID_IDENTIFY, ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT}}
ZB_ZCL_CLUSTER_ID_IDENTIFY \
} \
}
/** @endcond */ /* internals_doc */ /** @endcond */ /* internals_doc */

View file

@ -53,6 +53,7 @@ LOG_MODULE_REGISTER(app, LOG_LEVEL_INF);
struct zb_device_ctx { struct zb_device_ctx {
zb_zcl_basic_attrs_ext_t basic_attr; zb_zcl_basic_attrs_ext_t basic_attr;
zb_zcl_identify_attrs_t identify_attr; zb_zcl_identify_attrs_t identify_attr;
zb_zcl_temp_measurement_attrs_t temp_measure_attrs;
}; };
/* Zigbee device application context storage. */ /* Zigbee device application context storage. */
@ -76,10 +77,17 @@ ZB_ZCL_DECLARE_BASIC_ATTRIB_LIST_EXT(
&dev_ctx.basic_attr.ph_env, &dev_ctx.basic_attr.ph_env,
dev_ctx.basic_attr.sw_ver); dev_ctx.basic_attr.sw_ver);
ZB_ZCL_DECLARE_TEMP_MEASUREMENT_ATTRIB_LIST(temp_measurement_attr_list,
&dev_ctx.temp_measure_attrs.measure_value,
&dev_ctx.temp_measure_attrs.min_measure_value,
&dev_ctx.temp_measure_attrs.max_measure_value,
&dev_ctx.temp_measure_attrs.tolerance);
ZB_DECLARE_RANGE_EXTENDER_CLUSTER_LIST( ZB_DECLARE_RANGE_EXTENDER_CLUSTER_LIST(
app_template_clusters, app_template_clusters,
basic_attr_list, basic_attr_list,
identify_attr_list); identify_attr_list,
temp_measurement_attr_list);
ZB_DECLARE_RANGE_EXTENDER_EP( ZB_DECLARE_RANGE_EXTENDER_EP(
app_template_ep, app_template_ep,
@ -106,6 +114,11 @@ static void app_clusters_attr_init(void) {
PRST_BASIC_MODEL_ID, PRST_BASIC_MODEL_ID,
ZB_ZCL_STRING_CONST_SIZE(PRST_BASIC_MODEL_ID)); ZB_ZCL_STRING_CONST_SIZE(PRST_BASIC_MODEL_ID));
static zb_int16_t temperature_value = 27;
zb_zcl_set_attr_val(APP_TEMPLATE_ENDPOINT, ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT,
ZB_ZCL_CLUSTER_SERVER_ROLE, ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID,
(zb_uint8_t*)&temperature_value, ZB_FALSE);
/* Identify cluster attributes data. */ /* Identify cluster attributes data. */
dev_ctx.identify_attr.identify_time = dev_ctx.identify_attr.identify_time =
ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE; ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE;