Hi. I tried to add rel_humidity_measurement cluster to multisensor example. New cluster is visible , but i cant get humidity data report I used cli exemple, here are logs:
zigbee.report: Received value updates from the remote node 0x07EF
zigbee.report: Profile: 0x0104 Cluster: 0x0402 Attribute: 0x0000 Type: 41 Value: 4000
zigbee.report: Received value updates from the remote node 0x07EF
zcl subscribe on f4ce361cf4681e64 10 0405 0104 0 41
Error: Unable to configure attribute 0 reporting. Status: 141
Error: One or more attributes reporting were not configured successfully
Here is my code ZB_MULTI_SENSOR.H
#ifndef ZB_MULTI_SENSOR_H__ #define ZB_MULTI_SENSOR_H__ #include "zboss_api.h" #include "zboss_api_addons.h" #include "zb_zcl_pressure_measurement.h" #include "zb_zcl_rel_humidity_measurement.h" #ifdef __cplusplus extern "C" { #endif /* Basic cluster attributes initial values. For more information, see section 3.2.2.2 of the ZCL specification. */ #define SENSOR_INIT_BASIC_APP_VERSION 01 /**< Version of the application software (1 byte). */ #define SENSOR_INIT_BASIC_STACK_VERSION 10 /**< Version of the implementation of the Zigbee stack (1 byte). */ #define SENSOR_INIT_BASIC_HW_VERSION 11 /**< Version of the hardware of the device (1 byte). */ #define SENSOR_INIT_BASIC_MANUF_NAME "Custom" /**< Manufacturer name (32 bytes). */ #define SENSOR_INIT_BASIC_MODEL_ID "Multisensor" /**< Model number assigned by the manufacturer (32-bytes long string). */ #define SENSOR_INIT_BASIC_DATE_CODE "20200603" /**< Date provided by the manufacturer of the device in ISO 8601 format (YYYYMMDD), for the first 8 bytes. The remaining 8 bytes are manufacturer-specific. */ #define SENSOR_INIT_BASIC_POWER_SOURCE ZB_ZCL_BASIC_POWER_SOURCE_DC_SOURCE /**< Type of power source or sources available for the device. For possible values, see section 3.2.2.2.8 of the ZCL specification. */ #define SENSOR_INIT_BASIC_LOCATION_DESC "House" /**< Description of the physical location of the device (16 bytes). You can modify it during the commisioning process. */ #define SENSOR_INIT_BASIC_PH_ENV ZB_ZCL_BASIC_ENV_UNSPECIFIED /**< Description of the type of physical environment. For possible values, see section 3.2.2.2.10 of the ZCL specification. */ #define MULTI_SENSOR_ENDPOINT 10 /**< Device endpoint. Used to receive light controlling commands. */ /* Main application customizable context. Stores all settings and static values. */ typedef struct { zb_zcl_basic_attrs_ext_t basic_attr; zb_zcl_identify_attrs_t identify_attr; zb_zcl_temp_measurement_attrs_t temp_attr; zb_zcl_pressure_measurement_attrs_t pres_attr; zb_zcl_rel_humidity_measurement_attrs_t rel_hum_attr; } sensor_device_ctx_t; #define ZB_MULTI_SENSOR_REPORT_ATTR_COUNT 3 /**< Number of attributes mandatory for reporting in the Temperature, humidity and Pressure Measurement cluster. */ #define ZB_DEVICE_VER_MULTI_SENSOR 0 /**< Multisensor device version. */ #define ZB_MULTI_SENSOR_IN_CLUSTER_NUM 1 /**< Number of the input (server) clusters in the multisensor device. */ #define ZB_MULTI_SENSOR_OUT_CLUSTER_NUM 5 /**< Number of the output (client) clusters in the multisensor device. */ /** @brief Declares cluster list for the multisensor device. * * @param cluster_list_name Cluster list variable name. * @param basic_attr_list Attribute list for the Basic cluster. * @param identify_attr_list Attribute list for the Identify cluster. * @param temp_measure_attr_list Attribute list for the Temperature Measurement cluster. * @param pressure_measure_attr_list Attribute list for the Pressure Measurement cluster. * @param rel_humidity_measure_attr_list Attribute list for the Humidity Measurement cluster. */ #define ZB_DECLARE_MULTI_SENSOR_CLUSTER_LIST( \ cluster_list_name, \ basic_attr_list, \ identify_attr_list, \ temp_measure_attr_list, \ pres_measure_attr_list, \ rel_humidity_measure_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_measure_attr_list, zb_zcl_attr_t), \ (temp_measure_attr_list), \ ZB_ZCL_CLUSTER_SERVER_ROLE, \ ZB_ZCL_MANUF_CODE_INVALID \ ), \ ZB_ZCL_CLUSTER_DESC( \ ZB_ZCL_CLUSTER_ID_PRESSURE_MEASUREMENT, \ ZB_ZCL_ARRAY_SIZE(pres_measure_attr_list, zb_zcl_attr_t), \ (pres_measure_attr_list), \ ZB_ZCL_CLUSTER_SERVER_ROLE, \ ZB_ZCL_MANUF_CODE_INVALID \ ), \ ZB_ZCL_CLUSTER_DESC( \ ZB_ZCL_CLUSTER_ID_REL_HUMIDITY_MEASUREMENT, \ ZB_ZCL_ARRAY_SIZE(rel_humidity_measure_attr_list, zb_zcl_attr_t), \ (rel_humidity_measure_attr_list), \ ZB_ZCL_CLUSTER_SERVER_ROLE, \ ZB_ZCL_MANUF_CODE_INVALID \ ), \ ZB_ZCL_CLUSTER_DESC( \ ZB_ZCL_CLUSTER_ID_IDENTIFY, \ 0, \ NULL, \ ZB_ZCL_CLUSTER_CLIENT_ROLE, \ ZB_ZCL_MANUF_CODE_INVALID \ ) \ } /** @brief Declares simple descriptor for the "Device_name" device. * * @param ep_name Endpoint variable name. * @param ep_id Endpoint ID. * @param in_clust_num Number of the supported input clusters. * @param out_clust_num Number of the supported output clusters. */ #define ZB_ZCL_DECLARE_MULTI_SENSOR_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_HA_TEMPERATURE_SENSOR_DEVICE_ID, \ ZB_DEVICE_VER_MULTI_SENSOR, \ 0, \ in_clust_num, \ out_clust_num, \ { \ ZB_ZCL_CLUSTER_ID_BASIC, \ ZB_ZCL_CLUSTER_ID_IDENTIFY, \ ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT, \ ZB_ZCL_CLUSTER_ID_PRESSURE_MEASUREMENT, \ ZB_ZCL_CLUSTER_ID_REL_HUMIDITY_MEASUREMENT, \ ZB_ZCL_CLUSTER_ID_IDENTIFY, \ } \ } /** @brief Declares endpoint for the multisensor device. * * @param ep_name Endpoint variable name. * @param ep_id Endpoint ID. * @param cluster_list Endpoint cluster list. */ #define ZB_ZCL_DECLARE_MULTI_SENSOR_EP(ep_name, ep_id, cluster_list) \ ZB_ZCL_DECLARE_MULTI_SENSOR_DESC(ep_name, \ ep_id, \ ZB_MULTI_SENSOR_IN_CLUSTER_NUM, \ ZB_MULTI_SENSOR_OUT_CLUSTER_NUM); \ ZBOSS_DEVICE_DECLARE_REPORTING_CTX(reporting_info## device_ctx_name, \ ZB_MULTI_SENSOR_REPORT_ATTR_COUNT); \ 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, \ ZB_MULTI_SENSOR_REPORT_ATTR_COUNT, reporting_info## device_ctx_name, 0, NULL) #ifdef __cplusplus } #endif #endif // ZB_MULTI_SENSOR_H__
main.c
/** * Copyright (c) 2018 - 2020, Nordic Semiconductor ASA * * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * 2. Redistributions in binary form, except as embedded into a Nordic * Semiconductor ASA integrated circuit in a product or a software update for * such product, must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other * materials provided with the distribution. * * 3. Neither the name of Nordic Semiconductor ASA nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * 4. This software, with or without modification, must only be used with a * Nordic Semiconductor ASA integrated circuit. * * 5. Any software provided in binary form under this license must not be reverse * engineered, decompiled, modified and/or disassembled. * * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /** @file * * @defgroup zigbee_examples_multi_sensor main.c * @{ * @ingroup zigbee_examples * @brief Zigbee Pressure and Temperature sensor */ #include "zboss_api.h" #include "zb_mem_config_med.h" #include "zb_error_handler.h" #include "zigbee_helpers.h" #include "app_timer.h" #include "bsp.h" #include "boards.h" #include "sensorsim.h" #include "nrf_log.h" #include "nrf_log_ctrl.h" #include "nrf_log_default_backends.h" #include "zb_multi_sensor.h" #define IEEE_CHANNEL_MASK (1l << ZIGBEE_CHANNEL) /**< Scan only one, predefined channel to find the coordinator. */ #define ERASE_PERSISTENT_CONFIG ZB_TRUE /**< Do not erase NVRAM to save the network parameters after device reboot or power-off. */ #define ZIGBEE_NETWORK_STATE_LED BSP_BOARD_LED_2 /**< LED indicating that light switch successfully joind Zigbee network. */ #define MIN_TEMPERATURE_VALUE 0 /**< Minimum temperature value as returned by the simulated measurement function. */ #define MAX_TEMPERATURE_VALUE 4000 /**< Maximum temperature value as returned by the simulated measurement function. */ #define TEMPERATURE_VALUE_INCREMENT 50 /**< Value by which the temperature value is incremented/decremented for each call to the simulated measurement function. */ #define MIN_PRESSURE_VALUE 700 /**< Minimum pressure value as returned by the simulated measurement function. */ #define MAX_PRESSURE_VALUE 1100 /**< Maximum pressure value as returned by the simulated measurement function. */ #define PRESSURE_VALUE_INCREMENT 5 /**< Value by which the temperature value is incremented/decremented for each call to the simulated measurement function. */ /******************************************************* USER **********************************************************************/ #define MIN_HUMIDITY_VALUE 0 #define MAX_HUMIDITY_VALUE 10000 #define HUMIDITY_VALUE_INCREMENT 100 /***********************************************************************************************************************************/ #if !defined ZB_ED_ROLE #error Define ZB_ED_ROLE to compile End Device source code. #endif static sensor_device_ctx_t m_dev_ctx; ZB_ZCL_DECLARE_IDENTIFY_ATTRIB_LIST(identify_attr_list, &m_dev_ctx.identify_attr.identify_time); ZB_ZCL_DECLARE_BASIC_ATTRIB_LIST_EXT(basic_attr_list, &m_dev_ctx.basic_attr.zcl_version, &m_dev_ctx.basic_attr.app_version, &m_dev_ctx.basic_attr.stack_version, &m_dev_ctx.basic_attr.hw_version, m_dev_ctx.basic_attr.mf_name, m_dev_ctx.basic_attr.model_id, m_dev_ctx.basic_attr.date_code, &m_dev_ctx.basic_attr.power_source, m_dev_ctx.basic_attr.location_id, &m_dev_ctx.basic_attr.ph_env, m_dev_ctx.basic_attr.sw_ver); ZB_ZCL_DECLARE_TEMP_MEASUREMENT_ATTRIB_LIST(temperature_attr_list, &m_dev_ctx.temp_attr.measure_value, &m_dev_ctx.temp_attr.min_measure_value, &m_dev_ctx.temp_attr.max_measure_value, &m_dev_ctx.temp_attr.tolerance); ZB_ZCL_DECLARE_PRES_MEASUREMENT_ATTRIB_LIST(pressure_attr_list, &m_dev_ctx.pres_attr.measure_value, &m_dev_ctx.pres_attr.min_measure_value, &m_dev_ctx.pres_attr.max_measure_value, &m_dev_ctx.pres_attr.tolerance); /******************************************************* USER **********************************************************************/ ZB_ZCL_DECLARE_REL_HUMIDITY_MEASUREMENT_ATTRIB_LIST(rel_humidity_measure_attr_list, &m_dev_ctx.rel_hum_attr.measure_value, &m_dev_ctx.rel_hum_attr.min_measure_value, &m_dev_ctx.rel_hum_attr.max_measure_value); /***********************************************************************************************************************************/ ZB_DECLARE_MULTI_SENSOR_CLUSTER_LIST(multi_sensor_clusters, basic_attr_list, identify_attr_list, temperature_attr_list, pressure_attr_list, rel_humidity_measure_attr_list); /***********************************************************************************************************************************/ ZB_ZCL_DECLARE_MULTI_SENSOR_EP(multi_sensor_ep, MULTI_SENSOR_ENDPOINT, multi_sensor_clusters); ZBOSS_DECLARE_DEVICE_CTX_1_EP(multi_sensor_ctx, multi_sensor_ep); static sensorsim_cfg_t m_temperature_sim_cfg; /**< Temperature sensor simulator configuration. */ static sensorsim_state_t m_temperature_sim_state; /**< Temperature sensor simulator state. */ static sensorsim_cfg_t m_pressure_sim_cfg; /**< Pressure sensor simulator configuration. */ static sensorsim_state_t m_pressure_sim_state; /**< Pressure sensor simulator state. */ /******************************************************* USER **********************************************************************/ static sensorsim_cfg_t m_rel_humidity_sim_cfg; /**< Humidity sensor simulator configuration. */ static sensorsim_state_t m_rel_humidity_sim_state; /**< Humidity sensor simulator state. */ /***********************************************************************************************************************************/ APP_TIMER_DEF(zb_app_timer); /**@brief Function for the Timer initialization. * * @details Initializes the timer module. This creates and starts application timers. */ static void timers_init(void) { ret_code_t err_code; // Initialize timer module. err_code = app_timer_init(); APP_ERROR_CHECK(err_code); } /**@brief Function for initializing the nrf log module. */ static void log_init(void) { ret_code_t err_code = NRF_LOG_INIT(NULL); APP_ERROR_CHECK(err_code); NRF_LOG_DEFAULT_BACKENDS_INIT(); } /**@brief Function for initializing all clusters attributes. */ static void multi_sensor_clusters_attr_init(void) { /* Basic cluster attributes data */ m_dev_ctx.basic_attr.zcl_version = ZB_ZCL_VERSION; m_dev_ctx.basic_attr.app_version = SENSOR_INIT_BASIC_APP_VERSION; m_dev_ctx.basic_attr.stack_version = SENSOR_INIT_BASIC_STACK_VERSION; m_dev_ctx.basic_attr.hw_version = SENSOR_INIT_BASIC_HW_VERSION; /* Use ZB_ZCL_SET_STRING_VAL to set strings, because the first byte should * contain string length without trailing zero. * * For example "test" string wil be encoded as: * [(0x4), 't', 'e', 's', 't'] */ ZB_ZCL_SET_STRING_VAL(m_dev_ctx.basic_attr.mf_name, SENSOR_INIT_BASIC_MANUF_NAME, ZB_ZCL_STRING_CONST_SIZE(SENSOR_INIT_BASIC_MANUF_NAME)); ZB_ZCL_SET_STRING_VAL(m_dev_ctx.basic_attr.model_id, SENSOR_INIT_BASIC_MODEL_ID, ZB_ZCL_STRING_CONST_SIZE(SENSOR_INIT_BASIC_MODEL_ID)); ZB_ZCL_SET_STRING_VAL(m_dev_ctx.basic_attr.date_code, SENSOR_INIT_BASIC_DATE_CODE, ZB_ZCL_STRING_CONST_SIZE(SENSOR_INIT_BASIC_DATE_CODE)); m_dev_ctx.basic_attr.power_source = SENSOR_INIT_BASIC_POWER_SOURCE; ZB_ZCL_SET_STRING_VAL(m_dev_ctx.basic_attr.location_id, SENSOR_INIT_BASIC_LOCATION_DESC, ZB_ZCL_STRING_CONST_SIZE(SENSOR_INIT_BASIC_LOCATION_DESC)); m_dev_ctx.basic_attr.ph_env = SENSOR_INIT_BASIC_PH_ENV; /* Identify cluster attributes data */ m_dev_ctx.identify_attr.identify_time = ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE; /* Temperature measurement cluster attributes data */ m_dev_ctx.temp_attr.measure_value = ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_UNKNOWN; m_dev_ctx.temp_attr.min_measure_value = ZB_ZCL_ATTR_TEMP_MEASUREMENT_MIN_VALUE_MIN_VALUE; m_dev_ctx.temp_attr.max_measure_value = ZB_ZCL_ATTR_TEMP_MEASUREMENT_MAX_VALUE_MAX_VALUE; m_dev_ctx.temp_attr.tolerance = ZB_ZCL_ATTR_TEMP_MEASUREMENT_TOLERANCE_MAX_VALUE; /* Pressure measurement cluster attributes data */ m_dev_ctx.pres_attr.measure_value = ZB_ZCL_ATTR_PRES_MEASUREMENT_VALUE_UNKNOWN; m_dev_ctx.pres_attr.min_measure_value = ZB_ZCL_ATTR_PRES_MEASUREMENT_MIN_VALUE_MIN_VALUE; m_dev_ctx.pres_attr.max_measure_value = ZB_ZCL_ATTR_PRES_MEASUREMENT_MAX_VALUE_MAX_VALUE; m_dev_ctx.pres_attr.tolerance = ZB_ZCL_ATTR_PRES_MEASUREMENT_TOLERANCE_MAX_VALUE; /******************************************************* USER *************************************************************/ /* Humidity measurement cluster attributes data */ m_dev_ctx.rel_hum_attr.measure_value = ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_VALUE_UNKNOWN; m_dev_ctx.rel_hum_attr.min_measure_value = ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MIN_VALUE_MIN_VALUE; m_dev_ctx.rel_hum_attr.max_measure_value = ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_MAX_VALUE; /**************************************************************************************************************************/ } /**@brief Function for initializing LEDs. */ static zb_void_t leds_init(void) { ret_code_t error_code; /* Initialize LEDs and buttons - use BSP to control them. */ error_code = bsp_init(BSP_INIT_LEDS, NULL); APP_ERROR_CHECK(error_code); bsp_board_leds_off(); } /**@brief Function for handling nrf app timer. * * @param[IN] context Void pointer to context function is called with. * * @details Function is called with pointer to sensor_device_ep_ctx_t as argument. */ static void zb_app_timer_handler(void * context) { zb_zcl_status_t zcl_status; static zb_int16_t new_temp_value, new_pres_value, new_rel_hum_value; /* Get new temperature measured value */ new_temp_value = (zb_int16_t)sensorsim_measure(&m_temperature_sim_state, &m_temperature_sim_cfg); zcl_status = zb_zcl_set_attr_val(MULTI_SENSOR_ENDPOINT, ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT, ZB_ZCL_CLUSTER_SERVER_ROLE, ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID, (zb_uint8_t *)&new_temp_value, ZB_FALSE); if(zcl_status != ZB_ZCL_STATUS_SUCCESS) { NRF_LOG_INFO("Set temperature value fail. zcl_status: %d", zcl_status); } /* Get new pressure measured value */ new_pres_value = (zb_int16_t)sensorsim_measure(&m_pressure_sim_state, &m_pressure_sim_cfg); zcl_status = zb_zcl_set_attr_val(MULTI_SENSOR_ENDPOINT, ZB_ZCL_CLUSTER_ID_PRESSURE_MEASUREMENT, ZB_ZCL_CLUSTER_SERVER_ROLE, ZB_ZCL_ATTR_PRES_MEASUREMENT_VALUE_ID, (zb_uint8_t *)&new_pres_value, ZB_FALSE); if(zcl_status != ZB_ZCL_STATUS_SUCCESS) { NRF_LOG_INFO("Set pressure value fail. zcl_status: %d", zcl_status); } /******************************************************* USER ************************************************************/ new_rel_hum_value = (zb_int16_t)sensorsim_measure(&m_rel_humidity_sim_state, &m_rel_humidity_sim_cfg); zcl_status = zb_zcl_set_attr_val(MULTI_SENSOR_ENDPOINT, ZB_ZCL_CLUSTER_ID_REL_HUMIDITY_MEASUREMENT, ZB_ZCL_CLUSTER_SERVER_ROLE, ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_VALUE_ID, (zb_uint8_t *)&new_rel_hum_value, ZB_FALSE); if(zcl_status != ZB_ZCL_STATUS_SUCCESS) { NRF_LOG_INFO("Set humidity value fail. zcl_status: %d", zcl_status); } /**************************************************************************************************************************/ } /**@brief Function for initializing the sensor simulators. */ static void sensor_simulator_init(void) { m_temperature_sim_cfg.min = MIN_TEMPERATURE_VALUE; m_temperature_sim_cfg.max = MAX_TEMPERATURE_VALUE; m_temperature_sim_cfg.incr = TEMPERATURE_VALUE_INCREMENT; m_temperature_sim_cfg.start_at_max = false; sensorsim_init(&m_temperature_sim_state, &m_temperature_sim_cfg); m_pressure_sim_cfg.min = MIN_PRESSURE_VALUE; m_pressure_sim_cfg.max = MAX_PRESSURE_VALUE; m_pressure_sim_cfg.incr = PRESSURE_VALUE_INCREMENT; m_pressure_sim_cfg.start_at_max = false; sensorsim_init(&m_pressure_sim_state, &m_pressure_sim_cfg); /******************************************************* USER ************************************************************/ m_rel_humidity_sim_cfg.min = MIN_HUMIDITY_VALUE; m_rel_humidity_sim_cfg.max = MAX_HUMIDITY_VALUE; m_rel_humidity_sim_cfg.incr = HUMIDITY_VALUE_INCREMENT; m_rel_humidity_sim_cfg.start_at_max = false; sensorsim_init(&m_rel_humidity_sim_state, &m_rel_humidity_sim_cfg); /**************************************************************************************************************************/ } /**@brief Zigbee stack event handler. * * @param[in] bufid Reference to the Zigbee stack buffer used to pass signal. */ void zboss_signal_handler(zb_bufid_t bufid) { zb_zdo_app_signal_hdr_t * p_sg_p = NULL; zb_zdo_app_signal_type_t sig = zb_get_app_signal(bufid, &p_sg_p); zb_ret_t status = ZB_GET_APP_SIGNAL_STATUS(bufid); /* Update network status LED */ zigbee_led_status_update(bufid, ZIGBEE_NETWORK_STATE_LED); switch (sig) { case ZB_BDB_SIGNAL_DEVICE_REBOOT: /* fall-through */ case ZB_BDB_SIGNAL_STEERING: /* Call default signal handler. */ ZB_ERROR_CHECK(zigbee_default_signal_handler(bufid)); if (status == RET_OK) { ret_code_t err_code = app_timer_start(zb_app_timer, APP_TIMER_TICKS(2000), NULL); APP_ERROR_CHECK(err_code); } break; default: /* Call default signal handler. */ ZB_ERROR_CHECK(zigbee_default_signal_handler(bufid)); break; } if (bufid) { zb_buf_free(bufid); } } /**@brief Function for application main entry. */ int main(void) { zb_ret_t zb_err_code; ret_code_t err_code; zb_ieee_addr_t ieee_addr; /* Initialize loging system and GPIOs. */ timers_init(); log_init(); sensor_simulator_init(); leds_init(); /* Create Timer for reporting attribute */ err_code = app_timer_create(&zb_app_timer, APP_TIMER_MODE_REPEATED, zb_app_timer_handler); APP_ERROR_CHECK(err_code); /* Set Zigbee stack logging level and traffic dump subsystem. */ ZB_SET_TRACE_LEVEL(ZIGBEE_TRACE_LEVEL); ZB_SET_TRACE_MASK(ZIGBEE_TRACE_MASK); ZB_SET_TRAF_DUMP_OFF(); /* Initialize Zigbee stack. */ ZB_INIT("multi_sensor"); /* Set device address to the value read from FICR registers. */ zb_osif_get_ieee_eui64(ieee_addr); zb_set_long_address(ieee_addr); /* Set static long IEEE address. */ zb_set_network_ed_role(IEEE_CHANNEL_MASK); zigbee_erase_persistent_storage(ERASE_PERSISTENT_CONFIG); zb_set_ed_timeout(ED_AGING_TIMEOUT_64MIN); zb_set_keepalive_timeout(ZB_MILLISECONDS_TO_BEACON_INTERVAL(3000)); zb_set_rx_on_when_idle(ZB_FALSE); /* Initialize application context structure. */ UNUSED_RETURN_VALUE(ZB_MEMSET(&m_dev_ctx, 0, sizeof(m_dev_ctx))); /* Register temperature sensor device context (endpoints). */ ZB_AF_REGISTER_DEVICE_CTX(&multi_sensor_ctx); /* Initialize sensor device attibutes */ multi_sensor_clusters_attr_init(); /** Start Zigbee Stack. */ zb_err_code = zboss_start_no_autostart(); ZB_ERROR_CHECK(zb_err_code); while(1) { zboss_main_loop_iteration(); UNUSED_RETURN_VALUE(NRF_LOG_PROCESS()); } } /** * @} */
zb_zcl_rel_humidity_measurement.c
#include "zboss_api.h" #include "zb_zcl_rel_humidity_measurement.h" #include "app_error.h" #include "nrf_log.h" static zb_ret_t check_value_rel_humidity_measurement(zb_uint16_t attr_id, zb_uint8_t endpoint, zb_uint8_t * p_value) { zb_ret_t ret = ZB_FALSE; zb_int16_t val = ZB_ZCL_ATTR_GETS16(p_value); NRF_LOG_DEBUG("Pre-validating value %hi of Humidity attribute %d", val, attr_id); switch(attr_id) { case ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_VALUE_ID: /* Check if the value is unknown. */ if (val != ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_VALUE_UNKNOWN) { /* Check if the value is higher than the minimal allowed. */ zb_zcl_attr_t * p_attr_min_desc = zb_zcl_get_attr_desc_a(endpoint, ZB_ZCL_CLUSTER_ID_REL_HUMIDITY_MEASUREMENT, ZB_ZCL_CLUSTER_SERVER_ROLE, ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MIN_VALUE_ID); ASSERT(p_attr_min_desc); zb_int16_t minimal_value = ZB_ZCL_GET_ATTRIBUTE_VAL_S16(p_attr_min_desc); if ((minimal_value != ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MIN_VALUE_UNDEFINED) && (minimal_value > val)) { break; } /* Check if the value is lower than the maximal allowed. */ zb_zcl_attr_t * p_attr_max_desc = zb_zcl_get_attr_desc_a(endpoint, ZB_ZCL_CLUSTER_ID_REL_HUMIDITY_MEASUREMENT, ZB_ZCL_CLUSTER_SERVER_ROLE, ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_ID); ASSERT(p_attr_max_desc); zb_int16_t maximal_value = ZB_ZCL_GET_ATTRIBUTE_VAL_S16(p_attr_max_desc); if ((maximal_value != ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_UNDEFINED) && (val > maximal_value)) { break; } } ret = ZB_TRUE; break; case ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MIN_VALUE_ID: /* Check the invalid value */ if (val != ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MIN_VALUE_UNDEFINED) { /* Check the value is in bounds */ if ((val < ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MIN_VALUE_MIN_VALUE) || (val > ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MIN_VALUE_MAX_VALUE)) { break; } } ret = ZB_TRUE; break; case ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_ID: /* Check the invalid value */ if (val != ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_UNDEFINED) { /* Check the value is in bounds */ if ((val < ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_MIN_VALUE) || #if ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_MAX_VALUE != 0x7FFF /* Avoid compiler warning about always false condition */ (val > ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_MAX_VALUE_MAX_VALUE)) #else (0)) #endif { break; } } ret = ZB_TRUE; break; default: break; } return ret; } static zb_void_t zb_zcl_rel_humidity_measurement_write_attr_hook(zb_uint8_t endpoint, zb_uint16_t attr_id, zb_uint8_t * new_value) { UNUSED_PARAMETER(new_value); NRF_LOG_DEBUG("Writing attribute %d of Humidity Measurement Cluster on endpoint %d", attr_id, endpoint); if (attr_id == ZB_ZCL_ATTR_REL_HUMIDITY_MEASUREMENT_VALUE_ID) { /* Implement your own write attributes hook if needed. */ } } /**@brief Function which initialises the server side of Pressure Measurement Cluster. */ zb_void_t zb_zcl_rel_humidity_init_server() { zb_ret_t ret = zb_zcl_add_cluster_handlers(ZB_ZCL_CLUSTER_ID_REL_HUMIDITY_MEASUREMENT, ZB_ZCL_CLUSTER_SERVER_ROLE, check_value_rel_humidity_measurement, zb_zcl_rel_humidity_measurement_write_attr_hook, (zb_zcl_cluster_handler_t)NULL); ASSERT(ret == RET_OK); } /**@brief Function which initialises the client side of Pressure Measurement Cluster. */ zb_void_t zb_zcl_rel_humidity_init_client() { zb_ret_t ret = zb_zcl_add_cluster_handlers(ZB_ZCL_CLUSTER_ID_REL_HUMIDITY_MEASUREMENT, ZB_ZCL_CLUSTER_CLIENT_ROLE, check_value_rel_humidity_measurement, zb_zcl_rel_humidity_measurement_write_attr_hook, (zb_zcl_cluster_handler_t)NULL); ASSERT(ret == RET_OK); }
What i am doing wrong?