cancel
Showing results for 
Search instead for 
Did you mean: 

Zigbee connection control

oarslan
Associate II

Hello,

I have configured a Zigbee network using an STM32WB55 MCU with 1 coordinator device and 5 end devices. However, since I cannot check whether the Zigbee connection is lost or not, I am resetting the end devices every 1 minute using NVIC_SystemReset();. Instead of this, I am looking for a function that checks the connection status. Is this possible?

During debugging, I see that the static void APP_ZIGBEE_NwkForm(void) function is used for joining the network, but after joining the network, there is no check for whether the device is still connected. I would like to check if the device is still connected to the network after some time and if not, call the function to rejoin the network.

Is there a variable or function available for this check? I would greatly appreciate your support.

10 REPLIES 10
Ouadi
ST Employee

Hello @oarslan,

Thanks for contacting us, please have a look on this post hoping that answers your question :

 STM32wb55 Zigbee Network connection status 

Best regards,

Ouadi

oarslan
Associate II

Hi,

First of all, thank you for your attention. We reviewed your response and tried it in our code. Unfortunately, we didn't get positive results. We might be making a mistake somewhere. We placed the function you provided in the "app_zigbee.c" file within the ROUTER code, inside the "/* USER CODE BEGIN FD_LOCAL_FUNCTIONS */" section. Then we called this function within the "APP_ZIGBEE_StackLayersInit" function. However, when we did this, the connection was not re-established.

I have a few points where I think there might be an error that I'd like to ask about: "CFG_TIM_ZIGBEE_APP_ONOFF_BACK_TO_ONESHOT, TS_ID1,HW_TS_SERVER_1S_NB_TICKS, APP_ZIGBEE_Rejoin_cb"—should we define these values ourselves, or should they be called from other libraries? If we need to define them ourselves, what should their values be?

Best Regards,

Hello @oarslan,

The code attached in that post allows to detect the loss of connection over the ZB_NWK_STATUS_CODE_PARENT_LINK_FAILURE indication on the End device side, you have then to implement the right function to perform a reconnection as follow : 

#define HW_TS_SERVER_1S_NB_TICKS                    (4*500*1000/CFG_TS_TICK_VAL) /* 4s */ 
/**
 * @brief  Zigbee Rejoin Callback
 * @param  None
 * @retval None
 */
 static void APP_ZIGBEE_Rejoin_cb(void){
  APP_DBG("Rejoin Callback");
  if(ZbStartupRejoinWait(zigbee_app_info.zb) != ZB_STATUS_SUCCESS) {
       /* Handle error. Try to rejoin again later? */
        APP_DBG("Rejoin failure / Retry in 20 seconds");
  }
  else 
  {
       APP_DBG("Rejoin success");
  }
  HW_TS_Create(CFG_TIM_ZIGBEE_APP_ONOFF_BACK_TO_ONESHOT, &TS_ID1, hw_ts_SingleShot, APP_ZIGBEE_OnOff_Toggle);    
  HW_TS_Start(TS_ID1, 10*HW_TS_SERVER_1S_NB_TICKS);
return;
}

Best regards,

Ouadi

 

oarslan
Associate II

 

Hi,

You mentioned that the connection loss can be detected on the end device side with the ZB_NWK_STATUS_CODE_PARENT_LINK_FAILURE indication. Is this code also applicable for a router? Because our network consists only of a coordinator and routers, with no end devices.

If this is valid for the router, I'm encountering an error and a warning with the code you provided:

  • "warning: implicit declaration of function 'ZbStartupRejoinWait'; did you mean 'ZbStartupRejoin'?"
  • "error: 'APP_ZIGBEE_OnOff_Toggle' undeclared (first use in this function)"
Best Regards,
 

Hello,

The Parent Link Failure indication is used only for the end devices which are attached to a parent/ coordinator, the behavior is not the same for the routers which keeps the network alive even when the coordinator leave the network. 

My answer was related to the configuration you mentioned on the top of this post : 1 coordinator/ 5 end devices.

Now, can you please provide more details on your setup and some inputs logs, Wireshark captures to demonstrate that your devices leaves the network ?

Regards,

Ouadi

oarslan
Associate II

Hi,

Our network setup is as follows:

It consists of 1 coordinator and hundreds of routers connected to this coordinator (currently we are testing with 5 routers). The reason we chose to use the devices as routers instead of end devices is that our router devices will be placed in a single line with 5 meters between them. If we had used them as end devices, the devices farther away would not have been able to connect to the coordinator.

Each of our router devices transmits specific sensor data to the coordinator through other routers when certain conditions are met. When I monitor the data arriving at the coordinator, I notice that after a while, the data flow stops, and no data is transmitted afterward. However, when we use the "NVIC_SystemReset();" function as mentioned earlier, the connection is reestablished from scratch, and the data flow continues. Therefore, I believe the connection is lost, and we are unable to reconnect.

Regards,

Ouadi
ST Employee

Hi,

The data transmission failure can not only be caused by a loss of the connection at the stack level but may be due to a wrong implementation on the app side.

To further analyze this case, I recommend to sniff the network and share with us the captures and logs of the concerned devices.

Regards,

Ouadi

Hi,

Thank you. As you mentioned, the issue was indeed caused by something wrong in the implementation rather than a connection loss.

I have one more question. Do we need to perform any additional configuration for the routers to send data to the coordinator through other routers? How can we determine if a router is sending data directly or through other routers, and is it possible to know through which routers the data has passed?

Regards,

Hi,

The management of the routing is done by Zigbee stack with no other configuration on the application layer, however, application can decide which routing mode to use :table routing, broadcast, multicast..

To determine which node is sending the original message, you can use the Source address information of the incoming APS message using the structure ZbApsAddrT.

Best regards,

Ouadi