I’ve been working on a ZigBee project using the Nordic Light Bulb example and integrating it with ZigBee2MQTT. However, I’m facing an issue where I can’t trigger the device identification feature. After discussing with the ZigBee2MQTT team, they suspect the problem lies in my firmware. I’m reaching out to the community for help or any working references for NCS 2.8 with ZigBee identification. Here’s the main application code snippet for reference:
c
#include <zephyr/types.h>
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/logging/log.h>
#include <zephyr/drivers/sensor.h>
#include <zephyr/settings/settings.h>
#include <soc.h>
#include <dk_buttons_and_leds.h>
#include <zboss_api.h>
#include <zb_nrf_platform.h>
#include <zboss_api_addons.h>
#include <zb_mem_config_med.h>
#include <zigbee/zigbee_app_utils.h>
#include <zigbee/zigbee_error_handler.h>
#include “beelight.h”
#define ZIGBEE_NETWORK_STATE_LED DK_LED3
#define IDENTIFY_MODE_BUTTON DK_BTN4_MSK
static device_ctx_t dev_ctx;
ZB_ZCL_DECLARE_IDENTIFY_CLIENT_ATTRIB_LIST(identify_client_attr_list);
ZB_ZCL_DECLARE_IDENTIFY_SERVER_ATTRIB_LIST(identify_server_attr_list, &dev_ctx.identify_attr.identify_time);
static void start_identifying(zb_bufid_t bufid) {
ZVUNUSED(bufid);
if (ZB_JOINED()) {
if (dev_ctx.identify_attr.identify_time == ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE) {
zb_ret_t zb_err_code = zb_bdb_finding_binding_target(LIGHT_SENSOR_ENDPOINT);
if (zb_err_code == RET_OK) {
LOG_INF(“Enter identify mode”);
} else if (zb_err_code == RET_INVALID_STATE) {
LOG_WRN(“RET_INVALID_STATE - Cannot enter identify mode”);
} else {
ZB_ERROR_CHECK(zb_err_code);
}
} else {
LOG_INF(“Cancel identify mode”);
zb_bdb_finding_binding_target_cancel();
}
} else {
LOG_WRN(“Device not in a network - cannot enter identify mode”);
}
}
static void button_changed(uint32_t button_state, uint32_t has_changed) {
if (IDENTIFY_MODE_BUTTON & has_changed) {
if (IDENTIFY_MODE_BUTTON & button_state) {
// Button pressed
} else {
// Button released
if (!was_factory_reset_done()) {
ZB_SCHEDULE_APP_CALLBACK(start_identifying, 0);
}
}
}
check_factory_reset_button(button_state, has_changed);
}
static void toggle_identify_led(zb_bufid_t bufid) {
static int blink_status;
ZB_SCHEDULE_APP_ALARM(toggle_identify_led, bufid, ZB_MILLISECONDS_TO_BEACON_INTERVAL(100));
}
static void identify_cb(zb_bufid_t bufid) {
LOG_INF(“A”);
if (bufid) {
ZB_SCHEDULE_APP_CALLBACK(toggle_identify_led, bufid);
} else {
zb_ret_t zb_err_code = ZB_SCHEDULE_APP_ALARM_CANCEL(toggle_identify_led, ZB_ALARM_ANY_PARAM);
ZVUNUSED(zb_err_code);
}
}
int main(void) {
configure_gpio();
register_factory_reset_button(FACTORY_RESET_BUTTON);
ZB_ZCL_REGISTER_DEVICE_CB(zcl_device_cb);
ZB_AF_REGISTER_DEVICE_CTX(&light_sensor_ctx);
clusters_attr_init();
ZB_AF_SET_IDENTIFY_NOTIFICATION_HANDLER(LIGHT_SENSOR_ENDPOINT, identify_cb);
zigbee_enable();
LOG_INF(“Light sensor application started”);
return 0;
}
If anyone has a working implementation or can point me in the right direction, I’d greatly appreciate it. Let’s work together to resolve this issue!