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

Advertising data update NRF_ERROR_INVALID_ADDR

I'm trying to use the new ble_advertising_advdata_update from SDK 15.1 by doing 

ble_gap_adv_data_t adv_data;
uint8_t data[2];
memcpy(&data, &m_adv_manuf_array, sizeof(m_adv_manuf_array));
adv_data.adv_data.p_data = data;
adv_data.adv_data.len = sizeof(data);
ret_code = ble_advertising_advdata_update(&m_advertising, &adv_data, true);
APP_ERROR_CHECK(ret_code);

but I get NRF_ERROR_INVALID_ADDR

What do I need to do to get it to work?

  • I solved it like this. I had hoped that there would be some simpler way to update the manufacturer specific data while advertising.

    void advertising_update()
    {
        ret_code_t ret_code;
    
        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);
    
        // Update manufacturer specific data
        const uint8_t manuf_data_offset = 15;
        adv_manuf_data_update();
        memcpy(&new_data.adv_data.p_data[manuf_data_offset],
               &adv.manuf_data_array,
               sizeof(adv.manuf_data_array));
    
        // 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);
    
        ret_code = ble_advertising_advdata_update(&m_advertising, &new_data, true);
        APP_ERROR_CHECK(ret_code);
    
        buffer_index = !buffer_index;
    }

  • Hi,

    Yes, it looks like you still need to handle the double buffering for the "permanent" option of ble_advertising_advdata_update() to work, at least with the v6.1.0 SoftDevice. I have notified the SoftDevice team about this, and we are looking into the issue.

    Regards,
    Terje

  • it looks like you still need to handle the double buffering for the "permanent" option of

    Could you explain that ?

    In the code:

        // Update manufacturer specific data
        const uint8_t manuf_data_offset = 15;
        adv_manuf_data_update();

    • Where does the Magic Number 15 come from?
    • What is (or was) adv_manuf_data_update() ? I can't see it anywhere in SDK 15.3.0
  • I got the offset 15 just by looking at the advertised data and see where the manuf data started. It depends which data you add to your advertising data during initialization. I'm sure there is some way to calculate it but I didn't find it at the time.

    adv_manuf_data_update is my local function which retrieves whatever I want in the manufacturer specific data into adv.manuf_data_array which is just a global byte array that I created.

Related