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

ble_advertising_advdata_update

Hi All. 

I am trying to use the "ble_advertising_advdata_update" function, but my compiler is giving me the following error. Which class do I need to add?

undefined reference to `ble_advertising_advdata_update


I am using SDK nRF5_SDK_15.0.0_a53641a. Advertising works ok after initialisation, but I am trying to update the manufacturer data whilst advertising.

Thanks

void advertising_update(void)
{
    ret_code_t err_code;
    uint8_t testData[8] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x11, 0x22};

    ble_gap_adv_data_t adv_data2 = {
        .adv_data.p_data = testData,
        .adv_data.len = 0x08,
        .scan_rsp_data.p_data = testData,
        .scan_rsp_data.len = 0//sizeof(raw_scan_rsp_data_buffer2)
    };

    err_code = ble_advertising_advdata_update(&m_advertising, &adv_data2, true);
    APP_ERROR_CHECK(err_code);
}

  • Ok, so I have updated the ble_advertising .c and .h files with the ones from the newer SDK (the function was missing from SDK 15.0.0).

    However I am still getting the error?

  • It is sort of working now. I had to rename ble_advertising_advdata_update and then name it back, as SES was caching something.

    I updated the code based on this useful answer to similar question;

    https://devzone.nordicsemi.com/f/nordic-q-a/38056/advertising-data-update-nrf_error_invalid_addr

    It now updates and using scanner you can see the modified data / byte, however it returns a NRF_ERROR_INVALID_STATE error, and crashes the device after working once.

    void advertising_update(uint8_t value)
    {
        ret_code_t err_code;
        uint8_t testData[8] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x11, 0x22};
        testData[7] = value;
     
        static bool buffer_index; // We alternate between two data buffer in order to hot-swap
        static ble_gap_adv_data_t new_data;
        ble_gap_adv_data_t *old_data  = &m_advertising.adv_data;
    
        // Copy advertising data
        static uint8_t data[2][BLE_GAP_ADV_SET_DATA_SIZE_MAX];
        new_data.adv_data.p_data      = data[buffer_index];
        new_data.adv_data.len         = old_data->adv_data.len;
        memcpy(new_data.adv_data.p_data, old_data->adv_data.p_data, old_data->adv_data.len);
    
    //memcpy(test2, old_data->adv_data.p_data, old_data->adv_data.len);
    
        // Update manufacturer specific data
        const uint8_t manuf_data_offset = 7;
        memcpy(&new_data.adv_data.p_data[manuf_data_offset], testData, 0x08);
    
        // Copy scan response data
        static uint8_t scan_data[2][BLE_GAP_ADV_SET_DATA_SIZE_MAX];
        new_data.scan_rsp_data.p_data = scan_data[buffer_index];
        new_data.scan_rsp_data.len    = old_data->scan_rsp_data.len;
        memcpy(new_data.scan_rsp_data.p_data,
               old_data->scan_rsp_data.p_data,
               old_data->scan_rsp_data.len);
    
    
    
        err_code = ble_advertising_advdata_update(&m_advertising, &new_data, true);
        APP_ERROR_CHECK(err_code);
    }

  • Hi.

    I see that you have created a new ticket about the invalid state issue, so that question will be answered in that ticket. @ref ticket.

    Best regards,

    Andreas

  • Resurrecting this ticket as I'm trying to do the same thing now.

    The accepted answer uses ble_advertising_advdata_update()

    The documentation for ble_advertising_advdata_update() says,

    "This function can be called if you wish to reconfigure the advertising data The update will be effective even if advertising has already been started"

    (my emphasis)

    The 2nd parameter of ble_advertising_advdata_update()  is of type ble_gap_adv_data_t - for which the documentation says:

    "GAP advertising data buffers.
    The application must provide the buffers for advertisement. The memory shall reside in application RAM, and
    shall never be modified while advertising"

    (my emphasis again)

    This seems to contradict the statement that ble_advertising_advdata_update()   can be used during advertising?!

    Please clarify!

    I see that you have created a new ticket about the invalid state issue, so that question will be answered in that ticket. @ref ticket.

    Unfortunately, that seems to be a Private ticket - was the resolution relevant to this question?

    I am looking at SDK 15.3.0

  • Hi. Yes was a private ticket.

    No we couldn't get ble_advertising_advdata_update() working more than once. The device would reset on the second attempt of an update.

    I have a work around I can share with you, but it is not pretty compare to the function that should work.

    Phil

Related