This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

如何把SNV空间扩大,以提高绑定设备数量

Other Parts Discussed in Thread: CC2541

现在有一个项目,使用HIDEbd例程需要提高绑定设备数量,

#define GAP_BONDINGS_MAX    10    //!< Maximum number of bonds that can be saved in NV.

结合 snv空间地址定义及各参数存储大小

// Bonding NV Items - Range 0x20 - 0x5F - This allows for 10 bondings
#define BLE_NVID_GAP_BOND_START 0x20 //!< Start of the GAP Bond Manager's NV IDs
#define BLE_NVID_GAP_BOND_END 0x5f //!< End of the GAP Bond Manager's NV IDs Range

// GATT Configuration NV Items - Range 0x70 - 0x79 - This must match the number of Bonding entries
#define BLE_NVID_GATT_CFG_START 0x70 //!< Start of the GATT Configuration NV IDs
#define BLE_NVID_GATT_CFG_END 0x79 //!< End of the GATT Configuration NV IDs

绑定的数量10已经是最大,无法变大,如果要扩大绑定数量,就需要扩大SNV空间,相应修改各个参数存储地址。

故请教下扩大SNV空间的步骤是什么,或提供相关资料。(注:芯片空间256K,程序空间不大,有很多空间剩余)

  • CC26XX 的snv大小是限定的【The protocol stack can be configured to reserve up to two 4kB flash pages for SNV, although valid data is only stored in one active flash page.】,如果需要更多的空间,建议通过自己的程序实现NV存储,这部分可以参考C:\ti\simplelink\ble_sdk_2_02_02_25\src\components\services\src\nv\cc26xx
  • 我用的是cc2541,为什么工程里面找不到OSAL_Nv.c文件
  • CC2541用定義在osal_nv.h的osal_nv_write/osal_nv_read

  • 没看明白,这方面的资料太少,还是不扩容了吧。

    当配对表满后,删除最早保存的绑定设备信息。我想咨询下,

    1.GAPBondMgr_SetParameter中GAPBOND_ERASE_SINGLEBOND删除一个设备需要在连接断开情况下,请问下如果在连接状态下,即gapBondMgrAddBond时发现列表为空时直接删除一个绑定设备,我可不可在发现列表为空时,直接把一个idx给设备,不调用 GAPBondMgr_SetParameter中GAPBOND_ERASE_SINGLEBOND去删除。

    2、

    删除列表函数中这个两个if判断是做什么用,为什么要进行这两个判断

  • 建议不要,删除绑定的前提是不影响蓝牙连接,所以才要求在连接断开的情况下删除。

    删除绑定的示例代码如下:

    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;
           }
         }
         else
         {
           ret = INVALIDPARAMETER;
         }
       }
       else
       {
         // Parameter is not the correct length
         ret = bleInvalidRange;
       }
       break;