From 212470007c85a2920ab44a97f9813bd5c29b14c5 Mon Sep 17 00:00:00 2001 From: pankore <86098180+pankore@users.noreply.github.com> Date: Wed, 1 Jun 2022 21:36:49 +0800 Subject: [PATCH] [Ameba] Remove GetUniqueId in ConfigurationManagerImpl (#19033) * [ConfigurationManager] Remove GetUniqueId in ConfigurationManagerImpl - Also removed CHIPSessionResumptionIndex key, and added CHIPGroupDataProvider key * Restyled by clang-format Co-authored-by: Restyled.io --- src/platform/Ameba/AmebaConfig.cpp | 38 +++++++++---------- src/platform/Ameba/AmebaConfig.h | 2 +- .../Ameba/ConfigurationManagerImpl.cpp | 28 +------------- src/platform/Ameba/ConfigurationManagerImpl.h | 1 - 4 files changed, 22 insertions(+), 47 deletions(-) diff --git a/src/platform/Ameba/AmebaConfig.cpp b/src/platform/Ameba/AmebaConfig.cpp index 9ed767a4262e17..9dfed9d20ec783 100644 --- a/src/platform/Ameba/AmebaConfig.cpp +++ b/src/platform/Ameba/AmebaConfig.cpp @@ -42,25 +42,25 @@ namespace Internal { // *** CAUTION ***: Changing the names or namespaces of these values will *break* existing devices. // NVS namespaces used to store device configuration information. -const char AmebaConfig::kConfigNamespace_ChipFactory[] = "chip-factory"; -const char AmebaConfig::kConfigNamespace_ChipConfig[] = "chip-config"; -const char AmebaConfig::kConfigNamespace_ChipCounters[] = "chip-counters"; -const char AmebaConfig::kConfigNamespace_ChipFabric1[] = "chip-fabric-1"; -const char AmebaConfig::kConfigNamespace_ChipFabric2[] = "chip-fabric-2"; -const char AmebaConfig::kConfigNamespace_ChipFabric3[] = "chip-fabric-3"; -const char AmebaConfig::kConfigNamespace_ChipFabric4[] = "chip-fabric-4"; -const char AmebaConfig::kConfigNamespace_ChipFabric5[] = "chip-fabric-5"; -const char AmebaConfig::kConfigNamespace_ChipACL[] = "chip-acl"; -const char AmebaConfig::kConfigNamespace_ChipGroupMessageCounters[] = "chip-groupmsgcounters"; -const char AmebaConfig::kConfigNamespace_ChipAttributes[] = "chip-attributes"; -const char AmebaConfig::kConfigNamespace_ChipBindingTable[] = "chip-bindingtable"; -const char AmebaConfig::kConfigNamespace_ChipOTA[] = "chip-ota"; -const char AmebaConfig::kConfigNamespace_ChipFailSafe[] = "chip-failsafe"; -const char AmebaConfig::kConfigNamespace_ChipSessionResumptionIndex[] = "chip-sessionresumptionindex"; -const char AmebaConfig::kConfigNamespace_ChipSessionResumption[] = "chip-sessionresumption"; -const char AmebaConfig::kConfigNamespace_ChipDeviceInfoProvider[] = "chip-deviceinfoprovider"; -const char AmebaConfig::kConfigNamespace_ChipOthers[] = "chip-others"; -const char AmebaConfig::kConfigNamespace_ChipOthers2[] = "chip-others2"; +const char AmebaConfig::kConfigNamespace_ChipFactory[] = "chip-factory"; +const char AmebaConfig::kConfigNamespace_ChipConfig[] = "chip-config"; +const char AmebaConfig::kConfigNamespace_ChipCounters[] = "chip-counters"; +const char AmebaConfig::kConfigNamespace_ChipFabric1[] = "chip-fabric-1"; +const char AmebaConfig::kConfigNamespace_ChipFabric2[] = "chip-fabric-2"; +const char AmebaConfig::kConfigNamespace_ChipFabric3[] = "chip-fabric-3"; +const char AmebaConfig::kConfigNamespace_ChipFabric4[] = "chip-fabric-4"; +const char AmebaConfig::kConfigNamespace_ChipFabric5[] = "chip-fabric-5"; +const char AmebaConfig::kConfigNamespace_ChipACL[] = "chip-acl"; +const char AmebaConfig::kConfigNamespace_ChipGroupMessageCounters[] = "chip-groupmsgcounters"; +const char AmebaConfig::kConfigNamespace_ChipAttributes[] = "chip-attributes"; +const char AmebaConfig::kConfigNamespace_ChipBindingTable[] = "chip-bindingtable"; +const char AmebaConfig::kConfigNamespace_ChipOTA[] = "chip-ota"; +const char AmebaConfig::kConfigNamespace_ChipFailSafe[] = "chip-failsafe"; +const char AmebaConfig::kConfigNamespace_ChipSessionResumption[] = "chip-sessionresumption"; +const char AmebaConfig::kConfigNamespace_ChipDeviceInfoProvider[] = "chip-deviceinfoprovider"; +const char AmebaConfig::kConfigNamespace_ChipGroupDataProvider[] = "chip-groupdataprovider"; +const char AmebaConfig::kConfigNamespace_ChipOthers[] = "chip-others"; +const char AmebaConfig::kConfigNamespace_ChipOthers2[] = "chip-others2"; // Keys stored in the chip-factory namespace const AmebaConfig::Key AmebaConfig::kConfigKey_SerialNum = { kConfigNamespace_ChipFactory, "serial-num" }; diff --git a/src/platform/Ameba/AmebaConfig.h b/src/platform/Ameba/AmebaConfig.h index 4d1cb2645b3fca..95fc03971808c8 100755 --- a/src/platform/Ameba/AmebaConfig.h +++ b/src/platform/Ameba/AmebaConfig.h @@ -51,9 +51,9 @@ class AmebaConfig static const char kConfigNamespace_ChipBindingTable[]; static const char kConfigNamespace_ChipOTA[]; static const char kConfigNamespace_ChipFailSafe[]; - static const char kConfigNamespace_ChipSessionResumptionIndex[]; static const char kConfigNamespace_ChipSessionResumption[]; static const char kConfigNamespace_ChipDeviceInfoProvider[]; + static const char kConfigNamespace_ChipGroupDataProvider[]; static const char kConfigNamespace_ChipOthers[]; static const char kConfigNamespace_ChipOthers2[]; diff --git a/src/platform/Ameba/ConfigurationManagerImpl.cpp b/src/platform/Ameba/ConfigurationManagerImpl.cpp index 24f4e254b4ecb3..a1f4f00eac306b 100644 --- a/src/platform/Ameba/ConfigurationManagerImpl.cpp +++ b/src/platform/Ameba/ConfigurationManagerImpl.cpp @@ -77,12 +77,12 @@ CHIP_ERROR ConfigurationManagerImpl::Init() SuccessOrExit(err); err = AmebaConfig::EnsureNamespace(AmebaConfig::kConfigNamespace_ChipFailSafe); SuccessOrExit(err); - err = AmebaConfig::EnsureNamespace2(AmebaConfig::kConfigNamespace_ChipSessionResumptionIndex); - SuccessOrExit(err); err = AmebaConfig::EnsureNamespace(AmebaConfig::kConfigNamespace_ChipSessionResumption); SuccessOrExit(err); err = AmebaConfig::EnsureNamespace(AmebaConfig::kConfigNamespace_ChipDeviceInfoProvider); SuccessOrExit(err); + err = AmebaConfig::EnsureNamespace(AmebaConfig::kConfigNamespace_ChipGroupDataProvider); + SuccessOrExit(err); err = AmebaConfig::EnsureNamespace(AmebaConfig::kConfigNamespace_ChipOthers); SuccessOrExit(err); err = AmebaConfig::EnsureNamespace2(AmebaConfig::kConfigNamespace_ChipOthers2); @@ -177,30 +177,6 @@ CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf) return CHIP_NO_ERROR; } -CHIP_ERROR ConfigurationManagerImpl::GetUniqueId(char * buf, size_t bufSize) -{ -#ifdef CHIP_DEVICE_CONFIG_UNIQUE_ID - ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_UNIQUE_ID), CHIP_ERROR_BUFFER_TOO_SMALL); - strcpy(buf, CHIP_DEVICE_CONFIG_UNIQUE_ID); - return CHIP_NO_ERROR; -#else - ReturnErrorCodeIf(bufSize != 32, CHIP_ERROR_INVALID_MESSAGE_LENGTH); - char temp[32]; - int i = 0, j = 0; - - memset(&temp[0], 0, 32); - ReturnErrorCodeIf(wifi_get_mac_address(temp) != 0, CHIP_ERROR_INVALID_ARGUMENT); - - for (i = 0; i < bufSize; i++) - { - if (temp[i] != ':') - buf[j++] = temp[i]; - } - - return CHIP_NO_ERROR; -#endif -} - bool ConfigurationManagerImpl::CanFactoryReset() { // TODO: query the application to determine if factory reset is allowed. diff --git a/src/platform/Ameba/ConfigurationManagerImpl.h b/src/platform/Ameba/ConfigurationManagerImpl.h index 78555c6f07b126..def780ea343817 100644 --- a/src/platform/Ameba/ConfigurationManagerImpl.h +++ b/src/platform/Ameba/ConfigurationManagerImpl.h @@ -55,7 +55,6 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp void InitiateFactoryReset(void) override; CHIP_ERROR ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t & value) override; CHIP_ERROR WritePersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t value) override; - CHIP_ERROR GetUniqueId(char * buf, size_t bufSize) override; // NOTE: Other public interface methods are implemented by GenericConfigurationManagerImpl<>. // ===== Members that implement the GenericConfigurationManagerImpl protected interface.