Z-stack关键结构体解析

  • OSAL的消息队列
每一个消息都包含一个消息头osal_msg_hdr_t和用户自定义的消息,osal_msg_hdr_t结构体定义如下:
  1. typedef struct
  2. {
  3. void *next;
  4. uint16 len;
  5. uint8 dest_id;
  6. } osal_msg_hdr_t;
 

   在事件处理函数SampleApp_ProcessEvent()中,从消息队列中接收到一个消息,后才调用SampleApp_MessageMSGCB,接收到的消息中如何就包含了用户接收的数据消息呢?
是这样子的:每个消息都有一个用户自定义的消息部分,协调器收到数据后,将数据打包,存放在用户自定义消息部分,然后将其插入到消息队列,用户就可以从消息队列接收该消息
接收到数据后的消息格式如下图所示。

  • AF层的数据包结构体:afIncomingMSGPacket_t
  1. typedef struct
  2. {
  3. osal_event_hdr_t hdr; /* OSAL Message header */
  4. uint16 groupId; /* Message's group ID - 0 if not set */
  5. uint16 clusterId; /* Message's cluster ID */
  6. afAddrType_t srcAddr; /* Source Address, if endpoint is STUBAPS_INTER_PAN_EP,
  7. it's an InterPAN message */
  8. uint16 macDestAddr; /* MAC header destination short address */
  9. uint8 endPoint; /* destination endpoint */
  10. uint8 wasBroadcast; /* TRUE if network destination was a broadcast address */
  11. uint8 LinkQuality; /* The link quality of the received data frame */
  12. uint8 correlation; /* The raw correlation value of the received data frame */
  13. int8 rssi; /* The received RF power in units dBm */
  14. uint8 SecurityUse; /* deprecated */
  15. uint32 timestamp; /* receipt timestamp from MAC */
  16. afMSGCommandFormat_t cmd; /* Application Data */
  17. } afIncomingMSGPacket_t;

  • af地址类型
  1. typedef struct
  2. {
  3. union
  4. {
  5. uint16 shortAddr; //16位网络地址
  6. ZLongAddr_t extAddr; //设备IEEE64位物理地址
  7. } addr;
  8. afAddrMode_t addrMode;
  9. byte endPoint;
  10. uint16 panId;
  11. } afAddrType_t;
  • 数据传输模式
  1. typedef enum
  2. {
  3. afAddrNotPresent = AddrNotPresent,
  4. afAddr16Bit = Addr16Bit, //点播
  5. afAddr64Bit = Addr64Bit,
  6. afAddrGroup = AddrGroup, //组播
  7. afAddrBroadcast = AddrBroadcast //广播
  8. } afAddrMode_t;
  1. afStatus_t AF_DataRequest( afAddrType_t *dstAddr, endPointDesc_t *srcEP,
  2. uint16 cID, uint16 len, uint8 *buf, uint8 *transID,
  3. uint8 options, uint8 radius )
 

posted @ 2014-11-24 20:07  i-小乐  阅读(601)  评论(0编辑  收藏  举报