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.
CODE1
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 function
ZDO_StartNetworkReq(&zdoStartReq); //Sending a request to the stack
break;
}
...
static void appZdoStartNetworkConf(ZDO_StartNetworkConf_t *startInfo) {
//Check if the node has successfully started the network
if (ZDO_SUCCESS_STATUS == startInfo->status) {
appState = APP_IN_NETWORK_STATE;
...
}
appPostGlobalTask();
}
CODE2
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!