Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Adding ZCL clusters to application - Temperature - Error with build

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

Parents Reply Children
  • Thanks Amanda,

    Converting my project to SDK V2.3.0 didn't fix the issue. I followed the following steps to change SDK version and got the exact same errors.

    1. nRF Connect: Select nRF Connect SDK
    2. nRF Connect: Select nRF Connect SDK Toolchain
    3. Pristine build.

    In case it helps, here's the full terminal output from the build.

     *  Executing task: nRF Connect: Build: RGBWC_nRF52840/build (active) 
    
    Building RGBWC_nRF52840
    west build --build-dir n:\Projects\Nordic\myApps\RGBWC_nRF52840\build n:\Projects\Nordic\myApps\RGBWC_nRF52840
    
    [1/225] Building C object modules/nrfxlib/nrfxlib/zboss/production/src/CMakeFiles/zboss-sources.dir/zcl/zcl_s_daily_schedule.c.obj
    [2/225] Building C object modules/nrfxlib/nrfxlib/zboss/production/src/CMakeFiles/zboss-sources.dir/zcl/zcl_reporting.c.obj
    [3/225] Building C object modules/nrfxlib/nrfxlib/zboss/production/src/CMakeFiles/zboss-sources.dir/zcl/zcl_pressure_measurement.c.obj
    [4/225] Building C object modules/nrfxlib/nrfxlib/zboss/production/src/CMakeFiles/zboss-sources.dir/zcl/zcl_s_drlc.c.obj
    [5/225] Building C object modules/nrfxlib/nrfxlib/zboss/production/src/CMakeFiles/zboss-sources.dir/zcl/zcl_rel_humidity.c.obj
    [6/225] Building C object modules/nrfxlib/nrfxlib/zboss/production/src/CMakeFiles/zboss-sources.dir/zcl/zcl_scenes.c.obj
    [7/225] Building C object CMakeFiles/app.dir/src/main.c.obj
    FAILED: CMakeFiles/app.dir/src/main.c.obj 
    C:\ncs\SDK\toolchains\v2.3.0\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DCUSTOM_IEEE802154_L2=ZIGBEE_L2 -DKERNEL -DLIBZBOSS_CONFIG_FILE=\"C:/ncs/SDK/v2.3.0/nrfxlib/zboss/production/include/osif/libzboss_config.h\" -DNRF52840_XXAA -DNRF_802154_ACK_TIMEOUT_ENABLED=1 -DNRF_802154_CCA_CORR_LIMIT_DEFAULT=2 -DNRF_802154_CCA_CORR_THRESHOLD_DEFAULT=45 -DNRF_802154_CCA_ED_THRESHOLD_DEFAULT=45 -DNRF_802154_CCA_MODE_DEFAULT=NRF_RADIO_CCA_MODE_ED -DNRF_802154_ECB_PRIORITY=-1 -DNRF_802154_ENCRYPTION_ENABLED=0 -DNRF_802154_IE_WRITER_ENABLED=0 -DNRF_802154_INTERNAL_RADIO_IRQ_HANDLING=0 -DNRF_802154_PENDING_EXTENDED_ADDRESSES=16 -DNRF_802154_PENDING_SHORT_ADDRESSES=16 -DNRF_802154_RX_BUFFERS=16 -DNRF_802154_SECURITY_WRITER_ENABLED=0 -DNRF_802154_SWI_PRIORITY=1 -DNRF_802154_TX_STARTED_NOTIFY_ENABLED=1 -DNRF_802154_USE_RAW_API=1 -DUSE_PARTITION_MANAGER=1 -DZIGBEE_L2=ZIGBEE -D__PROGRAM_START -D__ZEPHYR__=1 -I../include -IC:/ncs/SDK/v2.3.0/nrf/drivers/mpsl/clock_control -IC:/ncs/SDK/v2.3.0/zephyr/include -Izephyr/include/generated -IC:/ncs/SDK/v2.3.0/zephyr/soc/arm/nordic_nrf/nrf52 -IC:/ncs/SDK/v2.3.0/zephyr/soc/arm/nordic_nrf/common/. -IC:/ncs/SDK/v2.3.0/nrf/include -IC:/ncs/SDK/v2.3.0/nrf/lib/multithreading_lock/. -IC:/ncs/SDK/v2.3.0/zephyr/drivers/flash -IC:/ncs/SDK/v2.3.0/nrf/tests/include -IC:/ncs/SDK/v2.3.0/modules/hal/cmsis/CMSIS/Core/Include -IC:/ncs/SDK/v2.3.0/modules/hal/nordic/nrfx -IC:/ncs/SDK/v2.3.0/modules/hal/nordic/nrfx/drivers/include -IC:/ncs/SDK/v2.3.0/modules/hal/nordic/nrfx/mdk -IC:/ncs/SDK/v2.3.0/zephyr/modules/hal_nordic/nrfx/. -IC:/ncs/SDK/v2.3.0/modules/debug/segger/SEGGER -IC:/ncs/SDK/v2.3.0/modules/debug/segger/Config -IC:/ncs/SDK/v2.3.0/zephyr/modules/segger/. -IC:/ncs/SDK/v2.3.0/nrfxlib/mpsl/include -IC:/ncs/SDK/v2.3.0/nrfxlib/mpsl/include/protocol -IC:/ncs/SDK/v2.3.0/nrfxlib/nrf_802154/driver/include -IC:/ncs/SDK/v2.3.0/nrfxlib/nrf_802154/sl/include -IC:/ncs/SDK/v2.3.0/nrf/subsys/zigbee/osif -IC:/ncs/SDK/v2.3.0/nrfxlib/zboss/production/src/zb_error -IC:/ncs/SDK/v2.3.0/nrfxlib/zboss/production/include/addons -IC:/ncs/SDK/v2.3.0/nrfxlib/zboss/production/include -IC:/ncs/SDK/v2.3.0/nrfxlib/zboss/production/include/zcl -IC:/ncs/SDK/v2.3.0/nrfxlib/zboss/production/include/ha -IC:/ncs/SDK/v2.3.0/nrfxlib/zboss/production/include/se -IC:/ncs/SDK/v2.3.0/nrfxlib/zboss/production/include/osif -isystem C:/ncs/SDK/v2.3.0/zephyr/lib/libc/minimal/include -isystem c:/ncs/sdk/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/include -isystem c:/ncs/sdk/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/include-fixed -isystem C:/ncs/SDK/v2.3.0/nrfxlib/crypto/nrf_cc310_platform/include -fno-strict-aliasing -Os -imacros N:/Projects/Nordic/myApps/RGBWC_nRF52840/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mfp16-format=ieee --sysroot=C:/ncs/SDK/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros C:/ncs/SDK/v2.3.0/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=N:/Projects/Nordic/myApps/RGBWC_nRF52840=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/ncs/SDK/v2.3.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/ncs/SDK/v2.3.0=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -Wno-packed-bitfield-compat -MD -MT CMakeFiles/app.dir/src/main.c.obj -MF CMakeFiles\app.dir\src\main.c.obj.d -o CMakeFiles/app.dir/src/main.c.obj -c ../src/main.c
    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.3.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.3.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
    [8/225] Building C object modules/nrfxlib/nrfxlib/zboss/production/src/CMakeFiles/zboss-sources.dir/zcl/zcl_temp_measurement.c.obj
    [9/225] Building C object modules/nrfxlib/nrfxlib/zboss/production/src/CMakeFiles/zboss-sources.dir/zcl/zcl_s_price.c.obj
    [10/225] Building C object modules/nrfxlib/nrfxlib/zboss/production/src/CMakeFiles/zboss-sources.dir/zcl/zcl_s_wwah.c.obj
    [11/225] Building C object modules/nrfxlib/nrfxlib/zboss/production/src/CMakeFiles/zboss-sources.dir/zcl/zcl_s_messaging.c.obj
    [12/225] Building C object modules/nrfxlib/nrfxlib/zboss/production/src/CMakeFiles/zboss-sources.dir/zcl/zcl_shade_config_commands.c.obj
    [13/225] Building C object modules/nrfxlib/nrfxlib/zboss/production/src/CMakeFiles/zboss-sources.dir/zcl/zcl_thermostat_commands.c.obj
    [14/225] Building C object modules/nrfxlib/nrfxlib/zboss/production/src/CMakeFiles/zboss-sources.dir/zcl/zcl_wwah_common.c.obj
    [15/225] Building C object modules/nrfxlib/nrfxlib/zboss/production/src/CMakeFiles/zboss-sources.dir/zcl/zcl_thermostat_ui_config.c.obj
    [16/225] Building C object modules/nrfxlib/nrfxlib/zboss/production/src/CMakeFiles/zboss-sources.dir/zcl/zcl_s_metering.c.obj
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: 'c:\ncs\SDK\toolchains\v2.3.0\opt\bin\cmake.EXE' --build 'n:\Projects\Nordic\myApps\RGBWC_nRF52840\build'
    
     *  The terminal process terminated with exit code: 1. 
     *  Terminal will be reused by tasks, press any key to close it. 
    

  • I've searched the SDK directory from VS Code for the `ZB_HA_DECLARE_TEMPERATURE_SENSOR_CLUSTER_LIST` and `ZB_HA_DECLARE_TEMPERATURE_SENSOR_EP` macros, and they don't exist outside of the documentation in `C:\ncs\SDK\v2.3.0\nrf\doc\nrf\protocols\zigbee\adding_clusters.rst`. The cluster list macro also appears in `C:\ncs\SDK\v2.3.0\nrf\doc\nrf\links.txt` but that's still just documentation, not a definition.

    Is there something wrong with my instance of the SDK, or are they just missing? I suspect that it's not my local instance of the SDK because I have the same issue with SDK V2.2.0 and SDK V2.3.0. I was thinking that I must have accidentally deleted a file, but I couldn't have done that in both versions.

  • Is anybody still looking at this? I don't think the `ZB_HA_DECLARE_TEMPERATURE_SENSOR_CLUSTER_LIST` or `ZB_HA_DECLARE_TEMPERATURE_SENSOR_EP` macros are defined in the SDK.

  • Hi, 

    Sorry for the late reply. I am waiting for the reply from the team. I would pin them again today. 

    -Amanda H.

  • Awesome. Thanks Amanda. I really appreciate it.

Related