From 6a354a2488b9ba9f1244e5f5594f7e58ed021ca4 Mon Sep 17 00:00:00 2001 From: Shubham Patil Date: Sat, 20 Aug 2022 14:19:51 +0530 Subject: [PATCH] [ESP32] Read product label and product url from the factory partition if available --- .../ESP32/ConfigurationManagerImpl.cpp | 20 +++++++++++++++++++ src/platform/ESP32/ConfigurationManagerImpl.h | 2 ++ src/platform/ESP32/ESP32Config.cpp | 2 ++ src/platform/ESP32/ESP32Config.h | 2 ++ 4 files changed, 26 insertions(+) diff --git a/src/platform/ESP32/ConfigurationManagerImpl.cpp b/src/platform/ESP32/ConfigurationManagerImpl.cpp index 21923bc4c568c3..ebdc3ad4a82fb0 100644 --- a/src/platform/ESP32/ConfigurationManagerImpl.cpp +++ b/src/platform/ESP32/ConfigurationManagerImpl.cpp @@ -184,6 +184,26 @@ CHIP_ERROR ConfigurationManagerImpl::StoreTotalOperationalHours(uint32_t totalOp return WriteConfigValue(ESP32Config::kCounterKey_TotalOperationalHours, totalOperationalHours); } +CHIP_ERROR ConfigurationManagerImpl::GetProductURL(char * buf, size_t bufSize) +{ + CHIP_ERROR err = ReadConfigValueStr(ESP32Config::kConfigKey_ProductURL, buf, bufSize, bufSize); + if (err == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND) + { + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; + } + return err; +} + +CHIP_ERROR ConfigurationManagerImpl::GetProductLabel(char * buf, size_t bufSize) +{ + CHIP_ERROR err = ReadConfigValueStr(ESP32Config::kConfigKey_ProductLabel, buf, bufSize, bufSize); + if (err == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND) + { + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; + } + return err; +} + CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf) { #if CHIP_DEVICE_CONFIG_ENABLE_WIFI diff --git a/src/platform/ESP32/ConfigurationManagerImpl.h b/src/platform/ESP32/ConfigurationManagerImpl.h index 56c5e5ad7679a0..2eaa5fac60c648 100644 --- a/src/platform/ESP32/ConfigurationManagerImpl.h +++ b/src/platform/ESP32/ConfigurationManagerImpl.h @@ -53,6 +53,8 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp CHIP_ERROR StoreRebootCount(uint32_t rebootCount) override; CHIP_ERROR GetTotalOperationalHours(uint32_t & totalOperationalHours) override; CHIP_ERROR StoreTotalOperationalHours(uint32_t totalOperationalHours) override; + CHIP_ERROR GetProductURL(char * buf, size_t bufSize) override; + CHIP_ERROR GetProductLabel(char * buf, size_t bufSize) override; static ConfigurationManagerImpl & GetDefaultInstance(); private: diff --git a/src/platform/ESP32/ESP32Config.cpp b/src/platform/ESP32/ESP32Config.cpp index 0feaa568886f29..507214bb8ef42b 100644 --- a/src/platform/ESP32/ESP32Config.cpp +++ b/src/platform/ESP32/ESP32Config.cpp @@ -72,6 +72,8 @@ const ESP32Config::Key ESP32Config::kConfigKey_VendorId = { kConfig const ESP32Config::Key ESP32Config::kConfigKey_VendorName = { kConfigNamespace_ChipFactory, "vendor-name" }; const ESP32Config::Key ESP32Config::kConfigKey_ProductId = { kConfigNamespace_ChipFactory, "product-id" }; const ESP32Config::Key ESP32Config::kConfigKey_ProductName = { kConfigNamespace_ChipFactory, "product-name" }; +const ESP32Config::Key ESP32Config::kConfigKey_ProductLabel = { kConfigNamespace_ChipFactory, "product-label" }; +const ESP32Config::Key ESP32Config::kConfigKey_ProductURL = { kConfigNamespace_ChipFactory, "product-url" }; const ESP32Config::Key ESP32Config::kConfigKey_UniqueId = { kConfigNamespace_ChipFactory, "unique-id" }; const ESP32Config::Key ESP32Config::kConfigKey_SupportedCalTypes = { kConfigNamespace_ChipFactory, "cal-types" }; const ESP32Config::Key ESP32Config::kConfigKey_SupportedLocaleSize = { kConfigNamespace_ChipFactory, "locale-sz" }; diff --git a/src/platform/ESP32/ESP32Config.h b/src/platform/ESP32/ESP32Config.h index 86138368352a7f..8d6839b86431ba 100644 --- a/src/platform/ESP32/ESP32Config.h +++ b/src/platform/ESP32/ESP32Config.h @@ -83,6 +83,8 @@ class ESP32Config static const Key kConfigKey_VendorName; static const Key kConfigKey_ProductId; static const Key kConfigKey_ProductName; + static const Key kConfigKey_ProductLabel; + static const Key kConfigKey_ProductURL; static const Key kConfigKey_SupportedCalTypes; static const Key kConfigKey_SupportedLocaleSize;