This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2530: Why Only the parent device can request to leave, otherwise silently discard the frame in Z-Stack 3.0.1?

Part Number: CC2530
Other Parts Discussed in Thread: Z-STACK

I see there is difference in ZDO_ProcessMgmtLeaveReq implementation between Z-Stack 3.0.1 and Z-Stack Home 1.2.2a. In Z-Stack 3.0.1, it says "Only the parent device can request to leave, otherwise silently discard the frame" (the red codes in the followings)

void ZDO_ProcessMgmtLeaveReq( zdoIncomingMsg_t *inMsg )
{
  NLME_LeaveReq_t req;
  ZStatus_t       status;
  uint8           option;
  uint8 *msg = inMsg->asdu;
 
  if ( ( AddrMgrExtAddrValid( msg ) == FALSE                 ) ||
       ( osal_ExtAddrEqual( msg, NLME_GetExtAddr() ) == TRUE )    )
  {
    if ( ( ZG_BUILD_COORDINATOR_TYPE ) && ( ZG_DEVICE_COORDINATOR_TYPE ) )
    {
      // Coordinator shall drop the leave request for itself
      // section 3.6.1.10.3.1 R21
      return;
    }
    else
    {
      // Remove this device
      req.extAddr = NULL;
    }
  }
  else
  {
    // Remove child device
    req.extAddr = msg;
  }
  if ( ( ZG_BUILD_ENDDEVICE_TYPE ) && ( ZG_DEVICE_ENDDEVICE_TYPE ) )
  {
    //Only the parent device can request to leave, otherwise silently discard the frame
    if(inMsg->srcAddr.addr.shortAddr != _NIB.nwkCoordAddress)
    {
      return;
    }
  }

  option = msg[Z_EXTADDR_LEN];
  if ( option & ZDP_MGMT_LEAVE_REQ_RC )
  {
    req.removeChildren = TRUE;
  }

  if ( option & ZDP_MGMT_LEAVE_REQ_REJOIN )
  {
     req.rejoin = TRUE;
  }

  req.silent = FALSE;
 
  //According to R21 spec sec2.4.3.3.5.2 Mgmt leave rsp must contain the status response from the nwk leave processing.
  //Latest discussion in Zigbee indicates that mgmt leave rsp due to an OTA command must have status=success (9/12/16)
  status = ZSuccess;
 
  ZDP_MgmtLeaveRsp( inMsg->TransSeq, &(inMsg->srcAddr), status, FALSE );
 
  if ( ZG_BUILD_ENDDEVICE_TYPE )
  {
    // Stop polling and get ready to reset
    NLME_SetPollRate( 0 );
    NLME_SetResponseRate(0);
    NLME_SetQueuedPollRate(0);
  }
 
  NLME_LeaveReq(&req);
 
  if (! (option & ZDP_MGMT_LEAVE_REQ_REJOIN) )
  {
    if(req.extAddr == NULL)
    {
      bdb_setFN();
    }
  }
}

But I don't see related code in ZDO_ProcessMgmtLeaveReq implementation in Z-Stack Home 1.2.2a. Is this new in latest Zigbee spec?