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:
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
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