diff --git a/src/platform/Ameba/AmebaConfig.cpp b/src/platform/Ameba/AmebaConfig.cpp index 05579271240081..08d552f440fd76 100644 --- a/src/platform/Ameba/AmebaConfig.cpp +++ b/src/platform/Ameba/AmebaConfig.cpp @@ -73,6 +73,7 @@ const AmebaConfig::Key AmebaConfig::kConfigKey_OperationalDeviceCert = { k const AmebaConfig::Key AmebaConfig::kConfigKey_OperationalDeviceICACerts = { kConfigNamespace_ChipConfig, "op-device-ca-certs" }; const AmebaConfig::Key AmebaConfig::kConfigKey_OperationalDevicePrivateKey = { kConfigNamespace_ChipConfig, "op-device-key" }; const AmebaConfig::Key AmebaConfig::kConfigKey_RegulatoryLocation = { kConfigNamespace_ChipConfig, "regulatory-location" }; +const AmebaConfig::Key AmebaConfig::kConfigKey_LocationCapability = { kConfigNamespace_ChipConfig, "location-capability" }; const AmebaConfig::Key AmebaConfig::kConfigKey_CountryCode = { kConfigNamespace_ChipConfig, "country-code" }; // Keys stored in the Chip-counters namespace diff --git a/src/platform/Ameba/AmebaConfig.h b/src/platform/Ameba/AmebaConfig.h index 71471a722decce..21bf9596aa09d6 100755 --- a/src/platform/Ameba/AmebaConfig.h +++ b/src/platform/Ameba/AmebaConfig.h @@ -62,6 +62,7 @@ class AmebaConfig static const Key kConfigKey_OperationalDevicePrivateKey; static const Key kConfigKey_SetupDiscriminator; static const Key kConfigKey_RegulatoryLocation; + static const Key kConfigKey_LocationCapability; static const Key kConfigKey_CountryCode; static const Key kConfigKey_Spake2pIterationCount; static const Key kConfigKey_Spake2pSalt; diff --git a/src/platform/Ameba/ConfigurationManagerImpl.cpp b/src/platform/Ameba/ConfigurationManagerImpl.cpp index a632cf585234c1..ab71f54a59132a 100644 --- a/src/platform/Ameba/ConfigurationManagerImpl.cpp +++ b/src/platform/Ameba/ConfigurationManagerImpl.cpp @@ -79,6 +79,20 @@ CHIP_ERROR ConfigurationManagerImpl::Init() SuccessOrExit(err); } + if (!AmebaConfig::ConfigValueExists(AmebaConfig::kConfigKey_RegulatoryLocation)) + { + uint32_t regulatoryLocation = to_underlying(app::Clusters::GeneralCommissioning::RegulatoryLocationType::kIndoor); + err = WriteConfigValue(AmebaConfig::kConfigKey_RegulatoryLocation, regulatoryLocation); + SuccessOrExit(err); + } + + if (!AmebaConfig::ConfigValueExists(AmebaConfig::kConfigKey_LocationCapability)) + { + uint32_t locationCapability = to_underlying(app::Clusters::GeneralCommissioning::RegulatoryLocationType::kIndoorOutdoor); + err = WriteConfigValue(AmebaConfig::kConfigKey_LocationCapability, locationCapability); + SuccessOrExit(err); + } + // Initialize the generic implementation base class. err = Internal::GenericConfigurationManagerImpl::Init(); SuccessOrExit(err); @@ -119,6 +133,21 @@ CHIP_ERROR ConfigurationManagerImpl::StoreBootReason(uint32_t bootReason) return WriteConfigValue(AmebaConfig::kCounterKey_BootReason, bootReason); } +CHIP_ERROR ConfigurationManagerImpl::GetLocationCapability(uint8_t & location) +{ + uint32_t value = 0; + + CHIP_ERROR err = ReadConfigValue(AmebaConfig::kConfigKey_LocationCapability, value); + + if (err == CHIP_NO_ERROR) + { + VerifyOrReturnError(value <= UINT8_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE); + location = static_cast(value); + } + + return err; +} + CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf) { char temp[32]; diff --git a/src/platform/Ameba/ConfigurationManagerImpl.h b/src/platform/Ameba/ConfigurationManagerImpl.h index 7587f5366d7ddf..eee20dcd8ee1db 100644 --- a/src/platform/Ameba/ConfigurationManagerImpl.h +++ b/src/platform/Ameba/ConfigurationManagerImpl.h @@ -45,6 +45,7 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp CHIP_ERROR StoreTotalOperationalHours(uint32_t totalOperationalHours) override; CHIP_ERROR GetBootReason(uint32_t & bootReason) override; CHIP_ERROR StoreBootReason(uint32_t bootReason) override; + CHIP_ERROR GetLocationCapability(uint8_t & locationCapability) override; private: // ===== Members that implement the ConfigurationManager public interface.