终端与协调器均不指定PANID,信道相同,之前遇到过一个终端只会对一个协调器发送beacon,第二个协调器似乎不会收到,请问终端的入网beacon不是广播的吗?如何让终端做到对某个协调器请求次数过多时放弃对其入网请求
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.
终端与协调器均不指定PANID,信道相同,之前遇到过一个终端只会对一个协调器发送beacon,第二个协调器似乎不会收到,请问终端的入网beacon不是广播的吗?如何让终端做到对某个协调器请求次数过多时放弃对其入网请求
如何让终端做到对某个协调器请求次数过多时放弃对其入网请求:
ZED /ZR 发送的是beacon request ZC/ZR回复的是beacon
你可以在beacon 的处理函数上相想办法:
/****************************************************************************
* @fn ZDApp_beaconIndProcessing
*
* @brief This function processes the incoming beacon indication.
*
* When another task (MT or App) is registered to process
* beacon indication themselves, this function will parse the
* beacon payload and pass the beacon descriptor to that task
* If no other tasks registered, this function will process
* the beacon payload and generate the network descriptor link
* list.
*
* @param
*
* @return none
*
*/
void ZDO_beaconNotifyIndCB( NLME_beaconInd_t *pBeacon )
{
// Pass the beacon Indication to another task if it registers the callback
// Otherwise, process the beacon notification here.
if (zdoCBFunc[ZDO_BEACON_NOTIFY_IND_CBID] != NULL )
{
zdoCBFunc[ZDO_BEACON_NOTIFY_IND_CBID]( (void*)pBeacon );
}
else
{
networkDesc_t *pNwkDesc;
networkDesc_t *pLastNwkDesc;
uint8 found = false;
// Add the network to the Network Descriptor List
pNwkDesc = NwkDescList;
pLastNwkDesc = NwkDescList;
while (pNwkDesc)
{
if ((pNwkDesc->panId == pBeacon->panID) &&
(pNwkDesc->logicalChannel == pBeacon->logicalChannel))
{
found = true;
break;
}
pLastNwkDesc = pNwkDesc;
pNwkDesc = pNwkDesc->nextDesc;
}
// If no existing descriptor found, make a new one and add to the list
if (found == false)
{
pNwkDesc = MAP_osal_mem_alloc( sizeof(networkDesc_t) );
if ( !pNwkDesc )
{
// Memory alloc failed, discard this beacon
return;
}
// Clear the network descriptor
MAP_osal_memset( pNwkDesc, 0, sizeof(networkDesc_t) );
// Initialize the descriptor
pNwkDesc->chosenRouter = INVALID_NODE_ADDR;
pNwkDesc->chosenRouterDepth = 0xFF;
// Save new entry into the descriptor list
if ( !NwkDescList )
{
NwkDescList = pNwkDesc;
}
else
{
pLastNwkDesc->nextDesc = pNwkDesc;
}
}
// Update the descriptor with the incoming beacon
pNwkDesc->stackProfile = pBeacon->stackProfile;
pNwkDesc->version = pBeacon->protocolVersion;
pNwkDesc->logicalChannel = pBeacon->logicalChannel;
pNwkDesc->panId = pBeacon->panID;
pNwkDesc->updateId = pBeacon->updateID;
// Save the extended PAN ID from the beacon payload only if 1.1 version network
if ( pBeacon->protocolVersion != ZB_PROT_V1_0 )
{
osal_cpyExtAddr( pNwkDesc->extendedPANID, pBeacon->extendedPanID );
}
else
{
MAP_osal_memset( pNwkDesc->extendedPANID, 0xFF, Z_EXTADDR_LEN );
}
// check if this device is a better choice to join...
// ...dont bother checking assocPermit flag is doing a rejoin
if ( ( pBeacon->LQI > gMIN_TREE_LQI ) &&
( ( pBeacon->permitJoining == TRUE ) || ( bdb_isDeviceNonFactoryNew() ) ) )
{
uint8 selected = FALSE;
uint8 capacity = FALSE;
if ( ((pBeacon->LQI > pNwkDesc->chosenRouterLinkQuality) &&
(pBeacon->depth < MAX_NODE_DEPTH)) ||
((pBeacon->LQI == pNwkDesc->chosenRouterLinkQuality) &&
(pBeacon->depth < pNwkDesc->chosenRouterDepth)) )
{
selected = TRUE;
}
if ( ZSTACK_ROUTER_BUILD )
{
capacity = pBeacon->routerCapacity;
}
else if ( ZSTACK_END_DEVICE_BUILD )
{
capacity = pBeacon->deviceCapacity;
}
if ( ( (capacity) || ( pBeacon->sourceAddr == _NIB.nwkCoordAddress ) ) && (selected) )
{
// this is the new chosen router for joining...
pNwkDesc->chosenRouter = pBeacon->sourceAddr;
pNwkDesc->chosenRouterLinkQuality = pBeacon->LQI;
pNwkDesc->chosenRouterDepth = pBeacon->depth;
}
if ( pBeacon->deviceCapacity )
pNwkDesc->deviceCapacity = 1;
if ( pBeacon->routerCapacity )
pNwkDesc->routerCapacity = 1;
}
}
}