ZigBee学习之14—ZStack API解读2.doc_第1页
ZigBee学习之14—ZStack API解读2.doc_第2页
ZigBee学习之14—ZStack API解读2.doc_第3页
ZigBee学习之14—ZStack API解读2.doc_第4页
ZigBee学习之14—ZStack API解读2.doc_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

#1楼主:【原创】ZigBee学习之14ZStack API解读2文章发表于:2010-02-06 15:50ZDO邦定API绑定机制允许一个应用服务在不知道目标地址的情况下向对方(的应用服务)发送数据包。发送时使用的目标地址将由应用支持子层从绑定表中自动获得,从而能使消息顺利被目标节点的一个或多个应用服务,乃至分组接收。由于所有邦定信息都在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_tZStatus_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 0x08CAPINFO_SECURITY_CAPABLE 0x40 CAPINFO_ALLOC_ADDR 0x80ZStatus_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(

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论