void ZDO_ProcessMgmtPermitJoinReq( zdoIncomingMsg_t *inMsg )
{
uint8 stat;
uint8 duration;
#if (ZG_BUILD_COORDINATOR_TYPE)
if(ZG_DEVICE_COORDINATOR_TYPE)
{
//If zgAllowRemoteTCPolicyChange is set to FALSE, the request from other
//devices cannot affect the Trust Center policies
if((zgAllowRemoteTCPolicyChange == 0) && (inMsg->srcAddr.addr.shortAddr!= 0x0000))
{
return;
}
}
#endif
duration = inMsg->asdu[ZDP_MGMT_PERMIT_JOIN_REQ_DURATION];
// Per R21 Spec this field is not longer relevant 2.4.3.3.7.2 (Mgmt_Permit_Joining_req Effect on Receipt)
//tcsig = inMsg->asdu[ZDP_MGMT_PERMIT_JOIN_REQ_TC_SIG];
// Per R21 Spec this duration cannot last forever 2.4.3.3.7.2 (Mgmt_Permit_Joining_req Effect on Receipt)
if(duration == 0xFF)
{
duration = 0xFE;
}
duration = 0xFF; //I set the var to 255,But it still doesn't work.
// Set the network layer permit join duration
stat = (byte) NLME_PermitJoiningRequest( duration );
//Handle the permit joining if running a distributed network
if(APSME_IsDistributedSecurity())
{
ZDSecMgrPermitJoining( duration );
}
// Handle the Trust Center Significance
if ( ZG_SECURE_ENABLED && ZG_BUILD_COORDINATOR_TYPE && ZG_DEVICE_COORDINATOR_TYPE )
{
ZDSecMgrPermitJoining( duration );
}
// Send a response if unicast
if ( !inMsg->wasBroadcast )
{
ZDP_MgmtPermitJoinRsp( inMsg->TransSeq, &(inMsg->srcAddr), stat, false );
}
}
YiKai Chen:
Zigbee 3.0 doesn’t allow permanent permit join so you have to start a periodic timer event to enable permit join.
Alvin Chen:
回复 YiKai Chen:
请采用YK的建议,做定时器或者按键触发。
zhou jiangtao:
回复 Alvin Chen:
这个我尝试过,奇怪的是第二次调permit就不起作用了。
下面这个函数是产生一个消息Mgmt_Permit_Join_req,fillAndSend, 然后ZDO_ProcessMgmtPermitJoinReq函数来处理消息,并调用NLME_PermitJoiningRequest( duration );
首次是可以的,经过第二次,设备就连接不上了。void bdb_nwkSteeringDeviceOnNwk(void)
{zAddrType_t dstAddr;dstAddr.addr.shortAddr = NWK_BROADCAST_SHORTADDR_DEVZCZR;dstAddr.addrMode = AddrBroadcast;// Trust Center significance is always trueZDP_MgmtPermitJoinReq( &dstAddr, BDBC_MIN_COMMISSIONING_TIME, TRUE, FALSE );osal_start_timerEx( bdb_TaskID, EVT_PERMIT_JOIN, 3000);//ZDP_MgmtPermitJoinReq( &dstAddr, 0xFF, TRUE, FALSE );
}
zhou jiangtao:
回复 zhou jiangtao:
EVT_PERMIT_JOIN是我定义的事件,我跟踪了,确实有多次调用到,分别 尝试了3秒和30秒,180秒。
YiKai Chen:
回复 zhou jiangtao:
你第二次调NLME_PermitJoiningRequest( duration )的duration用多少?
zhou jiangtao:
回复 YiKai Chen:
duration用多少?你没仔细看我上面的回复吧?第二次和第一次不都是上面那同一个函数吗?
zhou jiangtao:
回复 zhou jiangtao:
宏BDBC_MIN_COMMISSIONING_TIME分别用3秒,30,180秒试过了。
YiKai Chen:
回复 zhou jiangtao:
你之前貼的程序沒有duration的長度吧
zhou jiangtao:
回复 YiKai Chen:
BDBC_MIN_COMMISSIONING_TIME就是duration
YiKai Chen:
回复 zhou jiangtao:
用NLME_PermitJoiningRequest試試