zigbee 数据发送AF_Data_Request和数据接收afIncomingMSGPacket_t结构体
2014-06-05 14:15
429 查看
数据发送:
AF_DataRequest(
afAddrType_t *dstAddr, //目的地址结构体变量(含端点号)
endPointDesc_t *srcEP,
//设备端点描述符(源端点(?)描述)
unit16 cID, //串ID 即CLUSTERID (命令)
unit16 len, //有效数据长度
unit8 *buf, //数据
unit8 *transID,
unit8 *options,
unit8
radius,
)
unit8 *options, 发送选项,可以由下面一项,或几项相或得到
AF_ACK_REQUEST 0x10 要求APS应答,这是应用层的应答,只在直接发送(单播)时使用。
AF_DISCV_ROUTE 0x20 总要包含这个选项
AF_SKIP_ROUTING 0x80 设置这个选项将导致设备跳过路由而直接发送消息。终点设备将不向其父亲发送消息。在直接发送(单播)和广播消息时很好用。
uint8 radius 最大的跳数,用默认值AF_DEFAULT_RADIUS
设备端点描述符endPointDesc_t *srcEP, *srcEP,源端点什么意思?源端点就是发送数据的端点,目的端点就是接收数据的端点
节点 和 终端 是不是一个意思吗?
一个节点,相当于你一个PC主机,每个都有一个地址,相当于有一个IP地址,而端点,相当于TCP/IP的端口号
例子:
AF_DataRequest( &SampleApp_Flash_DstAddr,
&SampleApp_epDesc,
SAMPLEAPP_FLASH_CLUSTERID,
2,
buffer,
&SampleApp_TransID,
AF_DISCV_ROUTE,
AF_DEFAULT_RADIUS )
union
{
uint16 shortAddr; //16位网络地址
ZLongAddr_t extAddr; //64位IEEE地址
} addr;
afAddrMode_t addrMode; //发送模式 afAddrMode_t是一个枚举类型模式参数
byte endPoint; //指定的端点号 端点241—254保留端点 范围 1-240
uint16 panId; // used for the INTER_PAN feature
} afAddrType_t;
//目的地址结构体变量(含端点)
例:afAddrType_t SampleApp_Flash_DstAddr;
/* 设置闪烁命令的目的地址(发送给组1的所有成员)*/
SampleApp_Flash_DstAddr.addrMode = (afAddrMode_t) afAddrGroup;
SampleApp_Flash_DstAddr.endPoint = SAMPLEAPP_ENDPOINT;
SampleApp_Flash_DstAddr.addr.shortAddr = SAMPLEAPP_FLASH_GROUP;
afAddrNotPresent = AddrNotPresent,
//间接传送(Indirect)
afAddr16Bit = Addr16Bit,
//指定地址单点传送(Unicast) 16位
afAddrGroup = AddrGroup,
//组寻址(Group Addressing)
afAddrBroadcast = AddrBroadcast
//广播传送(broadcast)
} afAddrMode_t;//数据传送类型
设备端点描述符endPointDesc_t 和 afAddrType_t中都含有endPoint 是一样的吗?一样
byte endPoint;
byte *task_id;
// Pointer to location of the Application task ID.
SimpleDescriptionFormat_t *simpleDesc;
//设备简单描述符
afNetworkLatencyReq_t latencyReq;
} endPointDesc_t;//设备端点描述符
例:
endPointDesc_t SampleApp_epDesc;
/* 填充端点描述符 */
SampleApp_epDesc.endPoint = SAMPLEAPP_ENDPOINT;
SampleApp_epDesc.task_id = &SampleApp_TaskID;
SampleApp_epDesc.simpleDesc
= (SimpleDescriptionFormat_t *)&SampleApp_SimpleDesc;
SampleApp_epDesc.latencyReq = noLatencyReqs;
typedef struct
{
byte EndPoint;
//EP ID (EP=End Point)
uint16 AppProfId;
// profile ID(剖面ID)
uint16 AppDeviceId;
// Device ID
byte AppDevVer:4;
//Device Version 0x00 为 Version 1.0
byte Reserved:4;
// AF_V1_SUPPORT uses for AppFlags:4.
byte AppNumInClusters;
//终端支持的输入簇的个数
cId_t *pAppInClusterList; //指向输入Cluster ID列表的指针
byte AppNumOutClusters;
//输出簇的个数
cId_t *pAppOutClusterList;
//指向输出Cluseter ID列表的指针
} SimpleDescriptionFormat_t;
例子:
const SimpleDescriptionFormat_t SampleApp_SimpleDesc =
{
SAMPLEAPP_ENDPOINT, // 端点号
SAMPLEAPP_PROFID, // Profile ID
SAMPLEAPP_DEVICEID, // 设备ID
SAMPLEAPP_DEVICE_VERSION, // 设备版本
SAMPLEAPP_FLAGS, // 标识
SAMPLEAPP_MAX_CLUSTERS, // 输入簇的数量
(cId_t *)SampleApp_ClusterList,
// 输入簇列表
SAMPLEAPP_MAX_CLUSTERS, // 输出簇的数量
(cId_t *)SampleApp_ClusterList
// 输出簇列表
};
afAddrType_t和zAddrType_t ((z是ZDO?)内容差不多 有什么区别?没区别
union
{
uint16 shortAddr;
ZLongAddr_t extAddr;
} addr;
byte addrMode;
} zAddrType_t; //地址变量(长地址或者短地址)
uint16 ID; // Unique to this table
uint8 name[APS_GROUP_NAME_LEN]; // Human readable name of group
} aps_Group_t; //组结构体
数据接收:
osal_event_hdr_t hdr; /* OSAL Message header */
uint16 groupId; /* Message's group ID - 0 if not set */
uint16 clusterId; /* Message's cluster ID */
afAddrType_t srcAddr; /* Source Address, if endpoint is STUBAPS_INTER_PAN_EP,
it's an InterPAN message */
uint16 macDestAddr; /* MAC header destination short address */
uint8 endPoint; /* destination endpoint */
uint8 wasBroadcast; /* TRUE if network destination was a broadcast address */
uint8 LinkQuality; /* The link quality of the received data frame */
uint8 correlation; /* The raw correlation value of the received data frame */
int8 rssi; /* The received RF power in units dBm */
uint8 SecurityUse; /* deprecated */
uint32 timestamp; /* receipt timestamp from MAC */
afMSGCommandFormat_t cmd; /* Application Data */
} afIncomingMSGPacket_t;
//afIncomingMSGPacket_t gtwRxFromNode;
// Generalized MSG Command Format
byte TransSeqNumber;
uint16 DataLength; // Number of bytes in TransData
byte *Data;
} afMSGCommandFormat_t;
typedef struct // osal_event_hdr_t;
{
uint8 event;
uint8 status;
} osal_event_hdr_t;
osal_event_hdr_t hdr;
byte endpoint;
byte transID;
} afDataConfirm_t;
uint8 status;
uint16 nwkAddr; // Network address of interest
uint8 cnt;
uint8 epList[];
} ZDO_ActiveEndpointRsp_t;
AF_DataRequest(
afAddrType_t *dstAddr, //目的地址结构体变量(含端点号)
endPointDesc_t *srcEP,
//设备端点描述符(源端点(?)描述)
unit16 cID, //串ID 即CLUSTERID (命令)
unit16 len, //有效数据长度
unit8 *buf, //数据
unit8 *transID,
unit8 *options,
unit8
radius,
)
unit8 *options, 发送选项,可以由下面一项,或几项相或得到
AF_ACK_REQUEST 0x10 要求APS应答,这是应用层的应答,只在直接发送(单播)时使用。
AF_DISCV_ROUTE 0x20 总要包含这个选项
AF_SKIP_ROUTING 0x80 设置这个选项将导致设备跳过路由而直接发送消息。终点设备将不向其父亲发送消息。在直接发送(单播)和广播消息时很好用。
uint8 radius 最大的跳数,用默认值AF_DEFAULT_RADIUS
设备端点描述符endPointDesc_t *srcEP, *srcEP,源端点什么意思?源端点就是发送数据的端点,目的端点就是接收数据的端点
节点 和 终端 是不是一个意思吗?
一个节点,相当于你一个PC主机,每个都有一个地址,相当于有一个IP地址,而端点,相当于TCP/IP的端口号
例子:
AF_DataRequest( &SampleApp_Flash_DstAddr,
&SampleApp_epDesc,
SAMPLEAPP_FLASH_CLUSTERID,
2,
buffer,
&SampleApp_TransID,
AF_DISCV_ROUTE,
AF_DEFAULT_RADIUS )
typedef struct
{union
{
uint16 shortAddr; //16位网络地址
ZLongAddr_t extAddr; //64位IEEE地址
} addr;
afAddrMode_t addrMode; //发送模式 afAddrMode_t是一个枚举类型模式参数
byte endPoint; //指定的端点号 端点241—254保留端点 范围 1-240
uint16 panId; // used for the INTER_PAN feature
} afAddrType_t;
//目的地址结构体变量(含端点)
例:afAddrType_t SampleApp_Flash_DstAddr;
/* 设置闪烁命令的目的地址(发送给组1的所有成员)*/
SampleApp_Flash_DstAddr.addrMode = (afAddrMode_t) afAddrGroup;
SampleApp_Flash_DstAddr.endPoint = SAMPLEAPP_ENDPOINT;
SampleApp_Flash_DstAddr.addr.shortAddr = SAMPLEAPP_FLASH_GROUP;
typedef enum
{afAddrNotPresent = AddrNotPresent,
//间接传送(Indirect)
afAddr16Bit = Addr16Bit,
//指定地址单点传送(Unicast) 16位
afAddrGroup = AddrGroup,
//组寻址(Group Addressing)
afAddrBroadcast = AddrBroadcast
//广播传送(broadcast)
} afAddrMode_t;//数据传送类型
设备端点描述符endPointDesc_t 和 afAddrType_t中都含有endPoint 是一样的吗?一样
typedef struct
{byte endPoint;
byte *task_id;
// Pointer to location of the Application task ID.
SimpleDescriptionFormat_t *simpleDesc;
//设备简单描述符
afNetworkLatencyReq_t latencyReq;
} endPointDesc_t;//设备端点描述符
例:
endPointDesc_t SampleApp_epDesc;
/* 填充端点描述符 */
SampleApp_epDesc.endPoint = SAMPLEAPP_ENDPOINT;
SampleApp_epDesc.task_id = &SampleApp_TaskID;
SampleApp_epDesc.simpleDesc
= (SimpleDescriptionFormat_t *)&SampleApp_SimpleDesc;
SampleApp_epDesc.latencyReq = noLatencyReqs;
typedef struct
{
byte EndPoint;
//EP ID (EP=End Point)
uint16 AppProfId;
// profile ID(剖面ID)
uint16 AppDeviceId;
// Device ID
byte AppDevVer:4;
//Device Version 0x00 为 Version 1.0
byte Reserved:4;
// AF_V1_SUPPORT uses for AppFlags:4.
byte AppNumInClusters;
//终端支持的输入簇的个数
cId_t *pAppInClusterList; //指向输入Cluster ID列表的指针
byte AppNumOutClusters;
//输出簇的个数
cId_t *pAppOutClusterList;
//指向输出Cluseter ID列表的指针
} SimpleDescriptionFormat_t;
例子:
const SimpleDescriptionFormat_t SampleApp_SimpleDesc =
{
SAMPLEAPP_ENDPOINT, // 端点号
SAMPLEAPP_PROFID, // Profile ID
SAMPLEAPP_DEVICEID, // 设备ID
SAMPLEAPP_DEVICE_VERSION, // 设备版本
SAMPLEAPP_FLAGS, // 标识
SAMPLEAPP_MAX_CLUSTERS, // 输入簇的数量
(cId_t *)SampleApp_ClusterList,
// 输入簇列表
SAMPLEAPP_MAX_CLUSTERS, // 输出簇的数量
(cId_t *)SampleApp_ClusterList
// 输出簇列表
};
afAddrType_t和zAddrType_t ((z是ZDO?)内容差不多 有什么区别?没区别
typedef struct
{union
{
uint16 shortAddr;
ZLongAddr_t extAddr;
} addr;
byte addrMode;
} zAddrType_t; //地址变量(长地址或者短地址)
typedef struct
{uint16 ID; // Unique to this table
uint8 name[APS_GROUP_NAME_LEN]; // Human readable name of group
} aps_Group_t; //组结构体
数据接收:
typedef struct
{osal_event_hdr_t hdr; /* OSAL Message header */
uint16 groupId; /* Message's group ID - 0 if not set */
uint16 clusterId; /* Message's cluster ID */
afAddrType_t srcAddr; /* Source Address, if endpoint is STUBAPS_INTER_PAN_EP,
it's an InterPAN message */
uint16 macDestAddr; /* MAC header destination short address */
uint8 endPoint; /* destination endpoint */
uint8 wasBroadcast; /* TRUE if network destination was a broadcast address */
uint8 LinkQuality; /* The link quality of the received data frame */
uint8 correlation; /* The raw correlation value of the received data frame */
int8 rssi; /* The received RF power in units dBm */
uint8 SecurityUse; /* deprecated */
uint32 timestamp; /* receipt timestamp from MAC */
afMSGCommandFormat_t cmd; /* Application Data */
} afIncomingMSGPacket_t;
//afIncomingMSGPacket_t gtwRxFromNode;
// Generalized MSG Command Format
typedef struct // afMSGCommandFormat_t;
{byte TransSeqNumber;
uint16 DataLength; // Number of bytes in TransData
byte *Data;
} afMSGCommandFormat_t;
typedef struct // osal_event_hdr_t;
{uint8 event;
uint8 status;
} osal_event_hdr_t;
typedef struct
{osal_event_hdr_t hdr;
byte endpoint;
byte transID;
} afDataConfirm_t;
typedef struct
{uint8 status;
uint16 nwkAddr; // Network address of interest
uint8 cnt;
uint8 epList[];
} ZDO_ActiveEndpointRsp_t;
相关文章推荐
- (六) 发送函数AF_DataRequest zigbee数据发送和接受
- 如何用ace_message_block发送和接收struct结构的数据
- C Socket 发送/接收数据结构
- Ajax核心XMLHttpRequest对象、(发送请求、接收)方法和属性介绍、AJAX开发框架、数据格式提要(XML、JSON、HTML)
- Zigbee协议栈发送函数AF_DataRequest说明
- 通过消息跨进程发送与接收 TCopyDataStruct 数据 - 回复 "skymesh"
- 【Z-Stack发送函数AF_DataRequest】
- Ajax核心XMLHttpRequest对象、(发送请求、接收)方法和属性介绍、AJAX开发框架、数据格式提要(XML、JSON、HTML)
- ASP.NET中将数据作为XML数据发送 使用 Request.InputStream 接收
- 通过SOCKET发送、接收结构体数据
- Ajax 使用XMLHttpRequest对象发送数据和接收处理XML源代码
- zigbee__AF_DataRequest函数详解
- ZigBee组网机制以及数据的发送和接收
- Ajax核心XMLHttpRequest对象、(发送请求、接收)方法和属性介绍、AJAX开发框架、数据格式提要(XML、JSON、HTML)
- 10XMLHttpRequest对象的创建,及发送和接收数据
- C#中用HttpWebRequest/HttpWebResponse来发送/接收数据
- Ajax核心XMLHttpRequest对象、(发送请求、接收)方法和属性介绍、AJAX开发框架、数据格式提要(XML、JSON、HTML)
- iOS通过ASIHttpRequest接收php端发送的Json数据
- iOS通过ASIHttpRequest接收php端发送的Json数据
- udp 发送和接收结构体数据