When the device powers up I want to grab the device name from a known location and also rewrite that same location when I get a new device name. How can I write to the internal flash in the least disruptive way to normal operation? Do I need to use the pstorage.c
or device_manager_peripheral.c
? The device manager seems to already perform the initialization of pstorage.
void update_name(const char* name) {
uint32_t err_code;
ble_gap_conn_sec_mode_t sec_mode;
// Write the new name to the soft device
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
err_code = sd_ble_gap_device_name_set(&sec_mode, (const uint8_t *)new_name, strlen(new_name));
APP_ERROR_CHECK(err_code);
// Write the new name to internal flash
????
}
soft device version: 8.0.0