Skip to content

Commit 20be667

Browse files
nordicjmjhedberg
authored andcommitted
mgmt: mcumgr: grp: settings_mgmt: Part revert settings save change
Partially reverts commit 7d2fb6c, it was originally thought that this commit added a method of saving one specific key using the value that the device already has set, but has been found to actually save the value that the user has provided, bypassing the current value that the device has, which is not compliant with the settings mgmt protocol, therefore remove this change and it will need to be reworked in future to function properly by saving one specific value from the device's current configuration, not a user-specified value Signed-off-by: Jamie McCrae <[email protected]>
1 parent 2408b80 commit 20be667

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

include/zephyr/mgmt/mcumgr/grp/settings_mgmt/settings_mgmt_callbacks.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,12 @@ struct settings_mgmt_access {
5959
#endif
6060

6161
/**
62-
* Data provided by the user (only set for SETTINGS_ACCESS_WRITE and SETTINGS_ACCESS_SAVE)
62+
* Data provided by the user (only set for SETTINGS_ACCESS_WRITE)
6363
*/
6464
const uint8_t *val;
6565

6666
/**
67-
* Length of data provided by the user (only set for SETTINGS_ACCESS_WRITE and
68-
* SETTINGS_ACCESS_SAVE)
67+
* Length of data provided by the user (only set for SETTINGS_ACCESS_WRITE)
6968
*/
7069
const size_t *val_length;
7170
};

subsys/mgmt/mcumgr/grp/settings_mgmt/src/settings_mgmt.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -437,13 +437,10 @@ static int settings_mgmt_save(struct smp_streamer *ctxt)
437437
zcbor_state_t *zse = ctxt->writer->zs;
438438
zcbor_state_t *zsd = ctxt->reader->zs;
439439
bool ok = true;
440-
struct zcbor_string data = {0};
441440
size_t decoded;
442441
struct zcbor_string key = {0};
443442
bool name_found = false;
444-
bool val_found = false;
445443
bool save_subtree = false;
446-
bool save_one = false;
447444

448445
#ifdef CONFIG_MCUMGR_GRP_SETTINGS_BUFFER_TYPE_HEAP
449446
char *key_name = NULL;
@@ -453,7 +450,6 @@ static int settings_mgmt_save(struct smp_streamer *ctxt)
453450

454451
struct zcbor_map_decode_key_val settings_save_decode[] = {
455452
ZCBOR_MAP_DECODE_KEY_DECODER("name", zcbor_tstr_decode, &key),
456-
ZCBOR_MAP_DECODE_KEY_DECODER("val", zcbor_bstr_decode, &data),
457453
};
458454

459455
ok = zcbor_map_decode_bulk(zsd, settings_save_decode, ARRAY_SIZE(settings_save_decode),
@@ -465,18 +461,14 @@ static int settings_mgmt_save(struct smp_streamer *ctxt)
465461

466462
name_found = zcbor_map_decode_bulk_key_found(settings_save_decode,
467463
ARRAY_SIZE(settings_save_decode), "name");
468-
val_found = zcbor_map_decode_bulk_key_found(settings_save_decode,
469-
ARRAY_SIZE(settings_save_decode), "val");
470464

471-
if ((name_found && key.len == 0) || (val_found && data.len == 0)) {
465+
if (name_found && key.len == 0) {
472466
return MGMT_ERR_EINVAL;
473-
} else if (name_found && val_found) {
474-
save_one = true;
475467
} else if (name_found) {
476468
save_subtree = true;
477469
}
478470

479-
if (save_one || save_subtree) {
471+
if (save_subtree) {
480472
if (key.len >= CONFIG_MCUMGR_GRP_SETTINGS_NAME_LEN) {
481473
ok = smp_add_cmd_err(zse, MGMT_GROUP_ID_SETTINGS,
482474
SETTINGS_MGMT_ERR_KEY_TOO_LONG);
@@ -499,8 +491,6 @@ static int settings_mgmt_save(struct smp_streamer *ctxt)
499491
struct settings_mgmt_access settings_access_data = {
500492
.access = SETTINGS_ACCESS_SAVE,
501493
.name = name_found ? key_name : NULL,
502-
.val = val_found ? data.value : NULL,
503-
.val_length = val_found ? &data.len : NULL,
504494
};
505495

506496
enum mgmt_cb_return status;
@@ -524,9 +514,7 @@ static int settings_mgmt_save(struct smp_streamer *ctxt)
524514
}
525515
}
526516

527-
if (save_one) {
528-
rc = settings_save_one(key_name, data.value, data.len);
529-
} else if (save_subtree) {
517+
if (save_subtree) {
530518
rc = settings_save_subtree(key_name);
531519
} else {
532520
rc = settings_save();

0 commit comments

Comments
 (0)