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.

ZDP_MgmtLeaveReq请求失败

版本2.5.1a.应用在协调器中,目的是把路由器移除网络。

相关代码如下:

  

      zAddrType_t leaveid;
      uint8 *extaddr;
      extaddr=pkt->srcAddr.addr.extAddr;
      leaveid.addrMode=(afAddrMode_t) Addr16Bit;
      leaveid.addr.shortAddr=pkt->srcAddr.addr.shortAddr;
      ZDP_MgmtLeaveReq(&leaveid,extaddr,0,0,0);

返回值显示成功发送,但是节点未移除

  • 已定义 ZDO_MGMT_LEAVE_REQUEST
                 ZDO_MGMT_LEAVE_RESPONSE

  • 注意到你的厂地址和短地址都是从 pkt->srcAddr 获取,而pkt->srcAddr.addr 是一个union, 这意味这 长短地址两者最多只有一个是正确的,取决于 pkt->srcAddr.addrMode 。 所以你的代码的问题是,地址错误。 可以使用 地址查询API获取 已知短地址的长地址(或已知长地址查询短地址)。 参考 

    APSME_LookupExtAddr()  APSME_ LookupNwkAddr () 

  • 首先 是获取 节点的MAC和网络地址,这个完成后

     

     其他需要注意的就是 

        #define ZDO_MGMT_LEAVE_REQUEST    

        #define ZDO_MGMT_LEAVE_RESPONSE

    这2个定义 必须在协调器和节点都要定义才可以

  • ZDP_MgmtLeaveReq(&leaveid,extaddr,0,0,0);这个函数里的参数设置错了

    ZDP_MgmtLeaveReq(&leaveid,extaddr,1,0,0);第三个参数是1才会移除子设备

    @fn ZDP_MgmtLeaveReq
    *
    * @brief This builds and send a Mgmt_Leave_req message.
    *
    * @param dstAddr - destination address of the message
    * IEEEAddr - IEEE adddress of device that is removed
    * RemoveChildren - set to 1 to remove the children of the
    * device as well. 0 otherwise.
    * Rejoin - set to 1 if the removed device should rejoin
    afterwards. 0 otherwise.
    *
    * @return afStatus_t