Hello,
I am trying to change the device name in the ble advertisement in the secure_bootloader example.
Module model: nrf52832
Sdk: 15.2
I have tried to put the following code just above the main function:
static char deviceName[20] = "abc";
static nrf_dfu_adv_name_t _name;
uint32_t nrf_dfu_init_user(void)
{
nrf_dfu_adv_name_t* name = &_name;
uint32_t err;
uint32_t deviceId = 12;
NRF_LOG_DEBUG("***in custom nrf_dfu_init_user, id = %d", deviceId);
snprintf(&deviceName[strlen(deviceName)], strlen(deviceName), "%d", deviceId);
strcpy(name->name, deviceName);
name->len = strlen(deviceName);
NRF_LOG_DEBUG("***advertise name length = %d", strlen(deviceName));
NRF_LOG_DEBUG("***advertise name = %s", deviceName);
err = nrf_dfu_settings_adv_name_write(name);
return err;
}
It does not work as the error code of NRF_ERROR_SVC_HANDLER_MISSING is returned at the nrf_dfu_settings_adv_name_write() call.
It looks like the softdevice is not enabled when this function is being called.
What is the correct way to change the device name in the advertisement dynamically without touching the sdk?
Changing the NRF_DFU_BLE_ADV_NAME in the sdk_config.h file works for static names, but I will need to attach a number at the end of the static name so I need to do it during run time.
Many thanks.