zigbee 綁定表

如何綁定可以參照: 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 )




發佈了67 篇原創文章 · 獲贊 22 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章