Hi,
I've been trying to learn how to use the SDK and I was following the Adding ZCL clusters to application guide to add temperature. I skipped adding the on/off switch and so I used `ZBOSS_DECLARE_DEVICE_CTX_2_EP` instead of `ZBOSS_DECLARE_DEVICE_CTX_3_EP`.
I've been getting build errors and I haven't been able to figure out what I've done wrong. I've been comparing my main.c to the guide, and also to several of the SDK examples (light bulb, light switch, weather station, etc.). I'm using SDK V2.2.0
Can somebody please help me figure this out?
Kind regards,
Dan
What I've Done:
Following the guide, I included zb_zcl_temp_measurement_addons.h
#include <zephyr/kernel.h> #include <zephyr/logging/log.h> #include <dk_buttons_and_leds.h> #include <zboss_api.h> #include <zigbee/zigbee_error_handler.h> #include <zigbee/zigbee_app_utils.h> #include <zb_nrf_platform.h> #include "zb_range_extender.h" /* Include temperature measurement. */ #include <addons/zcl/zb_zcl_temp_measurement_addons.h>
I defined the temperature measurement endpoint and placed this under the app template endpoint.
/* Device endpoint, used to receive ZCL commands. */ #define APP_TEMPLATE_ENDPOINT 10 /* Endpoint used to send temperature data. */ #define TEMPERATURE_SENSOR_ENDPOINT 12
I added the temperature measurement attributes to the zb_device_ctx structure.
struct zb_device_ctx { zb_zcl_basic_attrs_t basic_attr; zb_zcl_identify_attrs_t identify_attr; zb_zcl_temp_measurement_attrs_t temp_measure_attrs; };
I declared the attribute list for the temperature measurement cluster, the cluster list for the device, declared the endpoint, and edited the device context. I also moved the device context below the other declarations.
/* Declare attribute list for temperature measurement cluster. */ 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); /* Declare cluster list for temperature measurement device. */ ZB_HA_DECLARE_TEMPERATURE_SENSOR_CLUSTER_LIST( temperature_sensor_clusters, basic_attr_list, identify_attr_list, temp_measurement_attr_list); /* Declare endpoint for temperature measurement device. */ ZB_HA_DECLARE_TEMPERATURE_SENSOR_EP( temperature_sensor_ep, TEMPERATURE_SENSOR_ENDPOINT, temperature_sensor_clusters); ZBOSS_DECLARE_DEVICE_CTX_2_EP( app_template_ctx, app_template_ep, temperature_sensor_ep);
VS Code highlights `TEMPERATURE_SENSOR_ENDPOINT` from the `ZB_HA_DECLARE_TEMPERATURE_SENSOR_EP` declaration saying "expected an identifier".
And it highlights `ZBOSS_DECLARE_DEVICE_CTX_2_EP(...` saying "identifier "temperature_sensor_ep" is undefined".
When I try to build, I get the following output in terminal.
n:\Projects\Nordic\myApps\RGBWC_nRF52840\src\main.c:114:1: warning: data definition has no type or storage class 114 | ZB_HA_DECLARE_TEMPERATURE_SENSOR_CLUSTER_LIST( | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ n:\Projects\Nordic\myApps\RGBWC_nRF52840\src\main.c:114:1: error: type defaults to 'int' in declaration of 'ZB_HA_DECLARE_TEMPERATURE_SENSOR_CLUSTER_LIST' [-Werror=implicit-int] n:\Projects\Nordic\myApps\RGBWC_nRF52840\src\main.c:118:9: warning: parameter names (without types) in function declaration 118 | temp_measurement_attr_list); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ n:\Projects\Nordic\myApps\RGBWC_nRF52840\src\main.c:122:31: error: expected ')' before numeric constant 122 | temperature_sensor_ep, | ^ | ) In file included from C:\ncs\SDK\v2.2.0\nrfxlib\zboss\production\include\zboss_api.h:52, from n:\Projects\Nordic\myApps\RGBWC_nRF52840\src\main.c:38: n:\Projects\Nordic\myApps\RGBWC_nRF52840\src\main.c:129:9: error: 'temperature_sensor_ep' undeclared here (not in a function) 129 | temperature_sensor_ep); | ^~~~~~~~~~~~~~~~~~~~~ C:\ncs\SDK\v2.2.0\nrfxlib\zboss\production\include\zboss_api_af.h:586:6: note: in definition of macro 'ZBOSS_DECLARE_DEVICE_CTX_2_EP' 586 | &ep2_name, \ | ^~~~~~~~ cc1.exe: some warnings being treated as errors