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

Whitelisting one device

I'd like to apply bonding/whitelist so that once a peripheral device connects to a central, only that peripheral device can reconnect (until bonding/whitelist is cleared via button). 

So far, I just have a central and peripheral app automatically pairing using "Just Works" and scan name filtering.  The devices automatically pair without user input as desired...but must re-pair every time they boot.  I haven't been able to get them to bond via SDK calls thus far...though I can bond to the peripheral with the nRF Connect app on my phone.

A few questions:

1) Is peer manager the proper library to handle this, using SDK 15.2?  I've seen mention of peer manager being experimental, and I'm not familiar with all the libraries of the SDK yet.

2) Should the whitelist be done on the central or peripheral (or both) ?  It seems like there is mention of whitelisting in either type of device in the examples.

3) Is bonding required for whitelisting?  Thus far, I haven't been able to get devices automatically bonded, although SEC_PARAM_BOND is set to `1` for each app.

Parents
  • 1) Is peer manager the proper library to handle this, using SDK 15.2?  I've seen mention of peer manager being experimental, and I'm not familiar with all the libraries of the SDK yet.

     Yes, the peer manager is the right library to handle this, and it is not experimental anymore (For SDK's newer that version 11 I believe). You should be able to both bond and add a whitelist by using the Peer Manager

    2) Should the whitelist be done on the central or peripheral (or both) ?  It seems like there is mention of whitelisting in either type of device in the examples.

    Yes it is possible to set a whitelist on the central and the peripheral, as mentioned here. What to choose, depends on the needs of your application. If you want the central to connect and bond to one specific peripheral, but let the peripheral be able to receive scan requests from other central devices, then you should only add a whitelist to the central only. If you want both the central and peripheral to just see each other, then you should add a whitelist on both devices.

    3) Is bonding required for whitelisting?  Thus far, I haven't been able to get devices automatically bonded, although SEC_PARAM_BOND is set to `1` for each app.

     Yes it is possible to use whitelisting without bonding. See this case.

    If you have any more question regarding the implementation of bonding and whitelisting, please ask.

    Best regards,

    Simon

  • Thanks Simon, one of the links suggested looking at the `ble_app_hrs_c` example, which helped me realize I am not calling `pm_conn_sec()` from my central app currently. 

    I need to dig into whether this answers my other questions and will update the post again.

  • Glad to hear you got smarter. Yes, please update me if you have any more questions.

  • Hi Simon,

    Is editing `BLE_GAP_WHITELIST_ADDR_MAX_COUNT` in the SDK source code the proper way to limit whitelist to 1? 

    Is there a way to change that value without impacting other apps that use the SDK?

  • Take a look at the ble_app_hids_keyboard example, it shows how you can limit the whitelist to 1 without editing the BLE_GAP_WHITELIST_ADDR_MAX_COUNT definition in the shared BLE library ble_gap.h.

    When you call pm_whitelist_set(..), you provide the max size of the whitelist as the second argument, and this will eventually decide the size of the whitelist. The call will eventually end up in sd_ble_gap_whitelist_set(..), and the size provided with the first function will be sent in as an argument here and decide the length of the whitelist.

    However, the value of BLE_GAP_WHITELIST_ADDR_MAX_COUNT in ble_gap.h will matter. E.g. if you set BLE_GAP_WHITELIST_ADDR_MAX_COUNT to 2 in ble_gap.h, and call with a whitelist of size 5 (pm_whitelist_set(peer_ids, 5)) you will get an error.

    The same logic applies to pm_whitelist_get(..).

    Best regards,

    Simon

Reply
  • Take a look at the ble_app_hids_keyboard example, it shows how you can limit the whitelist to 1 without editing the BLE_GAP_WHITELIST_ADDR_MAX_COUNT definition in the shared BLE library ble_gap.h.

    When you call pm_whitelist_set(..), you provide the max size of the whitelist as the second argument, and this will eventually decide the size of the whitelist. The call will eventually end up in sd_ble_gap_whitelist_set(..), and the size provided with the first function will be sent in as an argument here and decide the length of the whitelist.

    However, the value of BLE_GAP_WHITELIST_ADDR_MAX_COUNT in ble_gap.h will matter. E.g. if you set BLE_GAP_WHITELIST_ADDR_MAX_COUNT to 2 in ble_gap.h, and call with a whitelist of size 5 (pm_whitelist_set(peer_ids, 5)) you will get an error.

    The same logic applies to pm_whitelist_get(..).

    Best regards,

    Simon

Children
Related