Author Topic: [BitCloud] ZigBee NWK Leave frame when a device leaves on its own  (Read 1973 times)

0 Members and 1 Guest are viewing this topic.

Offline rflemingTopic starter

  • Regular Contributor
  • *
  • Posts: 73
  • Country: au
Hi guys (Alex :) ),

I've been looking at a few different units I have on hand with ZigBee and have found that when a router leaves the network on its own it broadcasts a "NWK Leave" frame. When this is done, I'm not 100% but it appears to clear up some of my tables on my coordinator such that when I get the device to join by association, my coorindator handles the announce frame issued by the new router.

On the other hand, if the NWK Leave frame was not issued over the network when I do a normal MGMT_LEAVE through a ZDP Request, the command is only handled internally on the router. So when I go to join the network by association once more, it gets authorization (event BC_EVENT_ACCESS_REQUEST is triggered), but the announce event isn't.

In summation, it appears that when a router leaves locally, no command is issued over the network. Thus when it joins the network once more by association its like it never left.

Cheers,
Ryan.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11269
  • Country: us
    • Personal site
Re: [BitCloud] ZigBee NWK Leave frame when a device leaves on its own
« Reply #1 on: July 28, 2016, 04:19:34 am »
The only thing that come to mind are  CS_LEAVE_REJOIN_CONTROL_ID and CS_LEAVE_NON_REJOIN_CONTROL_ID parameters. Both have "silent" member.

But it is normally set to 0 and none of the standard applications change it. But will not hurt to check.
Alex
 

Offline rflemingTopic starter

  • Regular Contributor
  • *
  • Posts: 73
  • Country: au
Re: [BitCloud] ZigBee NWK Leave frame when a device leaves on its own
« Reply #2 on: November 21, 2016, 05:26:27 am »
FYI.

Finally found after spending a lot of time looking for it...

If I am trying to get a node like a router to leave the network on its own, I should use a "NWK_LeaveReq_t" query passed to "NWK_LeaveReq" function. It doesn't appear to be documented anyway. Kind of just went searching through specifications and source code for things that resembled this.

Assigning the extended address member (deviceAddress) to 0. Assigning this to 0 will send a bradcast frame instead...yay!

Ryan.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11269
  • Country: us
    • Personal site
Re: [BitCloud] ZigBee NWK Leave frame when a device leaves on its own
« Reply #3 on: November 21, 2016, 05:31:23 am »
Actually, the correct way is to use ZDP command. Both WSNDemo and ZLLDemo contain examples of this. For example, here is the code from WSNDemo:
Code: [Select]
    case APP_LEAVING_NETWORK_STATE:
    {
      //Get the pointer to the request's payload
      ZDO_MgmtLeaveReq_t *zdpLeaveReq = &leaveReq.req.reqPayload.mgmtLeaveReq;

      visualizeNwkLeaving();
      //Configure parameters of the leave network ZDP request
      leaveReq.ZDO_ZdpResp =  appZdpLeaveResp; //Set the callback function
      leaveReq.reqCluster = MGMT_LEAVE_CLID; //Set the request' type
      leaveReq.dstAddrMode = APS_EXT_ADDRESS;
      COPY_EXT_ADDR(leaveReq.dstAddress.extAddress, *MAC_GetExtAddr());
      zdpLeaveReq->deviceAddr = 0; //The current node is requested to leave the network
      zdpLeaveReq->rejoin = 0; //Without rejoining the network after leaving it
      zdpLeaveReq->removeChildren = 1; //Command all end device children to leave the network as well
      zdpLeaveReq->reserved = 0;
      //Send the configure ZDP request to the stack
      ZDO_ZdpReq(&leaveReq);
    }
    break;
I don't see how this can not send a frame, especially with removeChildren set to "1".
« Last Edit: November 21, 2016, 05:34:25 am by ataradov »
Alex
 

Offline rflemingTopic starter

  • Regular Contributor
  • *
  • Posts: 73
  • Country: au
Re: [BitCloud] ZigBee NWK Leave frame when a device leaves on its own
« Reply #4 on: November 21, 2016, 06:20:18 am »
While you're arguably correct, when I issue this exact command (ctrl-c + ctrl-v) on my router code, it will only leave locally without broadcasting the NWK Leave frame, or any other frame. The NWK Leave frame is required when leaving a network else the coordinator will not know it has left, thus leaving a lot of information in various tables.

Testing your example, after I have issued the command and utilising the following callback:

Code: [Select]
void LeaveMe(ZDO_ZdpResp_t *zdpResp)
{
//PDS_Delete(PDS_ALL_EXISTENT_MEMORY); //clears both default and user space PDS
PDS_Delete(BC_ALL_MEMORY_MEM_ID); //clears all default PDS. Leaves user space in tact

HAL_WarmReset();
}

This happens:
  • Router Restarts and is awaiting a nwk to join
  • I Permit Joining on the Coordinator
  • Router joins the network as if it had never been in it at all
  • The Coordinator Assigns the same node ID as it previously did
  • The Router sends an announce frame over the network
  • The Coordinator responds to BC_EVENT_ACCESS_REQUEST but not the BC_ZDP_DEVICE_ANNOUNCE_RECEIVED event
  • All the information between the two units is kind of...fked. If the coordinator sends any commands to the router, zdp, zcl or others, the router responds correctly, but the coordinator doesn't wont acknowledge the response.
  • Reboot the Coordinator, everything works fine

In this process I also tried setting the
Code: [Select]
zdpLeaveReq->deviceAddr = 0; to my routers extended address and issuing the ZDP Command to my coordinator (from router), actioning my router to leave. It once again would leave, but still did not send the NWK Leave broadcast frame. It appears that this frame would only be sent over the network if another device addressing my router as the device to leave. Thus my router would only leave when processing a request from an external device, not its own and not as a response.

So my solution before broadcasts this frame manually and leaves the network as well :)

Yay fixed :)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf