第一個(gè)功能:協(xié)調(diào)器的組網(wǎng),終端設(shè)備和路由設(shè)備發(fā)現(xiàn)網(wǎng)絡(luò)以及加入網(wǎng)絡(luò)
//第一步:Z-Stack 由 main()函數(shù)開始執(zhí)行,main()函數(shù)共做了 2 件事:一是系統(tǒng)初始化,另外一件是開
始執(zhí)行輪轉(zhuǎn)查詢式操作系統(tǒng)
int main( void )
{
.......
// Initialize the operating system
osal_init_system(); //第二步,操作系統(tǒng)初始化
......
osal_start_system(); //初始化完系統(tǒng)任務(wù)事件后,正式開始執(zhí)行操作系統(tǒng)
......
}
//第二步,進(jìn)入 osal_init_system()函數(shù),執(zhí)行操作系統(tǒng)初始化
uint8 osal_init_system( void ) //初始化操作系統(tǒng),其中最重要的是,初始化操作系統(tǒng)的任務(wù)
{
// Initialize the Memory Allocation System
osal_mem_init();
// Initialize the message queue
osal_qHead = NULL;
// Initialize the timers
osalTimerInit();
// Initialize the Power Management System
osal_pwrmgr_init();
// Initialize the system tasks.
osalInitTasks(); //第三步,執(zhí)行操作系統(tǒng)任務(wù)初始化函數(shù)
// Setup efficient search for the first free block of heap.
osal_mem_kick();
return ( SUCCESS );
}
// Check for manual "Hold Auto Start"
ZDAppCheckForHoldKey();
// Initialize ZDO items and setup the device - type of device to create.
ZDO_Init();
// Register the endpoint description with the AF
// This task doesn't have a Simple description, but we still need
// to register the endpoint.
afRegister( (endPointDesc_t *)&ZDApp_epDesc );