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

ble_advdata_set deprecated

Hello,

I am trying to move the

err_code = ble_advdata_set(&advdata, NULL);

 return err_code;

Looking the documentation the new functions to update the advertisment are:

 ret = ble_advdata_encode(&advdata_, new_advdata.adv_data.p_data, &new_advdata.adv_data.len);
    APP_ERROR_CHECK(ret);
     
        
 ret = sd_ble_gap_adv_set_configure(&(m_advertising).adv_handle, &new_advdata, NULL);
    APP_ERROR_CHECK(ret);

But I don't undestand how use it to modify the 0xFF type data,...

I am trying with a function like this:

uint32_t _ble_update_manuf_specific_data( uint16_t vSize, uint8_t * vData ){
    uint32_t err_code;
        
        ble_gap_adv_data_t     new_advdata;
        ble_advdata_t             adver_data;
    
        memset(&new_advdata, 0, sizeof(new_advdata));
        memset(&adver_data, 0, sizeof(adver_data));
    
        adver_data.name_type                       = BLE_ADVDATA_FULL_NAME;
    adver_data.include_appearance              = true;
    adver_data.flags                           = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    adver_data.uuids_complete.uuid_cnt         = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    adver_data.uuids_complete.p_uuids          = m_adv_uuids;
            
        adver_data.p_manuf_specific_data           = &m_manuf_specific_data;
        m_manuf_specific_data.data.p_data         = m_manuf_data_array;
    
        adver_data.p_manuf_specific_data->company_identifier = LULABYTES_ID;
        adver_data.p_manuf_specific_data->data.size                     = vSize;        
        for(uint32_t i = 0; i < vSize; i++){ m_manuf_data_array[i] = vData[i];    }    

          

    err_code = ble_advdata_encode(&adver_data, &(new_advdata->adver_data.p_data), &(new_advdata->adver_data.len));
    APP_ERROR_CHECK(err_code);
    
        err_code = sd_ble_gap_adv_set_configure(&(m_advertising).adv_handle, &new_advdata, NULL);
    APP_ERROR_CHECK(err_code);
    
    return err_code;
}

But it has errors.

  • Hi!

    Maybe you could provide some more specific information?

    In general it is very often useful to include a little information about your setup; SDK version, which device, Softdevice version etc.

    As for your issue "But it has errors"; could you include some information about which function returns the error code? What error code is returned?
    This makes is a lot easier to figure out what the problem is.

    Best regards,
    Joakim.

  • Hello!!

    I'm using nRF5_SDK_15.0.0_a53641a

    I would like to modify the advertise frame every 5 seconds.

    I was using this code to modify:

    uint32_t _ble_update_manuf_specific_data( uint16_t vSize, uint8_t * vData ){
        uint32_t err_code;
            
            
            advdata.p_manuf_specific_data                                       = &m_manuf_specific_data;
            m_manuf_specific_data.data.p_data                                 = m_manuf_data_array;
        
            advdata.p_manuf_specific_data->company_identifier = LULABYTES_ID;
            advdata.p_manuf_specific_data->data.size                     = vSize;        
            for(uint32_t i = 0; i < vSize; i++){
                    m_manuf_data_array[i] = vData[i];
            }
        
        
        err_code = ble_advdata_set(&advdata, NULL);
        return err_code;
    }

    But in this new version, the function ble_advdata_set is deprecated.

    So I would like to know how can modify this information. I found an example in the forum but it doesn't work.

    Best regards,

    Juan

  • Hello,

    Using this function:
    uint32_t advertising_data_update(uint8_t adv_manuf_byte){
        
          uint32_t ret = NRF_SUCCESS;
        ret_code_t err_code;
        ble_advdata_t                                  advdata;       /**< Advertising data: name, appearance, discovery flags, and more. */
        //ble_advdata_t                              srdata;        /**< Scan response data: Supplement to advertising data. */

            uint8_array_t                                    adv_manuf_data_array;
            uint8_t                                          adv_manuf_data_data[2] = {0x00,0x0B};
            ble_advdata_manuf_data_t                         adv_manuf_data;
            adv_manuf_data_data[0]                         = adv_manuf_byte;
        
        memset(&advdata, 0, sizeof(advdata));
        //memset(&srdata, 0, sizeof(srdata));
       
        advdata.name_type                      = BLE_ADVDATA_FULL_NAME;
        advdata.include_appearance             = false;
        advdata.flags                          = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;//BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
        advdata.uuids_complete.uuid_cnt     = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        advdata.uuids_complete.p_uuids      = m_adv_uuids;
            
            adv_manuf_data.company_identifier   = LULABYTES_ID;
            adv_manuf_data_array.p_data         = adv_manuf_data_data;
            adv_manuf_data_array.size                     = sizeof(adv_manuf_data_data);
            adv_manuf_data.data                                 = adv_manuf_data_array;
            advdata.p_manuf_specific_data             = &adv_manuf_data;

        ret = update_advertising_data(&m_advertising, &advdata, m_advertising.adv_data.adv_data.len +1, NULL, 0);
            
            return ret;
    }


    uint32_t update_advertising_data(ble_advertising_t *p_advertising, ble_advdata_t *p_adv_data, uint16_t adv_data_len,
                                                                                                                                         ble_advdata_t *p_sr_data, uint16_t sr_data_len){
        
        //ASSERT(p_advertising->initialized);
        uint32_t ret = NRF_SUCCESS;
        uint8_t buffer[adv_data_len];
        memset(buffer, 0, adv_data_len);
        
        ble_gap_adv_data_t new_advdata;
        memset(&new_advdata, 0, sizeof(new_advdata));
        new_advdata.adv_data.p_data = buffer;
        new_advdata.adv_data.len = adv_data_len;      
        ret = ble_advdata_encode(p_adv_data, new_advdata.adv_data.p_data, &new_advdata.adv_data.len);
        //APP_ERROR_CHECK(ret);

        if (p_sr_data){
            new_advdata.scan_rsp_data.len = sr_data_len;
            ret = ble_advdata_encode(p_sr_data, new_advdata.scan_rsp_data.p_data, &new_advdata.scan_rsp_data.len);
            //APP_ERROR_CHECK(ret);
        
            }else{
            new_advdata.scan_rsp_data.p_data = NULL;
            new_advdata.scan_rsp_data.len    = 0;
        }

        ret = sd_ble_gap_adv_set_configure(&p_advertising->adv_handle, &new_advdata, NULL);
        //APP_ERROR_CHECK(ret);
            
            return ret;
    }

    The first time that I call it I have Error Code 0, but the second time I get the ERROR CODE 8.

    Best regards,

    Juan

  • Hi again.

    Have you seen this post?
    https://devzone.nordicsemi.com/f/nordic-q-a/33606/updating-advertising-data-manuf-spec-data-in-sdk15

    This contains a long discussion, suggestions on how to do this, and workarounds for updating the advertisement data.

    If you haven't already, please take a look at the post.
    Please get back to me and let me know if you are not able find any useful information.

    Best regards,
    Joakim

Related