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
  • FormerMember
    0 FormerMember

    Thanks and Karl Ylvisaker for the support.

    awneil, I will make sure to follow the correct way to insert code snippets as shown by you. 

    Karl Ylvisaker, 

    The issue got resolved after using the BLE advertising library. I was not using the same.

    Yes. Actually what I meant earlier when I said data was not being sent was "there was no change in advertising data".

    Now after using the "ble_advertising_advdata_update" function data is being updated. I am verifying it using nRF Connect app.

    Here is the code snippet

    // data structure intialization
    BLE_ADVERTISING_DEF(pw_advertising);        //< Advertising module instance. 
    
    typedef struct{
    
      ble_advdata_manuf_data_t manuf_specific_data;
      ble_advertising_init_t pw_init; 
    
    }pw_ble_adv_data_t;
    
    static pw_ble_adv_data_t pw_ble_data;
    
    // Within Advertising Init function
        
    err_code = ble_advertising_init(&pw_advertising, &pw_ble_data.pw_init);
    
    if(err_code != NRF_SUCCESS)
    {
      NRF_LOG_INFO("Error Occured: %d",err_code);
    }
    
    ble_advertising_conn_cfg_tag_set(&pw_advertising, APP_BLE_CONN_CFG_TAG);
    
    
    // updation code after the timer expires
    ble_advertising_advdata_update(&pw_advertising,&pw_ble_data.pw_init.advdata,&pw_ble_data.pw_init.srdata);
    
    

    Few changes I had to do once I started to use the ble_advertising library

    //had to set the following macros to 1
    
    #define BLE_ADVERTISING_ENABLED 1
    
    #define NRF_SDH_BLE_PERIPHERAL_LINK_COUNT 1

    I got a error while debugging the code related to memory not being sufficient

    So I had to change this "Common project configuration" from

    RAM_START=0x200018C8

    to

    RAM_START=0x20001DC8

    Thanks

    pwarrier

  • Hello pwarrier,

    pwarrier said:
    The issue got resolved after using the BLE advertising library.

    I am happy to hear that it resolved your issue!

    Thank you for providing details on what you changed to make it work for your project, so other users might see in the future.
    I will also leave a link to this blogpost for future reference, which goes through how to dynamically change advertising data using the BLE Advertising library.

    Please do not hesitate to open a new ticket if you should encounter any issues or questions in the future.

    Good luck with your development!

    Best regards,
    Karl

Reply Children
No Data
Related