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:
parent
f090b25a2c
commit
d8322c9162
2 changed files with 62 additions and 55 deletions
|
|
@ -24,46 +24,42 @@
|
|||
/** @cond internals_doc */
|
||||
|
||||
/** 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 */
|
||||
#define ZB_RANGE_EXTENDER_OUT_CLUSTER_NUM 0
|
||||
|
||||
#define ZB_RANGE_EXTENDER_CLUSTER_NUM \
|
||||
(ZB_RANGE_EXTENDER_IN_CLUSTER_NUM + ZB_RANGE_EXTENDER_OUT_CLUSTER_NUM)
|
||||
(ZB_RANGE_EXTENDER_IN_CLUSTER_NUM + ZB_RANGE_EXTENDER_OUT_CLUSTER_NUM)
|
||||
|
||||
/** Number of attribute for reporting on Range extender device */
|
||||
#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( \
|
||||
cluster_list_name, \
|
||||
basic_attr_list, \
|
||||
identify_attr_list) \
|
||||
zb_zcl_cluster_desc_t cluster_list_name[] = \
|
||||
{ \
|
||||
ZB_ZCL_CLUSTER_DESC( \
|
||||
ZB_ZCL_CLUSTER_ID_IDENTIFY, \
|
||||
ZB_ZCL_ARRAY_SIZE(identify_attr_list, zb_zcl_attr_t), \
|
||||
(identify_attr_list), \
|
||||
ZB_ZCL_CLUSTER_SERVER_ROLE, \
|
||||
ZB_ZCL_MANUF_CODE_INVALID \
|
||||
), \
|
||||
ZB_ZCL_CLUSTER_DESC( \
|
||||
ZB_ZCL_CLUSTER_ID_BASIC, \
|
||||
ZB_ZCL_ARRAY_SIZE(basic_attr_list, zb_zcl_attr_t), \
|
||||
(basic_attr_list), \
|
||||
ZB_ZCL_CLUSTER_SERVER_ROLE, \
|
||||
ZB_ZCL_MANUF_CODE_INVALID \
|
||||
) \
|
||||
}
|
||||
#define ZB_DECLARE_RANGE_EXTENDER_CLUSTER_LIST( \
|
||||
cluster_list_name, \
|
||||
basic_attr_list, \
|
||||
identify_attr_list, \
|
||||
temp_measurement_attr_list) \
|
||||
zb_zcl_cluster_desc_t cluster_list_name[] = \
|
||||
{ \
|
||||
ZB_ZCL_CLUSTER_DESC( \
|
||||
ZB_ZCL_CLUSTER_ID_IDENTIFY, \
|
||||
ZB_ZCL_ARRAY_SIZE(identify_attr_list, zb_zcl_attr_t), \
|
||||
(identify_attr_list), \
|
||||
ZB_ZCL_CLUSTER_SERVER_ROLE, \
|
||||
ZB_ZCL_MANUF_CODE_INVALID), \
|
||||
ZB_ZCL_CLUSTER_DESC( \
|
||||
ZB_ZCL_CLUSTER_ID_BASIC, \
|
||||
ZB_ZCL_ARRAY_SIZE(basic_attr_list, zb_zcl_attr_t), \
|
||||
(basic_attr_list), \
|
||||
ZB_ZCL_CLUSTER_SERVER_ROLE, \
|
||||
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 */
|
||||
|
||||
|
|
@ -75,21 +71,19 @@ zb_zcl_cluster_desc_t cluster_list_name[] = \
|
|||
* @param out_clust_num - number of supported output clusters
|
||||
*/
|
||||
#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_AF_SIMPLE_DESC_TYPE(in_clust_num, out_clust_num) simple_desc_##ep_name = \
|
||||
{ \
|
||||
ep_id, \
|
||||
ZB_AF_HA_PROFILE_ID, \
|
||||
ZB_RANGE_EXTENDER_DEVICE_ID, \
|
||||
ZB_DEVICE_VER_RANGE_EXTENDER, \
|
||||
0, \
|
||||
in_clust_num, \
|
||||
out_clust_num, \
|
||||
{ \
|
||||
ZB_ZCL_CLUSTER_ID_BASIC, \
|
||||
ZB_ZCL_CLUSTER_ID_IDENTIFY \
|
||||
} \
|
||||
}
|
||||
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 = \
|
||||
{ \
|
||||
ep_id, \
|
||||
ZB_AF_HA_PROFILE_ID, \
|
||||
ZB_RANGE_EXTENDER_DEVICE_ID, \
|
||||
ZB_DEVICE_VER_RANGE_EXTENDER, \
|
||||
0, \
|
||||
in_clust_num, \
|
||||
out_clust_num, \
|
||||
{ZB_ZCL_CLUSTER_ID_BASIC, \
|
||||
ZB_ZCL_CLUSTER_ID_IDENTIFY, ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT}}
|
||||
|
||||
/** @endcond */ /* internals_doc */
|
||||
|
||||
|
|
@ -99,14 +93,14 @@ zb_zcl_cluster_desc_t cluster_list_name[] = \
|
|||
* @param ep_id - endpoint ID
|
||||
* @param cluster_list - endpoint cluster list
|
||||
*/
|
||||
#define ZB_DECLARE_RANGE_EXTENDER_EP(ep_name, ep_id, cluster_list) \
|
||||
ZB_ZCL_DECLARE_RANGE_EXTENDER_SIMPLE_DESC(ep_name, ep_id, \
|
||||
ZB_RANGE_EXTENDER_IN_CLUSTER_NUM, ZB_RANGE_EXTENDER_OUT_CLUSTER_NUM); \
|
||||
ZB_AF_DECLARE_ENDPOINT_DESC(ep_name, ep_id, ZB_AF_HA_PROFILE_ID, 0, NULL, \
|
||||
ZB_ZCL_ARRAY_SIZE(cluster_list, zb_zcl_cluster_desc_t), cluster_list, \
|
||||
(zb_af_simple_desc_1_1_t *)&simple_desc_##ep_name, \
|
||||
0, NULL, /* No reporting ctx */ \
|
||||
0, NULL) /* No CVC ctx */
|
||||
#define ZB_DECLARE_RANGE_EXTENDER_EP(ep_name, ep_id, cluster_list) \
|
||||
ZB_ZCL_DECLARE_RANGE_EXTENDER_SIMPLE_DESC(ep_name, ep_id, \
|
||||
ZB_RANGE_EXTENDER_IN_CLUSTER_NUM, ZB_RANGE_EXTENDER_OUT_CLUSTER_NUM); \
|
||||
ZB_AF_DECLARE_ENDPOINT_DESC(ep_name, ep_id, ZB_AF_HA_PROFILE_ID, 0, NULL, \
|
||||
ZB_ZCL_ARRAY_SIZE(cluster_list, zb_zcl_cluster_desc_t), cluster_list, \
|
||||
(zb_af_simple_desc_1_1_t *)&simple_desc_##ep_name, \
|
||||
0, NULL, /* No reporting ctx */ \
|
||||
0, NULL) /* No CVC ctx */
|
||||
|
||||
/*! @} */
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ LOG_MODULE_REGISTER(app, LOG_LEVEL_INF);
|
|||
struct zb_device_ctx {
|
||||
zb_zcl_basic_attrs_ext_t basic_attr;
|
||||
zb_zcl_identify_attrs_t identify_attr;
|
||||
zb_zcl_temp_measurement_attrs_t temp_measure_attrs;
|
||||
};
|
||||
|
||||
/* 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.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(
|
||||
app_template_clusters,
|
||||
basic_attr_list,
|
||||
identify_attr_list);
|
||||
identify_attr_list,
|
||||
temp_measurement_attr_list);
|
||||
|
||||
ZB_DECLARE_RANGE_EXTENDER_EP(
|
||||
app_template_ep,
|
||||
|
|
@ -106,6 +114,11 @@ static void app_clusters_attr_init(void) {
|
|||
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. */
|
||||
dev_ctx.identify_attr.identify_time =
|
||||
ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue