Skip to content

Commit

Permalink
[nrfconnect] Don't erase factory keys on the factory reset (#12253)
Browse files Browse the repository at this point in the history
* [nrfconnect] Don't erase factory keys on the factory reset

The factory reset on nRF Connect platforms erases all
settings starting with "mt/". Make sure that factory
configuration keys are not descendants of the "mt" subtree,
so use "mt-fact" prefix for them.

* Restyled by clang-format

Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
2 people authored and pull[bot] committed Feb 8, 2024
1 parent ff2264a commit 1076096
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/platform/Zephyr/ZephyrConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ namespace Internal {
(key); \
static_assert(sizeof(key) <= SETTINGS_MAX_NAME_LEN, "Config key too long: " key)

// Define the configuration keys to be part of the CHIP_DEVICE_CONFIG_SETTINGS_KEY subtree
// so that they get erased when KeyValueStoreManagerImpl::DoFactoryReset() is called.
// clang-format off
#define NAMESPACE_FACTORY CHIP_DEVICE_CONFIG_SETTINGS_KEY "/fct/"
#define NAMESPACE_CONFIG CHIP_DEVICE_CONFIG_SETTINGS_KEY "/cfg/"
// Define the configuration keys (except the factory keys) to be part of the
// CHIP_DEVICE_CONFIG_SETTINGS_KEY subtree so that they get erased when
// KeyValueStoreManagerImpl::DoFactoryReset() is called.
#define NAMESPACE_FACTORY CHIP_DEVICE_CONFIG_SETTINGS_KEY "-fct/"
#define NAMESPACE_CONFIG CHIP_DEVICE_CONFIG_SETTINGS_KEY "/cfg/"
#define NAMESPACE_COUNTERS CHIP_DEVICE_CONFIG_SETTINGS_KEY "/ctr/"
// clang-format on

// Keys stored in the chip factory nam
const ZephyrConfig::Key ZephyrConfig::kConfigKey_SerialNum = CONFIG_KEY(NAMESPACE_FACTORY "serial-num");
Expand Down

0 comments on commit 1076096

Please sign in to comment.