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

For BLE peripheral advertisement, is it possible to change device_name on the fly?

Hi , I need the BLE peripheral to have 'name1' at the start up and change it to 'name2' when a button is pressed. I want to do this without disabling and enabling the softdevice. I followed this sequence, but the device name is not changed (made sec_mode global):

ble_stack_init();
peer_manager_init(false);
gap_params_init();
advertising_init();
gatt_init();
services_init();
conn_params_init();

// Start execution.
advertising_start();	


sd_ble_gap_adv_stop();

uint32_t err_code = sd_ble_gap_device_name_set(&sec_mode,
                                      (const uint8_t *)PAIRING_DEVICE_NAME,
                                      strlen(PAIRING_DEVICE_NAME));
APP_ERROR_CHECK(err_code);	


err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
APP_ERROR_CHECK(err_code);
Related