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

Direct advertising example

Hi,

I'm trying to implement some direct advertising, but I'm a little lost in the process.

Could you provide me with an example of code ? I read somewhere that ble_app_hid_mouse was doing that, but all I can see is some whitelisting + a start advertising using BLE_ADV_MODE_FAST, even if directed is set to true during configuration phasis. Did I miss something ? Is direct advertising used only when some peer is bonded ?

More generally, my problem is that I have the ability to get the peer address by usb, so I'd like to use it to make direct advertising from the start. I Think I read elsewhere on the forum some problems linked to direct advertising, so I may be open to other approches, like whitelisting, but it seemed more logical to me to perform direct advertising ...

I'm using nRF5238 with SDK 16 and SoftDevice 7.

All the best,

Parents
  • Hi,

    You are right that the HID mouse example uses direct advertising, but only when it is bonded. In a normal use case, direct advertising only makes sense when bonded, since then you know which device you should advertise directed to. Also, please note that directed advertising is the only suitable for some special occasions, such as HID mouse and keyboards where you want very fast direct advertisement after a connection loss in order to seamlessly reconnect. You may not see so easily how this is done in the example since it uses the advertising module. Essentially the advertising module starts with the most aggressive and most restrictive advertising mode, and goes down the list, subsequently using each mode until it's timeout as long as it is enabled. You can most easily see this by looking at the implementation of adv_mode_next_avail_get() in components\ble\ble_advertising\ble_advertising.c.

    I do not know if that is the case for you, but my impression is that in most cases when customers ask for directed advertising, what they really want is to ensure that only a specific device is allowed to connect. In that case, whitelisting is usually a better approach. For instance, Apple recommends that directed advertising is not used.

  • I investigated a little more following your advice and found my error : I was setting my peer_address before my call to ble_advertising_start when I needed to set it in advertising event callback, under the BLE_ADV_EVT_PEER_ADDR_REQUEST event id. Considering this, it seems to works.

    I will now investigate whitelist for a better approch to my problem.

    Thanks again for your time,

    have a nice day.

Reply Children
No Data
Related