BLE advertising data update with SDK v17.0

FormerMember
FormerMember

Hello Noridc Support Team and All members,

I am new to BLE development.

I am using the nRF52 development kit and the SDK v17.0.2

My intent is to send the sensor data within BLE advertising packet.[BLE beacon mode]

I started of with the BLE beacon example from SDK and was able to send the sensor data.
However I faced issues when updating the sensor data at runtime. Data was not being sent.

After digging a bit into the stack code and reading forum posts I got to know that from SDK 15 on wards there was a change in the API


//Old API
err_code = ble_advdata_set(&advdata, NULL);
APP_ERROR_CHECK(err_code);

//New API
err_code = ble_advdata_encode(&siwi_ble_data.advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
APP_ERROR_CHECK(err_code);

err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);
APP_ERROR_CHECK(err_code);


Also I read the description about the data structure “ble_gap_adv_data_t”, which says this memory will remain unmodified in application RAM and in order to update user needs to create another buffer.

I tried few things but was not successful.


However I achieved the update of sensor data using SDK v14.2.0

What I would like to know is
- what is the correct way to update it using SDK v17.0
- Is there any documentation given by Nordic related to same.
- I am sure Nordic must have done these changes for a reason.
- I am also sure people must have reported this behaviour since the API was introduced in SDK v15

Can anyone help me with the same.

Thanks in advance

Parents
  • Hello,

    I am new to BLE development.

    Welcome!

    However I faced issues when updating the sensor data at runtime. Data was not being sent.

    Could you elaborate how you attempted to do this? When you say that data was not being sent, do you mean that the module was advertising as before - but there was not change in the advertised data - or do you mean that no advertising was happening?

    Are you using the BLE advertising library? If you are, you could use the ble_advertising_advdata_update function to update your advertising data at runtime. Please mind that you should declare the advdata struct globally or statically, so that it persists outside the scope of your updating function.

    Also I read the description about the data structure “ble_gap_adv_data_t”, which says this memory will remain unmodified in application RAM and in order to update user needs to create another buffer.
    - what is the correct way to update it using SDK v17.0
    - Is there any documentation given by Nordic related to same.
    - I am sure Nordic must have done these changes for a reason.
    - I am also sure people must have reported this behaviour since the API was introduced in SDK v15

    Yes. Previously to nRF5 SDK v16.0.0 the user had to manually double buffer their advertising data, in order to use the ble_advertising_advdata_update function. You might have read some older forum posts regarding this.
    However, since the release of SDK v.16.0.0 this is handled by the ble_advertising_advdata_update function itself, so the user does not have to remember this. If you would like to know exactly how this was changed you can compare the SDK ble_advertising.c source code from SDK v15.3.0 with the one from SDK v17.0.0. In essence, it makes sure that new buffers are provided to the configuration every time the update function is called.

    Please do not hesitate to ask if any part of my answer should be unclear, or if you encounter any other issues or questions!

    Best regards,
    Karl

Reply
  • Hello,

    I am new to BLE development.

    Welcome!

    However I faced issues when updating the sensor data at runtime. Data was not being sent.

    Could you elaborate how you attempted to do this? When you say that data was not being sent, do you mean that the module was advertising as before - but there was not change in the advertised data - or do you mean that no advertising was happening?

    Are you using the BLE advertising library? If you are, you could use the ble_advertising_advdata_update function to update your advertising data at runtime. Please mind that you should declare the advdata struct globally or statically, so that it persists outside the scope of your updating function.

    Also I read the description about the data structure “ble_gap_adv_data_t”, which says this memory will remain unmodified in application RAM and in order to update user needs to create another buffer.
    - what is the correct way to update it using SDK v17.0
    - Is there any documentation given by Nordic related to same.
    - I am sure Nordic must have done these changes for a reason.
    - I am also sure people must have reported this behaviour since the API was introduced in SDK v15

    Yes. Previously to nRF5 SDK v16.0.0 the user had to manually double buffer their advertising data, in order to use the ble_advertising_advdata_update function. You might have read some older forum posts regarding this.
    However, since the release of SDK v.16.0.0 this is handled by the ble_advertising_advdata_update function itself, so the user does not have to remember this. If you would like to know exactly how this was changed you can compare the SDK ble_advertising.c source code from SDK v15.3.0 with the one from SDK v17.0.0. In essence, it makes sure that new buffers are provided to the configuration every time the update function is called.

    Please do not hesitate to ask if any part of my answer should be unclear, or if you encounter any other issues or questions!

    Best regards,
    Karl

Children
No Data
Related