ZDO邦定API
绑定机制允许一个应用服务在不知道目标地址的情况下向对方(的应用服务)发送数据包。发送时使用的目标地址将由应用支持子层从绑定表中自动获得,从而能使消息顺利被目标节点的一个或多个应用服务,乃至分组接收。<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
由于所有邦定信息都在Zigbee协调器中,所以只有协调器才能接收邦定请求。
ZDO Binding API ZDP Binding Service Command
ZDP_EndDeviceBindReq() End_Device_Bind_req
ZDP_EndDeviceBindRsp() End_Device_Bind_rsp
ZDP_BindReq() Bind_req
ZDP_BindRsp() Bind_rsp
ZDP_UnbindReq() Unbind_req
ZDP_UnbindRsp() Unbind_rsp
afStatus_t ZDP_EndDeviceBindReq( zAddrType_t *dstAddr,uint16 LocalCoordinator, byte epIntf,
uint16 ProfileID,byte NumInClusters, byte *InClusterList,
byte NumOutClusters, byte *OutClusterList,byte SecuritySuite );
构建并发送节点设备邦定请求(Hand Bingding)。
LocalCoordinator - 设备父协调器的16位网络地址
NumInClusters - 输入簇中的cluster ID数目
InClusterList - 输入cluster IDs的数组
afStatus_t ZDP_EndDeviceBindRsp( byte TranSeq, zAddrType_t *dstAddr,
byte Status, byte SecurityEnable );
Status - SUCCESS 0
NOT_SUPPORTED 1
TIMEOUT 2
NO_MATCH 3
afStatus_t ZDP_BindReq( zAddrType_t *dstAddr, byte *SourceAddr,
byte SrcEPIntf, byte ClusterID, byte *DestinationAddr, byte DstEPIntf,
byte SecuritySuite );
请求协调器利用cluster ID邦定应用
ClusterID – 要邦定的cluster ID
DestinationAddr – 接收消息的设备的64位地址
afStatus_t ZDP_BindRsp( byte TranSeq, zAddrType_t *dstAddr,byte Status, byte SecurityEnable );
Status - SUCCESS 0
NOT_SUPPORTED 1
TABLE_FULL 2
afStatus_t ZDP_UnbindReq( zAddrType_t *dstAddr,
byte *SourceAddr, byte SrcEPIntf,
byte ClusterID,
byte *DestinationAddr, byte DstEPIntf,
byte SecuritySuite );
请求Zigbee协调器移除邦定。
afStatus_t ZDP_UnbindRsp( byte TranSeq, zAddrType_t *dstAddr, byte Status,byte SecurityEnable );
Status - SUCCESS 0x00
NOT_SUPPORTED 1
NO_ENTRY 2
ZDO管理API
这些消息用来取得设备状态和更新表格
ZDP Management API ZDP Network Management Service Command
ZDP_MgmtNwkDiscReq() Mgmt_NWK_Disc_req
ZDP_MgmtNwkDiscRsp() Mgmt_NWK_Disc_rsp
ZDP_MgmtLqiReq() Mgmt_Lqi_req
ZDP_MgmtLqiRsp() Mgmt_Lqi_rsp
ZDP_MgmtRtgReq() Mgmt_Lqi_req
ZDP_MgmtRtgRsp() Mgmt_Rtg_rsp
ZDP_MgmtBindReq() Mgmt_Bind_req
ZDP_MgmtBindRsp() Mgmt_Bind_rsp
ZDP_MgmtLeaveReq() Mgmt_Leave_req
ZDP_MgmtLeaveRsp() Mgmt_Leave_rsp
ZDP_MgmtDirectJoinReq() Mgmt_Direct_Join_req
ZDP_MgmtDirectJoinRsp() Mgmt_Direct_Join_rsp
ZDP_MgmtPermitJoinReq() Mgmt_Permit_Join_req
ZDP_MgmtPermitJoinRsp() Mgmt_Permit_Join_rsp
afStatus_t ZDP_MgmtNwkDiscReq( zAddrType_t *dstAddr,
uint32 ScanChannels, byte StartIndex, byte SecurityEnable );
如果设备支持这个命令,调用此函数将为目标设备产生一个扫描网络的请求。只有设置ZDO_MGMT_NWKDISC_REQUEST编译选项(ZDConfig.h)才能调用此函数。
afStatus_t ZDP_MgmtNwkDiscRsp( byte TranSeq, zAddrType_t *dstAddr,byte Status,
byte NetworkCount, byte StartIndex, byte NetworkCountList,
networkDesc_t *NetworkList, byte SecurityEnable );
若设置ZDO_MGMT_NWKDISC_RESPONSE编译选项,当接收到“Management Network Discovery Request”消息后将自动产生这个消息。
afStatus_t ZDP_MgmtLqiReq ( zAddrType_t *dstAddr,byte StartIndex, byte SecurityEnable );
若设置ZDO_MGMT_LQI_REQUEST编译选项,调用此函数将为目标设备产生返回邻居列表的请求。
ZStatus_t ZDP_MgmtLqiRsp( byte TranSeq, zAddrType_t *dstAddr,
byte Status, byte NeighborLqiEntries,
byte StartIndex, byte NeighborLqiCount,
neighborLqiItem_t *NeighborLqiList,
byte SecurityEnable );
afStatus_t ZDP_MgmtRtgReq( zAddrType_t *dstAddr,
byte StartIndex, byte SecurityEnable );
若设置ZDO_MGMT_RTG_REQUEST编译选项,调用此函数将为目标设备产生返回路由列表的请求。
ZStatus_t –状态值,定义在ZComDef.h中的ZStatus_t
ZStatus_t ZDP_MgmtRtgRsp( byte TranSeq, zAddrType_t *dstAddr,
byte Status, byte RoutingTableEntries,
byte StartIndex, byte RoutingListCount,
rtgItem_t *RoutingTableList, byte SecurityEnable );
若设置ZDO_MGMT_RTG_REQUEST编译选项,当接收到“Management Routing Request”消息后将自动产生这个消息。
afStatus_t ZDP_MgmtBindReq( zAddrType_t *dstAddr,
byte StartIndex, byte SecurityEnable );
若设置ZDO_MGMT_BIND_REQUEST编译选项,调用此函数将为目标设备产生返回邦定表的请求。
ZStatus_t ZDP_MgmtBindRsp( byte TranSeq, zAddrType_t *dstAddr,
byte Status, byte BindingTableEntries,
byte StartIndex, byte BindingTableListCount,
apsBindingItem_t *BindingTableList,
byte SecurityEnable );
afStatus_t ZDP_MgmtLeaveReq( zAddrType_t *dstAddr,byte *IEEEAddr, byte SecurityEnable );
若设置ZDO_MGMT_LEAVE_REQUEST编译选项,调用此函数将请求目标设备脱离网络或者请求其他设备脱离网络
ZStatus_t ZDP_MgmtLeaveRsp( byte TranSeq, zAddrType_t *dstAddr,byte Status, byte SecurityEnable );
若设置ZDO_MGMT_LEAVE_REQUEST编译选项,当接收到“Management Leave Reques”消息后将自动产生这个消息。
afStatus_t ZDP_MgmtDirectJoinReq( zAddrType_t *dstAddr,byte *deviceAddr, byte capInfo, byte SecurityEnable );
若设置ZDO_MGMT_JOINDIRECT_REQUEST编译选项,调用此函数将请求目标设备直接加入其他设备。
deviceAddr – 要加入的设备的64位地址
capInfo – 要加入设备的性能
CAPINFO_ALTPANCOORD 0x01
CAPINFO_DEVICETYPE_FFD 0x02
CAPINFO_POWER_AC 0x04
CAPINFO_RCVR_ON_IDLE 0x08
CAPINFO_SECURITY_CAPABLE 0x40
CAPINFO_ALLOC_ADDR 0x80
ZStatus_t ZDP_MgmtDirectJoinRsp( byte TranSeq, zAddrType_t *dstAddr,byte Status, byte SecurityEnable);
afStatus_t ZDP_MgmtPermitJoinReq( zAddrType_t *dstAddr, byte duration,
byte TcSignificance, byte SecurityEnable );
实际是直接调用宏ZDP_SendData (),函数构建并发送Mgmt_Permit_Joining_req来请求远端设备允许或不允许关联。这个请求由调试工具或者网络管理设备产生,
duration -协调器或路由器允许关联的时间(单位为秒),0x00和0xff分别表示没有时间限制的禁止和允许。
TcSignificance -如果设为0x01且远端设备为真实中心设备的话,命令将影响中心设备的授权机制。
ZStatus_t ZDP_MgmtPermitJoinRsp( byte *TransSeq,zAddrType_t *dstAddr, byte *Statue, byte SecurityEnable);
ZDO解析函数
用来解析接收到的消息
ZDO_NwkIEEEAddrResp_t *ZDO_ParseAddrRsp( zdoIncomingMsg_t *inMsg );
解析NWK_addr_rsp和IEEE_addr_rsp消息
inMsg -指向接收到的消息的指针
ZDO_NwkIEEEAddrResp_t -指向解析后的结构的指针,结构体由osal_mem_alloc分配空间,所以需要调用osal_mem_free()来释放空间
void ZDO_ParseNodeDescRsp( zdoIncomingMsg_t *inMsg,ZDO_NodeDescRsp_t *pNDRsp );
解析Node_Desc_rsp消息
pNDRsp -解析消息存放的地方
void ZDO_ParsePowerDescRsp( zdoIncomingMsg_t *inMsg,ZDO_PowerRsp_t *pNPRsp );
解析Power_Desc_rsp消息
void ZDO_ParseSimpleDescRsp( zdoIncomingMsg_t *inMsg,ZDO_SimpleDescRsp_t *pSimpleDescRsp );
pSimpleDescRsp -存放解析后的消息
ZDO_ActiveEndpointRsp_t *ZDO_ParseEPListRsp( zdoIncomingMsg_t *inMsg );
解析Active_EP_rsp或者Match_Desc_rsp的消息
#define ZDO_ParseBindRsp(a) ((uint8)(*(a->asdu)))
解析Bind_rsp, Unbind_rsp或End_Device_Bind_rsp消息
a -指向要解析的消息的指针
ZDO_MgmNwkDiscRsp_t *ZDO_ParseMgmNwkDiscRsp( zdoIncomingMsg_t *inMsg );
解析Mgmt_NWK_Disc_rsp消息
ZDO_MgmtLqiRsp_t *ZDO_ParseMgmtLqiRsp( zdoIncomingMsg_t *inMsg );
ZDO_MgmtRtgRsp_t *ZDO_ParseMgmtRtgRsp( zdoIncomingMsg_t *inMsg );
ZDO_MgmtBindRsp_t *ZDO_ParseMgmtBindRsp( zdoIncomingMsg_t *inMsg );
#define ZDO_ParseMgmtDirectJoinRsp(a) ((uint8)(*(a->asdu)))
#define ZDO_ParseMgmtLeaveRsp(a) ((uint8)(*(a->asdu)))
#define ZDO_ParseMgmtPermitJoinRsp(a) ((uint8)(*(a->asdu)))
ZDO_UserDescRsp_t *ZDO_ParseUserDescRsp( zdoIncomingMsg_t *inMsg );
void ZDO_ParseServerDiscRsp( zdoIncomingMsg_t *inMsg,ZDO_ServerDiscRsp_t *pRsp );
解析Server_Discovery_rsp消息
void ZDO_ParseEndDeviceBindReq( zdoIncomingMsg_t *inMsg,ZDEndDeviceBind_t *bindReq );
void ZDO_ParseBindUnbindReq( zdoIncomingMsg_t *inMsg,ZDO_BindUnbindReq_t *pReq );
#define ZDO_ParseUserDescConf(a) ((uint8)(*(a->asdu)))
void ZDO_ParseDeviceAnnce( zdoIncomingMsg_t *inMsg, ZDO_DeviceAnnce_t *pAnnce );
ZDO_MgmtNwkUpdateNotify_t *ZDO_ParseMgmtNwkUpdateNotify(zdoIncomingMsg_t *inMsg );
文章评论(0条评论)
登录后参与讨论