Skip to content

Commit ba9267c

Browse files
nordicjmnvlsianpu
authored andcommitted
samples: boot: mcuboot_recovery_entry: Add settings test code
Adds code to set bluetooth name to retention settings Signed-off-by: Jamie McCrae <[email protected]> Signed-off-by: Andrzej Puzdrowski <[email protected]>
1 parent 752047e commit ba9267c

File tree

3 files changed

+24
-1
lines changed
  • applications/firmware_loader/ble_mcumgr/src
  • samples/boot/mcuboot_recovery_entry

3 files changed

+24
-1
lines changed

applications/firmware_loader/ble_mcumgr/src/main.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <zephyr/logging/log_ctrl.h>
2525
#include <zephyr/settings/settings.h>
2626
#include <bm/settings/bluetooth_name.h> // to be moved to bm folder
27+
#include <zephyr/retention/retention.h>
2728

2829
LOG_MODULE_REGISTER(app, CONFIG_APP_LOG_LEVEL);
2930

@@ -270,6 +271,14 @@ int main(void)
270271
LOG_ERR("Failed to update advertising data, err %d", err);
271272
return 0;
272273
}
274+
275+
/* Clear settings after device name has been set so it does not persist */
276+
err = retention_clear(DEVICE_DT_GET(DT_CHOSEN(zephyr_settings_partition)));
277+
278+
if (err) {
279+
LOG_ERR("Failed to clear retention area, err %d", err);
280+
return 0;
281+
}
273282
}
274283

275284
err = ble_adv_start(&ble_adv, BLE_ADV_MODE_FAST);

samples/boot/mcuboot_recovery_entry/prj.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,9 @@ CONFIG_NRF_SDH_BLE_GATT_MAX_MTU_SIZE=498
4747
CONFIG_BLE_CONN_PARAMS_MAX_CONN_INTERVAL=24
4848
CONFIG_BLE_CONN_PARAMS_SUP_TIMEOUT=20
4949
CONFIG_BLE_CONN_PARAMS_MAX_SUP_TIMEOUT_DEVIATION=20
50+
51+
CONFIG_SETTINGS=y
52+
CONFIG_SETTINGS_RETENTION=y
53+
CONFIG_SETTINGS_RUNTIME=y
54+
CONFIG_MCUMGR_GRP_SETTINGS=y
55+
CONFIG_NCS_BM_SETTINGS_BLUETOOTH_NAME=y

samples/boot/mcuboot_recovery_entry/src/main.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <zephyr/logging/log.h>
1515
#include <zephyr/logging/log_ctrl.h>
1616
#include <zephyr/mgmt/mcumgr/mgmt/callbacks.h>
17-
17+
#include <zephyr/settings/settings.h>
1818

1919
LOG_MODULE_REGISTER(app, CONFIG_APP_LOG_LEVEL);
2020

@@ -184,6 +184,14 @@ int main(void)
184184
return 0;
185185
}
186186

187+
err = settings_subsys_init();
188+
189+
if (err) {
190+
LOG_ERR("Failed to enable settings: %d", err);
191+
}
192+
193+
/* settings_load(); */
194+
187195
LOG_INF("Bluetooth enabled");
188196

189197
nrf_err = ble_mcumgr_init();

0 commit comments

Comments
 (0)