利用freescale z-stack的serialApp做了一个结点离开网络的实验.ZC00有一孩子ZE0A。
现在SerialApp.c中修改void SerialApp_HandleKeys( byte shift, byte keys )函数如下:
void SerialApp_HandleKeys( byte shift, byte keys )
{
// Shift is used to make each button/switch dual purpose.
if ( shift )
{
if ( keys & EVAL_SW1 )
{
}
if ( keys & EVAL_SW2 )
{
}
if ( keys & EVAL_SW3 )
{
}
if ( keys & EVAL_SW4 )
{
}
}
else
{
if ( keys & EVAL_SW1 )
{
}
if ( keys & EVAL_SW2 )
{
// Initiate an End Device Bind Request for the mandatory endpoint
ZDApp_SendEndDeviceBindReq( SerialApp_epDesc.endPoint );
}
if ( keys & EVAL_SW3 )
{
//添加内容begin
zAddrType_t tempdstAddr;
tempdstAddr.addrMode=Addr16Bit;
tempdstAddr.addr.shortAddr =NLME_GetCoordShortAddr();
ZDP_MgmtLeaveReq(&tempdstAddr,((byte *)NLME_GetExtAddr()),FALSE);
//添加内容end
}
if ( keys & EVAL_SW4 )
{
// Initiate a Match Description Request (Service Discovery)
// for the mandatory endpoint
ZDApp_AutoFindDestination( SerialApp_epDesc.endPoint );
}
}
}
现首先让ZE0A离开网络,操作过程即按下ZE0A的SW3,sniffer抓下的包如下:
ZE0A:61 88 e4 ec c 0 0 a 0 4 0 0 0 a 0 7 1 0 0 34(mgmt_leave_req) 0 0 0 21 0 8 1 6 22 23 24 25 26 27
ZC00:2 0 e4
ZE0A:63 88 e5 ec c 0 0 a 0 4
ZC00:12 0 e5
ZC00:61 88 4e ec c a 0 0 0 5 0 a 0 0 0 1 1 4(leave command) 40(request,removechildren=0)
ZE0A:2 0 4e
ZE0A:61 88 e6 ec c 0 0 a 0 5 0 0 0 a 0 1 2 4(leave command) 0 (indication,removechildren=0)
ZC00:2 0 e6
ZE0A:63 c8 e7 ec c 0 0 1 6 22 23 24 25 26 27 4(poll data)
ZC00:41 8c 50 ec c 1 6 22 23 24 25 26 27 0 0
疑问1:这一过程实际上是ZE0A自己让自己离开。添加的代码的参数对吗?
疑问2:执行的效果ZE0A确实离开了网络,因为它不能再收发串口的包了。但是离开网络的过程中,ZE0A向ZC00发送了NWK_LEAVE_CMD(indication,0)之后,是否还应该发送NLME_DISASSOCIATE(Devices wishes to leave)?
疑问3:如何调用函数,使leave command的command option中,removechildren=1?
|