Skip to content

Commit cc5be70

Browse files
committed
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]>
1 parent 078c5a8 commit cc5be70

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <zephyr/logging/log_ctrl.h>
1414
#include <zephyr/mgmt/mcumgr/mgmt/callbacks.h>
1515
#include <bluetooth/services/ble_mcumgr.h>
16+
#include <zephyr/settings/settings.h>
1617

1718
LOG_MODULE_REGISTER(app, CONFIG_APP_LOG_LEVEL);
1819

@@ -180,6 +181,14 @@ int main(void)
180181
return 0;
181182
}
182183

184+
err = settings_subsys_init();
185+
186+
if (err) {
187+
LOG_ERR("Failed to enable settings: %d", err);
188+
}
189+
190+
/* settings_load(); */
191+
183192
LOG_INF("Bluetooth enabled");
184193

185194
err = ble_mcumgr_init();

samples/mcumgr/ble_mcumgr/src/main.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <ble_conn_params.h>
2323
#include <bluetooth/services/ble_mcumgr.h>
2424
#include <zephyr/settings/settings.h>
25+
#include <zephyr/retention/retention.h>
2526
#include <settings/bluetooth_name.h>
2627

2728
LOG_MODULE_REGISTER(app, CONFIG_APP_LOG_LEVEL);
@@ -270,6 +271,14 @@ int main(void)
270271
return 0;
271272
}
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);

0 commit comments

Comments
 (0)