在工程simpleapp工程文件中有个sapi.c文件中有个API专门指定某个设备是否可以入网 /****************************************************************************** * @fn zb_PermitJoiningRequest * * @brief The zb_PermitJoiningRequest function is used to control the * joining permissions and thus allow or disallow new devices from * joining the network. * * @param destination - The destination parameter indicates the address * of the device for which the joining permissions * should be set. This is usually the local device * address or the special broadcast address that denotes * all routers and coordinator ( 0xFFFC ). This way * the joining permissions of a single device or the * whole network can be controlled. * timeout - Indicates the amount of time in seconds for which * the joining permissions should be turned on. * If timeout is set to 0x00, the device will turn off the * joining permissions indefinitely. If it is set to 0xFF, * the joining permissions will be turned on indefinitely. * * * @return ZB_SUCCESS or a failure code * */ / ****************************************************************************** ?*@ FN zb_PermitJoiningRequest ?* ?*@简述zb_PermitJoiningRequest功能是用来控制 ?*加入权限,从而允许或不允许新设备 ?*加入该网络。 ?* ?*@参数目标 - 目标参数指示的地址 ?*加入许可的设备上 ?*应设置。这通常是本地设备 ?*地址或特殊的广播地址,表示 ?*所有路由器和协调(0xFFFC)。这种方式 ?*一个单一的设备或加入许可 ?*整个网络可以控制的。 ?*超时 - 表示以秒为单位的时间量 ?*加入权限应打开。 ?*如果超时设置为0x00,该装置将关闭 ?*加入许可下去。如果它被设置为0xFF, ?*加入许可将被无限期。 ?* ?* ?*@的返回ZB_SUCCESS或失败代码 ?* ?*/
uint8 zb_PermitJoiningRequest ( uint16 destination, uint8 timeout ) { #if defined( ZDO_MGMT_PERMIT_JOIN_REQUEST ) zAddrType_t dstAddr;
dstAddr.addrMode = Addr16Bit; dstAddr.addr.shortAddr = destination;
return( (uint8) ZDP_MgmtPermitJoinReq( &dstAddr, timeout, 0, 0 ) ); #else (void)destination; (void)timeout; return ZUnsupportedMode; #endif } 这个函数主要的配置方法是指定目标地址和超时,如果超时等于0x00禁止入网,如果等于0xff允许入网。 这个函数主要是调用了ZDP_MgmtPermitJoinReq( &dstAddr, timeout, 0, 0 ) ); /********************************************************************* * @fn ZDP_MgmtPermitJoinReq * * @brief This builds and send a Mgmt_Permit_Join_req message. * * @param dstAddr - destination address of the message * @param duration - Permit duration * @param TcSignificance - Trust Center Significance * * @return afStatus_t */ afStatus_t ZDP_MgmtPermitJoinReq( zAddrType_t *dstAddr, byte duration, byte TcSignificance, byte SecurityEnable ) { (void)SecurityEnable; // Intentionally unreferenced parameter
// Build buffer ZDP_TmpBuf[ZDP_MGMT_PERMIT_JOIN_REQ_DURATION] = duration; ZDP_TmpBuf[ZDP_MGMT_PERMIT_JOIN_REQ_TC_SIG] = TcSignificance;
// Send the message return fillAndSend( &ZDP_TransID, dstAddr, Mgmt_Permit_Join_req, ZDP_MGMT_PERMIT_JOIN_REQ_SIZE ); } 这个函数主要是调用了 fillAndSend( &ZDP_TransID, dstAddr, Mgmt_Permit_Join_req, ZDP_MGMT_PERMIT_JOIN_REQ_SIZE ) /********************************************************************* * @fn fillAndSend * * @brief Combined to reduce space * * @param * @param * * @return afStatus_t */ static afStatus_t fillAndSend( uint8 *transSeq, zAddrType_t *addr, cId_t clusterID, byte len ) { afAddrType_t afAddr;
osal_memset( &afAddr, 0, sizeof(afAddrType_t) ); ZADDR_TO_AFADDR( addr, afAddr );
*(ZDP_TmpBuf-1) = *transSeq;
return AF_DataRequest( &afAddr, &ZDApp_epDesc, clusterID, (uint16)(len+1), (uint8*)(ZDP_TmpBuf-1), transSeq, ZDP_TxOptions, AF_DEFAULT_RADIUS );
}
|