From 669e2ed7f3e754eb9866ed9973b12181926cce7b Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Mon, 10 Jan 2022 18:49:05 -0800 Subject: [PATCH] Add support for HourFormat & CalendarType in ConfigurationMgr --- src/include/platform/ConfigurationManager.h | 4 ++ .../GenericConfigurationManagerImpl.cpp | 46 +++++++++++++++++++ .../GenericConfigurationManagerImpl.h | 4 ++ src/platform/Ameba/AmebaConfig.cpp | 2 + src/platform/Ameba/AmebaConfig.h | 4 ++ src/platform/Darwin/PosixConfig.cpp | 2 + src/platform/Darwin/PosixConfig.h | 2 + src/platform/EFR32/EFR32Config.h | 8 ++-- src/platform/ESP32/ESP32Config.cpp | 2 + src/platform/ESP32/ESP32Config.h | 4 ++ src/platform/Linux/PosixConfig.cpp | 2 + src/platform/Linux/PosixConfig.h | 2 + src/platform/P6/P6Config.cpp | 10 ++-- src/platform/P6/P6Config.h | 4 ++ src/platform/Tizen/PosixConfig.cpp | 2 + src/platform/Tizen/PosixConfig.h | 2 + src/platform/Zephyr/ZephyrConfig.cpp | 5 +- src/platform/Zephyr/ZephyrConfig.h | 3 ++ src/platform/android/AndroidConfig.cpp | 2 + src/platform/android/AndroidConfig.h | 2 + .../chip/platform/ConfigurationManager.java | 2 + .../cc13x2_26x2/CC13X2_26X2Config.cpp | 8 +++- src/platform/cc13x2_26x2/CC13X2_26X2Config.h | 2 + src/platform/fake/ConfigurationManagerImpl.h | 4 ++ src/platform/mbed/MbedConfig.cpp | 2 + src/platform/mbed/MbedConfig.h | 2 + src/platform/nxp/k32w/k32w0/K32W0Config.h | 2 + src/platform/qpg/qpgConfig.h | 6 ++- src/platform/tests/TestConfigurationMgr.cpp | 30 ++++++++++++ 29 files changed, 158 insertions(+), 12 deletions(-) diff --git a/src/include/platform/ConfigurationManager.h b/src/include/platform/ConfigurationManager.h index 4488fdc4cc88d8..88a2c857cb4b1f 100644 --- a/src/include/platform/ConfigurationManager.h +++ b/src/include/platform/ConfigurationManager.h @@ -102,6 +102,8 @@ class ConfigurationManager virtual CHIP_ERROR GetCountryCode(char * buf, size_t bufSize, size_t & codeLen) = 0; virtual CHIP_ERROR GetActiveLocale(char * buf, size_t bufSize, size_t & codeLen) = 0; virtual CHIP_ERROR GetBreadcrumb(uint64_t & breadcrumb) = 0; + virtual CHIP_ERROR GetHourFormat(uint8_t & format) = 0; + virtual CHIP_ERROR GetCalendarType(uint8_t & type) = 0; virtual CHIP_ERROR StoreSerialNumber(const char * serialNum, size_t serialNumLen) = 0; virtual CHIP_ERROR StorePrimaryWiFiMACAddress(const uint8_t * buf) = 0; virtual CHIP_ERROR StorePrimary802154MACAddress(const uint8_t * buf) = 0; @@ -113,6 +115,8 @@ class ConfigurationManager virtual CHIP_ERROR StoreCountryCode(const char * code, size_t codeLen) = 0; virtual CHIP_ERROR StoreActiveLocale(const char * code, size_t codeLen) = 0; virtual CHIP_ERROR StoreBreadcrumb(uint64_t breadcrumb) = 0; + virtual CHIP_ERROR StoreHourFormat(uint8_t format) = 0; + virtual CHIP_ERROR StoreCalendarType(uint8_t type) = 0; virtual CHIP_ERROR GetRebootCount(uint32_t & rebootCount) = 0; virtual CHIP_ERROR StoreRebootCount(uint32_t rebootCount) = 0; virtual CHIP_ERROR GetTotalOperationalHours(uint32_t & totalOperationalHours) = 0; diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.cpp b/src/include/platform/internal/GenericConfigurationManagerImpl.cpp index 141c9bffead4f4..9108081aceabdf 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.cpp +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.cpp @@ -321,6 +321,52 @@ CHIP_ERROR GenericConfigurationManagerImpl::StoreRegulatoryLocation return WriteConfigValue(ConfigClass::kConfigKey_RegulatoryLocation, value); } +template +CHIP_ERROR GenericConfigurationManagerImpl::GetHourFormat(uint8_t & format) +{ + uint32_t value = 0; + + CHIP_ERROR err = ReadConfigValue(ConfigClass::kConfigKey_HourFormat, value); + + if (err == CHIP_NO_ERROR) + { + VerifyOrReturnError(value <= UINT8_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE); + format = static_cast(value); + } + + return err; +} + +template +CHIP_ERROR GenericConfigurationManagerImpl::StoreHourFormat(uint8_t format) +{ + uint32_t value = format; + return WriteConfigValue(ConfigClass::kConfigKey_HourFormat, value); +} + +template +CHIP_ERROR GenericConfigurationManagerImpl::GetCalendarType(uint8_t & type) +{ + uint32_t value = 0; + + CHIP_ERROR err = ReadConfigValue(ConfigClass::kConfigKey_CalendarType, value); + + if (err == CHIP_NO_ERROR) + { + VerifyOrReturnError(value <= UINT8_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE); + type = static_cast(value); + } + + return err; +} + +template +CHIP_ERROR GenericConfigurationManagerImpl::StoreCalendarType(uint8_t type) +{ + uint32_t value = type; + return WriteConfigValue(ConfigClass::kConfigKey_CalendarType, value); +} + template CHIP_ERROR GenericConfigurationManagerImpl::GetCountryCode(char * buf, size_t bufSize, size_t & codeLen) { diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.h b/src/include/platform/internal/GenericConfigurationManagerImpl.h index 247a2ef1360826..8311dd3365e140 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.h +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.h @@ -110,6 +110,10 @@ class GenericConfigurationManagerImpl : public ConfigurationManager CHIP_ERROR GetLocalConfigDisabled(bool & disabled) override; CHIP_ERROR GetReachable(bool & reachable) override; CHIP_ERROR GetUniqueId(char * buf, size_t bufSize) override; + CHIP_ERROR GetHourFormat(uint8_t & format) override; + CHIP_ERROR StoreHourFormat(uint8_t format) override; + CHIP_ERROR GetCalendarType(uint8_t & type) override; + CHIP_ERROR StoreCalendarType(uint8_t type) override; CHIP_ERROR RunUnitTests(void) override; bool IsFullyProvisioned() override; void InitiateFactoryReset() override; diff --git a/src/platform/Ameba/AmebaConfig.cpp b/src/platform/Ameba/AmebaConfig.cpp index 56de35a1e38b9b..4e23b7c115db21 100644 --- a/src/platform/Ameba/AmebaConfig.cpp +++ b/src/platform/Ameba/AmebaConfig.cpp @@ -74,6 +74,8 @@ const AmebaConfig::Key AmebaConfig::kConfigKey_RegulatoryLocation = { k const AmebaConfig::Key AmebaConfig::kConfigKey_CountryCode = { kConfigNamespace_ChipConfig, "country-code" }; const AmebaConfig::Key AmebaConfig::kConfigKey_ActiveLocale = { kConfigNamespace_ChipConfig, "active-locale" }; const AmebaConfig::Key AmebaConfig::kConfigKey_Breadcrumb = { kConfigNamespace_ChipConfig, "breadcrumb" }; +const AmebaConfig::Key AmebaConfig::kConfigKey_HourFormat = { kConfigNamespace_ChipConfig, "hour-format" }; +const AmebaConfig::Key AmebaConfig::kConfigKey_CalendarType = { kConfigNamespace_ChipConfig, "calendar-type" }; // Keys stored in the Chip-counters namespace const AmebaConfig::Key AmebaConfig::kCounterKey_RebootCount = { kConfigNamespace_ChipCounters, "reboot-count" }; diff --git a/src/platform/Ameba/AmebaConfig.h b/src/platform/Ameba/AmebaConfig.h index af49048f9ace14..1ba6bf7c37a6f8 100755 --- a/src/platform/Ameba/AmebaConfig.h +++ b/src/platform/Ameba/AmebaConfig.h @@ -68,6 +68,10 @@ class AmebaConfig static const Key kConfigKey_CountryCode; static const Key kConfigKey_ActiveLocale; static const Key kConfigKey_Breadcrumb; + static const Key kConfigKey_HourFormat; + static const Key kConfigKey_CalendarType; + + // Counter keys static const Key kCounterKey_RebootCount; static const Key kCounterKey_UpTime; static const Key kCounterKey_TotalOperationalHours; diff --git a/src/platform/Darwin/PosixConfig.cpp b/src/platform/Darwin/PosixConfig.cpp index 5ee3104038b4d4..ea815f11832a5c 100644 --- a/src/platform/Darwin/PosixConfig.cpp +++ b/src/platform/Darwin/PosixConfig.cpp @@ -67,6 +67,8 @@ const PosixConfig::Key PosixConfig::kConfigKey_RegulatoryLocation = { kConfigNam const PosixConfig::Key PosixConfig::kConfigKey_CountryCode = { kConfigNamespace_ChipConfig, "country-code" }; const PosixConfig::Key PosixConfig::kConfigKey_ActiveLocale = { kConfigNamespace_ChipConfig, "active-locale" }; const PosixConfig::Key PosixConfig::kConfigKey_Breadcrumb = { kConfigNamespace_ChipConfig, "breadcrumb" }; +const PosixConfig::Key PosixConfig::kConfigKey_HourFormat = { kConfigNamespace_ChipConfig, "hour-format" }; +const PosixConfig::Key PosixConfig::kConfigKey_CalendarType = { kConfigNamespace_ChipConfig, "calendar-type" }; // Prefix used for NVS keys that contain Chip group encryption keys. const char PosixConfig::kGroupKeyNamePrefix[] = "gk-"; diff --git a/src/platform/Darwin/PosixConfig.h b/src/platform/Darwin/PosixConfig.h index 009433a91d4a5a..1d852822078c43 100644 --- a/src/platform/Darwin/PosixConfig.h +++ b/src/platform/Darwin/PosixConfig.h @@ -74,6 +74,8 @@ class PosixConfig static const Key kConfigKey_CountryCode; static const Key kConfigKey_ActiveLocale; static const Key kConfigKey_Breadcrumb; + static const Key kConfigKey_HourFormat; + static const Key kConfigKey_CalendarType; static const char kGroupKeyNamePrefix[]; diff --git a/src/platform/EFR32/EFR32Config.h b/src/platform/EFR32/EFR32Config.h index 9879aeba72a374..c008db24251489 100644 --- a/src/platform/EFR32/EFR32Config.h +++ b/src/platform/EFR32/EFR32Config.h @@ -94,9 +94,11 @@ class EFR32Config static constexpr Key kConfigKey_RegulatoryLocation = EFR32ConfigKey(kChipConfig_KeyBase, 0x09); static constexpr Key kConfigKey_CountryCode = EFR32ConfigKey(kChipConfig_KeyBase, 0x0A); static constexpr Key kConfigKey_Breadcrumb = EFR32ConfigKey(kChipConfig_KeyBase, 0x0B); - static constexpr Key kConfigKey_GroupKeyBase = EFR32ConfigKey(kChipConfig_KeyBase, 0x0C); - static constexpr Key kConfigKey_ActiveLocale = EFR32ConfigKey(kChipConfig_KeyBase, 0x0D); - static constexpr Key kConfigKey_GroupKeyMax = EFR32ConfigKey(kChipConfig_KeyBase, 0x1B); // Allows 16 Group Keys to be created. + static constexpr Key kConfigKey_ActiveLocale = EFR32ConfigKey(kChipConfig_KeyBase, 0x0C); + static constexpr Key kConfigKey_HourFormat = EFR32ConfigKey(kChipConfig_KeyBase, 0x0D); + static constexpr Key kConfigKey_CalendarType = EFR32ConfigKey(kChipConfig_KeyBase, 0x0E); + static constexpr Key kConfigKey_GroupKeyBase = EFR32ConfigKey(kChipConfig_KeyBase, 0x0F); + static constexpr Key kConfigKey_GroupKeyMax = EFR32ConfigKey(kChipConfig_KeyBase, 0x1E); // Allows 16 Group Keys to be created. // CHIP Counter Keys static constexpr Key kConfigKey_BootCount = EFR32ConfigKey(kChipCounter_KeyBase, 0x00); diff --git a/src/platform/ESP32/ESP32Config.cpp b/src/platform/ESP32/ESP32Config.cpp index 5b2d6ea2f3073e..a41a86c0002b15 100644 --- a/src/platform/ESP32/ESP32Config.cpp +++ b/src/platform/ESP32/ESP32Config.cpp @@ -73,6 +73,8 @@ const ESP32Config::Key ESP32Config::kConfigKey_RegulatoryLocation = { kConfigNam const ESP32Config::Key ESP32Config::kConfigKey_CountryCode = { kConfigNamespace_ChipConfig, "country-code" }; const ESP32Config::Key ESP32Config::kConfigKey_ActiveLocale = { kConfigNamespace_ChipConfig, "active-locale" }; const ESP32Config::Key ESP32Config::kConfigKey_Breadcrumb = { kConfigNamespace_ChipConfig, "breadcrumb" }; +const ESP32Config::Key ESP32Config::kConfigKey_HourFormat = { kConfigNamespace_ChipConfig, "hour-format" }; +const ESP32Config::Key ESP32Config::kConfigKey_CalendarType = { kConfigNamespace_ChipConfig, "calendar-type" }; // Keys stored in the Chip-counters namespace const ESP32Config::Key ESP32Config::kCounterKey_RebootCount = { kConfigNamespace_ChipCounters, "reboot-count" }; diff --git a/src/platform/ESP32/ESP32Config.h b/src/platform/ESP32/ESP32Config.h index dfd6f9a4151359..a16254d661579d 100644 --- a/src/platform/ESP32/ESP32Config.h +++ b/src/platform/ESP32/ESP32Config.h @@ -75,6 +75,10 @@ class ESP32Config static const Key kConfigKey_CountryCode; static const Key kConfigKey_ActiveLocale; static const Key kConfigKey_Breadcrumb; + static const Key kConfigKey_HourFormat; + static const Key kConfigKey_CalendarType; + + // CHIP Counter keys static const Key kCounterKey_RebootCount; static const Key kCounterKey_UpTime; static const Key kCounterKey_TotalOperationalHours; diff --git a/src/platform/Linux/PosixConfig.cpp b/src/platform/Linux/PosixConfig.cpp index 3c09fa7b7a7808..7187070494043a 100644 --- a/src/platform/Linux/PosixConfig.cpp +++ b/src/platform/Linux/PosixConfig.cpp @@ -73,6 +73,8 @@ const PosixConfig::Key PosixConfig::kConfigKey_CountryCode = { kConfigNam const PosixConfig::Key PosixConfig::kConfigKey_ActiveLocale = { kConfigNamespace_ChipConfig, "active-locale" }; const PosixConfig::Key PosixConfig::kConfigKey_Breadcrumb = { kConfigNamespace_ChipConfig, "breadcrumb" }; const PosixConfig::Key PosixConfig::kConfigKey_LocationCapability = { kConfigNamespace_ChipConfig, "location-capability" }; +const PosixConfig::Key PosixConfig::kConfigKey_HourFormat = { kConfigNamespace_ChipConfig, "hour-format" }; +const PosixConfig::Key PosixConfig::kConfigKey_CalendarType = { kConfigNamespace_ChipConfig, "calendar-type" }; // Keys stored in the Chip-counters namespace const PosixConfig::Key PosixConfig::kCounterKey_RebootCount = { kConfigNamespace_ChipCounters, "reboot-count" }; diff --git a/src/platform/Linux/PosixConfig.h b/src/platform/Linux/PosixConfig.h index e4361af27e216e..4b38910fb65ea5 100644 --- a/src/platform/Linux/PosixConfig.h +++ b/src/platform/Linux/PosixConfig.h @@ -77,6 +77,8 @@ class PosixConfig static const Key kConfigKey_ActiveLocale; static const Key kConfigKey_Breadcrumb; static const Key kConfigKey_LocationCapability; + static const Key kConfigKey_HourFormat; + static const Key kConfigKey_CalendarType; static const Key kCounterKey_RebootCount; static const Key kCounterKey_UpTime; diff --git a/src/platform/P6/P6Config.cpp b/src/platform/P6/P6Config.cpp index ee28b6718ba6f5..d2ad8c7c4e6416 100644 --- a/src/platform/P6/P6Config.cpp +++ b/src/platform/P6/P6Config.cpp @@ -57,10 +57,6 @@ const P6Config::Key P6Config::kConfigKey_HardwareVersion = { kConfigNamespac const P6Config::Key P6Config::kConfigKey_ManufacturingDate = { kConfigNamespace_ChipFactory, "mfg-date" }; const P6Config::Key P6Config::kConfigKey_SetupPinCode = { kConfigNamespace_ChipFactory, "pin-code" }; const P6Config::Key P6Config::kConfigKey_SetupDiscriminator = { kConfigNamespace_ChipFactory, "discriminator" }; -const P6Config::Key P6Config::kConfigKey_RegulatoryLocation = { kConfigNamespace_ChipConfig, "regulatory-location" }; -const P6Config::Key P6Config::kConfigKey_CountryCode = { kConfigNamespace_ChipConfig, "country-code" }; -const P6Config::Key P6Config::kConfigKey_ActiveLocale = { kConfigNamespace_ChipConfig, "active-locale" }; -const P6Config::Key P6Config::kConfigKey_Breadcrumb = { kConfigNamespace_ChipConfig, "breadcrumb" }; // Keys stored in the chip-config namespace const P6Config::Key P6Config::kConfigKey_FabricId = { kConfigNamespace_ChipConfig, "fabric-id" }; @@ -71,6 +67,12 @@ const P6Config::Key P6Config::kConfigKey_GroupKeyIndex = { kConfigNamespace const P6Config::Key P6Config::kConfigKey_LastUsedEpochKeyId = { kConfigNamespace_ChipConfig, "last-ek-id" }; const P6Config::Key P6Config::kConfigKey_FailSafeArmed = { kConfigNamespace_ChipConfig, "fail-safe-armed" }; const P6Config::Key P6Config::kConfigKey_WiFiStationSecType = { kConfigNamespace_ChipConfig, "sta-sec-type" }; +const P6Config::Key P6Config::kConfigKey_RegulatoryLocation = { kConfigNamespace_ChipConfig, "regulatory-location" }; +const P6Config::Key P6Config::kConfigKey_CountryCode = { kConfigNamespace_ChipConfig, "country-code" }; +const P6Config::Key P6Config::kConfigKey_ActiveLocale = { kConfigNamespace_ChipConfig, "active-locale" }; +const P6Config::Key P6Config::kConfigKey_Breadcrumb = { kConfigNamespace_ChipConfig, "breadcrumb" }; +const P6Config::Key P6Config::kConfigKey_HourFormat = { kConfigNamespace_ChipConfig, "hour-format" }; +const P6Config::Key P6Config::kConfigKey_CalendarType = { kConfigNamespace_ChipConfig, "calendar-type" }; // Keys stored in the Chip-counters namespace const P6Config::Key P6Config::kCounterKey_RebootCount = { kConfigNamespace_ChipCounters, "reboot-count" }; diff --git a/src/platform/P6/P6Config.h b/src/platform/P6/P6Config.h index 071f031de48f9a..3b9cffcfe96731 100644 --- a/src/platform/P6/P6Config.h +++ b/src/platform/P6/P6Config.h @@ -76,6 +76,10 @@ class P6Config static const Key kConfigKey_CountryCode; static const Key kConfigKey_ActiveLocale; static const Key kConfigKey_Breadcrumb; + static const Key kConfigKey_HourFormat; + static const Key kConfigKey_CalendarType; + + // CHIP Counter keys static const Key kCounterKey_RebootCount; static const Key kCounterKey_UpTime; static const Key kCounterKey_TotalOperationalHours; diff --git a/src/platform/Tizen/PosixConfig.cpp b/src/platform/Tizen/PosixConfig.cpp index 92d0009356d685..fa8fce00810827 100644 --- a/src/platform/Tizen/PosixConfig.cpp +++ b/src/platform/Tizen/PosixConfig.cpp @@ -68,6 +68,8 @@ const PosixConfig::Key PosixConfig::kConfigKey_RegulatoryLocation = { kConfigNam const PosixConfig::Key PosixConfig::kConfigKey_CountryCode = { kConfigNamespace_ChipConfig, "country-code" }; const PosixConfig::Key PosixConfig::kConfigKey_Breadcrumb = { kConfigNamespace_ChipConfig, "breadcrumb" }; const PosixConfig::Key PosixConfig::kConfigKey_ActiveLocale = { kConfigNamespace_ChipConfig, "active-locale" }; +const PosixConfig::Key PosixConfig::kConfigKey_HourFormat = { kConfigNamespace_ChipConfig, "hour-format" }; +const PosixConfig::Key PosixConfig::kConfigKey_CalendarType = { kConfigNamespace_ChipConfig, "calendar-type" }; // Prefix used for NVS keys that contain Chip group encryption keys. const char PosixConfig::kGroupKeyNamePrefix[] = "gk-"; diff --git a/src/platform/Tizen/PosixConfig.h b/src/platform/Tizen/PosixConfig.h index e4beca4391b5b7..37cdbcb1aea540 100644 --- a/src/platform/Tizen/PosixConfig.h +++ b/src/platform/Tizen/PosixConfig.h @@ -74,6 +74,8 @@ class PosixConfig static const Key kConfigKey_CountryCode; static const Key kConfigKey_Breadcrumb; static const Key kConfigKey_ActiveLocale; + static const Key kConfigKey_HourFormat; + static const Key kConfigKey_CalendarType; static const char kGroupKeyNamePrefix[]; diff --git a/src/platform/Zephyr/ZephyrConfig.cpp b/src/platform/Zephyr/ZephyrConfig.cpp index 9f95a2fd9b0cc8..c151ccb23ac32a 100644 --- a/src/platform/Zephyr/ZephyrConfig.cpp +++ b/src/platform/Zephyr/ZephyrConfig.cpp @@ -72,6 +72,8 @@ const ZephyrConfig::Key ZephyrConfig::kConfigKey_RegulatoryLocation = CONFIG_KEY const ZephyrConfig::Key ZephyrConfig::kConfigKey_CountryCode = CONFIG_KEY(NAMESPACE_CONFIG "country-code"); const ZephyrConfig::Key ZephyrConfig::kConfigKey_ActiveLocale = CONFIG_KEY(NAMESPACE_CONFIG "active-locale"); const ZephyrConfig::Key ZephyrConfig::kConfigKey_Breadcrumb = CONFIG_KEY(NAMESPACE_CONFIG "breadcrumb"); +const ZephyrConfig::Key ZephyrConfig::kConfigKey_HourFormat = CONFIG_KEY(NAMESPACE_CONFIG "hour-format"); +const ZephyrConfig::Key ZephyrConfig::kConfigKey_CalendarType = CONFIG_KEY(NAMESPACE_CONFIG "calendar-type"); // Keys stored in the counters namespace const ZephyrConfig::Key ZephyrConfig::kCounterKey_RebootCount = CONFIG_KEY(NAMESPACE_COUNTERS "reboot-count"); @@ -86,7 +88,8 @@ constexpr const char * sAllResettableConfigKeys[] = { ZephyrConfig::kConfigKey_FabricSecret, ZephyrConfig::kConfigKey_GroupKeyIndex, ZephyrConfig::kConfigKey_LastUsedEpochKeyId, ZephyrConfig::kConfigKey_FailSafeArmed, ZephyrConfig::kConfigKey_RegulatoryLocation, ZephyrConfig::kConfigKey_CountryCode, - ZephyrConfig::kConfigKey_ActiveLocale, ZephyrConfig::kConfigKey_Breadcrumb + ZephyrConfig::kConfigKey_ActiveLocale, ZephyrConfig::kConfigKey_Breadcrumb, + ZephyrConfig::kConfigKey_HourFormat, ZephyrConfig::kConfigKey_CalendarType, }; // Data structure to be passed as a parameter of Zephyr's settings_load_subtree_direct() function diff --git a/src/platform/Zephyr/ZephyrConfig.h b/src/platform/Zephyr/ZephyrConfig.h index 288addd657a0a6..7afffaccbf95ad 100644 --- a/src/platform/Zephyr/ZephyrConfig.h +++ b/src/platform/Zephyr/ZephyrConfig.h @@ -64,6 +64,9 @@ class ZephyrConfig static const Key kConfigKey_CountryCode; static const Key kConfigKey_ActiveLocale; static const Key kConfigKey_Breadcrumb; + static const Key kConfigKey_HourFormat; + static const Key kConfigKey_CalendarType; + static const Key kCounterKey_RebootCount; static const Key kCounterKey_BootReason; static const Key kCounterKey_TotalOperationalHours; diff --git a/src/platform/android/AndroidConfig.cpp b/src/platform/android/AndroidConfig.cpp index cf6f4d506a9f8b..1488c56f2715ae 100644 --- a/src/platform/android/AndroidConfig.cpp +++ b/src/platform/android/AndroidConfig.cpp @@ -93,6 +93,8 @@ const AndroidConfig::Key AndroidConfig::kConfigKey_RegulatoryLocation = { kConfi const AndroidConfig::Key AndroidConfig::kConfigKey_CountryCode = { kConfigNamespace_ChipConfig, "country-code" }; const AndroidConfig::Key AndroidConfig::kConfigKey_ActiveLocale = { kConfigNamespace_ChipConfig, "active-locale" }; const AndroidConfig::Key AndroidConfig::kConfigKey_Breadcrumb = { kConfigNamespace_ChipConfig, "breadcrumb" }; +const AndroidConfig::Key AndroidConfig::kConfigKey_HourFormat = { kConfigNamespace_ChipConfig, "hour-format" }; +const AndroidConfig::Key AndroidConfig::kConfigKey_CalendarType = { kConfigNamespace_ChipConfig, "calendar-type" }; // Prefix used for NVS keys that contain Chip group encryption keys. const char AndroidConfig::kGroupKeyNamePrefix[] = "gk-"; diff --git a/src/platform/android/AndroidConfig.h b/src/platform/android/AndroidConfig.h index 82687bb47e3240..a9db855ef49979 100644 --- a/src/platform/android/AndroidConfig.h +++ b/src/platform/android/AndroidConfig.h @@ -76,6 +76,8 @@ class AndroidConfig static const Key kConfigKey_CountryCode; static const Key kConfigKey_ActiveLocale; static const Key kConfigKey_Breadcrumb; + static const Key kConfigKey_HourFormat; + static const Key kConfigKey_CalendarType; static const Key kConfigKey_ProductId; static const Key kConfigKey_ProductName; static const Key kConfigKey_SoftwareVersion; diff --git a/src/platform/android/java/chip/platform/ConfigurationManager.java b/src/platform/android/java/chip/platform/ConfigurationManager.java index a3aed3df257ecf..cd79a0c8fd3bd0 100644 --- a/src/platform/android/java/chip/platform/ConfigurationManager.java +++ b/src/platform/android/java/chip/platform/ConfigurationManager.java @@ -61,6 +61,8 @@ public interface ConfigurationManager { String kConfigKey_CountryCode = "country-code"; String kConfigKey_ActiveLocale = "active-locale"; String kConfigKey_Breadcrumb = "breadcrumb"; + String kConfigKey_HourFormat = "hour-format"; + String kConfigKey_CalendarType = "calendar-type"; // Prefix used for NVS keys that contain Chip group encryption keys. String kGroupKeyNamePrefix = "gk-"; diff --git a/src/platform/cc13x2_26x2/CC13X2_26X2Config.cpp b/src/platform/cc13x2_26x2/CC13X2_26X2Config.cpp index e39d73babc381e..a12c30fd6308f7 100644 --- a/src/platform/cc13x2_26x2/CC13X2_26X2Config.cpp +++ b/src/platform/cc13x2_26x2/CC13X2_26X2Config.cpp @@ -89,12 +89,16 @@ const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_Breadcrumb = .itemID = 0x001c } }; const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_ActiveLocale = { { .systemID = kCC13X2_26X2ChipFactory_Sysid, .itemID = 0x001d } }; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_HourFormat = { { .systemID = kCC13X2_26X2ChipFactory_Sysid, + .itemID = 0x001e } }; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_CalendarType = { { .systemID = kCC13X2_26X2ChipFactory_Sysid, + .itemID = 0x001f } }; /* Internal for the KVS interface. */ const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_KVS_key = { { .systemID = kCC13X2_26X2ChipFactory_Sysid, - .itemID = 0x001e } }; + .itemID = 0x0020 } }; const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_KVS_value = { { .systemID = kCC13X2_26X2ChipFactory_Sysid, - .itemID = 0x001f } }; + .itemID = 0x0021 } }; /* Static local variables */ static NVINTF_nvFuncts_t sNvoctpFps = { 0 }; diff --git a/src/platform/cc13x2_26x2/CC13X2_26X2Config.h b/src/platform/cc13x2_26x2/CC13X2_26X2Config.h index 034a067906fc43..854a7692eaf212 100644 --- a/src/platform/cc13x2_26x2/CC13X2_26X2Config.h +++ b/src/platform/cc13x2_26x2/CC13X2_26X2Config.h @@ -67,6 +67,8 @@ class CC13X2_26X2Config static const Key kConfigKey_CountryCode; static const Key kConfigKey_ActiveLocale; static const Key kConfigKey_Breadcrumb; + static const Key kConfigKey_HourFormat; + static const Key kConfigKey_CalendarType; static const Key kConfigKey_KVS_key; // special key for KVS system, key storage static const Key kConfigKey_KVS_value; // special key for KVS system, value storage diff --git a/src/platform/fake/ConfigurationManagerImpl.h b/src/platform/fake/ConfigurationManagerImpl.h index 18afa5923604b4..43faeb31e199c0 100644 --- a/src/platform/fake/ConfigurationManagerImpl.h +++ b/src/platform/fake/ConfigurationManagerImpl.h @@ -97,6 +97,10 @@ class ConfigurationManagerImpl : public ConfigurationManager CHIP_ERROR GetLocalConfigDisabled(bool & disabled) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetReachable(bool & reachable) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetUniqueId(char * buf, size_t bufSize) override { return CHIP_ERROR_NOT_IMPLEMENTED; } + CHIP_ERROR GetHourFormat(uint8_t & format) override { return CHIP_ERROR_NOT_IMPLEMENTED; }; + CHIP_ERROR StoreHourFormat(uint8_t format) override { return CHIP_ERROR_NOT_IMPLEMENTED; }; + CHIP_ERROR GetCalendarType(uint8_t & type) override { return CHIP_ERROR_NOT_IMPLEMENTED; }; + CHIP_ERROR StoreCalendarType(uint8_t type) override { return CHIP_ERROR_NOT_IMPLEMENTED; }; #if !defined(NDEBUG) CHIP_ERROR RunUnitTests(void) override { return CHIP_ERROR_NOT_IMPLEMENTED; } #endif diff --git a/src/platform/mbed/MbedConfig.cpp b/src/platform/mbed/MbedConfig.cpp index 608d732ce61425..aab9e6916ca9ed 100644 --- a/src/platform/mbed/MbedConfig.cpp +++ b/src/platform/mbed/MbedConfig.cpp @@ -82,6 +82,8 @@ const MbedConfig::Key MbedConfig::kConfigKey_RegulatoryLocation = { CONFIG_KEY(" const MbedConfig::Key MbedConfig::kConfigKey_CountryCode = { CONFIG_KEY("country-code") }; const MbedConfig::Key MbedConfig::kConfigKey_ActiveLocale = { CONFIG_KEY("active-locale") }; const MbedConfig::Key MbedConfig::kConfigKey_Breadcrumb = { CONFIG_KEY("breadcrumb") }; +const MbedConfig::Key MbedConfig::kConfigKey_HourFormat = { CONFIG_KEY("hour-format") }; +const MbedConfig::Key MbedConfig::kConfigKey_CalendarType = { CONFIG_KEY("calendar-type") }; CHIP_ERROR MbedConfig::ReadConfigValue(Key key, bool & val) { diff --git a/src/platform/mbed/MbedConfig.h b/src/platform/mbed/MbedConfig.h index 21d33df304e140..09ce576d1760d0 100644 --- a/src/platform/mbed/MbedConfig.h +++ b/src/platform/mbed/MbedConfig.h @@ -73,6 +73,8 @@ class MbedConfig static const Key kConfigKey_CountryCode; static const Key kConfigKey_ActiveLocale; static const Key kConfigKey_Breadcrumb; + static const Key kConfigKey_HourFormat; + static const Key kConfigKey_CalendarType; // Config value accessors. static CHIP_ERROR ReadConfigValue(Key key, bool & val); diff --git a/src/platform/nxp/k32w/k32w0/K32W0Config.h b/src/platform/nxp/k32w/k32w0/K32W0Config.h index b5cf3c6e23c0c4..da73746d4d463c 100644 --- a/src/platform/nxp/k32w/k32w0/K32W0Config.h +++ b/src/platform/nxp/k32w/k32w0/K32W0Config.h @@ -89,6 +89,8 @@ class K32WConfig static constexpr Key kConfigKey_CountryCode = K32WConfigKey(kPDMId_ChipConfig, 0x08); static constexpr Key kConfigKey_Breadcrumb = K32WConfigKey(kPDMId_ChipConfig, 0x09); static constexpr Key kConfigKey_ActiveLocale = K32WConfigKey(kPDMId_ChipConfig, 0x0A); + static constexpr Key kConfigKey_HourFormat = K32WConfigKey(kPDMId_ChipConfig, 0x0B); + static constexpr Key kConfigKey_CalendarType = K32WConfigKey(kPDMId_ChipConfig, 0x0C); // CHIP Counter Keys static constexpr Key kCounterKey_RebootCount = K32WConfigKey(kPDMId_ChipCounter, 0x00); diff --git a/src/platform/qpg/qpgConfig.h b/src/platform/qpg/qpgConfig.h index 426fb431203590..9c5130537de218 100644 --- a/src/platform/qpg/qpgConfig.h +++ b/src/platform/qpg/qpgConfig.h @@ -86,9 +86,11 @@ class QPGConfig static constexpr Key kConfigKey_CountryCode = QorvoConfigKey(kFileId_ChipConfig, 0x0A); static constexpr Key kConfigKey_Breadcrumb = QorvoConfigKey(kFileId_ChipConfig, 0x0B); static constexpr Key kConfigKey_ActiveLocale = QorvoConfigKey(kFileId_ChipConfig, 0x0C); + static constexpr Key kConfigKey_HourFormat = QorvoConfigKey(kFileId_ChipConfig, 0x0D); + static constexpr Key kConfigKey_CalendarType = QorvoConfigKey(kFileId_ChipConfig, 0x0E); - static constexpr Key kConfigKey_GroupKeyBase = QorvoConfigKey(kFileId_ChipConfig, 0x0D); - static constexpr Key kConfigKey_GroupKeyMax = QorvoConfigKey(kFileId_ChipConfig, 0x1C); // Allows 16 Group Keys to be created. + static constexpr Key kConfigKey_GroupKeyBase = QorvoConfigKey(kFileId_ChipConfig, 0x0F); + static constexpr Key kConfigKey_GroupKeyMax = QorvoConfigKey(kFileId_ChipConfig, 0x1E); // Allows 16 Group Keys to be created. static constexpr Key kConfigKey_CounterKeyBase = QorvoConfigKey(kFileId_ChipCounter, 0x00); static constexpr Key kConfigKey_CounterKeyMax = diff --git a/src/platform/tests/TestConfigurationMgr.cpp b/src/platform/tests/TestConfigurationMgr.cpp index 04d8998271627b..450e7a15f8bbcc 100644 --- a/src/platform/tests/TestConfigurationMgr.cpp +++ b/src/platform/tests/TestConfigurationMgr.cpp @@ -245,6 +245,34 @@ static void TestConfigurationMgr_ActiveLocale(nlTestSuite * inSuite, void * inCo NL_TEST_ASSERT(inSuite, strcmp(buf, activeLocale) == 0); } +static void TestConfigurationMgr_HourFormat(nlTestSuite * inSuite, void * inContext) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + uint8_t format = 0; + + err = ConfigurationMgr().StoreHourFormat(3); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + + err = ConfigurationMgr().GetHourFormat(format); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + + NL_TEST_ASSERT(inSuite, format == 3); +} + +static void TestConfigurationMgr_CalendarType(nlTestSuite * inSuite, void * inContext) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + uint8_t type = 0; + + err = ConfigurationMgr().StoreCalendarType(3); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + + err = ConfigurationMgr().GetCalendarType(type); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + + NL_TEST_ASSERT(inSuite, type == 3); +} + /** * Test Suite. It lists all the test functions. */ @@ -263,6 +291,8 @@ static const nlTest sTests[] = { NL_TEST_DEF("Test ConfigurationMgr::Breadcrumb", TestConfigurationMgr_Breadcrumb), NL_TEST_DEF("Test ConfigurationMgr::GetPrimaryMACAddress", TestConfigurationMgr_GetPrimaryMACAddress), NL_TEST_DEF("Test ConfigurationMgr::ActiveLocale", TestConfigurationMgr_ActiveLocale), + NL_TEST_DEF("Test ConfigurationMgr::HourFormat", TestConfigurationMgr_HourFormat), + NL_TEST_DEF("Test ConfigurationMgr::CalendarType", TestConfigurationMgr_CalendarType), NL_TEST_SENTINEL() };