利用3.0协议栈的绑定的理解:
1. 您好,我说一下我的理解关于绑定的:就是两个节点要绑定的时候必须先满足两个节点的 bdb_ZclType1Clusters[]和 bdb_ZclType2Clusters[]包含的簇必须完全一样(这就等于查找匹配了)。感觉好像有点牵强。寻找匹配应该是端点的描述符匹配啦。求教一下到底是哪里寻找匹配的?
2.然后在根据bdb_zclFindingBindingEpType()该函数进行判断谁是target谁是ininitor。在调用bdb_StartCommissioning(BDB_COMMISSIONING_MODE_FINDING_BINDING)就可实现绑定了。这样理解对吗?
3.到底绑定的流程是怎么样的。我看了BDB的规范。但是还是没有看见具体的代码实现在哪里?请Ti的大神帮忙解释一下,这个问题困扰我好多天了。最好有代码来说明,感激不尽了
Alvin Chen:
请根据Z-Stack 3.0 Developer's Guide中Finding and Binding章节。
if(bdbAttributes.bdbCommissioningMode & BDB_COMMISSIONING_MODE_FINDING_BINDING){bdbCommissioningProcedureState.bdbCommissioningState = BDB_COMMISSIONING_STATE_FINDING_BINDING;//Is the device on a network?if(bdb_isDeviceNonFactoryNew()){zclAttrRec_t attrRec;endPointDesc_t *bdb_CurrEpDescriptor = NULL;bdb_CurrEpDescriptor = bdb_setEpDescListToActiveEndpoint();//If not found endpoint with Identify cluster is found, then report failif(bdb_CurrEpDescriptor == NULL){bdb_exitFindingBindingWStatus(BDB_COMMISSIONING_FAILURE);return;}if( bdb_CurrEpDescriptorList->epDesc->epType & BDB_FINDING_AND_BINDING_TARGET)//F&B as Target{if (zclFindAttrRec( bdb_CurrEpDescriptor->endPoint, ZCL_CLUSTER_ID_GEN_IDENTIFY,ATTRID_IDENTIFY_TIME, &attrRec ) ){//Set it to at less 180if ( *((uint16*)attrRec.attr.dataPtr) <= BDBC_MIN_COMMISSIONING_TIME ){*((uint16*)attrRec.attr.dataPtr) = BDBC_MIN_COMMISSIONING_TIME;osal_start_timerEx( bdb_TaskID, BDB_IDENTIFY_TIMEOUT, 1000 );if(pfnIdentifyTimeChangeCB != NULL){if(bdbIndentifyActiveEndpoint == 0xFF){pfnIdentifyTimeChangeCB(bdbIndentifyActiveEndpoint);}else{pfnIdentifyTimeChangeCB(bdb_CurrEpDescriptor->endPoint);}}}//Attribute found and set, report successif(!(bdb_CurrEpDescriptorList->epDesc->epType & BDB_FINDING_AND_BINDING_INITIATOR)){bdb_exitFindingBindingWStatus(BDB_COMMISSIONING_FB_TARGET_IN_PROGRESS);}else{bdbCommissioningModeMsg_t bdbCommissioningModeMsg;bdbCommissioningModeMsg.bdbCommissioningMode = BDB_COMMISSIONING_FINDING_BINDING;bdbCommissioningModeMsg.bdbCommissioningStatus = BDB_COMMISSIONING_FB_TARGET_IN_PROGRESS;bdb_NotifyApp((uint8*)&bdbCommissioningModeMsg);}}else{//Attribute not found and no initiator process, report failif(!(bdb_CurrEpDescriptorList->epDesc->epType & BDB_FINDING_AND_BINDING_INITIATOR)){bdb_exitFindingBindingWStatus(BDB_COMMISSIONING_FAILURE);}}}//F&B Targetif( bdb_CurrEpDescriptorList->epDesc->epType & BDB_FINDING_AND_BINDING_INITIATOR)//F&B as Initiator{bdbCommissioningModeMsg_t bdbCommissioningModeMsg;//If no function to add binds is available then do not process Initiatorif(!pbindAddEntry){//If no target process, then report failif(!(bdb_CurrEpDescriptorList->epDesc->epType & BDB_FINDING_AND_BINDING_TARGET)){bdb_exitFindingBindingWStatus(BDB_COMMISSIONING_FAILURE);}}else{//Send identify query with the endpoint requestedif(bdb_SendIdentifyQuery(bdb_CurrEpDescriptor->endPoint) != ZSuccess){bdb_exitFindingBindingWStatus(BDB_COMMISSIONING_FAILURE);}//If periodic F&B is enabledif ( FINDING_AND_BINDING_PERIODIC_ENABLE == TRUE ){// total F&B time will be at least BDBC_MIN_COMMISSIONING_TIME, and at most (BDBC_MIN_COMMISSIONING_TIME + FINDING_AND_BINDING_PERIODIC_TIME - 1)bdb_FB_InitiatorCurrentCyclesNumber = (BDBC_MIN_COMMISSIONING_TIME + (FINDING_AND_BINDING_PERIODIC_TIME - 1)) / FINDING_AND_BINDING_PERIODIC_TIME;osal_start_timerEx(bdb_TaskID, BDB_FINDING_AND_BINDING_PERIOD_TIMEOUT, FINDING_AND_BINDING_PERIODIC_TIME * 1000);}bdbCommissioningModeMsg.bdbCommissioningMode = BDB_COMMISSIONING_FINDING_BINDING;bdbCommissioningModeMsg.bdbCommissioningStatus = BDB_COMMISSIONING_FB_INITITATOR_IN_PROGRESS;bdb_NotifyApp((uint8*)&bdbCommissioningModeMsg);}} //F&B Initiator}//Not in the networkelse{bdb_exitFindingBindingWStatus(BDB_COMMISSIONING_FAILURE);}根据这个去梳理。
user5764532:
回复 Alvin Chen:
好的,太感谢您了。谢谢您的指点