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

How to set ''Complete Local Name" of ibeacon

When I use master control panel to scan ibeacn, I find "Complete Local Name" in below picture,

How to set the "Complete local name" ?

I heard someone says set in the scan response struct,but how to set?

Thanks!

image description

  • If you want to use a short name in the advertisement data and the full name in the scan response data, you can edit the advertising_init() function in main.c to something like this:

    static void advertising_init(void)
    {
        uint32_t      err_code;
        ble_advdata_t advdata;
    
        memset(&advdata, 0, sizeof(advdata));
    
        advdata.name_type               = BLE_ADVDATA_SHORT_NAME;
        advdata.short_name_len          = 6;
        advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
        
        /* Create the scan response struct: */
        ble_advdata_t srdata;
        memset(&srdata, 0, sizeof(srdata));
        srdata.name_type               = BLE_ADVDATA_FULL_NAME;
        /**/
    
        ble_adv_modes_config_t options = {0};
        options.ble_adv_fast_enabled   = BLE_ADV_FAST_ENABLED;
        options.ble_adv_fast_interval  = APP_ADV_INTERVAL;
        options.ble_adv_fast_timeout   = APP_ADV_TIMEOUT_IN_SECONDS;
        
        /* Pass the srdata struct to the init function: */
        err_code = ble_advertising_init(&advdata, &srdata, &options, on_adv_evt, NULL);
        APP_ERROR_CHECK(err_code);
    }
    

    This will use the short name in advdata and the full name in srdata. Then you need to pass both to the ble_advertising_init() function.

  • I want to set ''Complete Local Name" of ibeacon .in nRF5_SDK_15.0.0_a53641 ,but the api 

        err_code = ble_advertising_init(&advdata, &srdata, &options, on_adv_evt, NULL);
    is not exist.can you tell me new api or other method solvetheproblem
  • For SDK15, I found that they use ble_advdata_encode rather than ble_advertising_init

    So I think you have to update each data packet seperately, which should look like:

        err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
        APP_ERROR_CHECK(err_code);
    
        err_code = ble_advdata_encode(&srdata, m_adv_data.scan_rsp_data.p_data, &m_adv_data.scan_rsp_data.len);
        APP_ERROR_CHECK(err_code);

Related