z-stack调试之ZDApp_init

协议栈版本z-stack1.43-1.2.1,SimpleApp

本人一般调试程序一般习惯自上而下的原则,在调试z-stack的过程中,在osal_init_system()就卡住了。进入osal_init_system()发现问题出在ZDApp_init().

ZDApp_init()是ZD层的初始化函数。首先,我找到了ZD层的定义。ZDO即zigbee device object(zigbee设备对象,用来描述设备的状态)TI的ZDO层的API函数提供了创建网络,发现网络,假如网络,绑定应用终节点和管理安全的功能。ZDO层所有功能的定义和调用都在ZDProfile里面。

ZDProflie描述了zigbee设备在ZDO执行的每一个细节,它定义了设备的description和cluster(簇就是一组应用的命令和回复的集合),通过定义消息结构体ZDProfile提供:设备建立网络,设备和服务发现,终端绑定、绑定和不绑定,网络管理服务 功能。(从TI提供的官方文档上面,我们获得了如上信息。)

默认startup a network是在ZDApp_init()里面。但是,application可以不用理会这个默认习惯。条件编译选项选择了HOLD_AUTO_START、NV_RESTORE,application就能控制设备网络的开始,通过调用ZDOInitDevice()。

void ZDApp_Init( byte task_id )
{
  uint8 capabilities;

  // Save the task ID
  ZDAppTaskID = task_id;  //分配任务ID

  // Initialize the ZDO global device short address storage
  ZDAppNwkAddr.addrMode = Addr16Bit;
  ZDAppNwkAddr.addr.shortAddr = INVALID_NODE_ADDR;//初始化短地址
  (void)NLME_GetExtAddr();  // Load the saveExtAddr pointer.

  // Check for manual "Hold Auto Start"
  ZDAppCheckForHoldKey();//检测SW5是否按下,如果按下设置标志位devState = DEV_HOLD

  // 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 ( devState != DEV_HOLD )
  {
    ZDOInitDevice( 0 );
  }
  else
  {
    // Blink LED to indicate HOLD_START
    HalLedBlink ( HAL_LED_4, 0, 50, 500 );
  }

  ZDApp_RegisterCBs();
} /* ZDO_Init() */

这里启动网络,在条件编译里面设置了hold——auto——start的话,检测到按键SW5后系统才会继续运行


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值