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);
}

Parents
  • 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

Reply Children
No Data
Related