This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

About the number of saved bonding information

Hello.
I am developing using nrf52832 (S132 v7.0.1, SDK v16.0.0).

I use whitelist to store bonding information. Is there an upper limit to the number that can be stored?
Also, how can I set it to increase the number that can be saved?

If you have any materials, please let me know.
Please let us know if you have any questions.
Thank you.

Parents
  • Hi Kei, 

    The number of peers can be handled by the peer manager is defined by the flash space that's the fds module has. 
    It's defined in sdk_config.h as FDS_VIRTUAL_PAGES (by default 3 pages) . So there isn't really a limit for number of peer in peer manager. You can just increase the number of page reserved for FDS.

    However, there is a limit for whitelisting. It's the limitation of the hardware. So the softdevice only allow a whitelist of max 8 devices (BLE_GAP_WHITELIST_ADDR_MAX_COUNT). 
    A workaround for this is to rotate this 8 devices list. So for example if you have 16 devices you want to put into the whitelist, you can scan/advertise with 8 devices in whitelist at a time, and then switch. 

  • thank you for your answer.

    When connecting to a BLE device and performing bonding, the information may be listed in the FDS using a white list.
    Therefore, I thought that all of them were registered on the white list.

    The action I want to do is receive advertisements from bonded BLE devices. For that purpose, I thought that by setting "filter_policy" to "BLE_GAP_SCAN_FP_WHITELIST", it would be possible to receive advertisements only for bonded BLE devices.

    How should I register for the white list?
    And how do you rotate the devices you want to whitelist?

    Thank you.

  • Hi Kei, 
    I'm sorry that I was not aware that the peer_list_get() was taken from one of our example. 
    I assume you are planning to have more than 2 peer in the database right ? The scenario of 2 peers is just for testing  ? 

    Note that if you simply want to filter the advertising packets, you can also filter them in the NRF_BLE_SCAN_EVT_FILTER_MATCH event if you use a filter or  NRF_BLE_SCAN_EVT_NOT_FOUND event ( It's the event for all advertising packet if you don't use any filter). 

    Regarding your code:

    In the example the peer_list_get will return the number of peers, so in your case if you have 2 peers in the database, it will return 2, not 1. 
    So in your case the first call should be: 
     peer_list_get(peers, &peer_cnt);

    ret = pm_whitelist_set(peers, 1);
    APP_ERROR_CHECK(ret);

    and the second call should be 

     peer_list_get(peers, &peer_cnt);

    ret = pm_whitelist_set(peers+sizeof(uint16_t), 1);
    APP_ERROR_CHECK(ret);

    Notice both time the number of peer count is 1. 

    if you plan to have more peers on each whitelist set, you need to change 1 to match with what you want. But it should not exceed the max number of peers (like what I described earlier, if you have 12 peers, on the first call you can call 8 peers, and the next one you use 4) 

  • Hello.

    Currently, we are confirming with bonding of 2 units as a study, but we are assuming bonding of 8 or more units in the future.
    I also use this filter because I want to communicate with a device that has been bonded once.

    I changed to the code you taught me and used nRF Connect to bond two devices. But I get the same error.
    After bonding two units and executing pm_list_get, when I checked the value of peer_cnt, it was 1 instead of 2.

    Why is peer_cnt 1 after running pm_list_get?

    Thank you.

  • Hi Kei, 
    I think I found what could be wrong here. 
    The correct code should be:

      if (whitelist_select==1)
        {
               ret = pm_whitelist_set(peers, 1);
              APP_ERROR_CHECK(ret);
    
              // Setup the device identies list.
              // Some SoftDevices do not support this feature.
              ret = pm_device_identities_list_set(peers, 1);
              if (ret != NRF_ERROR_NOT_SUPPORTED)
              {
                  APP_ERROR_CHECK(ret);
                }
    
           };
          if (whitelist_select==2)
          {
              ret = pm_whitelist_set(&peers[1], 1);
              APP_ERROR_CHECK(ret);
    
              // Setup the device identies list.
              // Some SoftDevices do not support this feature.
              ret = pm_device_identities_list_set(&peers[1], 1);
              if (ret != NRF_ERROR_NOT_SUPPORTED)
              {
                  APP_ERROR_CHECK(ret);
                }
    
           };

    I attached the code I used for my test here. Notice the addition code in bsp_event_handler() so when you click button 1 on the board (BSP_EVENT_SLEEP button id = 0) it will switch to whitelist 2. First it will disable scanning, then assign whitelist_select= 2 and start scanning again.

       case BSP_EVENT_SLEEP:
                //nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_SYSOFF);
            nrf_gpio_pin_toggle(LED_2);
            err_code =  sd_ble_gap_scan_stop();
            APP_ERROR_CHECK(err_code);
            whitelist_select=2;
           
            scan_start();
                break;

    When calling scan_start(), the function whitelist_load() will be called again due to NRF_BLE_SCAN_EVT_WHITELIST_REQUEST event. This time whitelist 2 will be used (because whitelist_select is now set to 2). 

    7571.main.zip

  • Hello.

    Thank you for the code.
    I don't have NRF 52DK, so I used the code as a reference.
    However, the error still occurs.

    When I checked, I bonded two devices, but the contents of the peers array were "0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff". I think that there are 0x0000 and 0x0001 if two units are bonded.

    Why is there only one?

    Also, the current code does not repeat receiving and not receiving advertisements alternately, but acts to receive both advices.

    How can this be resolved?

    Thank you.

  • Hello.

    "0x0000, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff"

    The cause of this phenomenon was that BLE_GAP_WHITELIST_ADDR_MAX_COUNT was 1. When I changed it to 8, I was able to get the peer ID "0x0000, 0x0001, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffffff".

    However, the error is not fixed. "Ret = pm_whitelist_set (peers [1], 1);" causes BLE_GAP_ERROR_WHITELIST_IN_USE.

    Thank you.

Reply Children
Related