[BitCloud] How shall the stack inform the app layer that it needs to rejoin? - Page 1
Forum section: electronics / general

author: danergo
author_rank: Regular Contributor
timestamp: May 14, 2018, 05:38:06 pm
content: Hello,I've a quite good working ZB network, and now I found a new issue with it:Every time, when I restart the Coordinator, all my EDs, and Routers are disconnected (that's not a problem), however they never gets reconnected until I manually reboot them as well.My question is, how the stack shall notify the app layer that it needs to do something, and what shall the app layer do exactly?What I have is a timer which tries pinging the C periodically, and when it does not succeed, it restarts the stack (or I thought it restarts it):Code://Try to pingappAPS_DataReq.APS_DataConf = appAPSDataConf;APS_DataReq(&appAPS_DataReq);void appAPSDataConf(APS_DataConf_t *confInfo) {if (APS_SUCCESS_STATUS == confInfo->status) __RESET_PING_TIMERelse {appInitialization();appState = APP_STARTING_NETWORK_STATE;appPostGlobalTask();}}//APP_STARTING_NETWORK_STATEZDO_StartNetworkReq(&zdoStartReq);Thank you!

author: ataradov
author_rank: Super Contributor
timestamp: May 14, 2018, 06:15:28 pm
content: You need to wait for ZDO_NETWORK_LOST_STATUS and ZDO_NETWORK_LEFT_STATUS notifications sent via ZDO_MgmtNwkUpdateNotf().Before you get ZDO_NETWORK_LEFT_STATUS the stack is in the network (before ZDO_NETWORK_LOST_STATUS) or attempting to restore the connectivity (after ZDO_NETWORK_LOST_STATUS).It will take quite some time, but those messages should always come. If you don't want to wait, then you need to do something like ZDO_ResetNetworkReq() followed by the start request.EDIT: But for routers it is different, since routers can be in the network without the coordinator. There you actually need to detect connectivity loss (the way you do in the example will work), and actively leave the network and start again.EDIT2: And even for EDs the first part will not apply as long as their parent router is still in the network. But if you implement leave and rejoin procedure for routers, then EDs will eventually notice and let you know that.

author: danergo
author_rank: Regular Contributor
timestamp: June 04, 2018, 09:22:55 pm
content: Thank you.Now I checked my architecture and I've a mechanism which "pings" the C periodically, and if it does not answer it resets the whole stack.This works fine, I just have debugged it. Even after resetting the C, the Router detects the missing reply for its ping request, and then it restarts the stack, and after a few seconds it rejoins successfully.Now the thing is that I have the exact same software running on a custom hw which does not have any serial interface for debugging.I'm trying to figure out what could have happened when it lose the network and don't rejoin automatically.I'm pretty sure that my custom HW pings the C and it fails, so it goes to reset. However if the board after reset is not able to join the network, the periodical ping request won't start either.So I would need some loop if the connection fails for the first time.CODE1Code:void APL_TaskHandler(void) {switch (appState) {...case APP_STARTING_NETWORK_STATE:{NWK_JoinControl_t joinControl = {.method = NWK_JOIN_BY_DEFAULT,.secured = true,.discoverNetworks = true,.annce = true};CS_WriteParameter(CS_JOIN_CONTROL_ID, &joinControl);//Starting network (results in joining to or forming a ZigBee network)zdoStartReq.ZDO_StartNetworkConf = appZdoStartNetworkConf; //Setting the callback functionZDO_StartNetworkReq(&zdoStartReq); //Sending a request to the stackbreak;}...static void appZdoStartNetworkConf(ZDO_StartNetworkConf_t *startInfo) {//Check if the node has successfully started the networkif (ZDO_SUCCESS_STATUS == startInfo->status) {appState = APP_IN_NETWORK_STATE;...}appPostGlobalTask();}CODE2Code:static void appZdoNwkUpdateHandler(ZDO_MgmtNwkUpdateNotf_t *updateParam) {switch (updateParam->status){case ZDO_NETWORK_LOST_STATUS:/** Indicates parent loss. After issuing this notification, the stack automatically* attempts to rejoin the network. This status can be received only on end* devices.*/appState = APP_STOP_STATE;...Questions:1.) In CODE1, Is that right? I mean, it will keep calling "ZDO_StartNetworkReq" until it does not return a ZDO_SUCCESS_STATUS. Right?2.) In CODE2, the comment section says true? Only EDs can receive the "LOST_STATUS"? (because I have a deadend there, which prevents the node to rejoin /APP_STOP_STATE has no following state/)3.) Also it is saying that the stack will attempt to rejoin. Even if the state sets to APP_STOP_STATE?4.) What would be the desired state in this case?Thank you!

author: ataradov
author_rank: Super Contributor
timestamp: June 04, 2018, 09:31:56 pm
content: 1. It is technically correct, but depending on the size of your network, you may want to introduce some delay between the failure and another attempt. Otherwise it is possible that device will just step on each other and the whole network rejoin will be extremely slow.2. As far as I remember, ZDO_NETWORK_LOST_STATUS can happen on the router only as a result of intentional internal or external request to leave the network. Routers have no periodic network loss detection.

author: danergo
author_rank: Regular Contributor
timestamp: June 04, 2018, 09:43:12 pm
content: So for 2. it is technically impossible that my router goes into this state if I don't ask it to disconnect from the network?BTW network size is way too small, only has 1 C and 1 R.

author: ataradov
author_rank: Super Contributor
timestamp: June 04, 2018, 09:45:25 pm
content: Yes, and also of you control entire network. Other devices in the network may also send leave request, and you will see the notification in that case as well. But this only happens under application control.