数据发送:
AF_DataRequest //数据发送函数
typedef struct// afAddrType_t;目的地址结构体变量
typedef enum//afAddrMode_t数据传送类型
typedef struct// endPointDesc_t;设备端点描述符
typedef struct// zAddrType_t;地址变量(长地址或者短地址)
typedef struct// aps_Group_t;组结构体
SimpleDescriptionFormat_t;/* 设备的简单描述符 */
数据接收:
typedef struct //afIncomingMSGPacket_t.
typedef struct //afMSGCommandFormat_t;
typedef struct // osal_event_hdr_t;
typedef struct //afDataConfirm_t;
typedef struct // ZDO_ActiveEndpointRsp_t;
typedef uint16 cId_t;// 命令结构体:...
数据发送:
AF_DataRequest(
afAddrType_t *dstAddr, //目的地址结构体变量(含端点)
endPointDesc_t *srcEP, //设备端点描述符(源端点描述)
unit16 cID, //串ID (命令)
unit16 len, //有效数据长度
unit8 *buf, //数据
unit8 *transID,
unit8 *options,
unit8 radius,
)
例子:
AF_DataRequest( &SampleApp_Flash_DstAddr,
&SampleApp_epDesc,
SAMPLEAPP_FLASH_CLUSTERID,
2,
buffer,
&SampleApp_TransID,
AF_DISCV_ROUTE,
AF_DEFAULT_RADIUS )
{
union
{
uint16 shortAddr;
ZLongAddr_t extAddr;
}addr;
afAddrMode_t addrMode;//afAddrMode_t是一个枚举类型模式参数
byte endPoint;//指定的端点号 端点241—254保留端点 范围 1-240
uint16 panId; // used for theINTER_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;//数据传送类型
{
byte endPoint;
byte *task_id; // Pointer to location of theApplication task ID.
SimpleDescriptionFormat_t *simpleDesc; //设备简单描述符
afNetworkLatencyReq_t latencyReq;
} endPointDesc_t;//设备端点描述符
例:
endPointDesc_tSampleApp_epDesc;
/* 填充端点描述符 */
SampleApp_epDesc.endPoint =SAMPLEAPP_ENDPOINT;
SampleApp_epDesc.task_id =&SampleApp_TaskID;
SampleApp_epDesc.simpleDesc
=(SimpleDescriptionFormat_t *)&SampleApp_SimpleDesc;
SampleApp_epDesc.latencyReq= noLatencyReqs;
{
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; //组结构体
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_tSampleApp_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 // 输出簇列表
};
数据接收:
{
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 isSTUBAPS_INTER_PAN_EP,
it's an InterPANmessage */
uint16 macDestAddr; /* MAC header destination short address*/
uint8 endPoint; /* destination endpoint */
uint8 wasBroadcast; /* TRUE if network destination was abroadcast address */
uint8 LinkQuality; /* The link quality of the receiveddata frame */
uint8 correlation; /* The raw correlation value of thereceived data frame */
int8 rssi; /* The received RF power inunits 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;
{
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;
// Simple Description Format Structure