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.
Issue description:
ZED will poll using REJOIN_POLL_RATE instead of POLL_RATE after being reset due to a parent leave request where the rejoin option was set.
Proposed fix:
In ZDApp_ProcessNetworkJoin of ZDApp.c, remove NLME_SetPollRate( zgRejoinPollRate ); from if (nwkStatus == ZSuccess) and place in the else statement instead. One must also set the zgRejoinPollRate when device state is DEV_END_DEVICE_UNAUTH
if ( ZG_SECURE_ENABLED && ( ZDApp_RestoreNwkKey( TRUE ) == false ) ) { if ( ZSTACK_END_DEVICE_BUILD ) { NLME_SetPollRate( zgRejoinPollRate ); } // wait for auth from trust center ZDApp_ChangeState( DEV_END_DEVICE_UNAUTH );
Optimally, also place NLME_SetPollRate( ZDApp_SavedPollRate ); inside of ZDO_JoinConfirmCB.
根據我的了解是在ZDApp.c的ZDApp_ProcessNetworkJoin修改下面紅色的部份
if (nwkStatus == ZSuccess)
{
//When the device has successfully rejoined then reset retryCnt
retryCnt = 0;
// Verify NWK key is available before sending Device_annce
if ( ZG_SECURE_ENABLED && ( ZDApp_RestoreNwkKey( TRUE ) == false ) )
{
if ( ZSTACK_END_DEVICE_BUILD )
{
NLME_SetPollRate( zgRejoinPollRate );
}
// wait for auth from trust center
ZDApp_ChangeState( DEV_END_DEVICE_UNAUTH );
// Start the reset timer for MAX UNAUTH time
ZDApp_ResetTimerStart( MAX_DEVICE_UNAUTH_TIMEOUT );
}
else
{
ZDApp_ChangeState( DEV_END_DEVICE );
osal_stop_timerEx( ZDAppTaskID, ZDO_REJOIN_BACKOFF );
// setup Power Manager Device
#if defined ( POWER_SAVING )
osal_pwrmgr_device( PWRMGR_BATTERY );
#endif
// The receiver is on, turn network layer polling off.
if ( ZDO_Config_Node_Descriptor.CapabilityFlags & CAPINFO_RCVR_ON_IDLE )
{
// if Child Table Management process is not enabled
if ( zgChildAgingEnable == FALSE )
{
NLME_SetPollRate( 0 );
NLME_SetQueuedPollRate( 0 );
NLME_SetResponseRate( 0 );
}
}
if ( ZSTACK_ROUTER_BUILD )
{
// NOTE: first two parameters are not used, see NLMEDE.h for details
if ( ZDO_Config_Node_Descriptor.LogicalType != NODETYPE_DEVICE )
{
NLME_StartRouterRequest( 0, 0, false );
}
}
ZDApp_AnnounceNewAddress();
if ( ( (ZDO_Config_Node_Descriptor.CapabilityFlags & CAPINFO_RCVR_ON_IDLE) == 0 )
|| ( (ZDO_Config_Node_Descriptor.CapabilityFlags & CAPINFO_RCVR_ON_IDLE)
&& (zgChildAgingEnable == TRUE) ) )
{
if(devStartMode == MODE_REJOIN)
{
NLME_SetPollRate( zgRejoinPollRate );
}
else
{
NLME_SetPollRate( ZDApp_SavedPollRate );
}
}
}
}
else
{
if ( devStartMode == MODE_RESUME )
{
if ( ++retryCnt <= MAX_RESUME_RETRY )
{
if ( _NIB.nwkPanId == 0xFFFF )
devStartMode = MODE_JOIN;
else
{
devStartMode = MODE_REJOIN;
_tmpRejoinState = true;
prevDevState = DEV_NWK_SEC_REJOIN_CURR_CHANNEL;
}
}
// Do a normal join to the network after certain times of rejoin retries
else if( AIB_apsUseInsecureJoin == true )
{
devStartMode = MODE_JOIN;
}
}
else if(devStartMode == MODE_REJOIN)
{
if ( ZSTACK_END_DEVICE_BUILD )
{
devStartMode = MODE_REJOIN;
_tmpRejoinState = true;
_NIB.nwkState = NWK_INIT;
if( prevDevState == DEV_NWK_SEC_REJOIN_CURR_CHANNEL )
{
runtimeChannel = MAX_CHANNELS_24GHZ;
prevDevState = DEV_NWK_SEC_REJOIN_ALL_CHANNEL ;
}
else if ( prevDevState == DEV_NWK_SEC_REJOIN_ALL_CHANNEL)
{
// Set the flag that will ask the device to do trust center network layer rejoin.
_NIB.nwkKeyLoaded = FALSE;
ZDApp_ResetNwkKey(); // Clear up the old network key.
runtimeChannel = (uint32) (1L << _NIB.nwkLogicalChannel);
prevDevState = DEV_NWK_TC_REJOIN_CURR_CHANNEL ;
}
else if ( prevDevState == DEV_NWK_TC_REJOIN_CURR_CHANNEL )
{
runtimeChannel = MAX_CHANNELS_24GHZ;
prevDevState= DEV_NWK_TC_REJOIN_ALL_CHANNEL ;
}
NLME_SetPollRate( zgRejoinPollRate );
}
}
// Clear the neighbor Table and network discovery tables.
nwkNeighborInitTable();
NLME_NwkDiscTerm();
// setup a retry for later...
ZDApp_NetworkInit( (uint16)(NWK_START_DELAY
+ (osal_rand()& EXTENDED_JOINING_RANDOM_MASK)) );
}