SDK: nRF5_SDK_for_Thread_and_Zigbee_v4.1.0
Board: nRF52840
Hi, I'm a newbie in zigbee stack. I have been get started with the door lock example.
I want to make custom cluster adding some attributes.
so, I declare like this.
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_IDENTIFY_ATTRIB_LIST(identify_attr_list, &m_dev_ctx.identify_attr.identify_time); ZB_ZCL_DECLARE_GROUPS_ATTRIB_LIST(groups_attr_list, &m_dev_ctx.groups_attr.name_support); MY_ZB_ZCL_DECLARE_DOOR_LOCK_ATTRIB_LIST(door_lock_attr_list, &m_dev_ctx.door_lock_attr.lock_state, &m_dev_ctx.door_lock_attr.lock_type, &m_dev_ctx.door_lock_attr.actuator_enabled, &m_dev_ctx.door_lock_attr.door_state, &m_dev_ctx.door_lock_attr.operating_mode, &m_dev_ctx.door_lock_attr.auto_relock_time, &m_dev_ctx.door_lock_attr.sound_volume); ZB_ZCL_DECLARE_IAS_ZONE_ATTRIB_LIST(ias_zone_attr_list, &m_dev_ctx.ias_zone_attr.zone_state, &m_dev_ctx.ias_zone_attr.zone_type, &m_dev_ctx.ias_zone_attr.zone_status, &m_dev_ctx.ias_zone_attr.ias_cie_address, &m_dev_ctx.ias_zone_attr.cie_short_addr, &m_dev_ctx.ias_zone_attr.cie_ep); /* OTA cluster attributes data */ ZB_ZCL_DECLARE_OTA_UPGRADE_ATTRIB_LIST(ota_upgrade_attr_list, m_dev_ctx.ota_attr.upgrade_server, &m_dev_ctx.ota_attr.file_offset, &m_dev_ctx.ota_attr.file_version, &m_dev_ctx.ota_attr.stack_version, &m_dev_ctx.ota_attr.downloaded_file_ver, &m_dev_ctx.ota_attr.downloaded_stack_ver, &m_dev_ctx.ota_attr.image_status, &m_dev_ctx.ota_attr.manufacturer, &m_dev_ctx.ota_attr.image_type, &m_dev_ctx.ota_attr.min_block_reque, &m_dev_ctx.ota_attr.image_stamp, &m_dev_ctx.ota_attr.server_addr, &m_dev_ctx.ota_attr.server_ep, (uint16_t)NRF_DFU_HW_VERSION, OTA_UPGRADE_TEST_DATA_SIZE, ZB_ZCL_OTA_UPGRADE_QUERY_TIMER_COUNT_DEF); MY_ZB_HA_DECLARE_DOOR_LOCK_CLUSTER_LIST(door_lock_clusters, door_lock_attr_list, basic_attr_list, identify_attr_list, groups_attr_list, ias_zone_attr_list, ota_upgrade_attr_list); ZB_HA_DECLARE_DOOR_LOCK_EP(door_lock_ep, DOOR_LOCK_ENDPOINT, door_lock_clusters); ZB_HA_DECLARE_DOOR_LOCK_CTX(door_lock_ctx, door_lock_ep);
I have added some attributes to the existing door lock attribute list.
typedef enum { DOOR_STATE_OPEN = 0x00, DOOR_STATE_CLOSE = 0x01, } zb_door_lock_door_state_t; typedef struct { zb_uint8_t lock_state; zb_uint8_t lock_type; zb_bool_t actuator_enabled; zb_uint8_t door_state; zb_uint8_t operating_mode; zb_uint8_t auto_relock_time; zb_uint8_t sound_volume; } zb_zcl_door_lock_custom_attrs_t;
#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DOOR_LOCK_DOOR_STATE_ID(data_ptr) \ { \ ZB_ZCL_ATTR_DOOR_LOCK_DOOR_STATE_ID, \ ZB_ZCL_ATTR_TYPE_8BIT, \ ZB_ZCL_ATTR_ACCESS_READ_ONLY, \ (zb_voidp_t) data_ptr \ } #define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DOOR_LOCK_OPERATING_MODE_ID(data_ptr) \ { \ ZB_ZCL_ATTR_DOOR_LOCK_OPERATING_MODE_ID, \ ZB_ZCL_ATTR_TYPE_8BIT, \ ZB_ZCL_ATTR_ACCESS_READ_WRITE, \ (zb_voidp_t) data_ptr \ } #define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DOOR_LOCK_AUTO_RELOCK_TIME_ID(data_ptr) \ { \ ZB_ZCL_ATTR_DOOR_LOCK_AUTO_RELOCK_TIME_ID, \ ZB_ZCL_ATTR_TYPE_8BIT, \ ZB_ZCL_ATTR_ACCESS_READ_WRITE, \ (zb_voidp_t) data_ptr \ } #define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DOOR_LOCK_SOUND_VOLUME_ID(data_ptr) \ { \ ZB_ZCL_ATTR_DOOR_LOCK_SOUND_VOLUME_ID, \ ZB_ZCL_ATTR_TYPE_8BIT, \ ZB_ZCL_ATTR_ACCESS_READ_WRITE, \ (zb_voidp_t) data_ptr \ } /** @brief Declare attribute list for DoorLock cluster @param attr_list - attribute list name @param lock_state @param lock_type @param actuator_enabled @param door_state */ #define MY_ZB_ZCL_DECLARE_DOOR_LOCK_ATTRIB_LIST(attr_list, \ lock_state, \ lock_type, \ actuator_enabled, \ door_state, \ operating_mode, \ auto_relock_time, \ sound_volume) \ ZB_ZCL_START_DECLARE_ATTRIB_LIST(attr_list) \ ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DOOR_LOCK_LOCK_STATE_ID, (lock_state)) \ ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DOOR_LOCK_LOCK_TYPE_ID, (lock_type)) \ ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DOOR_LOCK_ACTUATOR_ENABLED_ID, (actuator_enabled)) \ ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DOOR_LOCK_DOOR_STATE_ID, (door_state)) \ ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DOOR_LOCK_OPERATING_MODE_ID, (operating_mode)) \ ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DOOR_LOCK_AUTO_RELOCK_TIME_ID, (auto_relock_time)) \ ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DOOR_LOCK_SOUND_VOLUME_ID, (sound_volume)) \ ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST
and I want to add ias zone attributes to the cluster.
typedef enum { DOORLOCK_LOW_BATTERY_BIT = 0x0008, DOORLOCK_DEADBOLT_BIT = 0x0100, DOORLOCK_AWAY_BIT = 0x0200, DOORLOCK_DOUBLELOCK_BIT = 0x0400, DOORLOCK_INTRUSION_BIT = 0x0800, DOORLOCK_FIRE_BIT = 0x1000, DOORLOCK_OPEN_ERROR_BIT = 0x2000, DOORLOCK_CLOSE_ERROR_BIT = 0x4000, DOORLOCK_PRANK_ALARM_BIT = 0x8000, } zb_door_lock_ias_zone_status_bits_t; typedef struct { zb_uint8_t zone_state; zb_uint16_t zone_type; zb_uint16_t zone_status; zb_uint64_t ias_cie_address; zb_uint16_t cie_short_addr; zb_uint8_t cie_ep; } zb_zcl_ias_zone_attrs_t;
It is successfully compiled and I send report ias zone attribute.
I added report code like this.
zb_uint16_t ias_zone_state = DOORLOCK_PRANK_ALARM_BIT | DOORLOCK_LOW_BATTERY_BIT; zb_zcl_status_t ret = zb_zcl_set_attr_val(DOOR_LOCK_ENDPOINT, ZB_ZCL_CLUSTER_ID_IAS_ZONE, ZB_ZCL_CLUSTER_SERVER_ROLE, ZB_ZCL_ATTR_IAS_ZONE_ZONESTATUS_ID, (zb_uint8_t*) &ias_zone_state, ZB_FALSE);
But, I called this code. The board always was freezing.
ZBOSS SIG: ZB_ZDO_SIGNAL_PRODUCTION_CONFIG_READY Production config is not present or invalid <info> zboss: DE AD 1E 02 CA 00 10 00|........ <info> zboss: AA 01 A0 01 02 00 00 00|........ <info> zboss: 01 00 00 00 01 00 00 00|........ <info> zboss: 01 00 00 00 00 00 00 00|........ <info> zboss: DE AD 1A 02 11 01 11 00|........ <info> zboss: 2B 08 04 07 00 00 00 00|+....... <info> zboss: EB 99 00 00 10 00 00 00|........ <info> zboss: 01 00 00 00 DE AD 12 02|........ <info> zboss: 11 01 12 00 2B 08 05 07|....+... <info> zboss: BA D5 DC FD D9 F0 1A 2B|.......+ <info> zboss: DE AD 16 02 11 01 13 00|........ <info> zboss: 2B 08 F7 03 04 00 00 00|+....... <info> zboss: 00 00 00 00 06 00 00 00|........ ZBOSS SIG: ZB_BDB_SIGNAL_DEVICE_REBOOT Joined network successfully DOORLOCK STATUS: AB <info> zboss: DE AD 12 02 12 01 14 00|........ <info> zboss: 1A 08 62 01 00 05 00 00|..b..... <info> zboss: 01 00 00 00 DE AD 12 02|........ <info> zboss: 12 01 15 00 1A 08 77 01|......w. <info> zboss: 00 05 00 00 01 00 00 00|........ <info> zboss: DE AD 12 02 12 01 16 00|........ <info> zboss: 60 08 5B 00 16 08 00 00|`.[..... <info> zboss: 3D 03 00 00 |=...
with above printing logs.
And I tried to "ZB_ZCL_IAS_ZONE_SEND_STATUS_CHANGE_NOTIFICATION_REQ" macro.
zb_buf_t buf = {0}; ZB_ZCL_IAS_ZONE_SEND_STATUS_CHANGE_NOTIFICATION_REQ( &buf, ZB_PIBCACHE_NETWORK_ADDRESS(), 0x02, DOOR_LOCK_ENDPOINT, DOOR_LOCK_ENDPOINT, ZB_AF_HA_PROFILE_ID, NULL, ZB_ZCL_IAS_ZONE_ZONE_STATUS_BATTERY, 0, ZB_ZCL_ATTR_IAS_ZONE_ZONESTATUS_ID, 0);
but, The result is similar with zb_zcl_set_attr_val function.
<info> zboss: DE AD 12 02 D5 03 1C 00|........ <info> zboss: 60 08 5B 00 71 00 00 00|`.[.q... <info> zboss: 1D 02 00 00 |....
debugging trace with gdb.
Program received signal SIGTRAP, Trace/breakpoint trap. 0x000275ca in zb_osif_serial_flush () at ../../../../../../sdk/Thread_and_Zigbee/external/zboss/osif/zb_nrf52_nrf_logger.c:141 141 if (buffered) (gdb) where full #0 0x000275ca in zb_osif_serial_flush () at ../../../../../../sdk/Thread_and_Zigbee/external/zboss/osif/zb_nrf52_nrf_logger.c:141 No locals. #1 0x000273ce in zb_nrf52_abort () at ../../../../../../sdk/Thread_and_Zigbee/external/zboss/osif/zb_nrf52_common.c:179 No locals. #2 0x00054554 in zb_zcl_ias_zone_write_attr_hook_server () No symbol table info available. #3 0x0005219c in zb_zcl_set_attr_val () No symbol table info available.
called "zb_nrf52_abort" without any logs.
Is this correct way to add the attributes of the cluster?
Why the board is stuck after calling 'zb_zcl_set_attr_val' function?
Is this "zb_zcl_set_attr_va" function does send data to coordinator? What purpose is this function?
how can I send updated attribute data to coordinator?