ZigBee协议栈初始化网络启动流程
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
ZigBee协议栈初始化网络启动流程
ZigBee的基本流程:由协调器的组网(创建PAN ID),终端设备和路由设备发现网络以及加入网络。
基本流程:main()->osal_init_system()->osalInitTasks()->ZDApp_Init(),进协议栈初始化函数ZDApp_Init()。
进入程序入口main()。
中
C++ Code
int main( void )
{
*/
WatchDogEnable( WDTIMX );
#endif
osal_start_system(); }
ZDO_Init();
afRegister( (endPointDesc_t
*)&ZDApp_epDesc );
#if defined( ZDO_USERDESC_RESPONSE )
ZDApp_InitUserDesc();
#endif
zgInitItems( FALSE );
}
ZDConfig_InitDescriptors();
zgWriteStartupOptions( ZG_STARTUP_SET,
ZCD_STARTOPT_DEFAULT_NETWORK_STATE );
}
#if defined ( NV_RESTORE )
if ( HalKeyRead() == SW_BYPASS_NV )
networkStateNV =
ZDO_INITDEV_NEW_NETWORK_STATE;
else
{
On these devices or routers that have
If the
zgDefaultChannelList = MAX_CHANNELS_24GHZ;
}
#endif If the PAN is not found, an scan should be completed
// When devices rejoin the network and the PAN is not found from
zgDefaultChannelList = MAX_CHANNELS_24GHZ;
}
#endif // ZIGBEE_COMMISSIONING
#endif
}
else if ( startMode == MODE_RESUME )
{
if
( logicalType == NODETYPE_ROUTER )
{ ZMacScanCnf_t scanCnf;
devState = DEV_NWK_ORPHAN;
/* if router and nvram is available, fake successful orphan scan */ = ZSUCCESS;
= ZMAC_ORPHAN_SCAN;
= 0;
= 0;
nwk_ScanJoiningOrphan(&scanCnf);
ret = ZSuccess;
}
else
{ devState = DEV_NWK_ORPHAN;
ret = NLME_OrphanJoinRequest( zgDefaultChannelList,
zgDefaultStartingScanDuration );
}
}
else
{
#if defined( LCD_SUPPORTED )
HalLcdWrite Screen( "StartDevice ERR", "MODE unknown" );
#endif
}
}
if ( ret != ZSuccess )
osal_start_timerEx(ZDAppTaskID,
ZDO_NETWORK_INIT, NWK_RETRY_DELAY );
}
开启网络事件
C++ Code
void ZDO_NetworkFormationConfirmCB( ZStatus_t Status )
{
nwkStatus = (byte)Status;
if ( Status == ZSUCCESS )
{
// LED on shows Coordinator started
HalLedSet ( HAL_LED_3,
HAL_LED_MODE_ON );
// LED off forgets
HOLD_AUTO_START
HalLedSet (HAL_LED_4,
HAL_LED_MODE_OFF);
#if defined ( ZBIT )
SIM_SetColor(0xd0ffd0);
#endif
if ( devState == DEV_HOLD )
{
// Began with HOLD_AUTO_START
devState = DEV_COORD_STARTING;
}
}
#if defined(BLINK_LEDS)
else
HalLedSet ( HAL_LED_3, HAL_LED_MODE_FLASH ); // Flash LED to show failure
#endif
osal_set_event( ZDAppTaskID,
ZDO_NETWORK_START );
}