ZigBee绑定细节

ZigBee中的绑定由APS层来管理,除了绑定表管理外,APS层还有组表管理、快速地址查找等服务功能。应用层不能直接调用APS层中的数据服务来传输数据,只能通过AF层封装的AD_DataRequest函数来实现数据传输。

 

看了许多相关的文档,里面说及到,绑定服务在两个不同节点的简单描述符中,定义相同的簇ID,且方向相反(一个在输出簇,一个在输入簇),才能成功建立绑定。

 

APS绑定表的大小受限于静态RAM的大小,由f8wConfig.cfg中的参数来指定。

image

默认配置中,有四个绑定表条目,每个条目中,可以有4个簇ID。

要配置使用绑定表,需要定义REFLECTOR宏(在f8wconfig.cfg中配)

 

绑定表操作

对一个表的操作,无非就是增删改查。

1. 增加一个绑定表条目

函数原型:
BindingEntry_t *bindAddEntry( byte srcEpInt,
                              zAddrType_t *dstAddr, byte dstEpInt,
                              byte numClusterIds, uint16 *clusterIds )

srcEpInt:源端点
dstAddr:目的地址
dstEpInt:目的端点
numClusterIds:簇列表数目
clusterIds:簇列表

成功返回指向新加入绑定表的指针,失败返回NULL

2.移除一个绑定表条目

函数原型:
byte bindRemoveEntry( BindingEntry_t *pBind )
pBind:指向想要删除的绑定表指针

成功返回TRUE

3.移除绑定条目中的簇命令

函数原型:
byte bindRemoveClusterIdFromList( BindingEntry_t *entry, uint16 clusterId )
entry:绑定表的入口
clusterID:待删除的簇ID

成功返回TRUR,至少有一个对于的簇ID。如果没有的话,返回FALSE

4.增加绑定表条目中的簇

函数原型:
byte bindAddClusterIdToList( BindingEntry_t *entry, uint16 clusterId )
entry:绑定表入口
clusterID:需要添加的簇ID

成功返回TRUE,失败返回FALSE

5.找到一个已经存在的源端点到目的地址的绑定记录

函数类型:
BindingEntry_t *bindFindExisting( byte srcEpInt,
                                  zAddrType_t *dstAddr, byte dstEpInt )

srcEpInt:源端点
dstAddr:目的地址类型
dstEInt:目的地址端点号

 

使用Flash时,需要设置编译选项NV_RESTORE[f8wConfig.cfg],保存绑定表,建议使用BindWriteNV函数。

 

组管理

组用来将一系列节点集合到一个单地址实体的方式,向这个地址发送数据请求,请求能够达到组中的每个节点。

 

 image

第一个结构体为组结构标书,第二个结构体为组链表描述。

组操作函数有

将一个端点加入一个组:extern ZStatus_t aps_AddGroup( uint8 endpoint, aps_Group_t *group );

 

使用方法:

定义一个组:aps_Group_t  SampleApp_Group;

初始化组信息:

        SampleApp_Group.ID = SAMPLEAPP_FLASH_GROUP;
             osal_memcpy( SampleApp_Group.name, "Group 1", 7  );

将端点加入一个组:

        aps_AddGroup( SAMPLEAPP_ENDPOINT, &SampleApp_Group );

从组表中根据端点和组ID找到组索引

         aps_Group_t *grp;
              grp = aps_FindGroup( SAMPLEAPP_ENDPOINT, SAMPLEAPP_FLASH_GROUP );

根据组ID,移除其中的端点

        aps_RemoveGroup( SAMPLEAPP_ENDPOINT, SAMPLEAPP_FLASH_GROUP );

 

 

 

 

快速地址查找

APS提供函数用来快速地址转换,在IEEE和网络地址之间做转换。

 

uint8 APSME_LookupExtAddr( uint16 nwkAddr, uint8* extAddr ); 基于网络地址获得IEEE 地址

uint8 APSME_LookupNwkAddr( uint8* extAddr, uint16* nwkAddr ); 基于IEEE地址获得NWK地址

BINDING KuangJunBin:本文是作者根据TI Z-Stack开发文档,ZigBee Specification-2007,《Zigbee Wireless Networking》等英文资料整合和翻译而成,采用中英双语对照方便读者理解,文中翻译不当之处,望广大同行不吝赐教。推广ZigBee技术,提高国内电子行业的国际影响力,是我们无线通讯工程师的愿景。本文欢迎转载,请保留作者信息和出处,作为支持我继续努力前行的动力,谢谢! E-mail:kuangjunbin@gmail.com In the Zigbee 2006 release,the binding mechanism is implemented in all devices and is called source binding. Binding allows an application to send a packet without knowing the destination address,the APS layer determines the destination address from its binding table,and then forwards the message on to the destination application(or multiple applications)or group. ZigBee2006版本中规定,在全部节点中实现绑定机制,并将其称为源绑定绑定机制允许一个应用服务在不知道目标地址的情况下向对方(的应用服务)发送数据包。发送时使用的目标地址将由应用支持子层(APS)从绑定表中自动获得,从而能使消息顺利被目标节点的一个或多个应用服务,乃至分组接收。 Binding Table 1.Defined in RAM,but can be saved in Flash if the NV_RESTORE compiler option is used 2.Stored on source node(REFLECTOR compiler option required) 3.Entries map messages to their intended destination 4.Each entry in the binding table contains the following: typedef struct { uint16 srcIdx;//Source index uint8 srcEP;//Source endpoint uint8 dstGroupMode;//Specifies normal or group addressing uint16 dstIdx;//Destination index or group address uint8 dstEP;//Destination endpoint uint8 numClusterIds;//Number of cluster IDs in the clusterIdList below uint16 clusterIdList[MAX_BINDING_CLUSTER_IDS]; }BindingEntry_t; 绑定表 1. 绑定表存放的位置是内存中预先定义的RAM块,如果编译选项NV_RESTORE被激活,也能保存在Flash里。 2. 绑定表放置在源节点(需要激活编译选项REFLECTOR)。 3. 绑定表的条目把需要发送的消息映射到它们的目标地址上。 4. 绑定表中每个条目(entry)包括以下内容: 绑定表条目结构体的定义
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值