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

Whitelist set but not automatically restarted

Hi,

When I bond with a central to my device, the peer gets added to the whitelist. But I want my device (peripheral), to automatically start advertising in whitelist after the peer get's bonded, but it only does this when I restart the device.

I also make use of multipeers which can be connected at same time, perhaps that's the problem?

How can I force a restart of the advertising in whitelist whithout a reset of the device?

Parents Reply Children
  • I use nRF5 SDK. I used the multipeer example together with the HID Keyboard, because I wanted a multipeer with bonding capabilities.

  • Hi,

    I realize that this has been left unanswered for way too long, but answering in case you still see the issue and/or if others see the same in the future.

    The key to controlling whitelist usage in nRF5 SDK is through the advertising module. If you look at e.g. the HID keyboard example, the advertising settings are stored in m_advertising in main.c, and that structure is what at all times decides the current behavior of advertising. It is sent in to calls to the advertising module API.

    When initialized through ble_advertising_init() with a configuration to use whitelist (init.config.ble_adv_whitelist_enabled = true), it will use whitelist except for in a couple of situations:

    • If there are no peers for the whitelist.
    • If advertising without whitelist is explicitly initiated through ble_advertising_restart_without_whitelist().

    Places to look when not getting a whitelist:

    • Advertising module: The event handler for the advertising module (default name on_adv_event() e.g. in the HID keyboard example). It must handle the BLE_ADV_EVT_WHITELIST_REQUEST by returning a whitelist through ble_advertising_whitelist_reply().
    • Peer Manager: The policy for adding devices to the whitelist. Addresses are added to the whitelist on the PM_EVT_PEER_DATA_UPDATE_SUCCEEDED event from peer manager (default name pm_evt_handler() e.g. in the HID keyboard example.) It is added by a call to whitelist_set(), and the argument to that call describes what kind of addresses to add to the whitelist. If the newly added peer has an address of a type that is not to be stored in the whitelist, you will end up with an empty whitelist, which again can make the advertising module advertise without whitelist.
    • See if advertising is started by ble_advertising_restart_without_whitelist(). In some situations this is wanted, at least in most cases you need some way to recover and allow for new devices to connect for the situations where the known (whitelisted) devices get lost or forget the bond. But this may also be the way advertising gets started in the situation where you want whitelist but do not get it.

    Regards,
    Terje

Related