Broadcast Leave Request

I need to send broadcast leave request to all the zigbee devices connected to the network. 

zdo_mgmt_leave_req function sends leave request to a particular device but we want to broadcast this request to all devices connected to the network, how do we do that?
we are using nrf Connect SDK V2.1.0, hardware - nrf52840 
int RemoveZigbeeDevice()
{
  zb_ret_t zb_err_code;
    zb_err_code = (zb_buf_get_out_delayed(TrvSendLeaveReq));
	if (!zb_err_code) {
		LOG_DBG("Buffer is full");
	}
 	return zb_err_code;


 }



void TrvSendLeaveReq (zb_uint8_t param)
{
	
      
   zb_bufid_t buf = param;
  
  zb_zdo_mgmt_leave_param_t *req = NULL;
  zb_uint8_t tsn;

  TRACE_MSG(TRACE_ERROR, "zb_leave_req", (FMT__0));
  req = ZB_BUF_GET_PARAM(buf, zb_zdo_mgmt_leave_param_t);
  LOG_DBG("send_leave 0x%04hX\n", RemoveZigbeeShortAddr());
  ZB_MEMSET(req->device_address, 0, sizeof(zb_ieee_addr_t));
  req->remove_children = ZB_FALSE;
  req->rejoin = ZB_FALSE;
  req->dst_addr = RemoveZigbeeShortAddr();
  tsn = zdo_mgmt_leave_req(param, leave_callback);


 
	
}



void leave_callback(zb_uint8_t param)
{
  zb_zdo_mgmt_leave_res_t *resp = (zb_zdo_mgmt_leave_res_t *)zb_buf_begin(param);

  TRACE_MSG(TRACE_ERROR, "LEAVE CALLBACK status %hd", (FMT__H, resp->status));
  
  
}
  • Hi,

    Unfortunately there are no options to broadcast that every device should leave. In addition, according to the spec, the validation of the leave request states that if the message is sent to a broadcast address, then the message shall be dropped and no further processing shall be performed.

    If you really want to automate the leaving of every device in the network you will have to script it yourself by for instance gathering all the device ids, and to not iterate through them with the leave network request command and not iterate to the next device before the device has left the network. Or you could have the coordinator to go through the neighbor table and send a leave command to every router listed with a flag stating that the routers should also remove their child-nodes from the network but keep in mind that this may leave you in a situation where you have routers that are not neighbors on the network and out of reach of the coordinator. 

    Kind regards,
    Andreas

Related