【转自小峰博客】协调器的启动【自动模式】 发布: 2010-11-08 20:17 | 作者: tuzhuke | 来源: “飞比”Zigbee论坛 使用的协议栈版本信息: ZigBee2006\ZStack-1.4.3-1.2.1 Zigbee 网络设备启动流程—协调器(自启动模式)—以SampleApp 的协调器为例. 1、协调器预编译信息 通过 project->options->c/c++compiler->extraOptions 可以看到协调器所带的配置文件为: -f $PROJ_DIR$\..\..\..\Tools\CC2430DB\f8wCoord.cfg -f $PROJ_DIR$\..\..\..\Tools\CC2430DB\f8wConfig.cfg 即编译了 ZDO_COORDINATOR 和 RTR_NWK. 通过 project->options->c/c++compiler->Preprocessor->Defined symbols可以看到协调器预编译包含了: CC2430EB; ZTOOL_P1; MT_TASK; LCD_SUPPORTED=DEBUG; MANAGED_SCAN 没有编译 HOLD_AUTO_START 和 SOFT_START. 2、具体流程 main()->osal_init_system()->osalInitTasks()->ZDApp_Init() 进入 ZDApp_Init()函数: ************************************** void ZDApp_Init( byte task_id ) { uint8 capabilities; // Save the task ID ZDAppTaskID = task_id; // Initialize the ZDO global device short address storage ZDAppNwkAddr.addrMode = Addr16Bit; ZDAppNwkAddr.addr.shortAddr = INVALID_NODE_ADDR; //0xFFFE (void)NLME_GetExtAddr(); // Load the saveExtAddr pointer. // Check for manual"Hold Auto Start" //检测到有手工设置SW_1 则会设置devState = DEV_HOLD,从而避开网络初始化 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 ); #if defined( ZDO_USERDESC_RESPONSE ) ZDApp_InitUserDesc(); #endif // ZDO_USERDESC_RESPONSE // set broadcast address mask to support broadcast filtering NLME_GetRequest(nwkCapabilityInfo, 0, &capabilities); NLME_SetBroadcastFilter( capabilities ); // Start the device? if ( devS...