From 25358010551a0638eabfbd5d55908aad96e130ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Kr=C3=B3lik?= <66667989+Damian-Nordic@users.noreply.github.com> Date: Fri, 26 Nov 2021 14:39:56 +0100 Subject: [PATCH] [nrfconnect] Don't erase factory keys on the factory reset (#12253) * [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 --- src/platform/Zephyr/ZephyrConfig.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/platform/Zephyr/ZephyrConfig.cpp b/src/platform/Zephyr/ZephyrConfig.cpp index 7171a55b2f15ae..dadeabba34adc8 100644 --- a/src/platform/Zephyr/ZephyrConfig.cpp +++ b/src/platform/Zephyr/ZephyrConfig.cpp @@ -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");