使用GAPBondMgr_SetParameter(GAPBOND_ERASE_ALLBONDS, 0, NULL);可以删除绑定,而使用GAPBondMgr_SetParameter(GAPBOND_ERASE_SINGLEBOND, B_ADDR_LEN+1, pEvent->linkCmpl.devAddrType);不能删除单个设备的绑定,我的主设备只绑定了一个从设备,请大家给予指点,谢谢!
Viki Shi:
是连接手机吗?删除绑定信息需要两边都删除
Alvin Chen:
case GAPBOND_ERASE_SINGLEBOND:if ( len == (1 + B_ADDR_LEN) ){uint8 idx;uint8 devAddr[B_ADDR_LEN];// Reverse bytesVOID osal_revmemcpy( devAddr, (uint8 *)pValue+1, B_ADDR_LEN );// Resolve address and find indexidx = GAPBondMgr_ResolveAddr( *((uint8 *)pValue), devAddr, NULL );if ( idx < GAP_BONDINGS_MAX ){// Make sure there's no active connectionif ( GAP_NumActiveConnections() == 0 ){// Erase bondVOID gapBondMgrEraseBonding( idx );// See if NV needs a compactionVOID osal_snv_compact( NV_COMPACT_THRESHOLD );// Make sure Bond RAM Shadow is up-to-dategapBondMgrReadBonds();}else{// Mark entry to be deleted when disconnectedbondsToDelete[idx] = TRUE;}}else{ret = INVALIDPARAMETER;}}else{// Parameter is not the correct lengthret = bleInvalidRange;}break;你用法不对吧,后面是地址啊
Dan Feng2:
回复 Viki Shi:
不是两个开发板链接手机连接在手机端删除后就可以了
Dan Feng2:
回复 Alvin Chen:
我试过后面是地址也不对,而且后面确实是地址类型地址类型加1才是地址,这个我已经确定
Dan Feng2:
Dan Feng2对于此段代码我有两个疑问: 1、GAPBondMgr_SetParameter删除单个绑定GAPBOND_ERASE_SINGLEBOND里面已经操作了寻找idx代码,为何还要先寻找确定地址再去删除? case GAPBOND_ERASE_SINGLEBOND:
if ( len == (1 + B_ADDR_LEN) ) { uint8 idx; uint8 devAddr[B_ADDR_LEN];// Reverse bytes VOID osal_revmemcpy( devAddr, (uint8 *)pValue+1, B_ADDR_LEN );// Resolve address and find index 解析地址和查找索引 idx = GAPBondMgr_ResolveAddr( *((uint8 *)pValue), devAddr, NULL ); if ( idx < GAP_BONDINGS_MAX ) { // Make sure there's no active connection if ( GAP_NumActiveConnections() == 0 ) { // Erase bond VOID gapBondMgrEraseBonding( idx );// See if NV needs a compaction VOID osal_snv_compact( NV_COMPACT_THRESHOLD );// Make sure Bond RAM Shadow is up-to-date gapBondMgrReadBonds(); } else { // Mark entry to be deleted when disconnected bondsToDelete[idx] = TRUE; } } }2、上述函数调用了 idx = GAPBondMgr_ResolveAddr( *((uint8 *)pValue), devAddr, NULL );你的代码里同样用到idx = GAPBondMgr_ResolveAddr(testAddrType,testAddr,NULL); 找到这个函数的原型,第一个参数确实是地址类型,而这第一个参数就是GAPBondMgr_SetParameter( uint16 param, uint8 len, void *pValue )的最后一个参数,为何你在后面调用这个函数的最后一个参数还是地址,岂不自相矛盾?
Dan Feng2:
回复 Alvin Chen:
根据这个帖子解决了,非常感谢!