Hi,
Here's my setup:
Custom board built with nRF52840
nRF5_SDK_for_Thread_and_Zigbee_v4
Segger Embedded Studio for ARM v3.52
I have built a Zigbee Coordinator and a Zigbee Router using your cli_agent_router example. I can get ONE Router to connect to the Coordinator. But that's it. When I attempt to connect a second Router, it fails in my zboss_signal_handler() at ZB_BDB_SIGNAL_DEVICE_FIRST_START
void zboss_signal_handler(zb_bufid_t bufid) { zb_zdo_app_signal_hdr_t * p_sg_p = NULL; zb_zdo_app_signal_type_t sig = zb_get_app_signal(bufid, &p_sg_p); zb_ret_t status = ZB_GET_APP_SIGNAL_STATUS(bufid); zb_ret_t ret_code = RET_OK; zb_bool_t comm_status = ZB_TRUE; switch (sig) { case ZB_ZDO_SIGNAL_PRODUCTION_CONFIG_READY: // At this point Zigbee stack attempted to load production configuration from NVRAM. // This step is performed each time the stack is initialized. // // Note: if it is necessary for a device to have a valid production configuration to operate (e.g. due to legal reasons), // the application should implement the customized logic for this signal (e.g. assert on the signal status code). // if (status != RET_OK) { logit("zboss_signal_handler: ZB Production config is not present or invalid"); } break; case ZB_ZDO_SIGNAL_SKIP_STARTUP: // At this point Zigbee stack: // - Initialized the scheduler. // - Initialized and read NVRAM configuration. // - Initialized all stack-related global variables. // // Next step: perform BDB initialization procedure (see BDB specification section 7.1). // logit("Zigbee stack initialized"); comm_status = bdb_start_top_level_commissioning(ZB_BDB_INITIALIZATION); break; case ZB_BDB_SIGNAL_DEVICE_FIRST_START: // At this point Zigbee stack is ready to operate and the BDB initialization procedure has finished. // There is no network configuration stored inside NVRAM. // // Next step: // - If the device implements Zigbee router or Zigbee end device, // perform network steering for a node not on a network (see BDB specification section 8.3). // - If the device implements Zigbee coordinator, // perform network formation (see BDB specification section 8.4). // if (status == RET_OK) { logit("zboss_signal_handler: ZB Device started fro the first time - Start network steering"); comm_status = bdb_start_top_level_commissioning(ZB_BDB_NETWORK_STEERING); } else { logit("zboss_signal_handler: ZB Failed to initialize Zigbee stack - Status [%d] retry after 1 second", status); ret_code = ZB_SCHEDULE_APP_ALARM((zb_callback_t)bdb_start_top_level_commissioning, ZB_BDB_NETWORK_STEERING, ZB_TIME_ONE_SECOND); } break; case ZB_BDB_SIGNAL_DEVICE_REBOOT: // At this point Zigbee stack is ready to operate and the BDB initialization procedure has finished. // There is network configuration stored inside NVRAM, so the device will try to rejoin. // // Next step: if the device implement Zigbee router or end device, and the initialization has failed, // perform network steering for a node on a network (see BDB specification section 8.2). // if (status == RET_OK) { zb_ext_pan_id_t extended_pan_id; char ieee_addr_buf[17] = {0}; int addr_len; zb_get_extended_pan_id(extended_pan_id); addr_len = ieee_addr_to_str(ieee_addr_buf, sizeof(ieee_addr_buf), extended_pan_id); if (addr_len < 0) { strcpy(ieee_addr_buf, "unknown"); } else if(!ZB_IS_64BIT_ADDR_ZERO(extended_pan_id)) { sprintf(&m_meshNode.zigbeePanIdCurrent[0], "%s,%04hx", NRF_LOG_PUSH(ieee_addr_buf), ZB_PIBCACHE_PAN_ID()); } logit("zboss_signal_handler: ZB Joined network successfully on reboot signal - Extended PAN ID [%s] PAN ID [0x%04hx]", NRF_LOG_PUSH(ieee_addr_buf), ZB_PIBCACHE_PAN_ID()); } else { NRF_LOG_INFO("zboss_signal_handler: ZB Unable to join the network - start network steering"); comm_status = bdb_start_top_level_commissioning(ZB_BDB_NETWORK_STEERING); } break; case ZB_BDB_SIGNAL_STEERING: // At this point the Zigbee stack has finished network steering procedure. // The device may have rejoined the network, which is indicated by signal's status code. // // Next step: // - If the device implements Zigbee router and the steering is not successful, // retry joining Zigbee network by starting network steering after 1 second. // - It is not expected to finish network steering with error status if the device implements Zigbee coordinator (see BDB specification section 8.2). // if (status == RET_OK) { zb_ext_pan_id_t extended_pan_id; char ieee_addr_buf[17] = {0}; int addr_len; zb_get_extended_pan_id(extended_pan_id); addr_len = ieee_addr_to_str(ieee_addr_buf, sizeof(ieee_addr_buf), extended_pan_id); if (addr_len < 0) { strcpy(ieee_addr_buf, "unknown"); } else if(!ZB_IS_64BIT_ADDR_ZERO(extended_pan_id)) { sprintf(&m_meshNode.zigbeePanIdCurrent[0], "%s,%04hx", NRF_LOG_PUSH(ieee_addr_buf), ZB_PIBCACHE_PAN_ID()); } logit("zboss_signal_handler: ZB Joined network successfully - Extended PAN ID [%s] PAN ID [0x%04hx]", NRF_LOG_PUSH(ieee_addr_buf), ZB_PIBCACHE_PAN_ID()); // Send WHO AM I data to the Coordinator (gateway) start_zigbee_whoami_timer(); } else { logit("zboss_signal_handler: ZB Restart network steering after 1 second (status: %d)", status); ret_code = ZB_SCHEDULE_APP_ALARM((zb_callback_t)bdb_start_top_level_commissioning, ZB_BDB_NETWORK_STEERING, ZB_TIME_ONE_SECOND); } break; case ZB_ZDO_SIGNAL_LEAVE: // This signal is generated when the device itself has left the network by sending leave command. // // Note: this signal will be generated if the device tries to join legacy Zigbee network and the TCLK // exchange cannot be completed. In such situation, the ZB_BDB_NETWORK_STEERING signal will be generated // afterwards, so this case may be left unimplemented. // if (status == RET_OK) { zb_zdo_signal_leave_params_t * p_leave_params; p_leave_params = ZB_ZDO_SIGNAL_GET_PARAMS(p_sg_p, zb_zdo_signal_leave_params_t); logit("zboss_signal_handler: ZB Network left - Leave type [%d]", p_leave_params->leave_type); // FIX: attempt to rejoin //zb_retry_join(p_leave_params->leave_type); } else { logit("zboss_signal_handler: ZB Unable to leave network - Status [%d]", status); } break; case ZB_ZDO_SIGNAL_LEAVE_INDICATION: // This signal is generated on the parent to indicate, that one of its child nodes left the network. // { zb_zdo_signal_leave_indication_params_t * leave_params = ZB_ZDO_SIGNAL_GET_PARAMS(&sig, zb_zdo_signal_leave_indication_params_t); zb_uint16_t short_addr = zb_address_short_by_ieee(leave_params->device_addr); logit("zboss_signal_handler: ZB Signal Leave - short address [%hx]", short_addr); } break; case ZB_ZDO_SIGNAL_DEVICE_UPDATE: // This signal notifies the Zigbee Trust center (usually implemented on the coordinator node) // or parent router application once a device joined, rejoined, or left the network. // // For more information see table 4.14 of the Zigbee Specification (R21). // { zb_zdo_signal_device_update_params_t * p_update_params = ZB_ZDO_SIGNAL_GET_PARAMS(p_sg_p, zb_zdo_signal_device_update_params_t); // FIX: Should I forward this information onto the Coordinator (gateway)? logit("zboss_update_handler: ZB Device update received - short address [%hx] Status [%d]", p_update_params->short_addr, p_update_params->status); } break; case ZB_ZDO_SIGNAL_DEVICE_ANNCE: // This signal is generated when a Device Announcement command is received by the device. // Such packet is generated whenever a node joins or rejoins the network, so this signal may be used to track the number of devices. // // Note: since the Device Announcement command is sent to the broadcast address, this method may miss some devices. // The complete knowledge about nodes has only the coordinator. // // Note: it may happen, that a device broadcasts the Device Announcement command and is removed by the coordinator afterwards, // due to security policy (lack of TCLK exchange). // { zb_zdo_signal_device_annce_params_t * dev_annce_params = ZB_ZDO_SIGNAL_GET_PARAMS(&sig, zb_zdo_signal_device_annce_params_t); logit("zboss_signal_handler: ZB New device commissioned or rejoined - short address [%hx]", dev_annce_params->device_short_addr); } break; case ZB_ZDO_SIGNAL_DEVICE_AUTHORIZED: // This signal notifies the Zigbee Trust center application (usually implemented on the coordinator node) // about authorization of a new device in the network. // // For Zigbee 3.0 (and newer) devices this signal is generated if: // - TCKL exchange procedure was successful // - TCKL exchange procedure timed out // // If the coordinator allows for legacy devices to join the network (enabled by zb_bdb_set_legacy_device_support(1) API call), // this signal is generated: // - If the parent router generates Update Device command and the joining device does not perform TCLK exchange within timeout. // - If the TCLK exchange is successful. // { zb_zdo_signal_device_authorized_params_t * p_authorize_params; p_authorize_params = ZB_ZDO_SIGNAL_GET_PARAMS(p_sg_p, zb_zdo_signal_device_authorized_params_t); logit("zboss_signal_handler: ZB Device authorization - short address [%04hx] authorization type [%d] status [%d]", p_authorize_params->short_addr, p_authorize_params->authorization_type, p_authorize_params->authorization_status); } break; case ZB_NWK_SIGNAL_NO_ACTIVE_LINKS_LEFT: // This signal informs the application that all links to other routers has expired. // In such situation, the node can communicate only with its children. // // Example reasons of signal generation: // - The device was brought too far from the rest of the network. // - There was a power cut and the whole network suddenly disappeared. // // Note: This signal is not generated for the coordinator node, since it may operate alone // in the network. // logit("zboss_signal_handler: ZB Parent is unreachable"); break; default: // Unimplemented signal. For more information see: zb_zdo_app_signal_type_e and zb_ret_e logit("zboss_signal_handler: ZB Unimplemented signal [%d] Status [%d]", sig, status); break; } if (bufid) { zb_buf_free(bufid); } }
It returns "zboss_signal_handler: ZB Failed to initialize Zigbee stack - Status [-1] retry after 3 seconds". It then continues to fail in the ZB_BDB_SIGNAL_STEERING event. Note, this only happens for the second Router to attach to the Coordinator.
Attached is a Wireshark Zigbee trace of the second Router attempting to connect.
Thanks in advance for any help!
John