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

Advertising: replicating sd_ble_gap_adv_start behaviour with softdevice S140 v6.0.0

Hi

With the release of softdevice S140 v6.0.0, the advertising API has changed to incorporate the concept of Advertising Set that was introduced in Bluetooth Core Specification v5.0. As a result, the functions sd_ble_gap_adv_set_configure() and sd_ble_gap_adv_start() must both be called in order to advertise, whereas in previous versions of the softdevice, only sd_ble_gap_adv_start() was needed.

My questions is, what do we need to do to our pre-existing app to replicate the behaviour we got on previous softdevices (e.g. softdevce v6.0.0-alpha.6). Specifically, for sd_ble_gap_adv_set_configure(), what must we set the advertising data to in order to be able to start sending out connectable and scannable adverts? We have tried setting that to NULL but we are getting the error NRF_ERROR_NOT_FOUND.

This is our pseudo-code:-


ble_gap_adv_params_t adv_params;
ble_gap_adv_data_t * p_adv_data;
uint8_t m_adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET;
p_adv_data = NULL;

memset(&adv_params, 0, sizeof(adv_params));
adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;
adv_params.properties.anonymous = 0;
adv_params.properties.include_tx_power = 0;
adv_params.p_peer_addr = NULL; // Undirected advertisement.
adv_params.filter_policy = BLE_GAP_ADV_FP_ANY;
adv_params.interval = BLE_GAP_ADV_INTERVAL_MAX;
adv_params.duration = 0;

nrfErr = sd_ble_gap_adv_set_configure(&m_adv_handle, p_adv_data, &adv_params);

nrfErr = sd_ble_gap_adv_start(m_adv_handle, BLE_CONN_CFG_TAG_DEFAULT);


We are using softdevice S140 v6.0.0 and SDK v15.0.0 on an nRF52840 PDK.

Thanks

Youssif

Parents
  • Hello Youssif,

    What function call returns NRF_ERROR_NOT_FOUND? sd_ble_gap_adv_start(), I assume? You must set something as advertising data in sd_ble_gap_adv_set_configure();

     

    You must run sd_ble_gap_adv_set_configure(); before sd_ble_gap_adv_start();

    Have you looked in ble_advertising.c in the new SDK(15.0.0)?

     

    In all the examples inside ble_peripheral, you can see how the advertisement is set up and started. But please check e.g. the ble_app_hrs example. You can see that sd_ble_gap_adv_set_configure() is called from main.c --> advertising_init() --> ble_advertising_init() --> sd_ble_gap_adv_set_configure();

     

    Best regards,

    Edvin

  • Hi Edvin

    Thank you for getting back to me so quickly and for your detailed response. The function that is returning NRF_ERROR_NOT_FOUND is sd_ble_gap_adv_set_configure(). I believe I am getting this error because I have set p_adv_data to NULL (please see pseudo-code above), but I am not sure.

    I have looked at ble_advertising.c in the new SDK(15.0.0). The file is just a library/component file so we cannot follow it directly. I have also looked at the examples that have used this component file, and for connectable and scannable adverts, the function ble_advdata_encode() is always used to set the advert data. However, this is a new concept introduced in this SDK and there is no mention of this function in the migration document. Furthermore, whenever ble_advdata_encode() is called, it is working with app-specific advertising data (e.g. blinky) and we are looking for a normal generic advert.

    Basically what I want to do is as follows:- I have a PDK with SDK14.2.0 and sd6.0.0-alpha.6, and all my app does is call sd_ble_enable() followed by sd_ble_gap_adv_start() to start advertising connectable and scannable adverts. What do I need to do in order to replicate exactly the same behaviour but with SDK15.0.0 and sd6.0.0? What should p_adv_data be set to and is there anything additional I need to do in order to cater for the new API?

    The example in the migration document is again too specific and shows how advertising is done using two user-specified advertising data.

    Thanks

    Youssif

  • Hello,

    The reason that I asked what function that returned NRF_ERROR_NOT_FOUND is because according to infocenter, sd_ble_gap_adv_set_configure() can't return NRF_ERROR_NOT_FOUND, but I have seen that they return values that are not listed before.

    I am sorry, I haven't been able to test this just yet. I am out travelling. Could you please confirm that sd_ble_gap_adv_set_configure() actually is the function that  returns this? According to infocenter you should be able to set the adv_data pointer to NULL. I have asked a co-worker to test the sd_blle_gap_adv_set_configure(..., NULL, ...), but it does not return NRF_ERROR_NOT_FOUND. If it really does, it must be some sort of corner conditions that we would have to check out. Do you have a project that you could send that can replicate the issue?

     

     

    Best regards,

    Edvin

  • By the way, the example ble_app_pwr_profiling calls sd_ble_gap_adv_set_configure() with NULL for the *adv_data pointer.

     

    Best regards,

    Edvin

Reply Children
No Data
Related