z-satck的协议栈提供了两种aging 的方法,一种是发orphan 一种是发data request。 取决于父节点上zgNwkParentInformation 的取值
zgNwkParentInformation = NWK_PARENT_INFO_MAC_DATA_POLL 使用 data request
zgNwkParentInformation = NWK_PARENT_INFO_ORPHAN_NOTIFICATION; 使用 orphan notification
默认使用orphan notification
在ZGlobals.c 中 有一段代码 注释,上面讲得很详细:
//======= Child Aging PARENT ROUTER (ZR/ZC) configuration ========
// You can setup a router to support Child Table Aging in 1 of 2 modes of
// operation. The first mode is NWK_PARENT_INFO_ORPHAN_NOTIFICATION and it
// expects end devices to use orphan scan periodically as a means of a keep-alive
// notification to the parent. The other mode is NWK_PARENT_INFO_MAC_DATA_POLL
// which uses the end device's MAC POLL request as the keep-alive notification.
// The first method is preferred for new devices, where the end devices provide
// support for it (which will be manditory in future Zigbee Home Automation
// Specifications).
// The second method is compatible with older end devices without the need for
// specific child aging support.
//
// The method supported by the router (or coordinator) is determined at build time
// by setting zgNwkParentInformation to either NWK_PARENT_INFO_ORPHAN_NOTIFICATION
// or NWK_PARENT_INFO_MAC_DATA_POLL.
//
// End device built with Child Table Aging support both methods, the method is
// determined by the parent and communicated at run-time.
在终端设备里面的几个POLL RATE
/* The number of milliseconds to wait between data request polls to the coordinator. */
-DPOLL_RATE=1000
/* This is used after receiving a data indication to poll immediately
* for queued messages...in milliseconds.
*/
-DQUEUED_POLL_RATE=100
/* This is used after receiving a data confirmation to poll immediately
* for response messages...in milliseconds
*/
-DRESPONSE_POLL_RATE=100
/* This is used as an alternate response poll rate only for rejoin request.
* This rate is determined by the response time of the parent that the device
* is trying to join.
*/
-DREJOIN_POLL_RATE=440
/* Rejoin retry backoff silent period timer duration in milliseconds - default 15 minutes according to HA test spec */
-DREJOIN_BACKOFF=900000
/* Rejoin retry backoff scan timer duration in milliseconds - default 15 minutes according to HA test spec */
-DREJOIN_SCAN=900000
当节点POLL不到父节点时会变成孤儿节点从而执行下面的程序
if( events & ZDO_REJOIN_BACKOFF )
{
if( devState == DEV_NWK_BACKOFF )
{
ZDApp_ChangeState(DEV_NWK_DISC);
// Restart scan for rejoin
ZDApp_StartJoiningCycle();
osal_start_timerEx( ZDAppTaskID, ZDO_REJOIN_BACKOFF, zgDefaultRejoinScan );
}
else
{
// Rejoin backoff, silent period
ZDApp_ChangeState(DEV_NWK_BACKOFF);
ZDApp_StopJoiningCycle();
osal_start_timerEx( ZDAppTaskID, ZDO_REJOIN_BACKOFF, zgDefaultRejoinBackoff );
}
return ( events ^ ZDO_REJOIN_BACKOFF);
}