zigbee 绑定表

来源:互联网 发布:淘宝游戏专营怎么进入 编辑:程序博客网 时间:2024/06/05 20:08

如何绑定可以参照: http://blog.csdn.net/tanqiuwei/article/details/7642766

首先绑定表: BindingEntry_t 


typedef struct 

uint16 srcIdx; // Address Manager index 
uint8 srcEP; 
uint8 dstGroupMode; // Destination address type; 0 - Normal address index, 1 - 
// Group address 
uint16 dstIdx; // This field is used in both modes (group and non-group) to 
// save NV and RAM space 
// dstGroupMode = 0 - Address Manager index 
// dstGroupMode = 1 - Group Address 
uint8 dstEP; 
uint8 numClusterIds; 
uint16 clusterIdList【MAX_BINDING_CLUSTER_IDS】; 
// Don‘t use MAX_BINDING_CLUSTERS_ID when 
// using the clusterIdList field. Use 
// gMAX_BINDING_CLUSTER_IDS 
} BindingEntry_t; 

 1.加入

static uint16 BindClusterIds[] = { ZCL_CLUSTER_ID_GEN_ON_OFF };  zAddrType_t ZC_DstAddr;  ZC_DstAddr.addrMode = Addr16Bit;  ZC_DstAddr.addr.shortAddr = 0x0000;    bindAddEntry( SAMPLEswitch_ENDPOINT,&ZC_DstAddr,                          SAMPLELIGHT_ENDPOINT,1, BindClusterIds );  

   2.移除

void bindRemoveDev( zAddrType_t *Addr ); //移除之后需要:ZDApp_NVUpdate();
3.更新地址
void bindUpdateAddr( uint16 oldAddr, uint16 newAddr ); //交换邦定表中的短地址,所有oldAddr将被newAddr取代。 BindingEntry_t *bindFindExisting( zAddrType_t *srcAddr, byte srcEpInt, zAddrType_t *dstAddr, byte dstEpInt ); 
4.查询
byte bindNumBoundTo( zAddrType_t *devAddr, byte devEpInt, byte srcMode ); 计算符合条件的邦定表入口数目。返回找到的邦定表入口数目。 devAddr -要查找的邦定表地址 devEpInt -终端 srcMode TRUE 查找源地址,FALSE 查找目的地址 uint16 bindNumOfEntries( void ); 返回邦定表中的条目数,以cluster计数。 void bindCapacity( uint16 *maxEntries, uint16 *usedEntries ); 返回邦定表的可能最大数目,和在用的最大数目,以入口记录计数。 maxEntries -指向最大入口数目的变量,绑定表的最大入口可以通过 NWK_MAX_BINDING_ENTRIES【f8wConfig.cfg】更改 


z-stack3.0:
/********************************************************************* * @fn      bdb_zclFindingBindingEpType * * @brief   Gives the Ep Type according to application clusters in *          simple descriptor * * @return  epType - If Target, Initiator or both */uint8 bdb_zclFindingBindingEpType( endPointDesc_t *epDesc )
/********************************************************************* * @fn      bdb_zclFindingBindingAddBindEntry * * @brief   This function is used to Add an entry to the binding table * * @param   SrcEndpInt - source endpoint * @param   BindClusterId - cluster to try bind * @param   Cnt - list of remote clusters * @param   ClusterList - pointer to the Object ID list * @param   DstAddr - Address of remote node * @param   DstEndpInt - EndPoint of remote node * * @return  status - Success if added */static ZStatus_t bdb_zclFindingBindingAddBindEntry( byte SrcEndpInt,                                  uint16 BindClusterId,                                  byte Cnt,                                                   uint16 * ClusterList,                                  zAddrType_t *DstAddr, byte DstEndpInt )

/********************************************************************* * @fn      bdb_exitFindingBindingWStatus * * @brief   Clean respondent list and reports the status to bdb state machine * * @return   */void bdb_exitFindingBindingWStatus( uint8 status )/********************************************************************* * @fn      bdb_zclSimpleDescClusterListClean * * @brief   This function free Simple Descriptor cluster lists * * @param   pSimpleDesc - pointer to simple descriptor * * @return  status */static void bdb_zclSimpleDescClusterListClean( SimpleDescriptionFormat_t *pSimpleDesc )




原创粉丝点击