Trying to set up nrf52840 dongle as zigbee switch to control multiple endpoints.

Hi,

   I am trying to modify the zigbee light switch example in nrf Connect SDK to control multiple endpoints.

   I am developing using the nrf52833 development kit and the aim is to use the nrf52840 dongle for the final implementation.

  Note: The aim is to control the endpoints (zigbee devices) using a DWIN screen via the dongle hence the UART blocks in the code.  

   Below is the main.c file

   

   

#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/logging/log.h>
#include <ram_pwrdn.h>

#include <zboss_api.h>
#include <zboss_api_addons.h>
#include <zigbee/zigbee_app_utils.h>
#include <zigbee/zigbee_error_handler.h>
#include <zb_nrf_platform.h>
#include "zb_mem_config_custom.h"
#include "zb_dimmer_switch.h"

/* Source endpoint used to control light bulb. */
#define LIGHT_SWITCH_ENDPOINT_1 1
#define LIGHT_SWITCH_ENDPOINT_2 2
#define LIGHT_SWITCH_ENDPOINT_3 3
#define LIGHT_SWITCH_ENDPOINT_4 4
#define LIGHT_SWITCH_ENDPOINT_5 5

/* Delay between the light switch startup and light bulb finding procedure. */
#define MATCH_DESC_REQ_START_DELAY K_SECONDS(2)
/* Timeout for finding procedure. */
#define MATCH_DESC_REQ_TIMEOUT K_SECONDS(5)
/* Find only non-sleepy device. */
#define MATCH_DESC_REQ_ROLE ZB_NWK_BROADCAST_RX_ON_WHEN_IDLE

/* Do not erase NVRAM to save the network parameters after device reboot or
 * power-off. NOTE: If this option is set to ZB_TRUE then do full device erase
 * for all network devices before running other samples.
 */
#define ERASE_PERSISTENT_CONFIG ZB_FALSE

/* Dim step size - increases/decreses current level (range 0x000 - 0xfe). */
#define DIMM_STEP 15

/* Transition time for a single step operation in 0.1 sec units.
 * 0xFFFF - immediate change.
 */
#define DIMM_TRANSACTION_TIME 2

LOG_MODULE_REGISTER(app, LOG_LEVEL_INF);

struct bulb_context
{
	zb_uint8_t endpoint;
	zb_uint16_t short_addr;
	struct k_timer find_alarm;
};

struct zb_device_ctx
{
	zb_zcl_basic_attrs_t basic_attr;
	zb_zcl_identify_attrs_t identify_attr;
};

static struct bulb_context bulb_ctx;
static struct zb_device_ctx dev_ctx;

/* Declare attribute list for Basic cluster (server). */
ZB_ZCL_DECLARE_BASIC_SERVER_ATTRIB_LIST(
	basic_server_attr_list,
	&dev_ctx.basic_attr.zcl_version,
	&dev_ctx.basic_attr.power_source);

/* Declare attribute list for Identify cluster (client). */
ZB_ZCL_DECLARE_IDENTIFY_CLIENT_ATTRIB_LIST(
	identify_client_attr_list);

/* Declare attribute list for Identify cluster (server). */
ZB_ZCL_DECLARE_IDENTIFY_SERVER_ATTRIB_LIST(
	identify_server_attr_list,
	&dev_ctx.identify_attr.identify_time);

/* Declare attribute list for On/Off cluster (client). */
ZB_ZCL_DECLARE_ON_OFF_CLIENT_ATTRIB_LIST(
	on_off_client_attr_list);

/* Declare attribute list for Level control cluster (client). */
ZB_ZCL_DECLARE_LEVEL_CONTROL_CLIENT_ATTRIB_LIST(
	level_control_client_attr_list);

/* Declare cluster list for Dimmer Switch device. */
ZB_DECLARE_DIMMER_SWITCH_CLUSTER_LIST(
	dimmer_switch_clusters,
	basic_server_attr_list,
	identify_client_attr_list,
	identify_server_attr_list,
	NULL,
	NULL,
	on_off_client_attr_list,
	level_control_client_attr_list);

/* Declare endpoint for Dimmer Switch device. */
ZB_DECLARE_DIMMER_SWITCH_EP(
	dimmer_switch_ep_1,
	LIGHT_SWITCH_ENDPOINT_1,
	dimmer_switch_clusters);

ZB_DECLARE_DIMMER_SWITCH_EP(
	dimmer_switch_ep_2,
	LIGHT_SWITCH_ENDPOINT_2,
	dimmer_switch_clusters);

ZB_DECLARE_DIMMER_SWITCH_EP(
	dimmer_switch_ep_3,
	LIGHT_SWITCH_ENDPOINT_3,
	dimmer_switch_clusters);

// ZB_DECLARE_DIMMER_SWITCH_EP(
// 	dimmer_switch_ep_4,
// 	LIGHT_SWITCH_ENDPOINT_4,
// 	dimmer_switch_clusters);

// ZB_DECLARE_DIMMER_SWITCH_EP(
// 	dimmer_switch_ep_5,
// 	LIGHT_SWITCH_ENDPOINT_5,
// 	dimmer_switch_clusters);

// Declare application's device context (list of registered endpoints) for Dimmer Switch device.
// ZBOSS_DECLARE_DEVICE_CTX_1_EP(dimmer_switch_ctx, dimmer_switch_ep_1);
// ZBOSS_DECLARE_DEVICE_CTX_2_EP(dimmer_switch_ctx, dimmer_switch_ep_1, dimmer_switch_ep_2);
ZBOSS_DECLARE_DEVICE_CTX_3_EP(dimmer_switch_ctx, dimmer_switch_ep_1, dimmer_switch_ep_2, dimmer_switch_ep_3);
// ZBOSS_DECLARE_DEVICE_CTX_EP_VA(dimmer_switch_ctx, dimmer_switch_ep_1, dimmer_switch_ep_2, dimmer_switch_ep_3, dimmer_switch_ep_4, dimmer_switch_ep_5);

int light_switch_endpoint;

// =================================================== uart ===============================================================
#include <zephyr/devicetree.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/sys/printk.h>
#include <zephyr/drivers/uart.h>

#define SLEEP_TIME_MS 1000
#define RECEIVE_BUFF_SIZE 9
#define RECEIVE_TIMEOUT 100

/* STEP 4.1 - Get the device pointer of the UART hardware */
const struct device *uart = DEVICE_DT_GET(DT_NODELABEL(uart0));

/* STEP 9.1 - Define the transmission buffer, which is a buffer to hold the data to be sent over UART */
static uint8_t tx_buf[] = {"nRF Connect SDK Fundamentals Course\n\r"
						   "Press 1/0 on your keyboard to toggle bulb on zigbee network\n\r"};

/* STEP 10.1.2 - Define the receive buffer */
static uint8_t rx_buf[RECEIVE_BUFF_SIZE] = {0};

// ==================================================================================================================

/**@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 *sig_hndler = NULL;
	zb_zdo_app_signal_type_t sig = zb_get_app_signal(bufid, &sig_hndler);
	zb_ret_t status = ZB_GET_APP_SIGNAL_STATUS(bufid);

	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)
			/* Check the light device address. */
			if (bulb_ctx.short_addr == 0xFFFF)
				k_timer_start(&bulb_ctx.find_alarm, MATCH_DESC_REQ_START_DELAY, MATCH_DESC_REQ_TIMEOUT);
		break;
	case ZB_ZDO_SIGNAL_LEAVE:
		/* If device leaves the network, reset bulb short_addr. */
		if (status == RET_OK)
		{
			zb_zdo_signal_leave_params_t *leave_params = ZB_ZDO_SIGNAL_GET_PARAMS(sig_hndler, zb_zdo_signal_leave_params_t);

			if (leave_params->leave_type == ZB_NWK_LEAVE_TYPE_RESET)
				bulb_ctx.short_addr = 0xFFFF;
		}

		/* Call default signal handler. */
		ZB_ERROR_CHECK(zigbee_default_signal_handler(bufid));
		break;

	default:
		/* Call default signal handler. */
		ZB_ERROR_CHECK(zigbee_default_signal_handler(bufid));
		break;
	}

	if (bufid)
		zb_buf_free(bufid);
}

// ==================================================================================================================

/**@brief Starts identifying the device.
 *
 * @param  bufid  Unused parameter, required by ZBOSS scheduler API.
 */
static void start_identifying(zb_bufid_t bufid)
{
	LOG_INF("start identifying function called");
	ZVUNUSED(bufid);

	if (ZB_JOINED())
	{
		/* Check if endpoint is in identifying mode,
		 * if not, put desired endpoint in identifying mode.
		 */
		if (dev_ctx.identify_attr.identify_time == ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE)
		{
			LOG_INF("Endpoint: %d", light_switch_endpoint);
			zb_ret_t zb_err_code = zb_bdb_finding_binding_target(light_switch_endpoint);

			if (zb_err_code == RET_OK)
				LOG_INF("Enter identify mode");
			else if (zb_err_code == RET_INVALID_STATE)
				LOG_INF("RET_INVALID_STATE - Cannot enter identify mode");
			else
			{
				LOG_INF("error in start identifying");
				ZB_ERROR_CHECK(zb_err_code);
			}
		}
		else
		{
			LOG_INF("Cancel identify mode");
			zb_bdb_finding_binding_target_cancel();
		}
	}
	else
		LOG_INF("Device not in a network - cannot enter identify mode");
}

/*@brief Function for sending step requests to the light bulb.
 *
 * @param[in]   bufid        Non-zero reference to Zigbee stack buffer that
 *                           will be used to construct step request.
 * @param[in]   cmd_id       ZCL command id.
 */
static void light_switch_send_step(zb_bufid_t bufid, zb_uint16_t cmd_id)
{
	LOG_INF("Send step level command: %d", cmd_id);
	LOG_INF("Endpoint: %d", light_switch_endpoint);

	ZB_ZCL_LEVEL_CONTROL_SEND_STEP_REQ(bufid,
									   bulb_ctx.short_addr,
									   ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
									   bulb_ctx.endpoint,
									   light_switch_endpoint,
									   ZB_AF_HA_PROFILE_ID,
									   ZB_ZCL_DISABLE_DEFAULT_RESPONSE,
									   NULL,
									   cmd_id,
									   DIMM_STEP,
									   DIMM_TRANSACTION_TIME);
}

// @brief Function for sending ON/OFF requests to the light bulb.
static void light_switch_send_on_off(zb_bufid_t bufid, zb_uint16_t cmd_id)
{
	LOG_INF("Send ON/OFF command in switch_func: %d", cmd_id);
	LOG_INF("Endpoint: %d", light_switch_endpoint);

	ZB_ZCL_ON_OFF_SEND_REQ(bufid,
						   bulb_ctx.short_addr,
						   ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
						   bulb_ctx.endpoint,
						   light_switch_endpoint,
						   ZB_AF_HA_PROFILE_ID,
						   ZB_ZCL_DISABLE_DEFAULT_RESPONSE,
						   cmd_id,
						   NULL);
}

// ==================================================================================================================

void toggle_light(struct uart_event *evt)
{
	zb_uint16_t cmd_id;
	zb_ret_t zb_err_code;

	if (evt->data.rx.buf[evt->data.rx.offset + 8] == 0x00)
		cmd_id = ZB_ZCL_CMD_ON_OFF_OFF_ID;
	else if (evt->data.rx.buf[evt->data.rx.offset + 8] == 0x01)
		cmd_id = ZB_ZCL_CMD_ON_OFF_ON_ID;

	LOG_INF("String: %s", evt->data.rx.buf);
	zb_err_code = zb_buf_get_out_delayed_ext(light_switch_send_on_off, cmd_id, 0);
	ZB_ERROR_CHECK(zb_err_code);
}

void dim_controller(struct uart_event *evt)
{
	zb_uint16_t cmd_id;
	zb_ret_t zb_err_code;

	if (evt->data.rx.buf[evt->data.rx.offset + 8] == 0x00)
		cmd_id = ZB_ZCL_LEVEL_CONTROL_STEP_MODE_DOWN;
	else if (evt->data.rx.buf[evt->data.rx.offset + 8] == 0x01)
		cmd_id = ZB_ZCL_LEVEL_CONTROL_STEP_MODE_UP;

	/* Allocate output buffer and send step command. */
	zb_err_code = zb_buf_get_out_delayed_ext(light_switch_send_step, cmd_id, 0);
	if (!zb_err_code)
		LOG_WRN("Buffer is full");
}

void factoryReset_pairing_mode(struct uart_event *evt)
{
	if (evt->data.rx.buf[evt->data.rx.offset + 8] == 0x00)
		ZB_SCHEDULE_APP_CALLBACK(zb_bdb_reset_via_local_action, 0);
	else if (evt->data.rx.buf[evt->data.rx.offset + 8] == 0x01)
		ZB_SCHEDULE_APP_CALLBACK(start_identifying, 0);
}

// ==================================================================================================================

/* STEP 7 - Define the callback function for UART */
static void uart_cb(const struct device *dev, struct uart_event *evt, void *user_data)
{

	/* Inform default signal handler about user input at the device. */
	user_input_indicate();

	if (bulb_ctx.short_addr == 0xFFFF)
	{
		LOG_INF("No bulb found yet.");
		return;
	}

	switch (evt->type)
	{
	case UART_RX_RDY:
		/* For ON/OFF of Light */
		if (evt->data.rx.buf[evt->data.rx.offset] == 0x5A)
		{
			// ============================================ for LIGHT_SWITCH_ENDPOINT_1 ============================================
			if (evt->data.rx.buf[evt->data.rx.offset + 4] == 0x15)
			{
				light_switch_endpoint = LIGHT_SWITCH_ENDPOINT_1;
				LOG_INF("Endpoint: %d", light_switch_endpoint);
				toggle_light(evt);
			}
			else if ((evt->data.rx.buf[evt->data.rx.offset + 4] == 0x16) || (evt->data.rx.buf[evt->data.rx.offset + 4] == 0x17))
			{
				light_switch_endpoint = LIGHT_SWITCH_ENDPOINT_1;
				LOG_INF("Endpoint: %d", light_switch_endpoint);
				dim_controller(evt);
			}
			else if ((evt->data.rx.buf[evt->data.rx.offset + 4] == 0x18) || (evt->data.rx.buf[evt->data.rx.offset + 4] == 0x19))
			{
				light_switch_endpoint = LIGHT_SWITCH_ENDPOINT_1;
				LOG_INF("Endpoint: %d", light_switch_endpoint);
				factoryReset_pairing_mode(evt);
			}

			// ============================================ for LIGHT_SWITCH_ENDPOINT_2 ============================================
			else if (evt->data.rx.buf[evt->data.rx.offset + 4] == 0x25)
			{
				light_switch_endpoint = LIGHT_SWITCH_ENDPOINT_2;
				LOG_INF("Endpoint: %d", light_switch_endpoint);
				toggle_light(evt);
			}
			else if ((evt->data.rx.buf[evt->data.rx.offset + 4] == 0x26) || (evt->data.rx.buf[evt->data.rx.offset + 4] == 0x27))
			{
				light_switch_endpoint = LIGHT_SWITCH_ENDPOINT_2;
				LOG_INF("Endpoint: %d", light_switch_endpoint);
				dim_controller(evt);
			}
			else if ((evt->data.rx.buf[evt->data.rx.offset + 4] == 0x28) || (evt->data.rx.buf[evt->data.rx.offset + 4] == 0x29))
			{
				light_switch_endpoint = LIGHT_SWITCH_ENDPOINT_2;
				LOG_INF("Endpoint: %d", light_switch_endpoint);
				factoryReset_pairing_mode(evt);
			}

			// ============================================ for LIGHT_SWITCH_ENDPOINT_3 ============================================
			else if (evt->data.rx.buf[evt->data.rx.offset + 4] == 0x35)
			{
				light_switch_endpoint = LIGHT_SWITCH_ENDPOINT_3;
				LOG_INF("Endpoint: %d", light_switch_endpoint);
				toggle_light(evt);
			}
			else if ((evt->data.rx.buf[evt->data.rx.offset + 4] == 0x36) || (evt->data.rx.buf[evt->data.rx.offset + 4] == 0x37))
			{
				light_switch_endpoint = LIGHT_SWITCH_ENDPOINT_3;
				LOG_INF("Endpoint: %d", light_switch_endpoint);
				dim_controller(evt);
			}
			else if ((evt->data.rx.buf[evt->data.rx.offset + 4] == 0x38) || (evt->data.rx.buf[evt->data.rx.offset + 4] == 0x39))
			{
				light_switch_endpoint = LIGHT_SWITCH_ENDPOINT_3;
				LOG_INF("Endpoint: %d", light_switch_endpoint);
				factoryReset_pairing_mode(evt);
			}

			// // ============================================ for LIGHT_SWITCH_ENDPOINT_4 ============================================
			// else if (evt->data.rx.buf[evt->data.rx.offset + 4] == 0x45)
			// {
			// 	light_switch_endpoint = LIGHT_SWITCH_ENDPOINT_4;
			// 	toggle_light(evt);
			// }
			// else if ((evt->data.rx.buf[evt->data.rx.offset + 4] == 0x46) || (evt->data.rx.buf[evt->data.rx.offset + 4] == 0x47))
			// {
			// 	light_switch_endpoint = LIGHT_SWITCH_ENDPOINT_4;
			// 	dim_controller(evt);
			// }
			// else if ((evt->data.rx.buf[evt->data.rx.offset + 4] == 0x48) || (evt->data.rx.buf[evt->data.rx.offset + 4] == 0x49))
			// {
			// 	light_switch_endpoint = LIGHT_SWITCH_ENDPOINT_4;
			// 	factoryReset_pairing_mode(evt);
			// }

			// // ============================================ for LIGHT_SWITCH_ENDPOINT_5 ============================================
			// else if (evt->data.rx.buf[evt->data.rx.offset + 4] == 0x55)
			// {
			// 	light_switch_endpoint = LIGHT_SWITCH_ENDPOINT_5;
			// 	toggle_light(evt);
			// }
			// else if ((evt->data.rx.buf[evt->data.rx.offset + 4] == 0x56) || (evt->data.rx.buf[evt->data.rx.offset + 4] == 0x57))
			// {
			// 	light_switch_endpoint = LIGHT_SWITCH_ENDPOINT_5;
			// 	dim_controller(evt);
			// }
			// else if ((evt->data.rx.buf[evt->data.rx.offset + 4] == 0x58) || (evt->data.rx.buf[evt->data.rx.offset + 4] == 0x59))
			// {
			// 	light_switch_endpoint = LIGHT_SWITCH_ENDPOINT_5;
			// 	factoryReset_pairing_mode(evt);
			// }

			else
				LOG_INF("VP error");
		}
		else
			LOG_INF("First hex is not 0x5A");

		break;

	case UART_RX_DISABLED:
		uart_rx_enable(dev, rx_buf, sizeof rx_buf, RECEIVE_TIMEOUT);
		break;
	default:
		break;
	}
}

// ==================================================================================================================

// @brief Callback function receiving finding procedure results.
static void find_light_bulb_cb(zb_bufid_t bufid)
{
	LOG_INF("find_light_bulb_cb called");

	/* Get the beginning of the response. */
	zb_zdo_match_desc_resp_t *resp =
		(zb_zdo_match_desc_resp_t *)zb_buf_begin(bufid);
	/* Get the pointer to the parameters buffer, which stores APS layer
	 * response.
	 */
	zb_apsde_data_indication_t *ind = ZB_BUF_GET_PARAM(bufid, zb_apsde_data_indication_t);
	zb_uint8_t *match_ep;

	if ((resp->status == ZB_ZDP_STATUS_SUCCESS) && (resp->match_len > 0) && (bulb_ctx.short_addr == 0xFFFF))
	{
		/* Match EP list follows right after response header. */
		match_ep = (zb_uint8_t *)(resp + 1);

		/* We are searching for exact cluster, so only 1 EP
		 * may be found.
		 */
		bulb_ctx.endpoint = *match_ep;
		bulb_ctx.short_addr = ind->src_addr;

		LOG_INF("Found bulb addr: %d ep: %d",
				bulb_ctx.short_addr,
				bulb_ctx.endpoint);

		k_timer_stop(&bulb_ctx.find_alarm);
	}

	else
		LOG_INF("Bulb not found, try again");

	if (bufid)
		zb_buf_free(bufid);
}

/**@brief Function for sending ON/OFF and Level Control find request.
 *
 * @param[in]   bufid   Reference to Zigbee stack buffer that will be used to
 *                      construct find request.
 */
static void find_light_bulb(zb_bufid_t bufid)
{
	LOG_INF("find_light_bulb called");

	zb_zdo_match_desc_param_t *req;
	zb_uint8_t tsn = ZB_ZDO_INVALID_TSN;

	/* Initialize pointers inside buffer and reserve space for
	 * zb_zdo_match_desc_param_t request.
	 */
	req = zb_buf_initial_alloc(bufid, sizeof(zb_zdo_match_desc_param_t) + (1) * sizeof(zb_uint16_t));

	req->nwk_addr = MATCH_DESC_REQ_ROLE;
	req->addr_of_interest = MATCH_DESC_REQ_ROLE;
	req->profile_id = ZB_AF_HA_PROFILE_ID;

	/* We are searching for 2 clusters: On/Off and Level Control Server. */
	req->num_in_clusters = 2;
	req->num_out_clusters = 0;
	req->cluster_list[0] = ZB_ZCL_CLUSTER_ID_ON_OFF;
	req->cluster_list[1] = ZB_ZCL_CLUSTER_ID_LEVEL_CONTROL;

	/* Set 0xFFFF to reset short address in order to parse
	 * only one response.
	 */
	bulb_ctx.short_addr = 0xFFFF;
	tsn = zb_zdo_match_desc_req(bufid, find_light_bulb_cb);

	/* Free buffer if failed to send a request. */
	if (tsn == ZB_ZDO_INVALID_TSN)
	{
		zb_buf_free(bufid);
		LOG_INF("Failed to send Match Descriptor request");
	}
}

/**@brief Find bulb alarm handler.
 *
 * @param[in]   timer   Address of timer.
 */
static void find_light_bulb_alarm(struct k_timer *timer)
{
	LOG_INF("find_light_bulb_alarm called");
	ZB_ERROR_CHECK(zb_buf_get_out_delayed(find_light_bulb));
}

// ==================================================================================================================

int main(void)
{
	int ret;

	/* STEP 4.2 - Verify that the UART device is ready */
	if (!device_is_ready(uart))
	{
		printk("UART device not ready\r\n");
		return 1;
	}

	/* STEP 8 - Register the UART callback function */
	ret = uart_callback_set(uart, uart_cb, NULL);
	if (ret)
		return 1;

	/* STEP 9.2 - Send the data over UART by calling uart_tx() */
	ret = uart_tx(uart, tx_buf, sizeof(tx_buf), SYS_FOREVER_US);
	if (ret)
		return 1;

	/* STEP 10.3  - Start receiving by calling uart_rx_enable() and pass it the address of the receive  buffer */
	ret = uart_rx_enable(uart, rx_buf, sizeof rx_buf, RECEIVE_TIMEOUT);
	if (ret)
		return 1;

	// ==================================================================================================================

	LOG_INF("Starting ZBOSS Light Switch example");

	k_timer_init(&bulb_ctx.find_alarm, find_light_bulb_alarm, NULL);

	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));

	/* Set default bulb short_addr. */
	bulb_ctx.short_addr = 0xFFFF;

	/* Power off unused sections of RAM to lower device power consumption. */
	if (IS_ENABLED(CONFIG_RAM_POWER_DOWN_LIBRARY))
		power_down_unused_ram();

	/* Register dimmer switch device context (endpoints). */
	ZB_AF_REGISTER_DEVICE_CTX(&dimmer_switch_ctx);

	/* Basic cluster attributes data. */
	dev_ctx.basic_attr.zcl_version = ZB_ZCL_VERSION;
	dev_ctx.basic_attr.power_source = ZB_ZCL_BASIC_POWER_SOURCE_UNKNOWN;

	/* Identify cluster attributes data. */
	dev_ctx.identify_attr.identify_time = ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE;

	/* Start Zigbee default thread. */
	zigbee_enable();

	// ==================================================================================================================

	LOG_INF("ZBOSS Light Switch example started");
	while (1)
	{
		k_sleep(K_FOREVER);
		// k_msleep(SLEEP_TIME_MS);
	}
}

   I keep getting this error again and again.

I tried changing a few lines in zboss files but couldnt resolve the error. I am still pretty new at this so any help would be appreciated.

Thanks in advance.

Parents Reply Children
  • Hi, 

    Yes this error shows after building the application.

  • Have you changed any of the source file by accident? I can't find any occurrences of  "zb_af_simple_desc_1_1_" in NCS v2.4.2.

    You can use "git status"/"git diff" in each repository (e.g., open terminal in nrfxlib directory and run command) to see changed files.

  • This is the only file I could find.

    /*
     * ZBOSS Zigbee 3.0
     *
     * Copyright (c) 2012-2021 DSR Corporation, Denver CO, USA.
     * www.dsr-zboss.com
     * www.dsr-corporation.com
     * All rights reserved.
     *
     *
     * Use in source and binary forms, redistribution in binary form only, with
     * or without modification, are permitted provided that the following conditions
     * are met:
     *
     * 1. 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.
     *
     * 2. 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.
     *
     * 3. This software, with or without modification, must only be used with a Nordic
     *    Semiconductor ASA integrated circuit.
     *
     * 4. 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.
     */
    /* PURPOSE: ZBOSS AF API
    */
    
    
    #ifndef ZBOSS_API_AF_H
    #define ZBOSS_API_AF_H 1
    
    
    /**
     *  @addtogroup af_api
     *  @{
     */
    
    
    /**
     * @addtogroup af_data_service AF data service
     * @{
     */
    
    
    /**
       Node descriptor
     */
    typedef ZB_PACKED_PRE struct zb_af_node_desc_s
    {
      zb_uint16_t          node_desc_flags;            /*!< node description */
      zb_uint8_t           mac_capability_flags;       /*!< mac capability */
      zb_uint16_t          manufacturer_code;          /*!< Manufacturer code */
      zb_uint8_t           max_buf_size;               /*!< Maximum buffer size */
      zb_uint16_t          max_incoming_transfer_size; /*!< Maximum incoming transfer size */
      zb_uint16_t          server_mask;                /*!< Server mask */
      zb_uint16_t          max_outgoing_transfer_size; /*!< Maximum outgoing transfer size */
      zb_uint8_t           desc_capability_field;      /*!< Descriptor capability field */
    }
    ZB_PACKED_STRUCT
    zb_af_node_desc_t;
    
    
    typedef zb_nwk_device_type_t zb_logical_type_t;
    
    
    /** @} */ /* af_data_service */
    
    
    /**
     *  @addtogroup af_node_desc_dev_types AF device types
     *  @{
     */
    /** Device type - Coordinator */
    #define ZB_COORDINATOR ZB_NWK_DEVICE_TYPE_COORDINATOR
    /** Device type - Router */
    #define ZB_ROUTER      ZB_NWK_DEVICE_TYPE_ROUTER
    /** Device type - End Device */
    #define ZB_END_DEVICE  ZB_NWK_DEVICE_TYPE_ED
    /*! @} */ /* af_node_desc_dev_types */
    
    
    /**
     * @addtogroup af_common_constants AF common constants
     * @{
     */
    /**
     * @name Node descriptor - frequency value
     * @anchor freq_band
     *
     * Note: These values were members of `enum zb_freq_band_e` type but were converted to a
     * set of macros due to MISRA violations.
     */
    /** @{ */
    #define ZB_FREQ_BAND_868            1U        /*!< 868-868.6 MHz BPSK */
    #define ZB_FREQ_BAND_SUB_GHZ_NA_FSK (1U << 2) /*!< 902-928 MHz BPSK */
    #define ZB_FREQ_BAND_2400           (1U << 3) /*!< 2400-2483.5 MHz */
    /** Zigbee R22: European FSK sub-GHz bands (863-876MHz, 915-921MHz) */
    #define ZB_FREQ_BAND_SUB_GHZ_EU_FSK (1U << 4)
    /** @} */
    
    
    /**
     * @name Node descriptor - server mask
     * @anchor server_mask_bit
     *
     * Note: These values were members of `enum zb_server_mask_bit_e` type but were converted to a
     * set of macros due to MISRA violations.
     */
    /** @{ */
    #define ZB_PRIMARY_TRUST_CENTER         1U        /*!< Primary Trust Center */
    #define ZB_BACKUP_TRUST_CENTER          (1U << 1) /*!< Backup Trust Center */
    #define ZB_PRIMARY_BINDING_TABLE_CENTER (1U << 2) /*!< Primary Binding Table Center */
    #define ZB_BACKUP_BINDING_TABLE_CENTER  (1U << 3) /*!< Backup Binding Table Center */
    #define ZB_PRIMARY_DISCOVERY_CACHE      (1U << 4) /*!< Primary Discovery Cache */
    #define ZB_BACKUP_DISCOVERY_CACHE       (1U << 5) /*!< Backup Discovery Cache */
    #define ZB_NETWORK_MANAGER              (1U << 6) /*!< Network Manager */
    /** @} */
    
    
    /**
     * @name Node descriptor - capability mask
     * @anchor desc_capability
     *
     * Note: These values were members of `enum zb_desc_capability_e` type but were converted to a
     * set of macros due to MISRA violations.
     */
    /** @{ */
    #define ZB_EXT_ACTIVE_EP_LIST   1U        /*!< Extended Active Endpoint List Available */
    #define ZB_EXT_SIMPLE_DESC_LIST (1U << 1) /*!< Extended Simple Descriptor List Available */
    /** @} */
    
    
    /**
     * @name Power descriptor types
     * @anchor current_power_mode
     */
    /** @{ */
    /*!< Receiver synchronized with the receiver on when idle subfield of the node descriptor. */
    #define ZB_POWER_MODE_SYNC_ON_WHEN_IDLE 0U
    /*!< Receiver comes on periodically as defined by the node power descriptor. */
    #define ZB_POWER_MODE_COME_ON_PERIODICALLY 1U
    /*!< Receiver comes on when stimulated, for example, by a user pressing a button. */
    #define ZB_POWER_MODE_COME_ON_WHEN_STIMULATED 2U
    /** @} */
    
    
    /**
     * @brief Type for power descriptor types.
     *
     * Holds one of @ref current_power_mode. Kept only for backward compatibility as
     * @ref current_power_mode were declared previously as enum. Can be removed in future releases.
     */
    typedef zb_uint8_t zb_current_power_mode_t;
    
    
    /**
     * @name Power source types
     * @anchor power_src
     */
    /** @{ */
    #define ZB_POWER_SRC_CONSTANT             1U        /*!< Constant (mains) power */
    #define ZB_POWER_SRC_RECHARGEABLE_BATTERY (1U << 1) /*!< Rechargeable battery */
    #define ZB_POWER_SRC_DISPOSABLE_BATTERY   (1U << 2) /*!< Disposable battery */
    /** @} */
    
    
    /**
     * @brief Type for power source types.
     *
     * @deprecated holds one of @ref power_src. Kept only for backward compatibility as
     * @ref power_src were declared previously as enum. Can be removed in future releases.
     */
    typedef zb_uint8_t zb_power_src_t;
    
    
    /**
     * @name Power source level values
     * @anchor power_source_level
     */
    /** @{ */
    #define ZB_POWER_LEVEL_CRITICAL 0U  /*!< Critical */
    #define ZB_POWER_LEVEL_33       4U  /*!< 33% */
    #define ZB_POWER_LEVEL_66       8U  /*!< 66% */
    #define ZB_POWER_LEVEL_100      12U /*!< 100% */
    /** @} */
    
    
    /**
     * @brief Type for power source level values.
     *
     * Holds one of @ref power_source_level. Kept only for backward compatibility as
     * @ref power_source_level were declared previously as enum. Can be removed in future releases.
     */
    typedef zb_uint8_t zb_power_source_level_t;
    
    
    /** @} */ /* af_common_constants */
    
    
    /**
     * @addtogroup af_data_service AF data service
     * @{
     */
    
    
    /**
       Node power descriptor
     */
    typedef ZB_PACKED_PRE struct zb_af_node_power_desc_s
    {
    /**   Field name               Bits
     * Current power mode:         4@n
     * Available power sources:    4@n
     * Current power source:       4@n
     * Current power source level: 4
     */
      zb_uint16_t power_desc_flags;
    } ZB_PACKED_STRUCT zb_af_node_power_desc_t;
    
    
    
    
    /** @cond DOXYGEN_INTERNAL_DOC */
    #define CAT5(a, b, c, d, e) a##b##c##d##e
    /** @endcond */ /* DOXYGEN_INTERNAL_DOC */
    
    
    /** Generate simple descriptor type name */
    #define ZB_AF_SIMPLE_DESC_TYPE(in_num, out_num)  CAT5(zb_af_simple_desc_,in_num,_,out_num,_t)
    
    
    /**
       Declares Simple descriptor type
    
    
       @param in_clusters_count - number of input clusters in descriptor
       @param out_clusters_count - number of output clusters in descriptor
    
    
       @b Example:
       @code
         ZB_DECLARE_SIMPLE_DESC(5, 5);
       @endcode
     */
    
    
    #define ZB_DECLARE_SIMPLE_DESC(in_clusters_count, out_clusters_count)   \
      typedef ZB_PACKED_PRE struct zb_af_simple_desc_ ## in_clusters_count ## _ ## out_clusters_count ## _s \
      {                                                                                       \
        zb_uint8_t    endpoint;                 /* Endpoint */                                \
        zb_uint16_t   app_profile_id;           /* Application profile identifier */          \
        zb_uint16_t   app_device_id;            /* Application device identifier */           \
        zb_bitfield_t app_device_version:4;     /* Application device version */              \
        zb_bitfield_t reserved:4;               /* Reserved */                                \
        zb_uint8_t    app_input_cluster_count;  /* Application input cluster count */         \
        zb_uint8_t    app_output_cluster_count; /* Application output cluster count */        \
        /* Application input and output cluster list */                                       \
        zb_uint16_t   app_cluster_list[(in_clusters_count) + (out_clusters_count)];               \
      } ZB_PACKED_STRUCT                                                                      \
      zb_af_simple_desc_ ## in_clusters_count ## _ ## out_clusters_count ## _
    
    
    /** @} */ /* af_data_service */
    
    
    /**
     * @addtogroup af_management_service AF management service
     * @{
     */
    /** General descriptor type */
    ZB_DECLARE_SIMPLE_DESC(1,1);
    /** ZDO descriptor type */
    ZB_DECLARE_SIMPLE_DESC(8,9);
    /** @} */ /* af_management_service */
    
    
    /**
     * @addtogroup af_common_constants AF common constants
     * @{
     */
    
    
    /**
     * @name Profile identifiers
     * @anchor af_profile_id
     *
     * Note: These values were members of `enum zb_af_profile_id_e` type but were converted to a
     * set of macros due to MISRA violations.
     */
    /** @{ */
    /** ZDO profile ID */
    #define ZB_AF_ZDO_PROFILE_ID      0x0000U
    /** Legacy profile */
    #define ZB_AF_LEGACY_PROFILE1_ID  0x0101U
    /** Legacy profile */
    #define ZB_AF_LEGACY_PROFILE2_ID  0x0102U
    /** Legacy profile */
    #define ZB_AF_LEGACY_PROFILE3_ID  0x0103U
    /** HA profile ID*/
    #define ZB_AF_HA_PROFILE_ID       0x0104U
    /** Legacy profile */
    #define ZB_AF_LEGACY_PROFILE4_ID  0x0105U
    /** Legacy profile */
    #define ZB_AF_LEGACY_PROFILE5_ID  0x0106U
    /** Legacy profile */
    #define ZB_AF_LEGACY_PROFILE6_ID  0x0107U
    /** Legacy profile */
    #define ZB_AF_LEGACY_PROFILE7_ID  0x0108U
    /** SE profile ID */
    #define ZB_AF_SE_PROFILE_ID       0x0109U
    /** ZLL profile identifier. */
    #define ZB_AF_ZLL_PROFILE_ID      0xC05EU
    /** Wildcard profile identifier. */
    #define ZB_AF_WILDCARD_PROFILE_ID 0xFFFFU
    /** GreenPower profile ID */
    #define ZB_AF_GP_PROFILE_ID       0xA1E0U
    #ifdef ZB_CONTROL4_NETWORK_SUPPORT
    /** Control4 profile identifier. */
    #define ZB_AF_CONTROL4_PROFILE_ID 0xC25DU
    #endif
    /** @} */
    
    
    /** @} */ /* af_common_constants */
    
    
    /** @cond DOXYGEN_INTERNAL_DOC */
    #if !(defined ZB_ZCL_DISABLE_REPORTING) || defined(DOXYGEN)
    struct zb_zcl_reporting_info_s; /* Forward declaration */
    #endif
    struct zb_zcl_cluster_desc_s;   /* Forward declaration */
    /** @endcond */ /* DOXYGEN_INTERNAL_DOC */
    
    
    /**
     * @addtogroup af_management_service AF management service
     * @{
     */
    /**
     * Device command handler
     *
     * @param param - index of buffer with ZCL command
     * @return status (see @ref zb_bool_t)
     */
    typedef zb_uint8_t (*zb_device_handler_t)(zb_uint8_t param);
    /** @} */ /* af_management_service */
    /**
     * @addtogroup af_data_service AF data service
     * @{
     */
    
    
    /** Endpoint description for user applications. */
    
    
    /*! @brief Endpoint descriptor. */
    typedef ZB_PACKED_PRE struct zb_af_endpoint_desc_s
    {
      zb_uint8_t ep_id;               /*!< Endpoint ID */
      zb_uint16_t profile_id;         /*!< Application profile, which implemented on endpoint */
      zb_device_handler_t device_handler;   /*!< Device specific callback, handles all commands */
      /*! @brief Identify notification callback
    
    
          If set, will be called on identification start and stop indicating start
          event with a non-zero argument
      */
      zb_callback_t identify_handler;
      zb_uint8_t reserved_size; /*!< Unused parameter (reserved for future use) */
      void* reserved_ptr; /*!< Unused parameter (reserved for future use) */
      zb_uint8_t cluster_count;       /*!< Number of supported clusters */
      struct zb_zcl_cluster_desc_s *cluster_desc_list;  /*!< Supported clusters list */
      zb_af_simple_desc_1_1_t *simple_desc; /*!< Simple descriptor */
    #if defined ZB_ENABLE_ZLL || defined DOXYGEN
      zb_uint8_t group_id_count;
    #endif /* defined ZB_ENABLE_ZLL || defined DOXYGEN */
    
    
      /* Moved here from device descriptor */
      zb_uint8_t rep_info_count;           /*!< Number of reporting info slots */
      /* Reporting info structure should be better stored in ZCL main,
       * moved here to allow compile-time memory allocating for
       * reporting_info array, see ZB_AF_DECLARE_DEVICE_CTX() */
      struct zb_zcl_reporting_info_s *reporting_info; /*!< Attributes reporting information */
    
    
      zb_uint8_t cvc_alarm_count;          /*!< Number of continuous value change alarm slots */
      struct zb_zcl_cvc_alarm_variables_s *cvc_alarm_info;
    }ZB_PACKED_STRUCT
    zb_af_endpoint_desc_t;
    /** @} */ /* af_data_service */
    
    
    /**
     * @addtogroup af_management_service AF management service
     * @{
     */
    
    
    /**
     *  @brief Search for endpoint (device) descriptor by endpoint ID.
     *  @param ep_id - identifier of the endpoint.
     *  @returns NULL if no endpoint found, or pointer to the endpoint descriptor.
     */
    zb_af_endpoint_desc_t* zb_af_get_endpoint_desc(zb_uint8_t ep_id);
    
    
    /**
     *  @brief Check endpoint registration in ZCL.
     *  @param _ep - identifier of the endpoint under consideration.
     *  @returns ZB_TRUE if endpoint is registered, ZB_FALSE otherwise.
     */
    #define ZB_AF_IS_EP_REGISTERED( _ep ) ((zb_af_get_endpoint_desc( _ep ) != NULL)?(ZB_TRUE):(ZB_FALSE))
    /** @} */ /* af_management_service */
    
    
    /** @cond DOXYGEN_INTERNAL_DOC */
    /**
      AF device context, contains a list of registered endpoints
    */
    typedef ZB_PACKED_PRE struct zb_af_device_ctx_s
    {
      zb_uint8_t ep_count;                 /*!< Number of endpoints on device */
      zb_af_endpoint_desc_t **ep_desc_list; /*!< Endpoint list */
    }ZB_PACKED_STRUCT
    zb_af_device_ctx_t;
    /** @endcond */ /* DOXYGEN_INTERNAL_DOC */
    
    
    /**
     * @addtogroup af_management_service AF management service
     * @{
     */
    /**
       General macro to declare endpoint description list
       @param ep_list_name - name of ep list structure
    */
    #define ZB_AF_START_DECLARE_ENDPOINT_LIST(ep_list_name) \
      zb_af_endpoint_desc_t *ep_list_name[] = {
    
    
    /**
      @brief Initialize endpoint descriptor
    
    
       @param ep_name - endpoint name
      @param ep_id - endpoint ID
      @param profile_id - ID of profile deployed on this endpoint
       @param reserved_length - unused parameter
       @param reserved_ptr - unused parameter
      @param cluster_number - number of clusters deployed on endpoint
      @param cluster_list - pointer to cluster list
      @param simple_desc - pointer to simple descriptor
      @param rep_count - maximum number of attributes that are
      being reported on a device
      @param rep_ctx - reporting context variable name (NULL if no reporting context)
      @param lev_ctrl_count - number of level control attributes
      @param lev_ctrl_ctx - level control context variable name (NULL if no level control context)
    */
    #define ZB_AF_DECLARE_ENDPOINT_DESC(     \
      ep_name,                               \
      ep_id,                                 \
      profile_id,                            \
      reserved_length,                       \
      reserved_ptr,                          \
      cluster_number,                        \
      cluster_list,                          \
      simple_desc,                           \
      rep_count,                             \
      rep_ctx,                               \
      lev_ctrl_count,                        \
      lev_ctrl_ctx)                          \
      zb_af_endpoint_desc_t ep_name =        \
      {                                      \
        ep_id,                               \
        profile_id,                          \
        NULL,                                \
        NULL,                                \
        reserved_length,                     \
        (void*)reserved_ptr,            \
        cluster_number,                      \
        cluster_list,                        \
        simple_desc,                         \
        rep_count,                           \
        rep_ctx,                             \
        lev_ctrl_count,                      \
        lev_ctrl_ctx                         \
      }
    
    
    /** Finishes endpoint list declaration */
    #define ZB_AF_FINISH_DECLARE_ENDPOINT_LIST     }
    
    
    /**
     *  @brief Allows application to register cluster commands handler for a specific endpoint
     *  @param endpoint - Endpoint number
     *  @param handler - Pointer to a function, function type zb_device_handler_t
     *  @attention Endpoint should be registered. ZB_AF_SET_ENDPOINT_HANDLER() should be called after
     *  device context is registered, using call to ZB_AF_REGISTER_DEVICE_CTX()
     *
     * @cond DOXYGEN_INTERNAL_DOC
     *  TODO: add snippet
     * @endcond
     */
    #define ZB_AF_SET_ENDPOINT_HANDLER(endpoint, handler)                 \
      (zb_af_get_endpoint_desc((endpoint))->device_handler = (handler))
    
    
    /*! @brief Sets identify notification handler for endpoint
    
    
        Utilized by ZCL Identify cluster
        @param endpoint number
        @param handler to set
        @attention Assumes that endpoint already registered
     *
     * @cond DOXYGEN_INTERNAL_DOC
     *  TODO: add snippet
     * @endcond
    */
    #define ZB_AF_SET_IDENTIFY_NOTIFICATION_HANDLER(endpoint, handler)    \
      (zb_af_get_endpoint_desc((endpoint))->identify_handler = (handler))
    
    
    #define ZB_ZCL_CLUSTER_DESC(cluster_id, attr_count, attr_desc_list, cluster_role_mask, manuf_code)         \
    {                                                                                                          \
      (cluster_id),                                                                                            \
      (attr_count),                                                                                            \
      (attr_desc_list),                                                                                        \
      (cluster_role_mask),                                                                                     \
      (manuf_code),                                                                                            \
      (((cluster_role_mask) == ZB_ZCL_CLUSTER_SERVER_ROLE) ? cluster_id##_SERVER_ROLE_INIT : \
       (((cluster_role_mask) == ZB_ZCL_CLUSTER_CLIENT_ROLE) ? cluster_id##_CLIENT_ROLE_INIT : NULL)) \
    }
    
    
    /** WARNING: This API is deprecated, use ZBOSS_DECLARE_DEVICE_CTX instead. */
    #define ZB_AF_DECLARE_DEVICE_CTX(device_ctx_name, ep_list_name, ep_count, reporting_attr_count) \
      zb_zcl_reporting_info_t reporting_info## device_ctx_name[reporting_attr_count]; \
      zb_af_device_ctx_t device_ctx_name =                                  \
      {                                                                     \
        ep_count,                                                           \
        ep_list_name,                                                       \
        reporting_attr_count,                                               \
        reporting_info## device_ctx_name,                                   \
        0,                                                                  \
        NULL                                                                \
      }
    
    
    /** WARNING: This API is deprecated, use ZBOSS_DECLARE_DEVICE_CTX instead. */
    #define ZB_AF_DECLARE_DEVICE_CTX_NO_REP(device_ctx_name, ep_list_name, ep_count) \
      zb_af_device_ctx_t device_ctx_name =                                  \
      {                                                                     \
        ep_count,                                                           \
        ep_list_name,                                                       \
        0,                                                                  \
        NULL,                                                               \
        0,                                                                  \
        NULL                                                                \
      }
    
    
    /**
      Declare device reporting context
      @param rep_ctx - reporting context variable name
      @param rep_count - number of reporting attributes
    */
    #define ZBOSS_DEVICE_DECLARE_REPORTING_CTX(rep_ctx, rep_count) \
      zb_zcl_reporting_info_t rep_ctx[rep_count]
    
    
    /**
      Declare device level control context
      @param lev_ctrl_ctx - level control context variable name
      @param lev_ctrl_count - number of level control attributes
    */
    #define ZBOSS_DEVICE_DECLARE_LEVEL_CONTROL_CTX(lev_ctrl_ctx, lev_ctrl_count) \
      zb_zcl_cvc_alarm_variables_t lev_ctrl_ctx[lev_ctrl_count]
    
    
    /**
      Declare application's device context
      @param device_ctx_name - device context variable name
      @param ep_list_name - name of endpoint list
      @param ep_count - number of supported endpoints
    */
    #define ZBOSS_DECLARE_DEVICE_CTX(device_ctx_name, ep_list_name, ep_count) \
      zb_af_device_ctx_t device_ctx_name =                                  \
      {                                                                     \
        ep_count,                                                           \
        ep_list_name,                                                       \
      }
    
    
    /**
      Declare application's device context for single-endpoint device
    
    
      @note Device has an additional Green Power endpoint if it is ZC or ZR
      and GPPB feature is enabled (Mandatory for Zigbee 3.0 ZC/ZR).
    
    
      @param device_ctx_name - device context variable name
      @param ep_name - variable holding endpoint context
    */
    #define ZBOSS_DECLARE_DEVICE_CTX_1_EP(device_ctx_name, ep_name)        \
      ZB_AF_START_DECLARE_ENDPOINT_LIST(ep_list_##device_ctx_name)         \
        &ep_name,                                                          \
      ZB_AF_FINISH_DECLARE_ENDPOINT_LIST;                                  \
      ZBOSS_DECLARE_DEVICE_CTX(device_ctx_name, ep_list_##device_ctx_name, \
                               (ZB_ZCL_ARRAY_SIZE(ep_list_##device_ctx_name, zb_af_endpoint_desc_t*)))
    
    
    /**
      Declare application's device context for two-endpoint device
    
    
      @note Device has an additional Green Power endpoint if it is ZC or ZR
      and GPPB feature (Mandatory for Zigbee 3.0 ZC/ZR) is enabled.
    
    
      @param device_ctx_name - device context variable name
      @param ep1_name - variable holding context for endpoint 1
      @param ep2_name - variable holding context for endpoint 2
    */
    #define ZBOSS_DECLARE_DEVICE_CTX_2_EP(device_ctx_name, ep1_name, ep2_name) \
      ZB_AF_START_DECLARE_ENDPOINT_LIST(ep_list_##device_ctx_name)          \
        &ep1_name,                                                          \
        &ep2_name,                                                          \
      ZB_AF_FINISH_DECLARE_ENDPOINT_LIST;                                   \
      ZBOSS_DECLARE_DEVICE_CTX(device_ctx_name, ep_list_##device_ctx_name,  \
                               (ZB_ZCL_ARRAY_SIZE(ep_list_##device_ctx_name, zb_af_endpoint_desc_t*)))
    
    
    /**
      Declare application's device context for three-endpoint device
    
    
      @note Device has an additional Green Power endpoint if it is ZC or ZR
      and GPPB feature (Mandatory for Zigbee 3.0 ZC/ZR) is enabled.
    
    
      @param device_ctx_name - device context variable name
      @param ep1_name - variable holding context for endpoint 1
      @param ep2_name - variable holding context for endpoint 2
      @param ep3_name - variable holding context for endpoint 3
    */
    #define ZBOSS_DECLARE_DEVICE_CTX_3_EP(device_ctx_name, ep1_name, ep2_name, ep3_name) \
      ZB_AF_START_DECLARE_ENDPOINT_LIST(ep_list_##device_ctx_name)          \
        &ep1_name,                                                          \
        &ep2_name,                                                          \
        &ep3_name,                                                          \
      ZB_AF_FINISH_DECLARE_ENDPOINT_LIST;                                   \
      ZBOSS_DECLARE_DEVICE_CTX(device_ctx_name, ep_list_##device_ctx_name,  \
                               (ZB_ZCL_ARRAY_SIZE(ep_list_##device_ctx_name, zb_af_endpoint_desc_t*)))
    
    
    /**
      Declare application's device context for for-endpoint device
    
    
      @note Device has an additional Green Power endpoint if it is ZC or ZR
      and GPPB feature (Mandatory for Zigbee 3.0 ZC/ZR) is enabled.
    
    
      @param device_ctx_name - device context variable name
      @param ep1_name - variable holding context for endpoint 1
      @param ep2_name - variable holding context for endpoint 2
      @param ep3_name - variable holding context for endpoint 3
      @param ep4_name - variable holding context for endpoint 4
    */
    #define ZBOSS_DECLARE_DEVICE_CTX_4_EP(device_ctx_name, ep1_name, ep2_name, ep3_name, ep4_name) \
      ZB_AF_START_DECLARE_ENDPOINT_LIST(ep_list_##device_ctx_name)          \
        &ep1_name,                                                          \
        &ep2_name,                                                          \
        &ep3_name,                                                          \
        &ep4_name,                                                          \
      ZB_AF_FINISH_DECLARE_ENDPOINT_LIST;                                   \
      ZBOSS_DECLARE_DEVICE_CTX(device_ctx_name, ep_list_##device_ctx_name,  \
                               (ZB_ZCL_ARRAY_SIZE(ep_list_##device_ctx_name, zb_af_endpoint_desc_t*)))
    
    
    
    
    /** @cond DOXYGEN_INTERNAL_DOC */
    #if defined ZB_ENABLE_ZCL && !defined ZB_ZCL_DISABLE_REPORTING
    void zb_zcl_init_reporting_ctx(void);
    void zb_zcl_reset_reporting_ctx(void);
    #endif /* ZB_ENABLE_ZCL && !ZB_ZCL_DISABLE_REPORTING */
    /** @endcond */ /* DOXYGEN_INTERNAL_DOC */
    
    
    /* TODO: extend this ifdef*/
    #if defined ZB_ENABLE_ZCL || DOXYGEN
    /** @cond DOXYGEN_INTERNAL_DOC */
    /**
      Register device context.
      @param device_ctx - pointer to device context
     */
    void zb_af_register_device_ctx(zb_af_device_ctx_t *device_ctx);
    /** @endcond */ /* DOXYGEN_INTERNAL_DOC */
    /**
      Register device context.
      @param _device_ctx - Pointer to the device context
    
    
      @b Example:
      @snippet onoff_server/on_off_output_zc.c af_register_device_context
    */
    #define ZB_AF_REGISTER_DEVICE_CTX(_device_ctx) zb_af_register_device_ctx(_device_ctx)
    #endif /* defined ZB_ENABLE_ZCL */
    /**
     *  @brief Set Device user application callback.
     *  The macro sets a callback being called upon to need inform User App about change device attribute or
     *  need to execute H/W command
     *  @param func_ptr - a callback to set (of type @ref zb_callback_t).
     *  @hideinitializer
     *
     * @b Example:
     * @snippet onoff_server/on_off_output_zc.c zcl_register_device_cb_example_cb
     * @par Register callback:
     * @snippet onoff_server/on_off_output_zc.c zcl_register_device_cb
    */
    #define ZB_ZCL_REGISTER_DEVICE_CB(func_ptr) ZCL_CTX().device_cb = (func_ptr)
    
    
    /**
      Callback for notifying user about status of ZCL/ZDO command transmission
     */
    typedef void (*zb_af_transmission_res_cb_t) (zb_uint8_t status);
    
    
    /**
       Continue inconimg packet proicessing after ZG->zdo.af_data_cb returned TRUE
    
    
       @param param - incoming packet. Be sure it was initially passed to ZG->zdo.af_data_cb.
     */
    void zb_apsde_data_indication_cont(zb_uint8_t param);
    /** @} */ /* af_management_service */
    /*! @} */
    
    
    #endif /* ZBOSS_API_AF_H */
    

  • Please check that this file have not been modified.

    If this is not modified, please upload your full project for a review.

Related