From 901253cb579f3a43399d79bde4864f5ad79cfc02 Mon Sep 17 00:00:00 2001 From: chaitanya Date: Thu, 2 May 2024 17:06:23 -0700 Subject: [PATCH 01/32] added code to read vendor_name, product_name, hardware_version_string and software_version_string to read from config in reference linux and darwin platform --- .../platform/linux/CommissionableInit.cpp | 28 ++++++++ examples/platform/linux/Options.cpp | 32 +++++++++ examples/platform/linux/Options.h | 5 ++ src/include/platform/ConfigurationManager.h | 5 ++ .../GenericConfigurationManagerImpl.h | 5 ++ .../GenericConfigurationManagerImpl.ipp | 42 +++++++++++- .../GenericDeviceInstanceInfoProvider.ipp | 67 ++++++++++++++++--- src/platform/Darwin/PosixConfig.cpp | 5 ++ src/platform/Darwin/PosixConfig.h | 5 ++ src/platform/Linux/PosixConfig.cpp | 6 ++ src/platform/Linux/PosixConfig.h | 5 ++ 11 files changed, 193 insertions(+), 12 deletions(-) diff --git a/examples/platform/linux/CommissionableInit.cpp b/examples/platform/linux/CommissionableInit.cpp index 24fc347153c053..14414264f92fcf 100644 --- a/examples/platform/linux/CommissionableInit.cpp +++ b/examples/platform/linux/CommissionableInit.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "CommissionableInit.h" @@ -99,6 +100,33 @@ CHIP_ERROR InitConfigurationManager(ConfigurationManagerImpl & configManager, Li configManager.StoreProductId(options.payload.productID); } + if (options.vendorName.HasValue()) + { + const char * vendorName = options.vendorName.Value().c_str(); + configManager.StoreVendorName(vendorName, strlen(vendorName)); + } + if (options.productName.HasValue()) + { + const char * productName = options.productName.Value().c_str(); + configManager.StoreProductName(productName,strlen(productName)); + } + if (options.hardwareVersionString.HasValue()) + { + const char * hardwareVersionString = options.hardwareVersionString.Value().c_str(); + configManager.StoreHardwareVersionString(hardwareVersionString,strlen(hardwareVersionString)); + } + if (options.softwareVersionString.HasValue()) + { + const char * softwareVersionString = options.softwareVersionString.Value().c_str(); + configManager.StoreSoftwareVersionString(softwareVersionString,strlen(softwareVersionString)); + } + + if (options.serialNumber.HasValue()) + { + const char * serialNumber = options.serialNumber.Value().c_str(); + configManager.StoreSerialNumber(serialNumber, strlen(serialNumber)); + } + return CHIP_NO_ERROR; } diff --git a/examples/platform/linux/Options.cpp b/examples/platform/linux/Options.cpp index 9d6edc8bc43846..db8490c662496b 100644 --- a/examples/platform/linux/Options.cpp +++ b/examples/platform/linux/Options.cpp @@ -106,6 +106,12 @@ enum #if CHIP_WITH_NLFAULTINJECTION kDeviceOption_FaultInjection, #endif + kDeviceOption_VendorName = 0x1028, + kDeviceOption_ProductName = 0x1029, + kDeviceOption_HardwareVersionString = 0x102a, + kDeviceOption_SoftwareVersionString = 0x102b, + kDeviceOption_SerialNumber = 0x102c, + }; constexpr unsigned kAppUsageLength = 64; @@ -124,6 +130,11 @@ OptionDef sDeviceOptionDefs[] = { { "version", kArgumentRequired, kDeviceOption_Version }, { "vendor-id", kArgumentRequired, kDeviceOption_VendorID }, { "product-id", kArgumentRequired, kDeviceOption_ProductID }, + { "vendor-name", kArgumentRequired, kDeviceOption_VendorName }, + { "product-name", kArgumentRequired, kDeviceOption_ProductName }, + { "harware-version-string", kArgumentRequired, kDeviceOption_HardwareVersionString }, + { "software-version-string", kArgumentRequired, kDeviceOption_SoftwareVersionString }, + { "serial-number", kArgumentRequired, kDeviceOption_SerialNumber }, { "custom-flow", kArgumentRequired, kDeviceOption_CustomFlow }, { "capabilities", kArgumentRequired, kDeviceOption_Capabilities }, { "discriminator", kArgumentRequired, kDeviceOption_Discriminator }, @@ -587,8 +598,29 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier, retval = false; } break; + } #endif + case kDeviceOption_VendorName: + LinuxDeviceOptions::GetInstance().vendorName.SetValue(std::string{ aValue }); + break; + + case kDeviceOption_ProductName: + LinuxDeviceOptions::GetInstance().productName.SetValue(std::string{ aValue }); + break; + + case kDeviceOption_HardwareVersionString: + LinuxDeviceOptions::GetInstance().hardwareVersionString.SetValue(std::string{ aValue }); + break; + + case kDeviceOption_SoftwareVersionString: + LinuxDeviceOptions::GetInstance().softwareVersionString.SetValue(std::string{ aValue }); + break; + + case kDeviceOption_SerialNumber: + LinuxDeviceOptions::GetInstance().serialNumber.SetValue(std::string{ aValue }); + break; + default: PrintArgError("%s: INTERNAL ERROR: Unhandled option: %s\n", aProgram, aName); retval = false; diff --git a/examples/platform/linux/Options.h b/examples/platform/linux/Options.h index 51e60f0ab63eca..e07448e155ac1a 100644 --- a/examples/platform/linux/Options.h +++ b/examples/platform/linux/Options.h @@ -78,6 +78,11 @@ struct LinuxDeviceOptions int32_t subscriptionCapacity = CHIP_IM_MAX_NUM_SUBSCRIPTIONS; int32_t subscriptionResumptionRetryIntervalSec = -1; #endif + chip::Optional vendorName; + chip::Optional productName; + chip::Optional hardwareVersionString; + chip::Optional softwareVersionString; + chip::Optional serialNumber; static LinuxDeviceOptions & GetInstance(); }; diff --git a/src/include/platform/ConfigurationManager.h b/src/include/platform/ConfigurationManager.h index c7158d22c58d5e..bed6eea5cadb80 100644 --- a/src/include/platform/ConfigurationManager.h +++ b/src/include/platform/ConfigurationManager.h @@ -134,6 +134,11 @@ class ConfigurationManager virtual CHIP_ERROR GetBLEDeviceIdentificationInfo(Ble::ChipBLEDeviceIdentificationInfo & deviceIdInfo) = 0; + virtual CHIP_ERROR StoreVendorName(const char * vendorName, size_t vendorNameLen) = 0; + virtual CHIP_ERROR StoreProductName(const char * productName, size_t productNameLen) = 0; + virtual CHIP_ERROR StoreHardwareVersionString(const char * hardwareVersionString, size_t hardwareVersionStringLen) = 0; + virtual CHIP_ERROR StoreSoftwareVersionString(const char * softwareVersionString, size_t softwareVersionStringLen) = 0; + #if CHIP_CONFIG_TEST virtual void RunUnitTests() = 0; #endif diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.h b/src/include/platform/internal/GenericConfigurationManagerImpl.h index fa7e19503f845e..22189acd9b23e4 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.h +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.h @@ -103,6 +103,11 @@ class GenericConfigurationManagerImpl : public ConfigurationManager CHIP_ERROR GetUniqueId(char * buf, size_t bufSize) override; CHIP_ERROR StoreUniqueId(const char * uniqueId, size_t uniqueIdLen) override; CHIP_ERROR GenerateUniqueId(char * buf, size_t bufSize) override; + + CHIP_ERROR StoreVendorName(const char * vendorName, size_t vendorNameLen) override; + CHIP_ERROR StoreProductName(const char * productName, size_t productNameLen) override; + CHIP_ERROR StoreHardwareVersionString(const char * hardwareVersionString, size_t hardwareVersionStringLen) override; + CHIP_ERROR StoreSoftwareVersionString(const char * softwareVersionString, size_t softwareVersionStringLen) override; #if CHIP_CONFIG_TEST void RunUnitTests() override; #endif diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.ipp b/src/include/platform/internal/GenericConfigurationManagerImpl.ipp index 9b36f341042aa9..05148a6dc460ef 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.ipp +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.ipp @@ -351,9 +351,25 @@ CHIP_ERROR GenericConfigurationManagerImpl::GetSecondaryPairingHint template CHIP_ERROR GenericConfigurationManagerImpl::GetSoftwareVersionString(char * buf, size_t bufSize) { - ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING), CHIP_ERROR_BUFFER_TOO_SMALL); - strcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); - return CHIP_NO_ERROR; + ChipError err = CHIP_NO_ERROR; + size_t softwareVersionStringLen = 0; // without counting null-terminator + + err = ReadConfigValueStr(ConfigClass::kConfigKey_SoftwareVersionString, buf, bufSize, softwareVersionStringLen); +#ifdef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING + if (CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING[0] != 0 && err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + { + ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING), CHIP_ERROR_BUFFER_TOO_SMALL); + memcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING, sizeof(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING)); + softwareVersionStringLen = sizeof(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING) - 1; + err = CHIP_NO_ERROR; + } +#endif + ReturnErrorOnFailure(err); + + ReturnErrorCodeIf(softwareVersionStringLen >= bufSize, CHIP_ERROR_BUFFER_TOO_SMALL); + ReturnErrorCodeIf(buf[softwareVersionStringLen] != 0, CHIP_ERROR_INVALID_STRING_LENGTH); + + return err; } template @@ -361,6 +377,26 @@ CHIP_ERROR GenericConfigurationManagerImpl::StoreSerialNumber(const { return WriteConfigValueStr(ConfigClass::kConfigKey_SerialNum, serialNum, serialNumLen); } +template +CHIP_ERROR GenericConfigurationManagerImpl::StoreVendorName(const char * vendorName, size_t vendorNameLen) +{ + return WriteConfigValueStr(ConfigClass::kConfigKey_VendorName, vendorName, vendorNameLen); +} +template +CHIP_ERROR GenericConfigurationManagerImpl::StoreProductName(const char * productName, size_t productNameLen) +{ + return WriteConfigValueStr(ConfigClass::kConfigKey_ProductName, productName, productNameLen); +} +template +CHIP_ERROR GenericConfigurationManagerImpl::StoreHardwareVersionString(const char * hardwareVersionString, size_t hardwareVersionStringLen) +{ + return WriteConfigValueStr(ConfigClass::kConfigKey_HardwareVersionString, hardwareVersionString, hardwareVersionStringLen); +} +template +CHIP_ERROR GenericConfigurationManagerImpl::StoreSoftwareVersionString(const char * softwareVersionString, size_t softwareVersionStringLen) +{ + return WriteConfigValueStr(ConfigClass::kConfigKey_SoftwareVersionString, softwareVersionString, softwareVersionStringLen); +} template CHIP_ERROR GenericConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf) diff --git a/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp b/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp index 549c3eb360aa95..a64c633e9011a0 100644 --- a/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp +++ b/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp @@ -38,18 +38,50 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetProductId(uint16_t template CHIP_ERROR GenericDeviceInstanceInfoProvider::GetVendorName(char * buf, size_t bufSize) { - ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME), CHIP_ERROR_BUFFER_TOO_SMALL); - strcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME); - return CHIP_NO_ERROR; + ChipError err = CHIP_NO_ERROR; + size_t vendorNameLen = 0; // without counting null-terminator + + err = mGenericConfigManager.ReadConfigValueStr(ConfigClass::kConfigKey_VendorName, buf, bufSize, vendorNameLen); +#ifdef CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME + if (CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME[0] != 0 && err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + { + ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME), CHIP_ERROR_BUFFER_TOO_SMALL); + memcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME, sizeof(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME)); + vendorNameLen = sizeof(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME) - 1; + err = CHIP_NO_ERROR; + } +#endif + ReturnErrorOnFailure(err); + + ReturnErrorCodeIf(vendorNameLen >= bufSize, CHIP_ERROR_BUFFER_TOO_SMALL); + ReturnErrorCodeIf(buf[vendorNameLen] != 0, CHIP_ERROR_INVALID_STRING_LENGTH); + + return err; } template CHIP_ERROR GenericDeviceInstanceInfoProvider::GetProductName(char * buf, size_t bufSize) { - ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME), CHIP_ERROR_BUFFER_TOO_SMALL); - strcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME); + ChipError err = CHIP_NO_ERROR; + size_t productNameLen = 0; // without counting null-terminator - return CHIP_NO_ERROR; + err = mGenericConfigManager.ReadConfigValueStr(ConfigClass::kConfigKey_ProductName, buf, bufSize, productNameLen); + +#ifdef CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME + if (CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME[0] != 0 && err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + { + ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME), CHIP_ERROR_BUFFER_TOO_SMALL); + memcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME, sizeof(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME)); + productNameLen = sizeof(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME) - 1; + err = CHIP_NO_ERROR; + } +#endif + ReturnErrorOnFailure(err); + + ReturnErrorCodeIf(productNameLen >= bufSize, CHIP_ERROR_BUFFER_TOO_SMALL); + ReturnErrorCodeIf(buf[productNameLen] != 0, CHIP_ERROR_INVALID_STRING_LENGTH); + + return err; } template @@ -176,9 +208,26 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetHardwareVersion(ui template CHIP_ERROR GenericDeviceInstanceInfoProvider::GetHardwareVersionString(char * buf, size_t bufSize) { - ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING), CHIP_ERROR_BUFFER_TOO_SMALL); - strcpy(buf, CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING); - return CHIP_NO_ERROR; + ChipError err = CHIP_NO_ERROR; + size_t hardwareVersionStringLen = 0; // without counting null-terminator + + err = mGenericConfigManager.ReadConfigValueStr(ConfigClass::kConfigKey_HardwareVersionString, buf, bufSize, hardwareVersionStringLen); + +#ifdef CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING + if (CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING[0] != 0 && err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + { + ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING), CHIP_ERROR_BUFFER_TOO_SMALL); + memcpy(buf, CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING, sizeof(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING)); + hardwareVersionStringLen = sizeof(CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER) - 1; + err = CHIP_NO_ERROR; + } +#endif + ReturnErrorOnFailure(err); + + ReturnErrorCodeIf(hardwareVersionStringLen >= bufSize, CHIP_ERROR_BUFFER_TOO_SMALL); + ReturnErrorCodeIf(buf[hardwareVersionStringLen] != 0, CHIP_ERROR_INVALID_STRING_LENGTH); + + return err; } template diff --git a/src/platform/Darwin/PosixConfig.cpp b/src/platform/Darwin/PosixConfig.cpp index d54713edf532de..d59431deeb2269 100644 --- a/src/platform/Darwin/PosixConfig.cpp +++ b/src/platform/Darwin/PosixConfig.cpp @@ -56,6 +56,11 @@ const PosixConfig::Key PosixConfig::kConfigKey_Spake2pVerifier = { kConfig const PosixConfig::Key PosixConfig::kConfigKey_VendorId = { kConfigNamespace_ChipFactory, "vendor-id" }; const PosixConfig::Key PosixConfig::kConfigKey_ProductId = { kConfigNamespace_ChipFactory, "product-id" }; +const PosixConfig::Key PosixConfig::kConfigKey_VendorName = { kConfigNamespace_ChipFactory, "vendor-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_ProductName = { kConfigNamespace_ChipFactory, "product-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipFactory, "hardware-version-string" }; +const PosixConfig::Key PosixConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipFactory, "software-version-string" }; + // Keys stored in the Chip-config namespace const PosixConfig::Key PosixConfig::kConfigKey_FailSafeArmed = { kConfigNamespace_ChipConfig, "fail-safe-armed" }; const PosixConfig::Key PosixConfig::kConfigKey_RegulatoryLocation = { kConfigNamespace_ChipConfig, "regulatory-location" }; diff --git a/src/platform/Darwin/PosixConfig.h b/src/platform/Darwin/PosixConfig.h index fe4c1dd48a4250..822f04a4335a9d 100644 --- a/src/platform/Darwin/PosixConfig.h +++ b/src/platform/Darwin/PosixConfig.h @@ -72,6 +72,11 @@ class PosixConfig static const Key kCounterKey_RebootCount; static const Key kCounterKey_BootReason; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + #if !CHIP_DISABLE_PLATFORM_KVS static CHIP_ERROR Init(void); diff --git a/src/platform/Linux/PosixConfig.cpp b/src/platform/Linux/PosixConfig.cpp index 61a1fbd4dda6ed..937a02b7b6ee1b 100644 --- a/src/platform/Linux/PosixConfig.cpp +++ b/src/platform/Linux/PosixConfig.cpp @@ -63,6 +63,12 @@ const PosixConfig::Key PosixConfig::kConfigKey_Spake2pVerifier = { kConfig const PosixConfig::Key PosixConfig::kConfigKey_VendorId = { kConfigNamespace_ChipFactory, "vendor-id" }; const PosixConfig::Key PosixConfig::kConfigKey_ProductId = { kConfigNamespace_ChipFactory, "product-id" }; +const PosixConfig::Key PosixConfig::kConfigKey_VendorName = { kConfigNamespace_ChipFactory, "vendor-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_ProductName = { kConfigNamespace_ChipFactory, "product-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipFactory, "hardware-version-string" }; +const PosixConfig::Key PosixConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipFactory, "software-version-string" }; + + // Keys stored in the Chip-config namespace const PosixConfig::Key PosixConfig::kConfigKey_ServiceConfig = { kConfigNamespace_ChipConfig, "service-config" }; const PosixConfig::Key PosixConfig::kConfigKey_PairedAccountId = { kConfigNamespace_ChipConfig, "account-id" }; diff --git a/src/platform/Linux/PosixConfig.h b/src/platform/Linux/PosixConfig.h index c04d4a9be1093f..22c78e30d457fc 100644 --- a/src/platform/Linux/PosixConfig.h +++ b/src/platform/Linux/PosixConfig.h @@ -83,6 +83,11 @@ class PosixConfig static const Key kCounterKey_TotalOperationalHours; static const Key kCounterKey_BootReason; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + static CHIP_ERROR Init(); // Config value accessors. From 6c62371e00f95927b2428a3e7922ecd5ec24b176 Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Fri, 3 May 2024 15:11:43 -0700 Subject: [PATCH 02/32] fixed few typos --- examples/platform/linux/Options.cpp | 30 +++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/examples/platform/linux/Options.cpp b/examples/platform/linux/Options.cpp index db8490c662496b..b229ae675da192 100644 --- a/examples/platform/linux/Options.cpp +++ b/examples/platform/linux/Options.cpp @@ -106,11 +106,11 @@ enum #if CHIP_WITH_NLFAULTINJECTION kDeviceOption_FaultInjection, #endif - kDeviceOption_VendorName = 0x1028, - kDeviceOption_ProductName = 0x1029, + kDeviceOption_VendorName = 0x1028, + kDeviceOption_ProductName = 0x1029, kDeviceOption_HardwareVersionString = 0x102a, kDeviceOption_SoftwareVersionString = 0x102b, - kDeviceOption_SerialNumber = 0x102c, + kDeviceOption_SerialNumber = 0x102c, }; @@ -132,7 +132,7 @@ OptionDef sDeviceOptionDefs[] = { { "product-id", kArgumentRequired, kDeviceOption_ProductID }, { "vendor-name", kArgumentRequired, kDeviceOption_VendorName }, { "product-name", kArgumentRequired, kDeviceOption_ProductName }, - { "harware-version-string", kArgumentRequired, kDeviceOption_HardwareVersionString }, + { "hardware-version-string", kArgumentRequired, kDeviceOption_HardwareVersionString }, { "software-version-string", kArgumentRequired, kDeviceOption_SoftwareVersionString }, { "serial-number", kArgumentRequired, kDeviceOption_SerialNumber }, { "custom-flow", kArgumentRequired, kDeviceOption_CustomFlow }, @@ -215,6 +215,21 @@ const char * sDeviceOptionHelp = " --product-id \n" " The Product ID is specified by vendor.\n" "\n" + " --vendor-name \n" + " The Product ID is specified by vendor.\n" + "\n" + " --product-name \n" + " The Product ID is specified by vendor.\n" + "\n" + " --hardware-version-string \n" + " The Product ID is specified by vendor.\n" + "\n" + " --software-version-string \n" + " The Product ID is specified by vendor.\n" + "\n" + " --serial-number \n" + " The Product ID is specified by vendor.\n" + "\n" " --custom-flow \n" " A 2-bit unsigned enumeration specifying manufacturer-specific custom flow options.\n" "\n" @@ -598,7 +613,6 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier, retval = false; } break; - } #endif case kDeviceOption_VendorName: @@ -612,15 +626,15 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier, case kDeviceOption_HardwareVersionString: LinuxDeviceOptions::GetInstance().hardwareVersionString.SetValue(std::string{ aValue }); break; - + case kDeviceOption_SoftwareVersionString: LinuxDeviceOptions::GetInstance().softwareVersionString.SetValue(std::string{ aValue }); break; - + case kDeviceOption_SerialNumber: LinuxDeviceOptions::GetInstance().serialNumber.SetValue(std::string{ aValue }); break; - + default: PrintArgError("%s: INTERNAL ERROR: Unhandled option: %s\n", aProgram, aName); retval = false; From 1af5cfda742dcddd07a54662bfcb717a08daebf9 Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Fri, 3 May 2024 15:43:46 -0700 Subject: [PATCH 03/32] added few comments --- examples/platform/linux/Options.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/platform/linux/Options.cpp b/examples/platform/linux/Options.cpp index b229ae675da192..43e07110f0fe63 100644 --- a/examples/platform/linux/Options.cpp +++ b/examples/platform/linux/Options.cpp @@ -216,19 +216,19 @@ const char * sDeviceOptionHelp = " The Product ID is specified by vendor.\n" "\n" " --vendor-name \n" - " The Product ID is specified by vendor.\n" + " The vendor name specified by the vendor.\n" "\n" " --product-name \n" - " The Product ID is specified by vendor.\n" + " The product name specified by vendor.\n" "\n" " --hardware-version-string \n" - " The Product ID is specified by vendor.\n" + " The hardware version string specified by vendor.\n" "\n" " --software-version-string \n" - " The Product ID is specified by vendor.\n" + " The software version string specified by vendor.\n" "\n" " --serial-number \n" - " The Product ID is specified by vendor.\n" + " The serial number specified by vendor.\n" "\n" " --custom-flow \n" " A 2-bit unsigned enumeration specifying manufacturer-specific custom flow options.\n" From 42ded2d6a1a7bbf474c89378ca794b8eb2f58ee4 Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Thu, 9 May 2024 11:44:19 -0700 Subject: [PATCH 04/32] fixed review comments, changed functions to taking spans, not separate pointer/length arguments --- .../platform/linux/CommissionableInit.cpp | 26 ++++++++------- examples/platform/linux/Options.cpp | 10 +++--- examples/platform/linux/Options.h | 2 ++ src/include/platform/ConfigurationManager.h | 11 +++---- .../GenericConfigurationManagerImpl.h | 10 +++--- .../GenericConfigurationManagerImpl.ipp | 33 ++++++++++--------- .../GenericDeviceInstanceInfoProvider.ipp | 20 ++++++----- src/platform/fake/ConfigurationManagerImpl.h | 2 +- src/platform/tests/TestConfigurationMgr.cpp | 6 ++-- 9 files changed, 65 insertions(+), 55 deletions(-) diff --git a/examples/platform/linux/CommissionableInit.cpp b/examples/platform/linux/CommissionableInit.cpp index 14414264f92fcf..effb511c85165f 100644 --- a/examples/platform/linux/CommissionableInit.cpp +++ b/examples/platform/linux/CommissionableInit.cpp @@ -102,31 +102,33 @@ CHIP_ERROR InitConfigurationManager(ConfigurationManagerImpl & configManager, Li if (options.vendorName.HasValue()) { - const char * vendorName = options.vendorName.Value().c_str(); - configManager.StoreVendorName(vendorName, strlen(vendorName)); + chip::Span vendor_name(options.vendorName.Value().c_str(), options.vendorName.Value().size()); + VerifyOrDie(configManager.StoreVendorName(vendor_name) == CHIP_NO_ERROR); } if (options.productName.HasValue()) { - const char * productName = options.productName.Value().c_str(); - configManager.StoreProductName(productName,strlen(productName)); + chip::Span product_name(options.productName.Value().c_str(), options.productName.Value().size()); + VerifyOrDie(configManager.StoreProductName(product_name) == CHIP_NO_ERROR); } if (options.hardwareVersionString.HasValue()) { - const char * hardwareVersionString = options.hardwareVersionString.Value().c_str(); - configManager.StoreHardwareVersionString(hardwareVersionString,strlen(hardwareVersionString)); + chip::Span hardware_version_string(options.hardwareVersionString.Value().c_str(), + options.hardwareVersionString.Value().size()); + VerifyOrDie(configManager.StoreHardwareVersionString(hardware_version_string) == CHIP_NO_ERROR); } if (options.softwareVersionString.HasValue()) { - const char * softwareVersionString = options.softwareVersionString.Value().c_str(); - configManager.StoreSoftwareVersionString(softwareVersionString,strlen(softwareVersionString)); + chip::Span software_version_string(options.softwareVersionString.Value().c_str(), + options.softwareVersionString.Value().size()); + VerifyOrDie(configManager.StoreSoftwareVersionString(software_version_string) == CHIP_NO_ERROR); } - + if (options.serialNumber.HasValue()) { - const char * serialNumber = options.serialNumber.Value().c_str(); - configManager.StoreSerialNumber(serialNumber, strlen(serialNumber)); + chip::Span serial_number(options.serialNumber.Value().c_str(), options.serialNumber.Value().size()); + VerifyOrDie(configManager.StoreSerialNumber(serial_number) == CHIP_NO_ERROR); } - + return CHIP_NO_ERROR; } diff --git a/examples/platform/linux/Options.cpp b/examples/platform/linux/Options.cpp index 43e07110f0fe63..32a4dbb1c477fe 100644 --- a/examples/platform/linux/Options.cpp +++ b/examples/platform/linux/Options.cpp @@ -215,19 +215,19 @@ const char * sDeviceOptionHelp = " --product-id \n" " The Product ID is specified by vendor.\n" "\n" - " --vendor-name \n" + " --vendor-name \n" " The vendor name specified by the vendor.\n" "\n" - " --product-name \n" + " --product-name \n" " The product name specified by vendor.\n" "\n" - " --hardware-version-string \n" + " --hardware-version-string \n" " The hardware version string specified by vendor.\n" "\n" - " --software-version-string \n" + " --software-version-string \n" " The software version string specified by vendor.\n" "\n" - " --serial-number \n" + " --serial-number \n" " The serial number specified by vendor.\n" "\n" " --custom-flow \n" diff --git a/examples/platform/linux/Options.h b/examples/platform/linux/Options.h index e07448e155ac1a..e6369c142b8465 100644 --- a/examples/platform/linux/Options.h +++ b/examples/platform/linux/Options.h @@ -82,7 +82,9 @@ struct LinuxDeviceOptions chip::Optional productName; chip::Optional hardwareVersionString; chip::Optional softwareVersionString; +#if defined(CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER) chip::Optional serialNumber; +#endif static LinuxDeviceOptions & GetInstance(); }; diff --git a/src/include/platform/ConfigurationManager.h b/src/include/platform/ConfigurationManager.h index bed6eea5cadb80..e00a1ab19c99d2 100644 --- a/src/include/platform/ConfigurationManager.h +++ b/src/include/platform/ConfigurationManager.h @@ -114,7 +114,6 @@ class ConfigurationManager #endif virtual CHIP_ERROR GetRegulatoryLocation(uint8_t & location) = 0; virtual CHIP_ERROR GetCountryCode(char * buf, size_t bufSize, size_t & codeLen) = 0; - virtual CHIP_ERROR StoreSerialNumber(const char * serialNum, size_t serialNumLen) = 0; virtual CHIP_ERROR StoreManufacturingDate(const char * mfgDate, size_t mfgDateLen) = 0; virtual CHIP_ERROR StoreSoftwareVersion(uint32_t softwareVer) = 0; virtual CHIP_ERROR StoreHardwareVersion(uint16_t hardwareVer) = 0; @@ -133,11 +132,11 @@ class ConfigurationManager virtual CHIP_ERROR SetFailSafeArmed(bool val) = 0; virtual CHIP_ERROR GetBLEDeviceIdentificationInfo(Ble::ChipBLEDeviceIdentificationInfo & deviceIdInfo) = 0; - - virtual CHIP_ERROR StoreVendorName(const char * vendorName, size_t vendorNameLen) = 0; - virtual CHIP_ERROR StoreProductName(const char * productName, size_t productNameLen) = 0; - virtual CHIP_ERROR StoreHardwareVersionString(const char * hardwareVersionString, size_t hardwareVersionStringLen) = 0; - virtual CHIP_ERROR StoreSoftwareVersionString(const char * softwareVersionString, size_t softwareVersionStringLen) = 0; + virtual CHIP_ERROR StoreSerialNumber(chip::Span serialNumber) = 0; + virtual CHIP_ERROR StoreVendorName(chip::Span vendorName) = 0; + virtual CHIP_ERROR StoreProductName(chip::Span productName) = 0; + virtual CHIP_ERROR StoreHardwareVersionString(chip::Span hardwareVersionString) = 0; + virtual CHIP_ERROR StoreSoftwareVersionString(chip::Span softwareVersionString) = 0; #if CHIP_CONFIG_TEST virtual void RunUnitTests() = 0; diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.h b/src/include/platform/internal/GenericConfigurationManagerImpl.h index 22189acd9b23e4..4a5c2dab475ac8 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.h +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.h @@ -68,7 +68,7 @@ class GenericConfigurationManagerImpl : public ConfigurationManager CHIP_ERROR StoreSoftwareVersion(uint32_t softwareVer) override; CHIP_ERROR GetFirmwareBuildChipEpochTime(System::Clock::Seconds32 & buildTime) override; CHIP_ERROR SetFirmwareBuildChipEpochTime(System::Clock::Seconds32 buildTime) override; - CHIP_ERROR StoreSerialNumber(const char * serialNum, size_t serialNumLen) override; + CHIP_ERROR StoreSerialNumber(chip::Span serialNumber) override; CHIP_ERROR GetPrimaryMACAddress(MutableByteSpan buf) override; CHIP_ERROR GetPrimaryWiFiMACAddress(uint8_t * buf) override; CHIP_ERROR GetPrimary802154MACAddress(uint8_t * buf) override; @@ -104,10 +104,10 @@ class GenericConfigurationManagerImpl : public ConfigurationManager CHIP_ERROR StoreUniqueId(const char * uniqueId, size_t uniqueIdLen) override; CHIP_ERROR GenerateUniqueId(char * buf, size_t bufSize) override; - CHIP_ERROR StoreVendorName(const char * vendorName, size_t vendorNameLen) override; - CHIP_ERROR StoreProductName(const char * productName, size_t productNameLen) override; - CHIP_ERROR StoreHardwareVersionString(const char * hardwareVersionString, size_t hardwareVersionStringLen) override; - CHIP_ERROR StoreSoftwareVersionString(const char * softwareVersionString, size_t softwareVersionStringLen) override; + CHIP_ERROR StoreVendorName(chip::Span vendorName) override; + CHIP_ERROR StoreProductName(chip::Span productName) override; + CHIP_ERROR StoreHardwareVersionString(chip::Span hardwareVersionString) override; + CHIP_ERROR StoreSoftwareVersionString(chip::Span softwareVersionString) override; #if CHIP_CONFIG_TEST void RunUnitTests() override; #endif diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.ipp b/src/include/platform/internal/GenericConfigurationManagerImpl.ipp index 05148a6dc460ef..bd3ab9d0e9c67f 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.ipp +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.ipp @@ -351,20 +351,20 @@ CHIP_ERROR GenericConfigurationManagerImpl::GetSecondaryPairingHint template CHIP_ERROR GenericConfigurationManagerImpl::GetSoftwareVersionString(char * buf, size_t bufSize) { - ChipError err = CHIP_NO_ERROR; + ChipError err = CHIP_NO_ERROR; size_t softwareVersionStringLen = 0; // without counting null-terminator err = ReadConfigValueStr(ConfigClass::kConfigKey_SoftwareVersionString, buf, bufSize, softwareVersionStringLen); -#ifdef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING + if (CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING[0] != 0 && err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) { ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING), CHIP_ERROR_BUFFER_TOO_SMALL); memcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING, sizeof(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING)); softwareVersionStringLen = sizeof(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING) - 1; - err = CHIP_NO_ERROR; + err = CHIP_NO_ERROR; } -#endif - ReturnErrorOnFailure(err); + + VerifyOrReturnError(err == CHIP_NO_ERROR, CHIP_ERROR_INTERNAL); ReturnErrorCodeIf(softwareVersionStringLen >= bufSize, CHIP_ERROR_BUFFER_TOO_SMALL); ReturnErrorCodeIf(buf[softwareVersionStringLen] != 0, CHIP_ERROR_INVALID_STRING_LENGTH); @@ -373,29 +373,32 @@ CHIP_ERROR GenericConfigurationManagerImpl::GetSoftwareVersionStrin } template -CHIP_ERROR GenericConfigurationManagerImpl::StoreSerialNumber(const char * serialNum, size_t serialNumLen) +CHIP_ERROR GenericConfigurationManagerImpl::StoreSerialNumber(chip::Span serialNumber) { - return WriteConfigValueStr(ConfigClass::kConfigKey_SerialNum, serialNum, serialNumLen); + return WriteConfigValueStr(ConfigClass::kConfigKey_SerialNum, serialNumber.data(), serialNumber.size()); } template -CHIP_ERROR GenericConfigurationManagerImpl::StoreVendorName(const char * vendorName, size_t vendorNameLen) +CHIP_ERROR GenericConfigurationManagerImpl::StoreVendorName(chip::Span vendorName) { - return WriteConfigValueStr(ConfigClass::kConfigKey_VendorName, vendorName, vendorNameLen); + + return WriteConfigValueStr(ConfigClass::kConfigKey_VendorName, vendorName.data(), vendorName.size()); } template -CHIP_ERROR GenericConfigurationManagerImpl::StoreProductName(const char * productName, size_t productNameLen) +CHIP_ERROR GenericConfigurationManagerImpl::StoreProductName(chip::Span productName) { - return WriteConfigValueStr(ConfigClass::kConfigKey_ProductName, productName, productNameLen); + return WriteConfigValueStr(ConfigClass::kConfigKey_ProductName, productName.data(), productName.size()); } template -CHIP_ERROR GenericConfigurationManagerImpl::StoreHardwareVersionString(const char * hardwareVersionString, size_t hardwareVersionStringLen) +CHIP_ERROR GenericConfigurationManagerImpl::StoreHardwareVersionString(chip::Span hardwareVersionString) { - return WriteConfigValueStr(ConfigClass::kConfigKey_HardwareVersionString, hardwareVersionString, hardwareVersionStringLen); + return WriteConfigValueStr(ConfigClass::kConfigKey_HardwareVersionString, hardwareVersionString.data(), + hardwareVersionString.size()); } template -CHIP_ERROR GenericConfigurationManagerImpl::StoreSoftwareVersionString(const char * softwareVersionString, size_t softwareVersionStringLen) +CHIP_ERROR GenericConfigurationManagerImpl::StoreSoftwareVersionString(chip::Span softwareVersionString) { - return WriteConfigValueStr(ConfigClass::kConfigKey_SoftwareVersionString, softwareVersionString, softwareVersionStringLen); + return WriteConfigValueStr(ConfigClass::kConfigKey_SoftwareVersionString, softwareVersionString.data(), + softwareVersionString.size()); } template diff --git a/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp b/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp index a64c633e9011a0..474117680ddeff 100644 --- a/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp +++ b/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp @@ -38,7 +38,7 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetProductId(uint16_t template CHIP_ERROR GenericDeviceInstanceInfoProvider::GetVendorName(char * buf, size_t bufSize) { - ChipError err = CHIP_NO_ERROR; + ChipError err = CHIP_NO_ERROR; size_t vendorNameLen = 0; // without counting null-terminator err = mGenericConfigManager.ReadConfigValueStr(ConfigClass::kConfigKey_VendorName, buf, bufSize, vendorNameLen); @@ -48,7 +48,7 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetVendorName(char * ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME), CHIP_ERROR_BUFFER_TOO_SMALL); memcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME, sizeof(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME)); vendorNameLen = sizeof(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME) - 1; - err = CHIP_NO_ERROR; + err = CHIP_NO_ERROR; } #endif ReturnErrorOnFailure(err); @@ -62,7 +62,7 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetVendorName(char * template CHIP_ERROR GenericDeviceInstanceInfoProvider::GetProductName(char * buf, size_t bufSize) { - ChipError err = CHIP_NO_ERROR; + ChipError err = CHIP_NO_ERROR; size_t productNameLen = 0; // without counting null-terminator err = mGenericConfigManager.ReadConfigValueStr(ConfigClass::kConfigKey_ProductName, buf, bufSize, productNameLen); @@ -73,7 +73,7 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetProductName(char * ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME), CHIP_ERROR_BUFFER_TOO_SMALL); memcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME, sizeof(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME)); productNameLen = sizeof(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME) - 1; - err = CHIP_NO_ERROR; + err = CHIP_NO_ERROR; } #endif ReturnErrorOnFailure(err); @@ -208,18 +208,20 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetHardwareVersion(ui template CHIP_ERROR GenericDeviceInstanceInfoProvider::GetHardwareVersionString(char * buf, size_t bufSize) { - ChipError err = CHIP_NO_ERROR; + ChipError err = CHIP_NO_ERROR; size_t hardwareVersionStringLen = 0; // without counting null-terminator - err = mGenericConfigManager.ReadConfigValueStr(ConfigClass::kConfigKey_HardwareVersionString, buf, bufSize, hardwareVersionStringLen); + err = mGenericConfigManager.ReadConfigValueStr(ConfigClass::kConfigKey_HardwareVersionString, buf, bufSize, + hardwareVersionStringLen); #ifdef CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING if (CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING[0] != 0 && err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) { ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING), CHIP_ERROR_BUFFER_TOO_SMALL); - memcpy(buf, CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING, sizeof(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING)); - hardwareVersionStringLen = sizeof(CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER) - 1; - err = CHIP_NO_ERROR; + memcpy(buf, CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING, + sizeof(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING)); + hardwareVersionStringLen = sizeof(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING) - 1; + err = CHIP_NO_ERROR; } #endif ReturnErrorOnFailure(err); diff --git a/src/platform/fake/ConfigurationManagerImpl.h b/src/platform/fake/ConfigurationManagerImpl.h index 510b2fc0dacc83..98da2c3c88ee22 100644 --- a/src/platform/fake/ConfigurationManagerImpl.h +++ b/src/platform/fake/ConfigurationManagerImpl.h @@ -49,7 +49,7 @@ class ConfigurationManagerImpl : public ConfigurationManager } CHIP_ERROR GetSoftwareVersion(uint32_t & softwareVer) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR StoreSoftwareVersion(uint32_t softwareVer) override { return CHIP_ERROR_NOT_IMPLEMENTED; } - CHIP_ERROR StoreSerialNumber(const char * serialNum, size_t serialNumLen) override { return CHIP_ERROR_NOT_IMPLEMENTED; } + CHIP_ERROR StoreSerialNumber(chip::Span serialNumber) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetPrimaryMACAddress(MutableByteSpan buf) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetPrimaryWiFiMACAddress(uint8_t * buf) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetPrimary802154MACAddress(uint8_t * buf) override { return CHIP_ERROR_NOT_IMPLEMENTED; } diff --git a/src/platform/tests/TestConfigurationMgr.cpp b/src/platform/tests/TestConfigurationMgr.cpp index d40c600c5d03f3..36530dfccc3373 100644 --- a/src/platform/tests/TestConfigurationMgr.cpp +++ b/src/platform/tests/TestConfigurationMgr.cpp @@ -84,8 +84,9 @@ TEST_F(TestConfigurationMgr, SerialNumber) char buf[64]; const char * serialNumber = "89051AAZZ236"; + chip::Span serial_number(serialNumber.Value().c_str(), serialNumber.Value().size()); - err = ConfigurationMgr().StoreSerialNumber(serialNumber, strlen(serialNumber)); + err = ConfigurationMgr().StoreSerialNumber(serial_number); EXPECT_EQ(err, CHIP_NO_ERROR); err = GetDeviceInstanceInfoProvider()->GetSerialNumber(buf, 64); @@ -94,7 +95,8 @@ TEST_F(TestConfigurationMgr, SerialNumber) EXPECT_EQ(strlen(buf), 12u); EXPECT_STREQ(buf, serialNumber); - err = ConfigurationMgr().StoreSerialNumber(serialNumber, 5); + chip::Span serial_number(serialNumber.Value().c_str(), 5); + err = ConfigurationMgr().StoreSerialNumber(serial_number); EXPECT_EQ(err, CHIP_NO_ERROR); err = GetDeviceInstanceInfoProvider()->GetSerialNumber(buf, 64); From 9e642fae562efbe0972b1df352b26733fcce0e06 Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Mon, 1 Jul 2024 11:23:16 -0700 Subject: [PATCH 05/32] defined vendor_name, product_name, hardware_version_string and software_version_string config variables in all platforms --- .../platform/linux/CommissionableInit.cpp | 15 +++--- examples/platform/linux/Options.cpp | 4 +- examples/platform/linux/Options.h | 3 +- src/include/platform/ConfigurationManager.h | 10 ++-- .../GenericConfigurationManagerImpl.h | 10 ++-- .../GenericConfigurationManagerImpl.ipp | 22 ++++----- .../GenericDeviceInstanceInfoProvider.ipp | 46 ++++++------------- src/platform/ASR/ASRConfig.h | 5 ++ src/platform/Ameba/AmebaConfig.h | 5 ++ src/platform/Beken/BekenConfig.h | 5 ++ src/platform/Infineon/PSOC6/P6Config.h | 5 ++ src/platform/Zephyr/ZephyrConfig.cpp | 5 ++ src/platform/Zephyr/ZephyrConfig.h | 5 ++ src/platform/bouffalolab/common/BLConfig.h | 5 ++ src/platform/cc13xx_26xx/CC13XX_26XXConfig.h | 5 ++ src/platform/cc32xx/CC32XXConfig.h | 5 ++ src/platform/fake/ConfigurationManagerImpl.h | 2 +- src/platform/mbed/MbedConfig.h | 5 ++ src/platform/nxp/common/NXPConfig.h | 5 ++ src/platform/nxp/k32w/k32w0/K32W0Config.cpp | 5 ++ src/platform/nxp/k32w/k32w0/K32W0Config.h | 5 ++ src/platform/nxp/k32w/k32w1/K32W1Config.h | 5 ++ src/platform/nxp/mw320/MW320Config.h | 5 ++ src/platform/openiotsdk/KVPsaPsStore.h | 5 ++ src/platform/qpg/qpgConfig.h | 5 ++ src/platform/silabs/SilabsConfig.h | 3 +- src/platform/tests/TestConfigurationMgr.cpp | 10 ++-- 27 files changed, 135 insertions(+), 75 deletions(-) diff --git a/examples/platform/linux/CommissionableInit.cpp b/examples/platform/linux/CommissionableInit.cpp index effb511c85165f..2418c64d8fc0a7 100644 --- a/examples/platform/linux/CommissionableInit.cpp +++ b/examples/platform/linux/CommissionableInit.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include "CommissionableInit.h" @@ -102,30 +101,30 @@ CHIP_ERROR InitConfigurationManager(ConfigurationManagerImpl & configManager, Li if (options.vendorName.HasValue()) { - chip::Span vendor_name(options.vendorName.Value().c_str(), options.vendorName.Value().size()); + CharSpan vendor_name(options.vendorName.Value().c_str(), options.vendorName.Value().size()); VerifyOrDie(configManager.StoreVendorName(vendor_name) == CHIP_NO_ERROR); } if (options.productName.HasValue()) { - chip::Span product_name(options.productName.Value().c_str(), options.productName.Value().size()); + CharSpan product_name(options.productName.Value().c_str(), options.productName.Value().size()); VerifyOrDie(configManager.StoreProductName(product_name) == CHIP_NO_ERROR); } if (options.hardwareVersionString.HasValue()) { - chip::Span hardware_version_string(options.hardwareVersionString.Value().c_str(), - options.hardwareVersionString.Value().size()); + CharSpan hardware_version_string(options.hardwareVersionString.Value().c_str(), + options.hardwareVersionString.Value().size()); VerifyOrDie(configManager.StoreHardwareVersionString(hardware_version_string) == CHIP_NO_ERROR); } if (options.softwareVersionString.HasValue()) { - chip::Span software_version_string(options.softwareVersionString.Value().c_str(), - options.softwareVersionString.Value().size()); + CharSpan software_version_string(options.softwareVersionString.Value().c_str(), + options.softwareVersionString.Value().size()); VerifyOrDie(configManager.StoreSoftwareVersionString(software_version_string) == CHIP_NO_ERROR); } if (options.serialNumber.HasValue()) { - chip::Span serial_number(options.serialNumber.Value().c_str(), options.serialNumber.Value().size()); + CharSpan serial_number(options.serialNumber.Value().c_str(), options.serialNumber.Value().size()); VerifyOrDie(configManager.StoreSerialNumber(serial_number) == CHIP_NO_ERROR); } diff --git a/examples/platform/linux/Options.cpp b/examples/platform/linux/Options.cpp index 32a4dbb1c477fe..aca10ef74913b8 100644 --- a/examples/platform/linux/Options.cpp +++ b/examples/platform/linux/Options.cpp @@ -222,10 +222,10 @@ const char * sDeviceOptionHelp = " The product name specified by vendor.\n" "\n" " --hardware-version-string \n" - " The hardware version string specified by vendor.\n" + " The HardwareVersionString to use in the basic information cluster.\n" "\n" " --software-version-string \n" - " The software version string specified by vendor.\n" + " The SoftwareVersionString to use in the basic information cluster.\n" "\n" " --serial-number \n" " The serial number specified by vendor.\n" diff --git a/examples/platform/linux/Options.h b/examples/platform/linux/Options.h index e6369c142b8465..901afea813bf6a 100644 --- a/examples/platform/linux/Options.h +++ b/examples/platform/linux/Options.h @@ -82,9 +82,8 @@ struct LinuxDeviceOptions chip::Optional productName; chip::Optional hardwareVersionString; chip::Optional softwareVersionString; -#if defined(CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER) chip::Optional serialNumber; -#endif + static LinuxDeviceOptions & GetInstance(); }; diff --git a/src/include/platform/ConfigurationManager.h b/src/include/platform/ConfigurationManager.h index e00a1ab19c99d2..d54e044b82d66a 100644 --- a/src/include/platform/ConfigurationManager.h +++ b/src/include/platform/ConfigurationManager.h @@ -132,11 +132,11 @@ class ConfigurationManager virtual CHIP_ERROR SetFailSafeArmed(bool val) = 0; virtual CHIP_ERROR GetBLEDeviceIdentificationInfo(Ble::ChipBLEDeviceIdentificationInfo & deviceIdInfo) = 0; - virtual CHIP_ERROR StoreSerialNumber(chip::Span serialNumber) = 0; - virtual CHIP_ERROR StoreVendorName(chip::Span vendorName) = 0; - virtual CHIP_ERROR StoreProductName(chip::Span productName) = 0; - virtual CHIP_ERROR StoreHardwareVersionString(chip::Span hardwareVersionString) = 0; - virtual CHIP_ERROR StoreSoftwareVersionString(chip::Span softwareVersionString) = 0; + virtual CHIP_ERROR StoreSerialNumber(CharSpan serialNumber) = 0; + virtual CHIP_ERROR StoreVendorName(CharSpan vendorName) = 0; + virtual CHIP_ERROR StoreProductName(CharSpan productName) = 0; + virtual CHIP_ERROR StoreHardwareVersionString(CharSpan hardwareVersionString) = 0; + virtual CHIP_ERROR StoreSoftwareVersionString(CharSpan softwareVersionString) = 0; #if CHIP_CONFIG_TEST virtual void RunUnitTests() = 0; diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.h b/src/include/platform/internal/GenericConfigurationManagerImpl.h index 4a5c2dab475ac8..faa8dfc79fa7ca 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.h +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.h @@ -68,7 +68,7 @@ class GenericConfigurationManagerImpl : public ConfigurationManager CHIP_ERROR StoreSoftwareVersion(uint32_t softwareVer) override; CHIP_ERROR GetFirmwareBuildChipEpochTime(System::Clock::Seconds32 & buildTime) override; CHIP_ERROR SetFirmwareBuildChipEpochTime(System::Clock::Seconds32 buildTime) override; - CHIP_ERROR StoreSerialNumber(chip::Span serialNumber) override; + CHIP_ERROR StoreSerialNumber(CharSpan serialNumber) override; CHIP_ERROR GetPrimaryMACAddress(MutableByteSpan buf) override; CHIP_ERROR GetPrimaryWiFiMACAddress(uint8_t * buf) override; CHIP_ERROR GetPrimary802154MACAddress(uint8_t * buf) override; @@ -104,10 +104,10 @@ class GenericConfigurationManagerImpl : public ConfigurationManager CHIP_ERROR StoreUniqueId(const char * uniqueId, size_t uniqueIdLen) override; CHIP_ERROR GenerateUniqueId(char * buf, size_t bufSize) override; - CHIP_ERROR StoreVendorName(chip::Span vendorName) override; - CHIP_ERROR StoreProductName(chip::Span productName) override; - CHIP_ERROR StoreHardwareVersionString(chip::Span hardwareVersionString) override; - CHIP_ERROR StoreSoftwareVersionString(chip::Span softwareVersionString) override; + CHIP_ERROR StoreVendorName(CharSpan vendorName) override; + CHIP_ERROR StoreProductName(CharSpan productName) override; + CHIP_ERROR StoreHardwareVersionString(CharSpan hardwareVersionString) override; + CHIP_ERROR StoreSoftwareVersionString(CharSpan softwareVersionString) override; #if CHIP_CONFIG_TEST void RunUnitTests() override; #endif diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.ipp b/src/include/platform/internal/GenericConfigurationManagerImpl.ipp index bd3ab9d0e9c67f..4ef3893cd91238 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.ipp +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.ipp @@ -351,51 +351,47 @@ CHIP_ERROR GenericConfigurationManagerImpl::GetSecondaryPairingHint template CHIP_ERROR GenericConfigurationManagerImpl::GetSoftwareVersionString(char * buf, size_t bufSize) { - ChipError err = CHIP_NO_ERROR; + CHIP_ERROR err = CHIP_NO_ERROR; size_t softwareVersionStringLen = 0; // without counting null-terminator err = ReadConfigValueStr(ConfigClass::kConfigKey_SoftwareVersionString, buf, bufSize, softwareVersionStringLen); - if (CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING[0] != 0 && err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) { ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING), CHIP_ERROR_BUFFER_TOO_SMALL); memcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING, sizeof(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING)); - softwareVersionStringLen = sizeof(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING) - 1; - err = CHIP_NO_ERROR; + + return CHIP_NO_ERROR; } VerifyOrReturnError(err == CHIP_NO_ERROR, CHIP_ERROR_INTERNAL); - - ReturnErrorCodeIf(softwareVersionStringLen >= bufSize, CHIP_ERROR_BUFFER_TOO_SMALL); - ReturnErrorCodeIf(buf[softwareVersionStringLen] != 0, CHIP_ERROR_INVALID_STRING_LENGTH); - return err; } template -CHIP_ERROR GenericConfigurationManagerImpl::StoreSerialNumber(chip::Span serialNumber) +CHIP_ERROR GenericConfigurationManagerImpl::StoreSerialNumber(CharSpan serialNumber) { return WriteConfigValueStr(ConfigClass::kConfigKey_SerialNum, serialNumber.data(), serialNumber.size()); } template -CHIP_ERROR GenericConfigurationManagerImpl::StoreVendorName(chip::Span vendorName) +CHIP_ERROR GenericConfigurationManagerImpl::StoreVendorName(CharSpan vendorName) { return WriteConfigValueStr(ConfigClass::kConfigKey_VendorName, vendorName.data(), vendorName.size()); } template -CHIP_ERROR GenericConfigurationManagerImpl::StoreProductName(chip::Span productName) +CHIP_ERROR GenericConfigurationManagerImpl::StoreProductName(CharSpan productName) { return WriteConfigValueStr(ConfigClass::kConfigKey_ProductName, productName.data(), productName.size()); } template -CHIP_ERROR GenericConfigurationManagerImpl::StoreHardwareVersionString(chip::Span hardwareVersionString) +CHIP_ERROR GenericConfigurationManagerImpl::StoreHardwareVersionString(CharSpan hardwareVersionString) { return WriteConfigValueStr(ConfigClass::kConfigKey_HardwareVersionString, hardwareVersionString.data(), hardwareVersionString.size()); } template -CHIP_ERROR GenericConfigurationManagerImpl::StoreSoftwareVersionString(chip::Span softwareVersionString) +CHIP_ERROR GenericConfigurationManagerImpl::StoreSoftwareVersionString(CharSpan softwareVersionString) { return WriteConfigValueStr(ConfigClass::kConfigKey_SoftwareVersionString, softwareVersionString.data(), softwareVersionString.size()); diff --git a/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp b/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp index 474117680ddeff..cb44bfc140341f 100644 --- a/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp +++ b/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp @@ -42,19 +42,15 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetVendorName(char * size_t vendorNameLen = 0; // without counting null-terminator err = mGenericConfigManager.ReadConfigValueStr(ConfigClass::kConfigKey_VendorName, buf, bufSize, vendorNameLen); -#ifdef CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME - if (CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME[0] != 0 && err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + + if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) { ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME), CHIP_ERROR_BUFFER_TOO_SMALL); memcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME, sizeof(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME)); - vendorNameLen = sizeof(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME) - 1; - err = CHIP_NO_ERROR; + err = CHIP_NO_ERROR; } -#endif - ReturnErrorOnFailure(err); - ReturnErrorCodeIf(vendorNameLen >= bufSize, CHIP_ERROR_BUFFER_TOO_SMALL); - ReturnErrorCodeIf(buf[vendorNameLen] != 0, CHIP_ERROR_INVALID_STRING_LENGTH); + VerifyOrReturnError(err == CHIP_NO_ERROR, CHIP_ERROR_INTERNAL); return err; } @@ -67,19 +63,14 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetProductName(char * err = mGenericConfigManager.ReadConfigValueStr(ConfigClass::kConfigKey_ProductName, buf, bufSize, productNameLen); -#ifdef CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME - if (CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME[0] != 0 && err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) { ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME), CHIP_ERROR_BUFFER_TOO_SMALL); memcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME, sizeof(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME)); - productNameLen = sizeof(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME) - 1; - err = CHIP_NO_ERROR; + err = CHIP_NO_ERROR; } -#endif - ReturnErrorOnFailure(err); - ReturnErrorCodeIf(productNameLen >= bufSize, CHIP_ERROR_BUFFER_TOO_SMALL); - ReturnErrorCodeIf(buf[productNameLen] != 0, CHIP_ERROR_INVALID_STRING_LENGTH); + VerifyOrReturnError(err == CHIP_NO_ERROR, CHIP_ERROR_INTERNAL); return err; } @@ -128,19 +119,15 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetSerialNumber(char err = mGenericConfigManager.ReadConfigValueStr(ConfigClass::kConfigKey_SerialNum, buf, bufSize, serialNumLen); -#ifdef CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER - if (CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER[0] != 0 && err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) { ReturnErrorCodeIf(sizeof(CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER) > bufSize, CHIP_ERROR_BUFFER_TOO_SMALL); memcpy(buf, CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER, sizeof(CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER)); - serialNumLen = sizeof(CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER) - 1; - err = CHIP_NO_ERROR; + + err = CHIP_NO_ERROR; } -#endif // CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER - ReturnErrorOnFailure(err); - ReturnErrorCodeIf(serialNumLen >= bufSize, CHIP_ERROR_BUFFER_TOO_SMALL); - ReturnErrorCodeIf(buf[serialNumLen] != 0, CHIP_ERROR_INVALID_STRING_LENGTH); + VerifyOrReturnError(err == CHIP_NO_ERROR, CHIP_ERROR_INTERNAL); return err; } @@ -214,20 +201,15 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetHardwareVersionStr err = mGenericConfigManager.ReadConfigValueStr(ConfigClass::kConfigKey_HardwareVersionString, buf, bufSize, hardwareVersionStringLen); -#ifdef CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING - if (CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING[0] != 0 && err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) { ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING), CHIP_ERROR_BUFFER_TOO_SMALL); memcpy(buf, CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING, sizeof(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING)); - hardwareVersionStringLen = sizeof(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING) - 1; - err = CHIP_NO_ERROR; + err = CHIP_NO_ERROR; } -#endif - ReturnErrorOnFailure(err); - ReturnErrorCodeIf(hardwareVersionStringLen >= bufSize, CHIP_ERROR_BUFFER_TOO_SMALL); - ReturnErrorCodeIf(buf[hardwareVersionStringLen] != 0, CHIP_ERROR_INVALID_STRING_LENGTH); + VerifyOrReturnError(err == CHIP_NO_ERROR, CHIP_ERROR_INTERNAL); return err; } diff --git a/src/platform/ASR/ASRConfig.h b/src/platform/ASR/ASRConfig.h index 71c90a3a79b242..b27f77dd5ffd10 100755 --- a/src/platform/ASR/ASRConfig.h +++ b/src/platform/ASR/ASRConfig.h @@ -91,6 +91,11 @@ class ASRConfig static const Key kCounterKey_UpTime; static const Key kCounterKey_TotalOperationalHours; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + // Config value accessors. static CHIP_ERROR ReadConfigValue(Key key, bool & val); static CHIP_ERROR ReadConfigValue(Key key, uint32_t & val); diff --git a/src/platform/Ameba/AmebaConfig.h b/src/platform/Ameba/AmebaConfig.h index 0c78e0e3a742bd..0c100b4713bd05 100755 --- a/src/platform/Ameba/AmebaConfig.h +++ b/src/platform/Ameba/AmebaConfig.h @@ -74,6 +74,11 @@ class AmebaConfig static const Key kCounterKey_TotalOperationalHours; static const Key kCounterKey_BootReason; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + // Config value accessors. static CHIP_ERROR ReadConfigValue(Key key, bool & val); static CHIP_ERROR ReadConfigValue(Key key, uint32_t & val); diff --git a/src/platform/Beken/BekenConfig.h b/src/platform/Beken/BekenConfig.h index 94362c092296f8..819d379267a3fd 100755 --- a/src/platform/Beken/BekenConfig.h +++ b/src/platform/Beken/BekenConfig.h @@ -74,6 +74,11 @@ class BekenConfig static const Key kCounterKey_TotalOperationalHours; static const Key kCounterKey_BootReason; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + static const char kGroupKeyNamePrefix[]; // Config value accessors. diff --git a/src/platform/Infineon/PSOC6/P6Config.h b/src/platform/Infineon/PSOC6/P6Config.h index 7e62fd6e66b772..e54e69cd2599a6 100644 --- a/src/platform/Infineon/PSOC6/P6Config.h +++ b/src/platform/Infineon/PSOC6/P6Config.h @@ -89,6 +89,11 @@ class P6Config static const Key kConfigKey_YearDaySchedules; static const Key kConfigKey_HolidaySchedules; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + // CHIP Counter keys static const Key kCounterKey_RebootCount; static const Key kCounterKey_UpTime; diff --git a/src/platform/Zephyr/ZephyrConfig.cpp b/src/platform/Zephyr/ZephyrConfig.cpp index f548e95bca09a7..ceb4e54e00bd0e 100644 --- a/src/platform/Zephyr/ZephyrConfig.cpp +++ b/src/platform/Zephyr/ZephyrConfig.cpp @@ -73,6 +73,11 @@ 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_UniqueId = CONFIG_KEY(NAMESPACE_CONFIG "unique-id"); +const ZephyrConfig::Key ZephyrConfig::kConfigKey_VendorName = CONFIG_KEY(NAMESPACE_CONFIG "vendor-name"); +const ZephyrConfig::Key ZephyrConfig::kConfigKey_ProductName = CONFIG_KEY(NAMESPACE_CONFIG "product-name"); +const ZephyrConfig::Key ZephyrConfig::kConfigKey_HardwareVersionString = CONFIG_KEY(NAMESPACE_CONFIG "hardware-version-string"); +const ZephyrConfig::Key ZephyrConfig::kConfigKey_SoftwareVersionString = CONFIG_KEY(NAMESPACE_CONFIG "software-version-string"); + // Keys stored in the counters namespace const ZephyrConfig::Key ZephyrConfig::kCounterKey_RebootCount = CONFIG_KEY(NAMESPACE_COUNTERS "reboot-count"); const ZephyrConfig::Key ZephyrConfig::kCounterKey_BootReason = CONFIG_KEY(NAMESPACE_COUNTERS "boot-reason"); diff --git a/src/platform/Zephyr/ZephyrConfig.h b/src/platform/Zephyr/ZephyrConfig.h index b451d0c13997e9..7e43667a76204e 100644 --- a/src/platform/Zephyr/ZephyrConfig.h +++ b/src/platform/Zephyr/ZephyrConfig.h @@ -66,6 +66,11 @@ class ZephyrConfig static const Key kConfigKey_Spake2pVerifier; static const Key kConfigKey_CertificationDeclaration; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + static const Key kCounterKey_RebootCount; static const Key kCounterKey_BootReason; static const Key kCounterKey_TotalOperationalHours; diff --git a/src/platform/bouffalolab/common/BLConfig.h b/src/platform/bouffalolab/common/BLConfig.h index bb9f57fd01b639..c665273a6ce349 100644 --- a/src/platform/bouffalolab/common/BLConfig.h +++ b/src/platform/bouffalolab/common/BLConfig.h @@ -77,6 +77,11 @@ class BLConfig static constexpr char kBLKey_factoryResetFlag[] = ("__factory_reset_pending"); + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + static void Init(void); // Config value accessors. diff --git a/src/platform/cc13xx_26xx/CC13XX_26XXConfig.h b/src/platform/cc13xx_26xx/CC13XX_26XXConfig.h index 2450c0f8c50544..0dcc405fc19553 100644 --- a/src/platform/cc13xx_26xx/CC13XX_26XXConfig.h +++ b/src/platform/cc13xx_26xx/CC13XX_26XXConfig.h @@ -82,6 +82,11 @@ class CC13XX_26XXConfig static const Key kConfigKey_TotalOperationalHours; static const Key kConfigKey_LifeTimeCounter; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + static CHIP_ERROR Init(void); // Config value accessors. diff --git a/src/platform/cc32xx/CC32XXConfig.h b/src/platform/cc32xx/CC32XXConfig.h index 8179d9877a4489..73c503b929d4c8 100644 --- a/src/platform/cc32xx/CC32XXConfig.h +++ b/src/platform/cc32xx/CC32XXConfig.h @@ -57,6 +57,11 @@ class CC32XXConfig static const Key kConfigKey_Breadcrumb; static const Key kConfigKey_UniqueId; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + static const Key kConfigKey_Spake2pIterationCount; static const Key kConfigKey_Spake2pSalt; static const Key kConfigKey_Spake2pVerifier; diff --git a/src/platform/fake/ConfigurationManagerImpl.h b/src/platform/fake/ConfigurationManagerImpl.h index 98da2c3c88ee22..25867fa68bdc87 100644 --- a/src/platform/fake/ConfigurationManagerImpl.h +++ b/src/platform/fake/ConfigurationManagerImpl.h @@ -49,7 +49,7 @@ class ConfigurationManagerImpl : public ConfigurationManager } CHIP_ERROR GetSoftwareVersion(uint32_t & softwareVer) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR StoreSoftwareVersion(uint32_t softwareVer) override { return CHIP_ERROR_NOT_IMPLEMENTED; } - CHIP_ERROR StoreSerialNumber(chip::Span serialNumber) override { return CHIP_ERROR_NOT_IMPLEMENTED; } + CHIP_ERROR StoreSerialNumber(CharSpan serialNumber) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetPrimaryMACAddress(MutableByteSpan buf) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetPrimaryWiFiMACAddress(uint8_t * buf) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetPrimary802154MACAddress(uint8_t * buf) override { return CHIP_ERROR_NOT_IMPLEMENTED; } diff --git a/src/platform/mbed/MbedConfig.h b/src/platform/mbed/MbedConfig.h index 70b1dfa6890a24..8482cd6866165c 100644 --- a/src/platform/mbed/MbedConfig.h +++ b/src/platform/mbed/MbedConfig.h @@ -72,6 +72,11 @@ class MbedConfig static const Key kConfigKey_Spake2pSalt; static const Key kConfigKey_Spake2pVerifier; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + // CHIP Counter keys static const Key kCounterKey_RebootCount; static const Key kCounterKey_UpTime; diff --git a/src/platform/nxp/common/NXPConfig.h b/src/platform/nxp/common/NXPConfig.h index c20dc7e5071d48..2a238f267c1ce3 100644 --- a/src/platform/nxp/common/NXPConfig.h +++ b/src/platform/nxp/common/NXPConfig.h @@ -103,6 +103,11 @@ class NXPConfig static constexpr Key kConfigKey_Spake2pSalt = config_key(kFileId_ChipFactory, 0x0B); static constexpr Key kConfigKey_Spake2pVerifier = config_key(kFileId_ChipFactory, 0x0C); + static constexpr Key kConfigKey_VendorName = config_key(kFileId_ChipFactory, 0x0D); + static constexpr Key kConfigKey_ProductName = config_key(kFileId_ChipFactory, 0x0E); + static constexpr Key kConfigKey_HardwareVersionString = config_key(kFileId_ChipFactory, 0x0F); + static constexpr Key kConfigKey_SoftwareVersionString = config_key(kFileId_ChipFactory, 0x10); + // CHIP Config Keys static constexpr Key kConfigKey_FabricId = config_key(kFileId_ChipConfig, 0x00); static constexpr Key kConfigKey_ServiceConfig = config_key(kFileId_ChipConfig, 0x01); diff --git a/src/platform/nxp/k32w/k32w0/K32W0Config.cpp b/src/platform/nxp/k32w/k32w0/K32W0Config.cpp index 850a1b7398ef06..050993f14c286b 100644 --- a/src/platform/nxp/k32w/k32w0/K32W0Config.cpp +++ b/src/platform/nxp/k32w/k32w0/K32W0Config.cpp @@ -64,6 +64,11 @@ const K32WConfig::Key K32WConfig::kConfigKey_UniqueId{ &K32WConfig::sConfigStora const K32WConfig::Key K32WConfig::kConfigKey_SoftwareVersion{ &K32WConfig::sConfigStorage, kKeyId_Config, 0x0B }; const K32WConfig::Key K32WConfig::kConfigKey_SoftwareUpdateCompleted{ &K32WConfig::sConfigStorage, kKeyId_Config, 0x0C }; +const K32WConfig::Key K32WConfig::kConfigKey_VendorName{ &K32WConfig::sConfigStorage, kKeyId_Config, 0x0D }; +const K32WConfig::Key K32WConfig::kConfigKey_ProductName{ &K32WConfig::sConfigStorage, kKeyId_Config, 0x0E }; +const K32WConfig::Key K32WConfig::kConfigKey_HardwareVersionString{ &K32WConfig::sConfigStorage, kKeyId_Config, 0x0F }; +const K32WConfig::Key K32WConfig::kConfigKey_SoftwareVersionString{ &K32WConfig::sConfigStorage, kKeyId_Config, 0x10 }; + const K32WConfig::Key K32WConfig::kCounterKey_RebootCount{ &K32WConfig::sCounterStorage, kKeyId_Counter, 0x00 }; const K32WConfig::Key K32WConfig::kCounterKey_UpTime{ &K32WConfig::sCounterStorage, kKeyId_Counter, 0x01 }; const K32WConfig::Key K32WConfig::kCounterKey_TotalOperationalHours{ &K32WConfig::sCounterStorage, kKeyId_Counter, 0x02 }; diff --git a/src/platform/nxp/k32w/k32w0/K32W0Config.h b/src/platform/nxp/k32w/k32w0/K32W0Config.h index e364c045c25b1c..3d6e9f557b3631 100644 --- a/src/platform/nxp/k32w/k32w0/K32W0Config.h +++ b/src/platform/nxp/k32w/k32w0/K32W0Config.h @@ -75,6 +75,11 @@ class K32WConfig static const Key kConfigKey_SoftwareVersion; static const Key kConfigKey_SoftwareUpdateCompleted; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + // CHIP Counter Keys static const Key kCounterKey_RebootCount; static const Key kCounterKey_UpTime; diff --git a/src/platform/nxp/k32w/k32w1/K32W1Config.h b/src/platform/nxp/k32w/k32w1/K32W1Config.h index a14b4d5cd10fdd..2d825bfe9448bf 100644 --- a/src/platform/nxp/k32w/k32w1/K32W1Config.h +++ b/src/platform/nxp/k32w/k32w1/K32W1Config.h @@ -92,6 +92,11 @@ class K32WConfig static constexpr Key kConfigKey_UniqueId = K32WConfigKey(kFileId_ChipConfig, 0x0A); static constexpr Key kConfigKey_SoftwareVersion = K32WConfigKey(kFileId_ChipConfig, 0x0B); + static constexpr Key kConfigKey_VendorName = K32WConfigKey(kFileId_ChipConfig, 0x0C); + static constexpr Key kConfigKey_ProductName = K32WConfigKey(kFileId_ChipConfig, 0x0D); + static constexpr Key kConfigKey_HardwareVersionString = K32WConfigKey(kFileId_ChipConfig, 0x0E); + static constexpr Key kConfigKey_SoftwareVersionString = K32WConfigKey(kFileId_ChipConfig, 0x0F); + // CHIP Counter Keys static constexpr Key kCounterKey_RebootCount = K32WConfigKey(kFileId_ChipCounter, 0x00); static constexpr Key kCounterKey_UpTime = K32WConfigKey(kFileId_ChipCounter, 0x01); diff --git a/src/platform/nxp/mw320/MW320Config.h b/src/platform/nxp/mw320/MW320Config.h index fbe66f66875061..8e7924667902eb 100644 --- a/src/platform/nxp/mw320/MW320Config.h +++ b/src/platform/nxp/mw320/MW320Config.h @@ -81,6 +81,11 @@ class MW320Config static constexpr Key kConfigKey_Spake2pSalt = ConfigKey(kFileId_ChipFactory, 0x0A); static constexpr Key kConfigKey_Spake2pVerifier = ConfigKey(kFileId_ChipFactory, 0x0B); + static constexpr Key kConfigKey_VendorName = ConfigKey(kFileId_ChipFactory, 0x0C); + static constexpr Key kConfigKey_ProductName = ConfigKey(kFileId_ChipFactory, 0x0D); + static constexpr Key kConfigKey_HardwareVersionString = ConfigKey(kFileId_ChipFactory, 0x0E); + static constexpr Key kConfigKey_SoftwareVersionString = ConfigKey(kFileId_ChipFactory, 0x0F); + // CHIP Config Keys static constexpr Key kConfigKey_FabricId = ConfigKey(kFileId_ChipConfig, 0x00); static constexpr Key kConfigKey_ServiceConfig = ConfigKey(kFileId_ChipConfig, 0x01); diff --git a/src/platform/openiotsdk/KVPsaPsStore.h b/src/platform/openiotsdk/KVPsaPsStore.h index acd3f695765650..297f6e24514f8a 100644 --- a/src/platform/openiotsdk/KVPsaPsStore.h +++ b/src/platform/openiotsdk/KVPsaPsStore.h @@ -89,6 +89,11 @@ class KVPsaPsStore static const Key kConfigKey_VendorId; static const Key kConfigKey_ProductId; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + // Config Keys static const Key kConfigKey_ServiceConfig; static const Key kConfigKey_PairedAccountId; diff --git a/src/platform/qpg/qpgConfig.h b/src/platform/qpg/qpgConfig.h index bc3e943926f7b5..47867112b5319c 100644 --- a/src/platform/qpg/qpgConfig.h +++ b/src/platform/qpg/qpgConfig.h @@ -76,6 +76,11 @@ class QPGConfig static constexpr Key kConfigKey_Spake2pSalt = QorvoConfigKey(kFileId_ChipFactory, 0x09); static constexpr Key kConfigKey_Spake2pVerifier = QorvoConfigKey(kFileId_ChipFactory, 0x0A); + static constexpr Key kConfigKey_VendorName = QorvoConfigKey(kFileId_ChipFactory, 0x0B); + static constexpr Key kConfigKey_ProductName = QorvoConfigKey(kFileId_ChipFactory, 0x0C); + static constexpr Key kConfigKey_HardwareVersionString = QorvoConfigKey(kFileId_ChipFactory, 0x0D); + static constexpr Key kConfigKey_SoftwareVersionString = QorvoConfigKey(kFileId_ChipFactory, 0x0E); + static constexpr Key kConfigKey_ServiceConfig = QorvoConfigKey(kFileId_ChipConfig, 0x01); static constexpr Key kConfigKey_PairedAccountId = QorvoConfigKey(kFileId_ChipConfig, 0x02); static constexpr Key kConfigKey_ServiceId = QorvoConfigKey(kFileId_ChipConfig, 0x03); diff --git a/src/platform/silabs/SilabsConfig.h b/src/platform/silabs/SilabsConfig.h index ccb14beeb8f177..99dabd6a299610 100644 --- a/src/platform/silabs/SilabsConfig.h +++ b/src/platform/silabs/SilabsConfig.h @@ -129,7 +129,8 @@ class SilabsConfig static constexpr Key kConfigKey_Provision_Request = SilabsConfigKey(kMatterFactory_KeyBase, 0x28); static constexpr Key kConfigKey_Provision_Version = SilabsConfigKey(kMatterFactory_KeyBase, 0x29); - static constexpr Key kOtaTlvEncryption_KeyId = SilabsConfigKey(kMatterFactory_KeyBase, 0x30); + static constexpr Key kOtaTlvEncryption_KeyId = SilabsConfigKey(kMatterFactory_KeyBase, 0x30); + static constexpr Key kConfigKey_SoftwareVersionString = SilabsConfigKey(kMatterFactory_KeyBase, 0x31); // Matter Config Keys static constexpr Key kConfigKey_ServiceConfig = SilabsConfigKey(kMatterConfig_KeyBase, 0x01); diff --git a/src/platform/tests/TestConfigurationMgr.cpp b/src/platform/tests/TestConfigurationMgr.cpp index 36530dfccc3373..139569eb79cd83 100644 --- a/src/platform/tests/TestConfigurationMgr.cpp +++ b/src/platform/tests/TestConfigurationMgr.cpp @@ -83,20 +83,18 @@ TEST_F(TestConfigurationMgr, SerialNumber) CHIP_ERROR err = CHIP_NO_ERROR; char buf[64]; - const char * serialNumber = "89051AAZZ236"; - chip::Span serial_number(serialNumber.Value().c_str(), serialNumber.Value().size()); + CharSpan serialNumber = "89051AAZZ236"_span; - err = ConfigurationMgr().StoreSerialNumber(serial_number); + err = ConfigurationMgr().StoreSerialNumber(serialNumber); EXPECT_EQ(err, CHIP_NO_ERROR); err = GetDeviceInstanceInfoProvider()->GetSerialNumber(buf, 64); EXPECT_EQ(err, CHIP_NO_ERROR); EXPECT_EQ(strlen(buf), 12u); - EXPECT_STREQ(buf, serialNumber); + EXPECT_STREQ(buf, serialNumber.data()); - chip::Span serial_number(serialNumber.Value().c_str(), 5); - err = ConfigurationMgr().StoreSerialNumber(serial_number); + err = ConfigurationMgr().StoreSerialNumber(serialNumber.SubSpan(5)); EXPECT_EQ(err, CHIP_NO_ERROR); err = GetDeviceInstanceInfoProvider()->GetSerialNumber(buf, 64); From 49c388ecf5b89cac503f5c45671b9ec1038a399f Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Mon, 8 Jul 2024 14:21:05 -0700 Subject: [PATCH 06/32] add the new config params to different platforms --- src/platform/ASR/ASRConfig.cpp | 5 +++++ src/platform/Ameba/AmebaConfig.cpp | 5 +++++ src/platform/Beken/BekenConfig.cpp | 5 +++++ src/platform/ESP32/ESP32Config.cpp | 2 ++ src/platform/ESP32/ESP32Config.h | 2 ++ src/platform/Infineon/PSOC6/P6Config.cpp | 9 +++++++++ src/platform/NuttX/PosixConfig.cpp | 5 +++++ src/platform/NuttX/PosixConfig.h | 5 +++++ src/platform/Tizen/PosixConfig.cpp | 9 +++++++++ src/platform/Tizen/PosixConfig.h | 5 +++++ src/platform/bouffalolab/common/BLConfig.h | 8 ++++---- src/platform/cc13xx_26xx/CC13XX_26XXConfig.cpp | 12 ++++++++++++ src/platform/cc32xx/CC32XXConfig.cpp | 5 +++++ src/platform/mbed/MbedConfig.cpp | 10 ++++++++++ src/platform/mt793x/MT793XConfig.cpp | 8 ++++++++ src/platform/mt793x/MT793XConfig.h | 5 +++++ src/platform/stm32/STM32Config.h | 6 ++++++ src/platform/webos/PosixConfig.cpp | 5 +++++ src/platform/webos/PosixConfig.h | 5 +++++ 19 files changed, 112 insertions(+), 4 deletions(-) diff --git a/src/platform/ASR/ASRConfig.cpp b/src/platform/ASR/ASRConfig.cpp index 1e87f3af518804..2a07f631384a29 100644 --- a/src/platform/ASR/ASRConfig.cpp +++ b/src/platform/ASR/ASRConfig.cpp @@ -80,6 +80,11 @@ const ASRConfig::Key ASRConfig::kConfigKey_WiFiSecurity = { kConfigNamespa const ASRConfig::Key ASRConfig::kConfigKey_WiFiMode = { kConfigNamespace_ChipConfig, "wifimode" }; const ASRConfig::Key ASRConfig::kConfigKey_UniqueId = { kConfigNamespace_ChipConfig, "unique-id" }; +const ASRConfig::Key ASRConfig::kConfigKey_VendorName = { kConfigNamespace_ChipConfig, "vendor-name" }; +const ASRConfig::Key ASRConfig::kConfigKey_ProductName = { kConfigNamespace_ChipConfig, "product-name" }; +const ASRConfig::Key ASRConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipConfig, "hardware-version-string" }; +const ASRConfig::Key ASRConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipConfig, "software-version-string" }; + // Keys stored in the Chip-counters namespace const ASRConfig::Key ASRConfig::kCounterKey_RebootCount = { kConfigNamespace_ChipCounters, "reboot-count" }; const ASRConfig::Key ASRConfig::kCounterKey_UpTime = { kConfigNamespace_ChipCounters, "up-time" }; diff --git a/src/platform/Ameba/AmebaConfig.cpp b/src/platform/Ameba/AmebaConfig.cpp index 6ac7948da07794..c59221ddbcf710 100644 --- a/src/platform/Ameba/AmebaConfig.cpp +++ b/src/platform/Ameba/AmebaConfig.cpp @@ -79,6 +79,11 @@ const AmebaConfig::Key AmebaConfig::kConfigKey_RegulatoryLocation = { k const AmebaConfig::Key AmebaConfig::kConfigKey_LocationCapability = { kConfigNamespace_ChipConfig, "location-capability" }; const AmebaConfig::Key AmebaConfig::kConfigKey_CountryCode = { kConfigNamespace_ChipConfig, "country-code" }; +const AmebaConfig::Key AmebaConfig::kConfigKey_VendorName = { kConfigNamespace_ChipConfig, "vendor-name" }; +const AmebaConfig::Key AmebaConfig::kConfigKey_ProductName = { kConfigNamespace_ChipConfig, "product-name" }; +const AmebaConfig::Key AmebaConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipConfig, "hardware-version-string" }; +const AmebaConfig::Key AmebaConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipConfig, "software-version-string" }; + // Keys stored in the Chip-counters namespace const AmebaConfig::Key AmebaConfig::kCounterKey_RebootCount = { kConfigNamespace_ChipCounters, "reboot-count" }; const AmebaConfig::Key AmebaConfig::kCounterKey_UpTime = { kConfigNamespace_ChipCounters, "up-time" }; diff --git a/src/platform/Beken/BekenConfig.cpp b/src/platform/Beken/BekenConfig.cpp index 60e2cdb09645f7..593001f9c8c73e 100644 --- a/src/platform/Beken/BekenConfig.cpp +++ b/src/platform/Beken/BekenConfig.cpp @@ -79,6 +79,11 @@ const BekenConfig::Key BekenConfig::kConfigKey_RegulatoryLocation = { k const BekenConfig::Key BekenConfig::kConfigKey_CountryCode = { kConfigNamespace_ChipConfig, "country-code" }; const BekenConfig::Key BekenConfig::kConfigKey_Breadcrumb = { kConfigNamespace_ChipConfig, "breadcrumb" }; +const BekenConfig::Key BekenConfig::kConfigKey_VendorName = { kConfigNamespace_ChipConfig, "vendor-name" }; +const BekenConfig::Key BekenConfig::kConfigKey_ProductName = { kConfigNamespace_ChipConfig, "product-name" }; +const BekenConfig::Key BekenConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipConfig, "hardware-version-string" }; +const BekenConfig::Key BekenConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipConfig, "software-version-string" }; + // Keys stored in the Chip-counters namespace const BekenConfig::Key BekenConfig::kCounterKey_RebootCount = { kConfigNamespace_ChipCounters, "reboot-count" }; const BekenConfig::Key BekenConfig::kCounterKey_UpTime = { kConfigNamespace_ChipCounters, "up-time" }; diff --git a/src/platform/ESP32/ESP32Config.cpp b/src/platform/ESP32/ESP32Config.cpp index 04e02f63004207..95da96f40e7be5 100644 --- a/src/platform/ESP32/ESP32Config.cpp +++ b/src/platform/ESP32/ESP32Config.cpp @@ -97,6 +97,8 @@ const ESP32Config::Key ESP32Config::kConfigKey_WeekDaySchedules = { kConfigNam const ESP32Config::Key ESP32Config::kConfigKey_YearDaySchedules = { kConfigNamespace_ChipConfig, "year-day-sched" }; const ESP32Config::Key ESP32Config::kConfigKey_HolidaySchedules = { kConfigNamespace_ChipConfig, "holiday-sched" }; +const ESP32Config::Key ESP32Config::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipConfig, "sw-ver-str" }; + // Keys stored in the Chip-counters namespace const ESP32Config::Key ESP32Config::kCounterKey_RebootCount = { kConfigNamespace_ChipCounters, "reboot-count" }; const ESP32Config::Key ESP32Config::kCounterKey_UpTime = { kConfigNamespace_ChipCounters, "up-time" }; diff --git a/src/platform/ESP32/ESP32Config.h b/src/platform/ESP32/ESP32Config.h index 5804f53105c20c..7d24a432219c5f 100644 --- a/src/platform/ESP32/ESP32Config.h +++ b/src/platform/ESP32/ESP32Config.h @@ -99,6 +99,8 @@ class ESP32Config static const Key kConfigKey_YearDaySchedules; static const Key kConfigKey_HolidaySchedules; + static const Key kConfigKey_SoftwareVersionString; + // CHIP Counter keys static const Key kCounterKey_RebootCount; static const Key kCounterKey_UpTime; diff --git a/src/platform/Infineon/PSOC6/P6Config.cpp b/src/platform/Infineon/PSOC6/P6Config.cpp index 2ef8a5ed038476..dcc5dddea2d62b 100644 --- a/src/platform/Infineon/PSOC6/P6Config.cpp +++ b/src/platform/Infineon/PSOC6/P6Config.cpp @@ -88,6 +88,15 @@ const P6Config::Key P6Config::kConfigKey_YearDaySchedules = { kConfigNamespace_C const P6Config::Key P6Config::kConfigKey_HolidaySchedules = { kConfigNamespace_ChipConfig, "holiday-schedules" }; ; +const P6Config::Key P6Config::kConfigKey_VendorName = { kConfigNamespace_ChipConfig, "vendor-name" }; +; +const P6Config::Key P6Config::kConfigKey_ProductName = { kConfigNamespace_ChipConfig, "product-name" }; +; +const P6Config::Key P6Config::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipConfig, "hardware-version-string" }; +; +const P6Config::Key P6Config::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipConfig, "software-version-string" }; +; + // Keys stored in the Chip-counters namespace const P6Config::Key P6Config::kCounterKey_RebootCount = { kConfigNamespace_ChipCounters, "reboot-count" }; const P6Config::Key P6Config::kCounterKey_UpTime = { kConfigNamespace_ChipCounters, "up-time" }; diff --git a/src/platform/NuttX/PosixConfig.cpp b/src/platform/NuttX/PosixConfig.cpp index 8e8feda20de202..d357ff24e363e2 100644 --- a/src/platform/NuttX/PosixConfig.cpp +++ b/src/platform/NuttX/PosixConfig.cpp @@ -74,6 +74,11 @@ const PosixConfig::Key PosixConfig::kConfigKey_CountryCode = { kConfigNam const PosixConfig::Key PosixConfig::kConfigKey_LocationCapability = { kConfigNamespace_ChipConfig, "location-capability" }; const PosixConfig::Key PosixConfig::kConfigKey_UniqueId = { kConfigNamespace_ChipFactory, "unique-id" }; +const PosixConfig::Key PosixConfig::kConfigKey_VendorName = { kConfigNamespace_ChipFactory, "vendor-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_ProductName = { kConfigNamespace_ChipFactory, "product-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipFactory, "hardware-version-string" }; +const PosixConfig::Key PosixConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipFactory, "software-version-string" }; + // Keys stored in the Chip-counters namespace const PosixConfig::Key PosixConfig::kCounterKey_RebootCount = { kConfigNamespace_ChipCounters, "reboot-count" }; const PosixConfig::Key PosixConfig::kCounterKey_UpTime = { kConfigNamespace_ChipCounters, "up-time" }; diff --git a/src/platform/NuttX/PosixConfig.h b/src/platform/NuttX/PosixConfig.h index c04d4a9be1093f..d0594cf69ed788 100644 --- a/src/platform/NuttX/PosixConfig.h +++ b/src/platform/NuttX/PosixConfig.h @@ -78,6 +78,11 @@ class PosixConfig static const Key kConfigKey_VendorId; static const Key kConfigKey_ProductId; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + 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 e6f18834ef6396..9b10ade642422e 100644 --- a/src/platform/Tizen/PosixConfig.cpp +++ b/src/platform/Tizen/PosixConfig.cpp @@ -66,6 +66,15 @@ const PosixConfig::Key PosixConfig::kConfigKey_RegulatoryLocation = { kConfigNam const PosixConfig::Key PosixConfig::kConfigKey_CountryCode = { kConfigNamespace_ChipConfig, "country-code" }; const PosixConfig::Key PosixConfig::kConfigKey_UniqueId = { kConfigNamespace_ChipConfig, "unique-id" }; +const PosixConfig::Key PosixConfig::kConfigKey_VendorName = { kConfigNamespace_ChipConfig, "vendor-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_ProductName = { kConfigNamespace_ChipConfig, "product-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipConfig, "hardware-version-string" }; +const PosixConfig::Key PosixConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipConfig, "software-version-string" }; + +static const Key kConfigKey_; +static const Key kConfigKey_; +static const Key kConfigKey_; +static const Key kConfigKey_; // Keys stored in the Chip-counters namespace const PosixConfig::Key PosixConfig::kCounterKey_TotalOperationalHours = { kConfigNamespace_ChipCounters, "total-operational-hours" }; diff --git a/src/platform/Tizen/PosixConfig.h b/src/platform/Tizen/PosixConfig.h index a5d8d6a6a8d45d..68353b2b4131ca 100644 --- a/src/platform/Tizen/PosixConfig.h +++ b/src/platform/Tizen/PosixConfig.h @@ -75,6 +75,11 @@ class PosixConfig static const Key kConfigKey_VendorId; static const Key kConfigKey_ProductId; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + static const Key kCounterKey_TotalOperationalHours; static const Key kCounterKey_BootReason; diff --git a/src/platform/bouffalolab/common/BLConfig.h b/src/platform/bouffalolab/common/BLConfig.h index c665273a6ce349..7f9885731b2136 100644 --- a/src/platform/bouffalolab/common/BLConfig.h +++ b/src/platform/bouffalolab/common/BLConfig.h @@ -77,10 +77,10 @@ class BLConfig static constexpr char kBLKey_factoryResetFlag[] = ("__factory_reset_pending"); - static const Key kConfigKey_VendorName; - static const Key kConfigKey_ProductName; - static const Key kConfigKey_HardwareVersionString; - static const Key kConfigKey_SoftwareVersionString; + static constexpr char kConfigKey_VendorName[] = ("vendor-name"); + static constexpr char kConfigKey_ProductName[] = ("product-name"); + static constexpr char kConfigKey_HardwareVersionString[] = ("hardware-version-string"); + static constexpr char kConfigKey_SoftwareVersionString[] = ("software-version-string"); static void Init(void); diff --git a/src/platform/cc13xx_26xx/CC13XX_26XXConfig.cpp b/src/platform/cc13xx_26xx/CC13XX_26XXConfig.cpp index b4ea1ec2924378..d983b3b19ea6e7 100644 --- a/src/platform/cc13xx_26xx/CC13XX_26XXConfig.cpp +++ b/src/platform/cc13xx_26xx/CC13XX_26XXConfig.cpp @@ -123,6 +123,18 @@ const CC13XX_26XXConfig::Key CC13XX_26XXConfig::kConfigKey_UniqueId = { { .systemID = kCC13XX_26XXMatter_SysID, .itemID = kCC13XX_26XXMatter_ItemID_ChipConfig, .subID = 0x0001d } }; +const CC13XX_26XXConfig::Key CC13XX_26XXConfig::kConfigKey_VendorName = { + { .systemID = kCC13XX_26XXMatter_SysID, .itemID = kCC13XX_26XXMatter_ItemID_ChipConfig, .subID = 0x0001e } +}; +const CC13XX_26XXConfig::Key CC13XX_26XXConfig::kConfigKey_ProductName = { + { .systemID = kCC13XX_26XXMatter_SysID, .itemID = kCC13XX_26XXMatter_ItemID_ChipConfig, .subID = 0x0001f } +}; +const CC13XX_26XXConfig::Key CC13XX_26XXConfig::kConfigKey_HardwareVersionString = { + { .systemID = kCC13XX_26XXMatter_SysID, .itemID = kCC13XX_26XXMatter_ItemID_ChipConfig, .subID = 0x00020 } +}; +const CC13XX_26XXConfig::Key CC13XX_26XXConfig::kConfigKey_SoftwareVersionString = { + { .systemID = kCC13XX_26XXMatter_SysID, .itemID = kCC13XX_26XXMatter_ItemID_ChipConfig, .subID = 0x00021 } +}; /* Internal for the KVS interface. */ const CC13XX_26XXConfig::Key CC13XX_26XXConfig::kConfigKey_KVS_key = { { .systemID = kCC13XX_26XXMatter_SysID, .itemID = kCC13XX_26XXMatter_ItemID_ChipKVS_key } }; diff --git a/src/platform/cc32xx/CC32XXConfig.cpp b/src/platform/cc32xx/CC32XXConfig.cpp index 7eace22b7dbc5e..1dcfc9f37ef43a 100644 --- a/src/platform/cc32xx/CC32XXConfig.cpp +++ b/src/platform/cc32xx/CC32XXConfig.cpp @@ -318,6 +318,11 @@ const CC32XXConfig::Key CC32XXConfig::kConfigKey_Spake2pIterationCount = { "TI_k const CC32XXConfig::Key CC32XXConfig::kConfigKey_Spake2pSalt = { "TI_kConfigKey_Spake2pSalt" }; const CC32XXConfig::Key CC32XXConfig::kConfigKey_Spake2pVerifier = { "TI_kConfigKey_Spake2pVerifier" }; +const CC32XXConfig::Key CC32XXConfig::kConfigKey_VendorName = { "TI_kConfigKey_VendorName" }; +const CC32XXConfig::Key CC32XXConfig::kConfigKey_ProductName = { "TI_kConfigKey_ProductName" }; +const CC32XXConfig::Key CC32XXConfig::kConfigKey_HardwareVersionString = { "TI_kConfigKey_HardwareVersionString" }; +const CC32XXConfig::Key CC32XXConfig::kConfigKey_SoftwareVersionString = { "TI_kConfigKey_SoftwareVersionString" }; + CC32XXKVSList * pList; CHIP_ERROR CC32XXConfig::Init() diff --git a/src/platform/mbed/MbedConfig.cpp b/src/platform/mbed/MbedConfig.cpp index 63d5f87295c145..df7d569547c5ab 100644 --- a/src/platform/mbed/MbedConfig.cpp +++ b/src/platform/mbed/MbedConfig.cpp @@ -85,6 +85,16 @@ const MbedConfig::Key MbedConfig::kConfigKey_RegulatoryLocation = { CONFIG_KEY(" const MbedConfig::Key MbedConfig::kConfigKey_CountryCode = { CONFIG_KEY("country-code") }; const MbedConfig::Key MbedConfig::kConfigKey_UniqueId = { CONFIG_KEY("unique-id") }; +const MbedConfig::Key MbedConfig::kConfigKey_VendorName = { CONFIG_KEY("vendor-name") }; +const MbedConfig::Key MbedConfig::kConfigKey_ProductName = { CONFIG_KEY("product-name") }; +const MbedConfig::Key MbedConfig::kConfigKey_HardwareVersionString = { CONFIG_KEY("hardware-version-string") }; +const MbedConfig::Key MbedConfig::kConfigKey_SoftwareVersionString = { CONFIG_KEY("software-version-string") }; + +static const Key kConfigKey_; +static const Key kConfigKey_; +static const Key kConfigKey_; +static const Key kConfigKey_; + // Keys stored in the Chip-counters namespace const MbedConfig::Key MbedConfig::kCounterKey_RebootCount = { COUNTER_KEY("reboot-count") }; const MbedConfig::Key MbedConfig::kCounterKey_UpTime = { COUNTER_KEY("up-time") }; diff --git a/src/platform/mt793x/MT793XConfig.cpp b/src/platform/mt793x/MT793XConfig.cpp index a524315657a762..12b303f93b1bc1 100644 --- a/src/platform/mt793x/MT793XConfig.cpp +++ b/src/platform/mt793x/MT793XConfig.cpp @@ -100,6 +100,14 @@ const MT793XConfig::Key MT793XConfig::kConfigKey_YearDaySchedules = { .Namespace .Name = "yearday-sched" }; const MT793XConfig::Key MT793XConfig::kConfigKey_HolidaySchedules = { .Namespace = kConfigNamespace_ChipConfig, .Name = "holiday-sched" }; + +const MT793XConfig::Key MT793XConfig::kConfigKey_VendorName = { .Namespace = kConfigNamespace_ChipConfig, .Name = "vendor-name" }; +const MT793XConfig::Key MT793XConfig::kConfigKey_ProductName = { .Namespace = kConfigNamespace_ChipConfig, .Name = "product-name" }; +const MT793XConfig::Key MT793XConfig::kConfigKey_HardwareVersionString = { .Namespace = kConfigNamespace_ChipConfig, + .Name = "hardware-version-string" }; +const MT793XConfig::Key MT793XConfig::kConfigKey_SoftwareVersionString = { .Namespace = kConfigNamespace_ChipConfig, + .Name = "software-version-string" }; + // CHIP Counter Keys const MT793XConfig::Key MT793XConfig::kConfigKey_BootCount = { .Namespace = kConfigNamespace_ChipCounters, .Name = "boot-count" }; const MT793XConfig::Key MT793XConfig::kConfigKey_TotalOperationalHours = { .Namespace = kConfigNamespace_ChipCounters, diff --git a/src/platform/mt793x/MT793XConfig.h b/src/platform/mt793x/MT793XConfig.h index 33358d4d064f4a..8e922f47265999 100644 --- a/src/platform/mt793x/MT793XConfig.h +++ b/src/platform/mt793x/MT793XConfig.h @@ -101,6 +101,11 @@ class MT793XConfig static const Key kConfigKey_WeekDaySchedules; static const Key kConfigKey_YearDaySchedules; static const Key kConfigKey_HolidaySchedules; + + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; // CHIP Counter Keys static const Key kConfigKey_BootCount; static const Key kConfigKey_TotalOperationalHours; diff --git a/src/platform/stm32/STM32Config.h b/src/platform/stm32/STM32Config.h index f1df1dc7638861..2d1d38261f4e13 100644 --- a/src/platform/stm32/STM32Config.h +++ b/src/platform/stm32/STM32Config.h @@ -67,6 +67,12 @@ class STM32Config static constexpr Key kConfigKey_Breadcrumb = 22; static constexpr Key kConfigKey_UniqueId = 23; static constexpr Key kConfigKey_ProductRevision = 24; + + static constexpr Key kConfigKey_VendorName = 25; + static constexpr Key kConfigKey_ProductName = 26; + static constexpr Key kConfigKey_HardwareVersionString = 27; + static constexpr Key kConfigKey_SoftwareVersionString = 28; + // Set key id limits for each group. static constexpr Key kConfigKey_Base = kConfigKey_SerialNum; static constexpr Key kConfigKey_Max = kConfigKey_UniqueId; diff --git a/src/platform/webos/PosixConfig.cpp b/src/platform/webos/PosixConfig.cpp index 79cbd2e0eaa49b..5675bf6bba7ffe 100644 --- a/src/platform/webos/PosixConfig.cpp +++ b/src/platform/webos/PosixConfig.cpp @@ -78,6 +78,11 @@ const PosixConfig::Key PosixConfig::kConfigKey_Breadcrumb = { kConfigNam const PosixConfig::Key PosixConfig::kConfigKey_LocationCapability = { kConfigNamespace_ChipConfig, "location-capability" }; const PosixConfig::Key PosixConfig::kConfigKey_UniqueId = { kConfigNamespace_ChipFactory, "unique-id" }; +const PosixConfig::Key PosixConfig::kConfigKey_VendorName = { kConfigNamespace_ChipFactory, "vendor-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_ProductName = { kConfigNamespace_ChipFactory, "product-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipFactory, "hardware-version-string" }; +const PosixConfig::Key PosixConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipFactory, "software-version-string" }; + // Keys stored in the Chip-counters namespace const PosixConfig::Key PosixConfig::kCounterKey_RebootCount = { kConfigNamespace_ChipCounters, "reboot-count" }; const PosixConfig::Key PosixConfig::kCounterKey_UpTime = { kConfigNamespace_ChipCounters, "up-time" }; diff --git a/src/platform/webos/PosixConfig.h b/src/platform/webos/PosixConfig.h index 8835bd04c60310..e948f381f6cab5 100644 --- a/src/platform/webos/PosixConfig.h +++ b/src/platform/webos/PosixConfig.h @@ -82,6 +82,11 @@ class PosixConfig static const Key kConfigKey_VendorId; static const Key kConfigKey_ProductId; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + static const Key kCounterKey_RebootCount; static const Key kCounterKey_UpTime; static const Key kCounterKey_TotalOperationalHours; From a98cc5428b121acfca572b7ebaff3bc9f2590dad Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Mon, 8 Jul 2024 16:33:23 -0700 Subject: [PATCH 07/32] fix compilation errors --- src/platform/Infineon/CYW30739/CYW30739Config.h | 2 ++ src/platform/Tizen/PosixConfig.cpp | 4 ---- src/platform/android/AndroidConfig.cpp | 1 + src/platform/android/AndroidConfig.h | 2 ++ src/platform/mbed/MbedConfig.cpp | 5 ----- src/platform/openiotsdk/KVPsaPsStore.cpp | 5 +++++ src/platform/tests/TestConfigurationMgr.cpp | 4 ++-- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/platform/Infineon/CYW30739/CYW30739Config.h b/src/platform/Infineon/CYW30739/CYW30739Config.h index 24b074689d0ecf..47079943908b2a 100644 --- a/src/platform/Infineon/CYW30739/CYW30739Config.h +++ b/src/platform/Infineon/CYW30739/CYW30739Config.h @@ -71,6 +71,8 @@ class CYW30739Config static constexpr Key kConfigKey_DACKey = CYW30739ConfigKey(kChipFactory_KeyBase, 0x21); static constexpr Key kConfigKey_PAICert = CYW30739ConfigKey(kChipFactory_KeyBase, 0x22); static constexpr Key kConfigKey_CertDeclaration = CYW30739ConfigKey(kChipFactory_KeyBase, 0x23); + static constexpr Key kConfigKey_SoftwareVersionString = CYW30739ConfigKey(kChipFactory_KeyBase, 0x24); + // CHIP Config Keys static constexpr Key kConfigKey_ServiceConfig = CYW30739ConfigKey(kChipConfig_KeyBase, 0x00); static constexpr Key kConfigKey_PairedAccountId = CYW30739ConfigKey(kChipConfig_KeyBase, 0x01); diff --git a/src/platform/Tizen/PosixConfig.cpp b/src/platform/Tizen/PosixConfig.cpp index 9b10ade642422e..046d40a9c7a303 100644 --- a/src/platform/Tizen/PosixConfig.cpp +++ b/src/platform/Tizen/PosixConfig.cpp @@ -71,10 +71,6 @@ const PosixConfig::Key PosixConfig::kConfigKey_ProductName = { kConfig const PosixConfig::Key PosixConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipConfig, "hardware-version-string" }; const PosixConfig::Key PosixConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipConfig, "software-version-string" }; -static const Key kConfigKey_; -static const Key kConfigKey_; -static const Key kConfigKey_; -static const Key kConfigKey_; // Keys stored in the Chip-counters namespace const PosixConfig::Key PosixConfig::kCounterKey_TotalOperationalHours = { kConfigNamespace_ChipCounters, "total-operational-hours" }; diff --git a/src/platform/android/AndroidConfig.cpp b/src/platform/android/AndroidConfig.cpp index afca2b43f3e96b..4ee83f18bec90a 100644 --- a/src/platform/android/AndroidConfig.cpp +++ b/src/platform/android/AndroidConfig.cpp @@ -82,6 +82,7 @@ const AndroidConfig::Key AndroidConfig::kConfigKey_Spake2pSalt = { kCo const AndroidConfig::Key AndroidConfig::kConfigKey_Spake2pVerifier = { kConfigNamespace_ChipFactory, "verifier" }; const AndroidConfig::Key AndroidConfig::kConfigKey_DeviceTypeId = { kConfigNamespace_ChipFactory, "device-type-id" }; const AndroidConfig::Key AndroidConfig::kConfigKey_DeviceName = { kConfigNamespace_ChipFactory, "device-name" }; +const AndroidConfig::Key AndroidConfig::kConfigKey_VendorName = { kConfigNamespace_ChipFactory, "vendor-name" }; // Keys stored in the Chip-config namespace const AndroidConfig::Key AndroidConfig::kConfigKey_ServiceConfig = { kConfigNamespace_ChipConfig, "service-config" }; diff --git a/src/platform/android/AndroidConfig.h b/src/platform/android/AndroidConfig.h index 507a2b62e87da8..4d3d03638943e4 100644 --- a/src/platform/android/AndroidConfig.h +++ b/src/platform/android/AndroidConfig.h @@ -84,6 +84,8 @@ class AndroidConfig static const Key kConfigKey_DeviceTypeId; static const Key kConfigKey_DeviceName; + static const Key kConfigKey_VendorName; + static CHIP_ERROR Init(); // Config value accessors. diff --git a/src/platform/mbed/MbedConfig.cpp b/src/platform/mbed/MbedConfig.cpp index df7d569547c5ab..39ddacea059a29 100644 --- a/src/platform/mbed/MbedConfig.cpp +++ b/src/platform/mbed/MbedConfig.cpp @@ -90,11 +90,6 @@ const MbedConfig::Key MbedConfig::kConfigKey_ProductName = { CONFIG_KE const MbedConfig::Key MbedConfig::kConfigKey_HardwareVersionString = { CONFIG_KEY("hardware-version-string") }; const MbedConfig::Key MbedConfig::kConfigKey_SoftwareVersionString = { CONFIG_KEY("software-version-string") }; -static const Key kConfigKey_; -static const Key kConfigKey_; -static const Key kConfigKey_; -static const Key kConfigKey_; - // Keys stored in the Chip-counters namespace const MbedConfig::Key MbedConfig::kCounterKey_RebootCount = { COUNTER_KEY("reboot-count") }; const MbedConfig::Key MbedConfig::kCounterKey_UpTime = { COUNTER_KEY("up-time") }; diff --git a/src/platform/openiotsdk/KVPsaPsStore.cpp b/src/platform/openiotsdk/KVPsaPsStore.cpp index 26215bf2e4431a..88083c37372abe 100644 --- a/src/platform/openiotsdk/KVPsaPsStore.cpp +++ b/src/platform/openiotsdk/KVPsaPsStore.cpp @@ -67,6 +67,11 @@ const KVPsaPsStore::Key KVPsaPsStore::kConfigKey_CountryCode = GetPsaPaKe const KVPsaPsStore::Key KVPsaPsStore::kConfigKey_LocationCapability = GetPsaPaKey(kMatterConfig_KeyOffset, 0x08); const KVPsaPsStore::Key KVPsaPsStore::kConfigKey_UniqueId = GetPsaPaKey(kMatterConfig_KeyOffset, 0x09); +const KVPsaPsStore::Key KVPsaPsStore::kConfigKey_VendorName = GetPsaPaKey(kMatterConfig_KeyOffset, 0x0A); +const KVPsaPsStore::Key KVPsaPsStore::kConfigKey_ProductName = GetPsaPaKey(kMatterConfig_KeyOffset, 0x0B); +const KVPsaPsStore::Key KVPsaPsStore::kConfigKey_HardwareVersionString = GetPsaPaKey(kMatterConfig_KeyOffset, 0x0C); +const KVPsaPsStore::Key KVPsaPsStore::kConfigKey_SoftwareVersionString = GetPsaPaKey(kMatterConfig_KeyOffset, 0x0D); + // Keys stored in the Matter counters group const KVPsaPsStore::Key KVPsaPsStore::kCounterKey_RebootCount = GetPsaPaKey(kMatterCounter_KeyOffset, 0x00); const KVPsaPsStore::Key KVPsaPsStore::kCounterKey_UpTime = GetPsaPaKey(kMatterCounter_KeyOffset, 0x01); diff --git a/src/platform/tests/TestConfigurationMgr.cpp b/src/platform/tests/TestConfigurationMgr.cpp index 139569eb79cd83..43c55efd786e7b 100644 --- a/src/platform/tests/TestConfigurationMgr.cpp +++ b/src/platform/tests/TestConfigurationMgr.cpp @@ -100,8 +100,8 @@ TEST_F(TestConfigurationMgr, SerialNumber) err = GetDeviceInstanceInfoProvider()->GetSerialNumber(buf, 64); EXPECT_EQ(err, CHIP_NO_ERROR); - EXPECT_EQ(strlen(buf), 5u); - EXPECT_STREQ(buf, "89051"); + EXPECT_EQ(strlen(buf), 7u); + EXPECT_STREQ(buf, "AAZZ236"); } TEST_F(TestConfigurationMgr, UniqueId) From 4ad02695e4c48aaa215d380020edcb8c48f12006 Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Tue, 9 Jul 2024 11:11:47 -0700 Subject: [PATCH 08/32] updated command line arg comments --- examples/platform/linux/Options.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/platform/linux/Options.cpp b/examples/platform/linux/Options.cpp index aca10ef74913b8..c9ed32919f2a67 100644 --- a/examples/platform/linux/Options.cpp +++ b/examples/platform/linux/Options.cpp @@ -222,10 +222,10 @@ const char * sDeviceOptionHelp = " The product name specified by vendor.\n" "\n" " --hardware-version-string \n" - " The HardwareVersionString to use in the basic information cluster.\n" + " The HardwareVersionString used in the basic information cluster.\n" "\n" " --software-version-string \n" - " The SoftwareVersionString to use in the basic information cluster.\n" + " The SoftwareVersionString used in the basic information cluster.\n" "\n" " --serial-number \n" " The serial number specified by vendor.\n" From 8d787edfeeca8dfbed8f311379e5f0f751ec1909 Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Tue, 9 Jul 2024 21:53:35 -0700 Subject: [PATCH 09/32] fix fake and tizen platform test errors --- .../Tizen/DeviceInstanceInfoProviderImpl.cpp | 12 ++++++++++++ src/platform/Tizen/DeviceInstanceInfoProviderImpl.h | 2 ++ src/platform/fake/ConfigurationManagerImpl.h | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/src/platform/Tizen/DeviceInstanceInfoProviderImpl.cpp b/src/platform/Tizen/DeviceInstanceInfoProviderImpl.cpp index 93ad7a18015762..022e40a0f491d5 100644 --- a/src/platform/Tizen/DeviceInstanceInfoProviderImpl.cpp +++ b/src/platform/Tizen/DeviceInstanceInfoProviderImpl.cpp @@ -33,5 +33,17 @@ CHIP_ERROR DeviceInstanceInfoProviderImpl::GetProductId(uint16_t & productId) return Internal::PosixConfig::ReadConfigValue(Internal::PosixConfig::kConfigKey_ProductId, productId); } +CHIP_ERROR DeviceInstanceInfoProviderImpl::GetVendorName(char * buf, size_t bufSize) +{ + size_t vendorNameLen = 0; + return Internal::PosixConfig::ReadConfigValueStr(Internal::PosixConfig::kConfigKey_VendorName, buf, bufSize, vendorNameLen); +} + +CHIP_ERROR DeviceInstanceInfoProviderImpl::GetProductName(char * buf, size_t bufSize) +{ + size_t productNameLen = 0; + return Internal::PosixConfig::ReadConfigValueStr(Internal::PosixConfig::kConfigKey_ProductName, buf, bufSize, productNameLen); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/Tizen/DeviceInstanceInfoProviderImpl.h b/src/platform/Tizen/DeviceInstanceInfoProviderImpl.h index 32e6a2cc5abec0..13f8045f6e4cbe 100644 --- a/src/platform/Tizen/DeviceInstanceInfoProviderImpl.h +++ b/src/platform/Tizen/DeviceInstanceInfoProviderImpl.h @@ -34,6 +34,8 @@ class DeviceInstanceInfoProviderImpl : public Internal::GenericDeviceInstanceInf public: CHIP_ERROR GetVendorId(uint16_t & vendorId) override; CHIP_ERROR GetProductId(uint16_t & productId) override; + CHIP_ERROR GetVendorName(char * buf, size_t bufSize) override; + CHIP_ERROR GetProductName(char * buf, size_t bufSize) override; DeviceInstanceInfoProviderImpl(ConfigurationManagerImpl & configManager) : Internal::GenericDeviceInstanceInfoProvider(configManager) diff --git a/src/platform/fake/ConfigurationManagerImpl.h b/src/platform/fake/ConfigurationManagerImpl.h index 25867fa68bdc87..11f44f9e1c4c0f 100644 --- a/src/platform/fake/ConfigurationManagerImpl.h +++ b/src/platform/fake/ConfigurationManagerImpl.h @@ -50,6 +50,10 @@ class ConfigurationManagerImpl : public ConfigurationManager CHIP_ERROR GetSoftwareVersion(uint32_t & softwareVer) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR StoreSoftwareVersion(uint32_t softwareVer) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR StoreSerialNumber(CharSpan serialNumber) override { return CHIP_ERROR_NOT_IMPLEMENTED; } + CHIP_ERROR StoreVendorName(CharSpan vendorName) override { return CHIP_ERROR_NOT_IMPLEMENTED; } + CHIP_ERROR StoreProductName(CharSpan productName) override { return CHIP_ERROR_NOT_IMPLEMENTED; } + CHIP_ERROR StoreHardwareVersionString(CharSpan hardwareVersionString) override { return CHIP_ERROR_NOT_IMPLEMENTED; } + CHIP_ERROR StoreSoftwareVersionString(CharSpan softwareVersionString) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetPrimaryMACAddress(MutableByteSpan buf) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetPrimaryWiFiMACAddress(uint8_t * buf) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetPrimary802154MACAddress(uint8_t * buf) override { return CHIP_ERROR_NOT_IMPLEMENTED; } From 800c5652b9ab5ae3881804e00c470f15b6de056c Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Tue, 16 Jul 2024 10:10:17 +0200 Subject: [PATCH 10/32] [Tizen] Initialize vendor and product names --- src/platform/Tizen/ConfigurationManagerImpl.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/platform/Tizen/ConfigurationManagerImpl.cpp b/src/platform/Tizen/ConfigurationManagerImpl.cpp index 8efe079993b7aa..dd6a33fac62fc7 100644 --- a/src/platform/Tizen/ConfigurationManagerImpl.cpp +++ b/src/platform/Tizen/ConfigurationManagerImpl.cpp @@ -26,6 +26,7 @@ #include "ConfigurationManagerImpl.h" #include +#include #include #include #include @@ -59,12 +60,24 @@ CHIP_ERROR ConfigurationManagerImpl::Init() SuccessOrExit(error); } + if (!Internal::PosixConfig::ConfigValueExists(Internal::PosixConfig::kConfigKey_VendorName)) + { + error = StoreVendorName(chip::CharSpan::fromCharString(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME)); + SuccessOrExit(error); + } + if (!Internal::PosixConfig::ConfigValueExists(Internal::PosixConfig::kConfigKey_ProductId)) { error = StoreProductId(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID); SuccessOrExit(error); } + if (!Internal::PosixConfig::ConfigValueExists(Internal::PosixConfig::kConfigKey_ProductName)) + { + error = StoreProductName(chip::CharSpan::fromCharString(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME)); + SuccessOrExit(error); + } + error = CHIP_NO_ERROR; exit: From b19ffdfdca4e1cbaddbd0c737676d54b86a7c37a Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 16 Jul 2024 08:17:36 +0000 Subject: [PATCH 11/32] Restyled by clang-format --- src/platform/Darwin/PosixConfig.cpp | 8 ++++---- src/platform/Linux/PosixConfig.cpp | 9 ++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/platform/Darwin/PosixConfig.cpp b/src/platform/Darwin/PosixConfig.cpp index d59431deeb2269..4fbd4da4671883 100644 --- a/src/platform/Darwin/PosixConfig.cpp +++ b/src/platform/Darwin/PosixConfig.cpp @@ -56,10 +56,10 @@ const PosixConfig::Key PosixConfig::kConfigKey_Spake2pVerifier = { kConfig const PosixConfig::Key PosixConfig::kConfigKey_VendorId = { kConfigNamespace_ChipFactory, "vendor-id" }; const PosixConfig::Key PosixConfig::kConfigKey_ProductId = { kConfigNamespace_ChipFactory, "product-id" }; -const PosixConfig::Key PosixConfig::kConfigKey_VendorName = { kConfigNamespace_ChipFactory, "vendor-name" }; -const PosixConfig::Key PosixConfig::kConfigKey_ProductName = { kConfigNamespace_ChipFactory, "product-name" }; -const PosixConfig::Key PosixConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipFactory, "hardware-version-string" }; -const PosixConfig::Key PosixConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipFactory, "software-version-string" }; +const PosixConfig::Key PosixConfig::kConfigKey_VendorName = { kConfigNamespace_ChipFactory, "vendor-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_ProductName = { kConfigNamespace_ChipFactory, "product-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipFactory, "hardware-version-string" }; +const PosixConfig::Key PosixConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipFactory, "software-version-string" }; // Keys stored in the Chip-config namespace const PosixConfig::Key PosixConfig::kConfigKey_FailSafeArmed = { kConfigNamespace_ChipConfig, "fail-safe-armed" }; diff --git a/src/platform/Linux/PosixConfig.cpp b/src/platform/Linux/PosixConfig.cpp index 937a02b7b6ee1b..c44a67d4fb3d23 100644 --- a/src/platform/Linux/PosixConfig.cpp +++ b/src/platform/Linux/PosixConfig.cpp @@ -63,11 +63,10 @@ const PosixConfig::Key PosixConfig::kConfigKey_Spake2pVerifier = { kConfig const PosixConfig::Key PosixConfig::kConfigKey_VendorId = { kConfigNamespace_ChipFactory, "vendor-id" }; const PosixConfig::Key PosixConfig::kConfigKey_ProductId = { kConfigNamespace_ChipFactory, "product-id" }; -const PosixConfig::Key PosixConfig::kConfigKey_VendorName = { kConfigNamespace_ChipFactory, "vendor-name" }; -const PosixConfig::Key PosixConfig::kConfigKey_ProductName = { kConfigNamespace_ChipFactory, "product-name" }; -const PosixConfig::Key PosixConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipFactory, "hardware-version-string" }; -const PosixConfig::Key PosixConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipFactory, "software-version-string" }; - +const PosixConfig::Key PosixConfig::kConfigKey_VendorName = { kConfigNamespace_ChipFactory, "vendor-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_ProductName = { kConfigNamespace_ChipFactory, "product-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipFactory, "hardware-version-string" }; +const PosixConfig::Key PosixConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipFactory, "software-version-string" }; // Keys stored in the Chip-config namespace const PosixConfig::Key PosixConfig::kConfigKey_ServiceConfig = { kConfigNamespace_ChipConfig, "service-config" }; From 94944cbc9f2fdd55575adc07590bf1ab7e370a76 Mon Sep 17 00:00:00 2001 From: chaitanya Date: Thu, 2 May 2024 17:06:23 -0700 Subject: [PATCH 12/32] added code to read vendor_name, product_name, hardware_version_string and software_version_string to read from config in reference linux and darwin platform --- .../platform/linux/CommissionableInit.cpp | 28 ++++++++ examples/platform/linux/Options.cpp | 32 +++++++++ examples/platform/linux/Options.h | 5 ++ src/include/platform/ConfigurationManager.h | 5 ++ .../GenericConfigurationManagerImpl.h | 5 ++ .../GenericConfigurationManagerImpl.ipp | 42 +++++++++++- .../GenericDeviceInstanceInfoProvider.ipp | 67 ++++++++++++++++--- src/platform/Darwin/PosixConfig.cpp | 5 ++ src/platform/Darwin/PosixConfig.h | 5 ++ src/platform/Linux/PosixConfig.cpp | 6 ++ src/platform/Linux/PosixConfig.h | 5 ++ 11 files changed, 193 insertions(+), 12 deletions(-) diff --git a/examples/platform/linux/CommissionableInit.cpp b/examples/platform/linux/CommissionableInit.cpp index 24fc347153c053..14414264f92fcf 100644 --- a/examples/platform/linux/CommissionableInit.cpp +++ b/examples/platform/linux/CommissionableInit.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "CommissionableInit.h" @@ -99,6 +100,33 @@ CHIP_ERROR InitConfigurationManager(ConfigurationManagerImpl & configManager, Li configManager.StoreProductId(options.payload.productID); } + if (options.vendorName.HasValue()) + { + const char * vendorName = options.vendorName.Value().c_str(); + configManager.StoreVendorName(vendorName, strlen(vendorName)); + } + if (options.productName.HasValue()) + { + const char * productName = options.productName.Value().c_str(); + configManager.StoreProductName(productName,strlen(productName)); + } + if (options.hardwareVersionString.HasValue()) + { + const char * hardwareVersionString = options.hardwareVersionString.Value().c_str(); + configManager.StoreHardwareVersionString(hardwareVersionString,strlen(hardwareVersionString)); + } + if (options.softwareVersionString.HasValue()) + { + const char * softwareVersionString = options.softwareVersionString.Value().c_str(); + configManager.StoreSoftwareVersionString(softwareVersionString,strlen(softwareVersionString)); + } + + if (options.serialNumber.HasValue()) + { + const char * serialNumber = options.serialNumber.Value().c_str(); + configManager.StoreSerialNumber(serialNumber, strlen(serialNumber)); + } + return CHIP_NO_ERROR; } diff --git a/examples/platform/linux/Options.cpp b/examples/platform/linux/Options.cpp index 6f8afea5bb496b..feb1d2e8ded513 100644 --- a/examples/platform/linux/Options.cpp +++ b/examples/platform/linux/Options.cpp @@ -119,6 +119,12 @@ enum #if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF kDeviceOption_WiFi_PAF, #endif + kDeviceOption_VendorName = 0x1028, + kDeviceOption_ProductName = 0x1029, + kDeviceOption_HardwareVersionString = 0x102a, + kDeviceOption_SoftwareVersionString = 0x102b, + kDeviceOption_SerialNumber = 0x102c, + }; constexpr unsigned kAppUsageLength = 64; @@ -140,6 +146,11 @@ OptionDef sDeviceOptionDefs[] = { { "version", kArgumentRequired, kDeviceOption_Version }, { "vendor-id", kArgumentRequired, kDeviceOption_VendorID }, { "product-id", kArgumentRequired, kDeviceOption_ProductID }, + { "vendor-name", kArgumentRequired, kDeviceOption_VendorName }, + { "product-name", kArgumentRequired, kDeviceOption_ProductName }, + { "harware-version-string", kArgumentRequired, kDeviceOption_HardwareVersionString }, + { "software-version-string", kArgumentRequired, kDeviceOption_SoftwareVersionString }, + { "serial-number", kArgumentRequired, kDeviceOption_SerialNumber }, { "custom-flow", kArgumentRequired, kDeviceOption_CustomFlow }, { "capabilities", kArgumentRequired, kDeviceOption_Capabilities }, { "discriminator", kArgumentRequired, kDeviceOption_Discriminator }, @@ -676,6 +687,7 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier, retval = false; } break; + } #endif #if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF @@ -685,6 +697,26 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier, break; } #endif + case kDeviceOption_VendorName: + LinuxDeviceOptions::GetInstance().vendorName.SetValue(std::string{ aValue }); + break; + + case kDeviceOption_ProductName: + LinuxDeviceOptions::GetInstance().productName.SetValue(std::string{ aValue }); + break; + + case kDeviceOption_HardwareVersionString: + LinuxDeviceOptions::GetInstance().hardwareVersionString.SetValue(std::string{ aValue }); + break; + + case kDeviceOption_SoftwareVersionString: + LinuxDeviceOptions::GetInstance().softwareVersionString.SetValue(std::string{ aValue }); + break; + + case kDeviceOption_SerialNumber: + LinuxDeviceOptions::GetInstance().serialNumber.SetValue(std::string{ aValue }); + break; + default: PrintArgError("%s: INTERNAL ERROR: Unhandled option: %s\n", aProgram, aName); retval = false; diff --git a/examples/platform/linux/Options.h b/examples/platform/linux/Options.h index 11a9061efcade8..b1072ffebbff15 100644 --- a/examples/platform/linux/Options.h +++ b/examples/platform/linux/Options.h @@ -91,6 +91,11 @@ struct LinuxDeviceOptions chip::Optional> commissioningArlEntries; chip::Optional> arlEntries; #endif + chip::Optional vendorName; + chip::Optional productName; + chip::Optional hardwareVersionString; + chip::Optional softwareVersionString; + chip::Optional serialNumber; static LinuxDeviceOptions & GetInstance(); }; diff --git a/src/include/platform/ConfigurationManager.h b/src/include/platform/ConfigurationManager.h index c7158d22c58d5e..bed6eea5cadb80 100644 --- a/src/include/platform/ConfigurationManager.h +++ b/src/include/platform/ConfigurationManager.h @@ -134,6 +134,11 @@ class ConfigurationManager virtual CHIP_ERROR GetBLEDeviceIdentificationInfo(Ble::ChipBLEDeviceIdentificationInfo & deviceIdInfo) = 0; + virtual CHIP_ERROR StoreVendorName(const char * vendorName, size_t vendorNameLen) = 0; + virtual CHIP_ERROR StoreProductName(const char * productName, size_t productNameLen) = 0; + virtual CHIP_ERROR StoreHardwareVersionString(const char * hardwareVersionString, size_t hardwareVersionStringLen) = 0; + virtual CHIP_ERROR StoreSoftwareVersionString(const char * softwareVersionString, size_t softwareVersionStringLen) = 0; + #if CHIP_CONFIG_TEST virtual void RunUnitTests() = 0; #endif diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.h b/src/include/platform/internal/GenericConfigurationManagerImpl.h index fa7e19503f845e..22189acd9b23e4 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.h +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.h @@ -103,6 +103,11 @@ class GenericConfigurationManagerImpl : public ConfigurationManager CHIP_ERROR GetUniqueId(char * buf, size_t bufSize) override; CHIP_ERROR StoreUniqueId(const char * uniqueId, size_t uniqueIdLen) override; CHIP_ERROR GenerateUniqueId(char * buf, size_t bufSize) override; + + CHIP_ERROR StoreVendorName(const char * vendorName, size_t vendorNameLen) override; + CHIP_ERROR StoreProductName(const char * productName, size_t productNameLen) override; + CHIP_ERROR StoreHardwareVersionString(const char * hardwareVersionString, size_t hardwareVersionStringLen) override; + CHIP_ERROR StoreSoftwareVersionString(const char * softwareVersionString, size_t softwareVersionStringLen) override; #if CHIP_CONFIG_TEST void RunUnitTests() override; #endif diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.ipp b/src/include/platform/internal/GenericConfigurationManagerImpl.ipp index 9b36f341042aa9..05148a6dc460ef 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.ipp +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.ipp @@ -351,9 +351,25 @@ CHIP_ERROR GenericConfigurationManagerImpl::GetSecondaryPairingHint template CHIP_ERROR GenericConfigurationManagerImpl::GetSoftwareVersionString(char * buf, size_t bufSize) { - ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING), CHIP_ERROR_BUFFER_TOO_SMALL); - strcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); - return CHIP_NO_ERROR; + ChipError err = CHIP_NO_ERROR; + size_t softwareVersionStringLen = 0; // without counting null-terminator + + err = ReadConfigValueStr(ConfigClass::kConfigKey_SoftwareVersionString, buf, bufSize, softwareVersionStringLen); +#ifdef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING + if (CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING[0] != 0 && err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + { + ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING), CHIP_ERROR_BUFFER_TOO_SMALL); + memcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING, sizeof(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING)); + softwareVersionStringLen = sizeof(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING) - 1; + err = CHIP_NO_ERROR; + } +#endif + ReturnErrorOnFailure(err); + + ReturnErrorCodeIf(softwareVersionStringLen >= bufSize, CHIP_ERROR_BUFFER_TOO_SMALL); + ReturnErrorCodeIf(buf[softwareVersionStringLen] != 0, CHIP_ERROR_INVALID_STRING_LENGTH); + + return err; } template @@ -361,6 +377,26 @@ CHIP_ERROR GenericConfigurationManagerImpl::StoreSerialNumber(const { return WriteConfigValueStr(ConfigClass::kConfigKey_SerialNum, serialNum, serialNumLen); } +template +CHIP_ERROR GenericConfigurationManagerImpl::StoreVendorName(const char * vendorName, size_t vendorNameLen) +{ + return WriteConfigValueStr(ConfigClass::kConfigKey_VendorName, vendorName, vendorNameLen); +} +template +CHIP_ERROR GenericConfigurationManagerImpl::StoreProductName(const char * productName, size_t productNameLen) +{ + return WriteConfigValueStr(ConfigClass::kConfigKey_ProductName, productName, productNameLen); +} +template +CHIP_ERROR GenericConfigurationManagerImpl::StoreHardwareVersionString(const char * hardwareVersionString, size_t hardwareVersionStringLen) +{ + return WriteConfigValueStr(ConfigClass::kConfigKey_HardwareVersionString, hardwareVersionString, hardwareVersionStringLen); +} +template +CHIP_ERROR GenericConfigurationManagerImpl::StoreSoftwareVersionString(const char * softwareVersionString, size_t softwareVersionStringLen) +{ + return WriteConfigValueStr(ConfigClass::kConfigKey_SoftwareVersionString, softwareVersionString, softwareVersionStringLen); +} template CHIP_ERROR GenericConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf) diff --git a/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp b/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp index 549c3eb360aa95..a64c633e9011a0 100644 --- a/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp +++ b/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp @@ -38,18 +38,50 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetProductId(uint16_t template CHIP_ERROR GenericDeviceInstanceInfoProvider::GetVendorName(char * buf, size_t bufSize) { - ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME), CHIP_ERROR_BUFFER_TOO_SMALL); - strcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME); - return CHIP_NO_ERROR; + ChipError err = CHIP_NO_ERROR; + size_t vendorNameLen = 0; // without counting null-terminator + + err = mGenericConfigManager.ReadConfigValueStr(ConfigClass::kConfigKey_VendorName, buf, bufSize, vendorNameLen); +#ifdef CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME + if (CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME[0] != 0 && err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + { + ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME), CHIP_ERROR_BUFFER_TOO_SMALL); + memcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME, sizeof(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME)); + vendorNameLen = sizeof(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME) - 1; + err = CHIP_NO_ERROR; + } +#endif + ReturnErrorOnFailure(err); + + ReturnErrorCodeIf(vendorNameLen >= bufSize, CHIP_ERROR_BUFFER_TOO_SMALL); + ReturnErrorCodeIf(buf[vendorNameLen] != 0, CHIP_ERROR_INVALID_STRING_LENGTH); + + return err; } template CHIP_ERROR GenericDeviceInstanceInfoProvider::GetProductName(char * buf, size_t bufSize) { - ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME), CHIP_ERROR_BUFFER_TOO_SMALL); - strcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME); + ChipError err = CHIP_NO_ERROR; + size_t productNameLen = 0; // without counting null-terminator - return CHIP_NO_ERROR; + err = mGenericConfigManager.ReadConfigValueStr(ConfigClass::kConfigKey_ProductName, buf, bufSize, productNameLen); + +#ifdef CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME + if (CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME[0] != 0 && err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + { + ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME), CHIP_ERROR_BUFFER_TOO_SMALL); + memcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME, sizeof(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME)); + productNameLen = sizeof(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME) - 1; + err = CHIP_NO_ERROR; + } +#endif + ReturnErrorOnFailure(err); + + ReturnErrorCodeIf(productNameLen >= bufSize, CHIP_ERROR_BUFFER_TOO_SMALL); + ReturnErrorCodeIf(buf[productNameLen] != 0, CHIP_ERROR_INVALID_STRING_LENGTH); + + return err; } template @@ -176,9 +208,26 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetHardwareVersion(ui template CHIP_ERROR GenericDeviceInstanceInfoProvider::GetHardwareVersionString(char * buf, size_t bufSize) { - ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING), CHIP_ERROR_BUFFER_TOO_SMALL); - strcpy(buf, CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING); - return CHIP_NO_ERROR; + ChipError err = CHIP_NO_ERROR; + size_t hardwareVersionStringLen = 0; // without counting null-terminator + + err = mGenericConfigManager.ReadConfigValueStr(ConfigClass::kConfigKey_HardwareVersionString, buf, bufSize, hardwareVersionStringLen); + +#ifdef CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING + if (CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING[0] != 0 && err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + { + ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING), CHIP_ERROR_BUFFER_TOO_SMALL); + memcpy(buf, CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING, sizeof(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING)); + hardwareVersionStringLen = sizeof(CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER) - 1; + err = CHIP_NO_ERROR; + } +#endif + ReturnErrorOnFailure(err); + + ReturnErrorCodeIf(hardwareVersionStringLen >= bufSize, CHIP_ERROR_BUFFER_TOO_SMALL); + ReturnErrorCodeIf(buf[hardwareVersionStringLen] != 0, CHIP_ERROR_INVALID_STRING_LENGTH); + + return err; } template diff --git a/src/platform/Darwin/PosixConfig.cpp b/src/platform/Darwin/PosixConfig.cpp index d54713edf532de..d59431deeb2269 100644 --- a/src/platform/Darwin/PosixConfig.cpp +++ b/src/platform/Darwin/PosixConfig.cpp @@ -56,6 +56,11 @@ const PosixConfig::Key PosixConfig::kConfigKey_Spake2pVerifier = { kConfig const PosixConfig::Key PosixConfig::kConfigKey_VendorId = { kConfigNamespace_ChipFactory, "vendor-id" }; const PosixConfig::Key PosixConfig::kConfigKey_ProductId = { kConfigNamespace_ChipFactory, "product-id" }; +const PosixConfig::Key PosixConfig::kConfigKey_VendorName = { kConfigNamespace_ChipFactory, "vendor-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_ProductName = { kConfigNamespace_ChipFactory, "product-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipFactory, "hardware-version-string" }; +const PosixConfig::Key PosixConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipFactory, "software-version-string" }; + // Keys stored in the Chip-config namespace const PosixConfig::Key PosixConfig::kConfigKey_FailSafeArmed = { kConfigNamespace_ChipConfig, "fail-safe-armed" }; const PosixConfig::Key PosixConfig::kConfigKey_RegulatoryLocation = { kConfigNamespace_ChipConfig, "regulatory-location" }; diff --git a/src/platform/Darwin/PosixConfig.h b/src/platform/Darwin/PosixConfig.h index fe4c1dd48a4250..822f04a4335a9d 100644 --- a/src/platform/Darwin/PosixConfig.h +++ b/src/platform/Darwin/PosixConfig.h @@ -72,6 +72,11 @@ class PosixConfig static const Key kCounterKey_RebootCount; static const Key kCounterKey_BootReason; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + #if !CHIP_DISABLE_PLATFORM_KVS static CHIP_ERROR Init(void); diff --git a/src/platform/Linux/PosixConfig.cpp b/src/platform/Linux/PosixConfig.cpp index 61a1fbd4dda6ed..937a02b7b6ee1b 100644 --- a/src/platform/Linux/PosixConfig.cpp +++ b/src/platform/Linux/PosixConfig.cpp @@ -63,6 +63,12 @@ const PosixConfig::Key PosixConfig::kConfigKey_Spake2pVerifier = { kConfig const PosixConfig::Key PosixConfig::kConfigKey_VendorId = { kConfigNamespace_ChipFactory, "vendor-id" }; const PosixConfig::Key PosixConfig::kConfigKey_ProductId = { kConfigNamespace_ChipFactory, "product-id" }; +const PosixConfig::Key PosixConfig::kConfigKey_VendorName = { kConfigNamespace_ChipFactory, "vendor-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_ProductName = { kConfigNamespace_ChipFactory, "product-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipFactory, "hardware-version-string" }; +const PosixConfig::Key PosixConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipFactory, "software-version-string" }; + + // Keys stored in the Chip-config namespace const PosixConfig::Key PosixConfig::kConfigKey_ServiceConfig = { kConfigNamespace_ChipConfig, "service-config" }; const PosixConfig::Key PosixConfig::kConfigKey_PairedAccountId = { kConfigNamespace_ChipConfig, "account-id" }; diff --git a/src/platform/Linux/PosixConfig.h b/src/platform/Linux/PosixConfig.h index c04d4a9be1093f..22c78e30d457fc 100644 --- a/src/platform/Linux/PosixConfig.h +++ b/src/platform/Linux/PosixConfig.h @@ -83,6 +83,11 @@ class PosixConfig static const Key kCounterKey_TotalOperationalHours; static const Key kCounterKey_BootReason; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + static CHIP_ERROR Init(); // Config value accessors. From 24704751e3087f3ddc83ab4968493e606f92cbba Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Fri, 3 May 2024 15:11:43 -0700 Subject: [PATCH 13/32] fixed few typos --- examples/platform/linux/Options.cpp | 33 ++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/examples/platform/linux/Options.cpp b/examples/platform/linux/Options.cpp index feb1d2e8ded513..75fe52f792a5a5 100644 --- a/examples/platform/linux/Options.cpp +++ b/examples/platform/linux/Options.cpp @@ -116,14 +116,17 @@ enum #if CHIP_WITH_NLFAULTINJECTION kDeviceOption_FaultInjection, #endif + #if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF kDeviceOption_WiFi_PAF, #endif - kDeviceOption_VendorName = 0x1028, - kDeviceOption_ProductName = 0x1029, + + kDeviceOption_VendorName = 0x1028, + kDeviceOption_ProductName = 0x1029, + kDeviceOption_HardwareVersionString = 0x102a, kDeviceOption_SoftwareVersionString = 0x102b, - kDeviceOption_SerialNumber = 0x102c, + kDeviceOption_SerialNumber = 0x102c, }; @@ -148,7 +151,7 @@ OptionDef sDeviceOptionDefs[] = { { "product-id", kArgumentRequired, kDeviceOption_ProductID }, { "vendor-name", kArgumentRequired, kDeviceOption_VendorName }, { "product-name", kArgumentRequired, kDeviceOption_ProductName }, - { "harware-version-string", kArgumentRequired, kDeviceOption_HardwareVersionString }, + { "hardware-version-string", kArgumentRequired, kDeviceOption_HardwareVersionString }, { "software-version-string", kArgumentRequired, kDeviceOption_SoftwareVersionString }, { "serial-number", kArgumentRequired, kDeviceOption_SerialNumber }, { "custom-flow", kArgumentRequired, kDeviceOption_CustomFlow }, @@ -241,6 +244,21 @@ const char * sDeviceOptionHelp = " --product-id \n" " The Product ID is specified by vendor.\n" "\n" + " --vendor-name \n" + " The Product ID is specified by vendor.\n" + "\n" + " --product-name \n" + " The Product ID is specified by vendor.\n" + "\n" + " --hardware-version-string \n" + " The Product ID is specified by vendor.\n" + "\n" + " --software-version-string \n" + " The Product ID is specified by vendor.\n" + "\n" + " --serial-number \n" + " The Product ID is specified by vendor.\n" + "\n" " --custom-flow \n" " A 2-bit unsigned enumeration specifying manufacturer-specific custom flow options.\n" "\n" @@ -687,7 +705,6 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier, retval = false; } break; - } #endif #if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF @@ -708,15 +725,15 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier, case kDeviceOption_HardwareVersionString: LinuxDeviceOptions::GetInstance().hardwareVersionString.SetValue(std::string{ aValue }); break; - + case kDeviceOption_SoftwareVersionString: LinuxDeviceOptions::GetInstance().softwareVersionString.SetValue(std::string{ aValue }); break; - + case kDeviceOption_SerialNumber: LinuxDeviceOptions::GetInstance().serialNumber.SetValue(std::string{ aValue }); break; - + default: PrintArgError("%s: INTERNAL ERROR: Unhandled option: %s\n", aProgram, aName); retval = false; From a35112063389e8d215366b61e7bc3e214e995b0c Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Fri, 3 May 2024 15:43:46 -0700 Subject: [PATCH 14/32] added few comments --- examples/platform/linux/Options.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/platform/linux/Options.cpp b/examples/platform/linux/Options.cpp index 75fe52f792a5a5..142e6838c03ab7 100644 --- a/examples/platform/linux/Options.cpp +++ b/examples/platform/linux/Options.cpp @@ -245,19 +245,19 @@ const char * sDeviceOptionHelp = " The Product ID is specified by vendor.\n" "\n" " --vendor-name \n" - " The Product ID is specified by vendor.\n" + " The vendor name specified by the vendor.\n" "\n" " --product-name \n" - " The Product ID is specified by vendor.\n" + " The product name specified by vendor.\n" "\n" " --hardware-version-string \n" - " The Product ID is specified by vendor.\n" + " The hardware version string specified by vendor.\n" "\n" " --software-version-string \n" - " The Product ID is specified by vendor.\n" + " The software version string specified by vendor.\n" "\n" " --serial-number \n" - " The Product ID is specified by vendor.\n" + " The serial number specified by vendor.\n" "\n" " --custom-flow \n" " A 2-bit unsigned enumeration specifying manufacturer-specific custom flow options.\n" From ff682fbde1991488d717b6c21944d7de363a2399 Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Thu, 9 May 2024 11:44:19 -0700 Subject: [PATCH 15/32] fixed review comments, changed functions to taking spans, not separate pointer/length arguments --- .../platform/linux/CommissionableInit.cpp | 26 ++++++++------- examples/platform/linux/Options.cpp | 10 +++--- examples/platform/linux/Options.h | 2 ++ src/include/platform/ConfigurationManager.h | 11 +++---- .../GenericConfigurationManagerImpl.h | 10 +++--- .../GenericConfigurationManagerImpl.ipp | 33 ++++++++++--------- .../GenericDeviceInstanceInfoProvider.ipp | 20 ++++++----- src/platform/fake/ConfigurationManagerImpl.h | 2 +- src/platform/tests/TestConfigurationMgr.cpp | 6 ++-- 9 files changed, 65 insertions(+), 55 deletions(-) diff --git a/examples/platform/linux/CommissionableInit.cpp b/examples/platform/linux/CommissionableInit.cpp index 14414264f92fcf..effb511c85165f 100644 --- a/examples/platform/linux/CommissionableInit.cpp +++ b/examples/platform/linux/CommissionableInit.cpp @@ -102,31 +102,33 @@ CHIP_ERROR InitConfigurationManager(ConfigurationManagerImpl & configManager, Li if (options.vendorName.HasValue()) { - const char * vendorName = options.vendorName.Value().c_str(); - configManager.StoreVendorName(vendorName, strlen(vendorName)); + chip::Span vendor_name(options.vendorName.Value().c_str(), options.vendorName.Value().size()); + VerifyOrDie(configManager.StoreVendorName(vendor_name) == CHIP_NO_ERROR); } if (options.productName.HasValue()) { - const char * productName = options.productName.Value().c_str(); - configManager.StoreProductName(productName,strlen(productName)); + chip::Span product_name(options.productName.Value().c_str(), options.productName.Value().size()); + VerifyOrDie(configManager.StoreProductName(product_name) == CHIP_NO_ERROR); } if (options.hardwareVersionString.HasValue()) { - const char * hardwareVersionString = options.hardwareVersionString.Value().c_str(); - configManager.StoreHardwareVersionString(hardwareVersionString,strlen(hardwareVersionString)); + chip::Span hardware_version_string(options.hardwareVersionString.Value().c_str(), + options.hardwareVersionString.Value().size()); + VerifyOrDie(configManager.StoreHardwareVersionString(hardware_version_string) == CHIP_NO_ERROR); } if (options.softwareVersionString.HasValue()) { - const char * softwareVersionString = options.softwareVersionString.Value().c_str(); - configManager.StoreSoftwareVersionString(softwareVersionString,strlen(softwareVersionString)); + chip::Span software_version_string(options.softwareVersionString.Value().c_str(), + options.softwareVersionString.Value().size()); + VerifyOrDie(configManager.StoreSoftwareVersionString(software_version_string) == CHIP_NO_ERROR); } - + if (options.serialNumber.HasValue()) { - const char * serialNumber = options.serialNumber.Value().c_str(); - configManager.StoreSerialNumber(serialNumber, strlen(serialNumber)); + chip::Span serial_number(options.serialNumber.Value().c_str(), options.serialNumber.Value().size()); + VerifyOrDie(configManager.StoreSerialNumber(serial_number) == CHIP_NO_ERROR); } - + return CHIP_NO_ERROR; } diff --git a/examples/platform/linux/Options.cpp b/examples/platform/linux/Options.cpp index 142e6838c03ab7..bd3c44b97a9630 100644 --- a/examples/platform/linux/Options.cpp +++ b/examples/platform/linux/Options.cpp @@ -244,19 +244,19 @@ const char * sDeviceOptionHelp = " --product-id \n" " The Product ID is specified by vendor.\n" "\n" - " --vendor-name \n" + " --vendor-name \n" " The vendor name specified by the vendor.\n" "\n" - " --product-name \n" + " --product-name \n" " The product name specified by vendor.\n" "\n" - " --hardware-version-string \n" + " --hardware-version-string \n" " The hardware version string specified by vendor.\n" "\n" - " --software-version-string \n" + " --software-version-string \n" " The software version string specified by vendor.\n" "\n" - " --serial-number \n" + " --serial-number \n" " The serial number specified by vendor.\n" "\n" " --custom-flow \n" diff --git a/examples/platform/linux/Options.h b/examples/platform/linux/Options.h index b1072ffebbff15..383c7efcc5c0cd 100644 --- a/examples/platform/linux/Options.h +++ b/examples/platform/linux/Options.h @@ -95,7 +95,9 @@ struct LinuxDeviceOptions chip::Optional productName; chip::Optional hardwareVersionString; chip::Optional softwareVersionString; +#if defined(CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER) chip::Optional serialNumber; +#endif static LinuxDeviceOptions & GetInstance(); }; diff --git a/src/include/platform/ConfigurationManager.h b/src/include/platform/ConfigurationManager.h index bed6eea5cadb80..e00a1ab19c99d2 100644 --- a/src/include/platform/ConfigurationManager.h +++ b/src/include/platform/ConfigurationManager.h @@ -114,7 +114,6 @@ class ConfigurationManager #endif virtual CHIP_ERROR GetRegulatoryLocation(uint8_t & location) = 0; virtual CHIP_ERROR GetCountryCode(char * buf, size_t bufSize, size_t & codeLen) = 0; - virtual CHIP_ERROR StoreSerialNumber(const char * serialNum, size_t serialNumLen) = 0; virtual CHIP_ERROR StoreManufacturingDate(const char * mfgDate, size_t mfgDateLen) = 0; virtual CHIP_ERROR StoreSoftwareVersion(uint32_t softwareVer) = 0; virtual CHIP_ERROR StoreHardwareVersion(uint16_t hardwareVer) = 0; @@ -133,11 +132,11 @@ class ConfigurationManager virtual CHIP_ERROR SetFailSafeArmed(bool val) = 0; virtual CHIP_ERROR GetBLEDeviceIdentificationInfo(Ble::ChipBLEDeviceIdentificationInfo & deviceIdInfo) = 0; - - virtual CHIP_ERROR StoreVendorName(const char * vendorName, size_t vendorNameLen) = 0; - virtual CHIP_ERROR StoreProductName(const char * productName, size_t productNameLen) = 0; - virtual CHIP_ERROR StoreHardwareVersionString(const char * hardwareVersionString, size_t hardwareVersionStringLen) = 0; - virtual CHIP_ERROR StoreSoftwareVersionString(const char * softwareVersionString, size_t softwareVersionStringLen) = 0; + virtual CHIP_ERROR StoreSerialNumber(chip::Span serialNumber) = 0; + virtual CHIP_ERROR StoreVendorName(chip::Span vendorName) = 0; + virtual CHIP_ERROR StoreProductName(chip::Span productName) = 0; + virtual CHIP_ERROR StoreHardwareVersionString(chip::Span hardwareVersionString) = 0; + virtual CHIP_ERROR StoreSoftwareVersionString(chip::Span softwareVersionString) = 0; #if CHIP_CONFIG_TEST virtual void RunUnitTests() = 0; diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.h b/src/include/platform/internal/GenericConfigurationManagerImpl.h index 22189acd9b23e4..4a5c2dab475ac8 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.h +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.h @@ -68,7 +68,7 @@ class GenericConfigurationManagerImpl : public ConfigurationManager CHIP_ERROR StoreSoftwareVersion(uint32_t softwareVer) override; CHIP_ERROR GetFirmwareBuildChipEpochTime(System::Clock::Seconds32 & buildTime) override; CHIP_ERROR SetFirmwareBuildChipEpochTime(System::Clock::Seconds32 buildTime) override; - CHIP_ERROR StoreSerialNumber(const char * serialNum, size_t serialNumLen) override; + CHIP_ERROR StoreSerialNumber(chip::Span serialNumber) override; CHIP_ERROR GetPrimaryMACAddress(MutableByteSpan buf) override; CHIP_ERROR GetPrimaryWiFiMACAddress(uint8_t * buf) override; CHIP_ERROR GetPrimary802154MACAddress(uint8_t * buf) override; @@ -104,10 +104,10 @@ class GenericConfigurationManagerImpl : public ConfigurationManager CHIP_ERROR StoreUniqueId(const char * uniqueId, size_t uniqueIdLen) override; CHIP_ERROR GenerateUniqueId(char * buf, size_t bufSize) override; - CHIP_ERROR StoreVendorName(const char * vendorName, size_t vendorNameLen) override; - CHIP_ERROR StoreProductName(const char * productName, size_t productNameLen) override; - CHIP_ERROR StoreHardwareVersionString(const char * hardwareVersionString, size_t hardwareVersionStringLen) override; - CHIP_ERROR StoreSoftwareVersionString(const char * softwareVersionString, size_t softwareVersionStringLen) override; + CHIP_ERROR StoreVendorName(chip::Span vendorName) override; + CHIP_ERROR StoreProductName(chip::Span productName) override; + CHIP_ERROR StoreHardwareVersionString(chip::Span hardwareVersionString) override; + CHIP_ERROR StoreSoftwareVersionString(chip::Span softwareVersionString) override; #if CHIP_CONFIG_TEST void RunUnitTests() override; #endif diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.ipp b/src/include/platform/internal/GenericConfigurationManagerImpl.ipp index 05148a6dc460ef..bd3ab9d0e9c67f 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.ipp +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.ipp @@ -351,20 +351,20 @@ CHIP_ERROR GenericConfigurationManagerImpl::GetSecondaryPairingHint template CHIP_ERROR GenericConfigurationManagerImpl::GetSoftwareVersionString(char * buf, size_t bufSize) { - ChipError err = CHIP_NO_ERROR; + ChipError err = CHIP_NO_ERROR; size_t softwareVersionStringLen = 0; // without counting null-terminator err = ReadConfigValueStr(ConfigClass::kConfigKey_SoftwareVersionString, buf, bufSize, softwareVersionStringLen); -#ifdef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING + if (CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING[0] != 0 && err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) { ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING), CHIP_ERROR_BUFFER_TOO_SMALL); memcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING, sizeof(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING)); softwareVersionStringLen = sizeof(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING) - 1; - err = CHIP_NO_ERROR; + err = CHIP_NO_ERROR; } -#endif - ReturnErrorOnFailure(err); + + VerifyOrReturnError(err == CHIP_NO_ERROR, CHIP_ERROR_INTERNAL); ReturnErrorCodeIf(softwareVersionStringLen >= bufSize, CHIP_ERROR_BUFFER_TOO_SMALL); ReturnErrorCodeIf(buf[softwareVersionStringLen] != 0, CHIP_ERROR_INVALID_STRING_LENGTH); @@ -373,29 +373,32 @@ CHIP_ERROR GenericConfigurationManagerImpl::GetSoftwareVersionStrin } template -CHIP_ERROR GenericConfigurationManagerImpl::StoreSerialNumber(const char * serialNum, size_t serialNumLen) +CHIP_ERROR GenericConfigurationManagerImpl::StoreSerialNumber(chip::Span serialNumber) { - return WriteConfigValueStr(ConfigClass::kConfigKey_SerialNum, serialNum, serialNumLen); + return WriteConfigValueStr(ConfigClass::kConfigKey_SerialNum, serialNumber.data(), serialNumber.size()); } template -CHIP_ERROR GenericConfigurationManagerImpl::StoreVendorName(const char * vendorName, size_t vendorNameLen) +CHIP_ERROR GenericConfigurationManagerImpl::StoreVendorName(chip::Span vendorName) { - return WriteConfigValueStr(ConfigClass::kConfigKey_VendorName, vendorName, vendorNameLen); + + return WriteConfigValueStr(ConfigClass::kConfigKey_VendorName, vendorName.data(), vendorName.size()); } template -CHIP_ERROR GenericConfigurationManagerImpl::StoreProductName(const char * productName, size_t productNameLen) +CHIP_ERROR GenericConfigurationManagerImpl::StoreProductName(chip::Span productName) { - return WriteConfigValueStr(ConfigClass::kConfigKey_ProductName, productName, productNameLen); + return WriteConfigValueStr(ConfigClass::kConfigKey_ProductName, productName.data(), productName.size()); } template -CHIP_ERROR GenericConfigurationManagerImpl::StoreHardwareVersionString(const char * hardwareVersionString, size_t hardwareVersionStringLen) +CHIP_ERROR GenericConfigurationManagerImpl::StoreHardwareVersionString(chip::Span hardwareVersionString) { - return WriteConfigValueStr(ConfigClass::kConfigKey_HardwareVersionString, hardwareVersionString, hardwareVersionStringLen); + return WriteConfigValueStr(ConfigClass::kConfigKey_HardwareVersionString, hardwareVersionString.data(), + hardwareVersionString.size()); } template -CHIP_ERROR GenericConfigurationManagerImpl::StoreSoftwareVersionString(const char * softwareVersionString, size_t softwareVersionStringLen) +CHIP_ERROR GenericConfigurationManagerImpl::StoreSoftwareVersionString(chip::Span softwareVersionString) { - return WriteConfigValueStr(ConfigClass::kConfigKey_SoftwareVersionString, softwareVersionString, softwareVersionStringLen); + return WriteConfigValueStr(ConfigClass::kConfigKey_SoftwareVersionString, softwareVersionString.data(), + softwareVersionString.size()); } template diff --git a/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp b/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp index a64c633e9011a0..474117680ddeff 100644 --- a/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp +++ b/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp @@ -38,7 +38,7 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetProductId(uint16_t template CHIP_ERROR GenericDeviceInstanceInfoProvider::GetVendorName(char * buf, size_t bufSize) { - ChipError err = CHIP_NO_ERROR; + ChipError err = CHIP_NO_ERROR; size_t vendorNameLen = 0; // without counting null-terminator err = mGenericConfigManager.ReadConfigValueStr(ConfigClass::kConfigKey_VendorName, buf, bufSize, vendorNameLen); @@ -48,7 +48,7 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetVendorName(char * ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME), CHIP_ERROR_BUFFER_TOO_SMALL); memcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME, sizeof(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME)); vendorNameLen = sizeof(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME) - 1; - err = CHIP_NO_ERROR; + err = CHIP_NO_ERROR; } #endif ReturnErrorOnFailure(err); @@ -62,7 +62,7 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetVendorName(char * template CHIP_ERROR GenericDeviceInstanceInfoProvider::GetProductName(char * buf, size_t bufSize) { - ChipError err = CHIP_NO_ERROR; + ChipError err = CHIP_NO_ERROR; size_t productNameLen = 0; // without counting null-terminator err = mGenericConfigManager.ReadConfigValueStr(ConfigClass::kConfigKey_ProductName, buf, bufSize, productNameLen); @@ -73,7 +73,7 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetProductName(char * ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME), CHIP_ERROR_BUFFER_TOO_SMALL); memcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME, sizeof(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME)); productNameLen = sizeof(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME) - 1; - err = CHIP_NO_ERROR; + err = CHIP_NO_ERROR; } #endif ReturnErrorOnFailure(err); @@ -208,18 +208,20 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetHardwareVersion(ui template CHIP_ERROR GenericDeviceInstanceInfoProvider::GetHardwareVersionString(char * buf, size_t bufSize) { - ChipError err = CHIP_NO_ERROR; + ChipError err = CHIP_NO_ERROR; size_t hardwareVersionStringLen = 0; // without counting null-terminator - err = mGenericConfigManager.ReadConfigValueStr(ConfigClass::kConfigKey_HardwareVersionString, buf, bufSize, hardwareVersionStringLen); + err = mGenericConfigManager.ReadConfigValueStr(ConfigClass::kConfigKey_HardwareVersionString, buf, bufSize, + hardwareVersionStringLen); #ifdef CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING if (CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING[0] != 0 && err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) { ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING), CHIP_ERROR_BUFFER_TOO_SMALL); - memcpy(buf, CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING, sizeof(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING)); - hardwareVersionStringLen = sizeof(CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER) - 1; - err = CHIP_NO_ERROR; + memcpy(buf, CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING, + sizeof(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING)); + hardwareVersionStringLen = sizeof(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING) - 1; + err = CHIP_NO_ERROR; } #endif ReturnErrorOnFailure(err); diff --git a/src/platform/fake/ConfigurationManagerImpl.h b/src/platform/fake/ConfigurationManagerImpl.h index 510b2fc0dacc83..98da2c3c88ee22 100644 --- a/src/platform/fake/ConfigurationManagerImpl.h +++ b/src/platform/fake/ConfigurationManagerImpl.h @@ -49,7 +49,7 @@ class ConfigurationManagerImpl : public ConfigurationManager } CHIP_ERROR GetSoftwareVersion(uint32_t & softwareVer) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR StoreSoftwareVersion(uint32_t softwareVer) override { return CHIP_ERROR_NOT_IMPLEMENTED; } - CHIP_ERROR StoreSerialNumber(const char * serialNum, size_t serialNumLen) override { return CHIP_ERROR_NOT_IMPLEMENTED; } + CHIP_ERROR StoreSerialNumber(chip::Span serialNumber) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetPrimaryMACAddress(MutableByteSpan buf) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetPrimaryWiFiMACAddress(uint8_t * buf) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetPrimary802154MACAddress(uint8_t * buf) override { return CHIP_ERROR_NOT_IMPLEMENTED; } diff --git a/src/platform/tests/TestConfigurationMgr.cpp b/src/platform/tests/TestConfigurationMgr.cpp index d40c600c5d03f3..36530dfccc3373 100644 --- a/src/platform/tests/TestConfigurationMgr.cpp +++ b/src/platform/tests/TestConfigurationMgr.cpp @@ -84,8 +84,9 @@ TEST_F(TestConfigurationMgr, SerialNumber) char buf[64]; const char * serialNumber = "89051AAZZ236"; + chip::Span serial_number(serialNumber.Value().c_str(), serialNumber.Value().size()); - err = ConfigurationMgr().StoreSerialNumber(serialNumber, strlen(serialNumber)); + err = ConfigurationMgr().StoreSerialNumber(serial_number); EXPECT_EQ(err, CHIP_NO_ERROR); err = GetDeviceInstanceInfoProvider()->GetSerialNumber(buf, 64); @@ -94,7 +95,8 @@ TEST_F(TestConfigurationMgr, SerialNumber) EXPECT_EQ(strlen(buf), 12u); EXPECT_STREQ(buf, serialNumber); - err = ConfigurationMgr().StoreSerialNumber(serialNumber, 5); + chip::Span serial_number(serialNumber.Value().c_str(), 5); + err = ConfigurationMgr().StoreSerialNumber(serial_number); EXPECT_EQ(err, CHIP_NO_ERROR); err = GetDeviceInstanceInfoProvider()->GetSerialNumber(buf, 64); From 6536e3335ad1cbb16541f63a0dff63d9f1517335 Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Mon, 1 Jul 2024 11:23:16 -0700 Subject: [PATCH 16/32] defined vendor_name, product_name, hardware_version_string and software_version_string config variables in all platforms --- .../platform/linux/CommissionableInit.cpp | 15 +++--- examples/platform/linux/Options.cpp | 4 +- examples/platform/linux/Options.h | 3 +- src/include/platform/ConfigurationManager.h | 10 ++-- .../GenericConfigurationManagerImpl.h | 10 ++-- .../GenericConfigurationManagerImpl.ipp | 22 ++++----- .../GenericDeviceInstanceInfoProvider.ipp | 46 ++++++------------- src/platform/ASR/ASRConfig.h | 5 ++ src/platform/Ameba/AmebaConfig.h | 5 ++ src/platform/Beken/BekenConfig.h | 5 ++ src/platform/Infineon/PSOC6/PSOC6Config.h | 5 ++ src/platform/Zephyr/ZephyrConfig.cpp | 5 ++ src/platform/Zephyr/ZephyrConfig.h | 5 ++ src/platform/bouffalolab/common/BLConfig.h | 5 ++ src/platform/cc13xx_26xx/CC13XX_26XXConfig.h | 5 ++ src/platform/cc32xx/CC32XXConfig.h | 5 ++ src/platform/fake/ConfigurationManagerImpl.h | 2 +- src/platform/mbed/MbedConfig.h | 5 ++ src/platform/nxp/common/NXPConfig.h | 5 ++ src/platform/nxp/k32w0/K32W0Config.cpp | 5 ++ src/platform/nxp/k32w0/K32W0Config.h | 5 ++ src/platform/nxp/mcxw71_k32w1/K32W1Config.h | 5 ++ src/platform/nxp/mw320/MW320Config.h | 5 ++ src/platform/openiotsdk/KVPsaPsStore.h | 5 ++ src/platform/qpg/qpgConfig.h | 5 ++ src/platform/silabs/SilabsConfig.h | 3 +- src/platform/tests/TestConfigurationMgr.cpp | 10 ++-- 27 files changed, 135 insertions(+), 75 deletions(-) diff --git a/examples/platform/linux/CommissionableInit.cpp b/examples/platform/linux/CommissionableInit.cpp index effb511c85165f..2418c64d8fc0a7 100644 --- a/examples/platform/linux/CommissionableInit.cpp +++ b/examples/platform/linux/CommissionableInit.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include "CommissionableInit.h" @@ -102,30 +101,30 @@ CHIP_ERROR InitConfigurationManager(ConfigurationManagerImpl & configManager, Li if (options.vendorName.HasValue()) { - chip::Span vendor_name(options.vendorName.Value().c_str(), options.vendorName.Value().size()); + CharSpan vendor_name(options.vendorName.Value().c_str(), options.vendorName.Value().size()); VerifyOrDie(configManager.StoreVendorName(vendor_name) == CHIP_NO_ERROR); } if (options.productName.HasValue()) { - chip::Span product_name(options.productName.Value().c_str(), options.productName.Value().size()); + CharSpan product_name(options.productName.Value().c_str(), options.productName.Value().size()); VerifyOrDie(configManager.StoreProductName(product_name) == CHIP_NO_ERROR); } if (options.hardwareVersionString.HasValue()) { - chip::Span hardware_version_string(options.hardwareVersionString.Value().c_str(), - options.hardwareVersionString.Value().size()); + CharSpan hardware_version_string(options.hardwareVersionString.Value().c_str(), + options.hardwareVersionString.Value().size()); VerifyOrDie(configManager.StoreHardwareVersionString(hardware_version_string) == CHIP_NO_ERROR); } if (options.softwareVersionString.HasValue()) { - chip::Span software_version_string(options.softwareVersionString.Value().c_str(), - options.softwareVersionString.Value().size()); + CharSpan software_version_string(options.softwareVersionString.Value().c_str(), + options.softwareVersionString.Value().size()); VerifyOrDie(configManager.StoreSoftwareVersionString(software_version_string) == CHIP_NO_ERROR); } if (options.serialNumber.HasValue()) { - chip::Span serial_number(options.serialNumber.Value().c_str(), options.serialNumber.Value().size()); + CharSpan serial_number(options.serialNumber.Value().c_str(), options.serialNumber.Value().size()); VerifyOrDie(configManager.StoreSerialNumber(serial_number) == CHIP_NO_ERROR); } diff --git a/examples/platform/linux/Options.cpp b/examples/platform/linux/Options.cpp index bd3c44b97a9630..e0afe54b0a0201 100644 --- a/examples/platform/linux/Options.cpp +++ b/examples/platform/linux/Options.cpp @@ -251,10 +251,10 @@ const char * sDeviceOptionHelp = " The product name specified by vendor.\n" "\n" " --hardware-version-string \n" - " The hardware version string specified by vendor.\n" + " The HardwareVersionString to use in the basic information cluster.\n" "\n" " --software-version-string \n" - " The software version string specified by vendor.\n" + " The SoftwareVersionString to use in the basic information cluster.\n" "\n" " --serial-number \n" " The serial number specified by vendor.\n" diff --git a/examples/platform/linux/Options.h b/examples/platform/linux/Options.h index 383c7efcc5c0cd..b64147108b180c 100644 --- a/examples/platform/linux/Options.h +++ b/examples/platform/linux/Options.h @@ -95,9 +95,8 @@ struct LinuxDeviceOptions chip::Optional productName; chip::Optional hardwareVersionString; chip::Optional softwareVersionString; -#if defined(CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER) chip::Optional serialNumber; -#endif + static LinuxDeviceOptions & GetInstance(); }; diff --git a/src/include/platform/ConfigurationManager.h b/src/include/platform/ConfigurationManager.h index e00a1ab19c99d2..d54e044b82d66a 100644 --- a/src/include/platform/ConfigurationManager.h +++ b/src/include/platform/ConfigurationManager.h @@ -132,11 +132,11 @@ class ConfigurationManager virtual CHIP_ERROR SetFailSafeArmed(bool val) = 0; virtual CHIP_ERROR GetBLEDeviceIdentificationInfo(Ble::ChipBLEDeviceIdentificationInfo & deviceIdInfo) = 0; - virtual CHIP_ERROR StoreSerialNumber(chip::Span serialNumber) = 0; - virtual CHIP_ERROR StoreVendorName(chip::Span vendorName) = 0; - virtual CHIP_ERROR StoreProductName(chip::Span productName) = 0; - virtual CHIP_ERROR StoreHardwareVersionString(chip::Span hardwareVersionString) = 0; - virtual CHIP_ERROR StoreSoftwareVersionString(chip::Span softwareVersionString) = 0; + virtual CHIP_ERROR StoreSerialNumber(CharSpan serialNumber) = 0; + virtual CHIP_ERROR StoreVendorName(CharSpan vendorName) = 0; + virtual CHIP_ERROR StoreProductName(CharSpan productName) = 0; + virtual CHIP_ERROR StoreHardwareVersionString(CharSpan hardwareVersionString) = 0; + virtual CHIP_ERROR StoreSoftwareVersionString(CharSpan softwareVersionString) = 0; #if CHIP_CONFIG_TEST virtual void RunUnitTests() = 0; diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.h b/src/include/platform/internal/GenericConfigurationManagerImpl.h index 4a5c2dab475ac8..faa8dfc79fa7ca 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.h +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.h @@ -68,7 +68,7 @@ class GenericConfigurationManagerImpl : public ConfigurationManager CHIP_ERROR StoreSoftwareVersion(uint32_t softwareVer) override; CHIP_ERROR GetFirmwareBuildChipEpochTime(System::Clock::Seconds32 & buildTime) override; CHIP_ERROR SetFirmwareBuildChipEpochTime(System::Clock::Seconds32 buildTime) override; - CHIP_ERROR StoreSerialNumber(chip::Span serialNumber) override; + CHIP_ERROR StoreSerialNumber(CharSpan serialNumber) override; CHIP_ERROR GetPrimaryMACAddress(MutableByteSpan buf) override; CHIP_ERROR GetPrimaryWiFiMACAddress(uint8_t * buf) override; CHIP_ERROR GetPrimary802154MACAddress(uint8_t * buf) override; @@ -104,10 +104,10 @@ class GenericConfigurationManagerImpl : public ConfigurationManager CHIP_ERROR StoreUniqueId(const char * uniqueId, size_t uniqueIdLen) override; CHIP_ERROR GenerateUniqueId(char * buf, size_t bufSize) override; - CHIP_ERROR StoreVendorName(chip::Span vendorName) override; - CHIP_ERROR StoreProductName(chip::Span productName) override; - CHIP_ERROR StoreHardwareVersionString(chip::Span hardwareVersionString) override; - CHIP_ERROR StoreSoftwareVersionString(chip::Span softwareVersionString) override; + CHIP_ERROR StoreVendorName(CharSpan vendorName) override; + CHIP_ERROR StoreProductName(CharSpan productName) override; + CHIP_ERROR StoreHardwareVersionString(CharSpan hardwareVersionString) override; + CHIP_ERROR StoreSoftwareVersionString(CharSpan softwareVersionString) override; #if CHIP_CONFIG_TEST void RunUnitTests() override; #endif diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.ipp b/src/include/platform/internal/GenericConfigurationManagerImpl.ipp index bd3ab9d0e9c67f..4ef3893cd91238 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.ipp +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.ipp @@ -351,51 +351,47 @@ CHIP_ERROR GenericConfigurationManagerImpl::GetSecondaryPairingHint template CHIP_ERROR GenericConfigurationManagerImpl::GetSoftwareVersionString(char * buf, size_t bufSize) { - ChipError err = CHIP_NO_ERROR; + CHIP_ERROR err = CHIP_NO_ERROR; size_t softwareVersionStringLen = 0; // without counting null-terminator err = ReadConfigValueStr(ConfigClass::kConfigKey_SoftwareVersionString, buf, bufSize, softwareVersionStringLen); - if (CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING[0] != 0 && err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) { ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING), CHIP_ERROR_BUFFER_TOO_SMALL); memcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING, sizeof(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING)); - softwareVersionStringLen = sizeof(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING) - 1; - err = CHIP_NO_ERROR; + + return CHIP_NO_ERROR; } VerifyOrReturnError(err == CHIP_NO_ERROR, CHIP_ERROR_INTERNAL); - - ReturnErrorCodeIf(softwareVersionStringLen >= bufSize, CHIP_ERROR_BUFFER_TOO_SMALL); - ReturnErrorCodeIf(buf[softwareVersionStringLen] != 0, CHIP_ERROR_INVALID_STRING_LENGTH); - return err; } template -CHIP_ERROR GenericConfigurationManagerImpl::StoreSerialNumber(chip::Span serialNumber) +CHIP_ERROR GenericConfigurationManagerImpl::StoreSerialNumber(CharSpan serialNumber) { return WriteConfigValueStr(ConfigClass::kConfigKey_SerialNum, serialNumber.data(), serialNumber.size()); } template -CHIP_ERROR GenericConfigurationManagerImpl::StoreVendorName(chip::Span vendorName) +CHIP_ERROR GenericConfigurationManagerImpl::StoreVendorName(CharSpan vendorName) { return WriteConfigValueStr(ConfigClass::kConfigKey_VendorName, vendorName.data(), vendorName.size()); } template -CHIP_ERROR GenericConfigurationManagerImpl::StoreProductName(chip::Span productName) +CHIP_ERROR GenericConfigurationManagerImpl::StoreProductName(CharSpan productName) { return WriteConfigValueStr(ConfigClass::kConfigKey_ProductName, productName.data(), productName.size()); } template -CHIP_ERROR GenericConfigurationManagerImpl::StoreHardwareVersionString(chip::Span hardwareVersionString) +CHIP_ERROR GenericConfigurationManagerImpl::StoreHardwareVersionString(CharSpan hardwareVersionString) { return WriteConfigValueStr(ConfigClass::kConfigKey_HardwareVersionString, hardwareVersionString.data(), hardwareVersionString.size()); } template -CHIP_ERROR GenericConfigurationManagerImpl::StoreSoftwareVersionString(chip::Span softwareVersionString) +CHIP_ERROR GenericConfigurationManagerImpl::StoreSoftwareVersionString(CharSpan softwareVersionString) { return WriteConfigValueStr(ConfigClass::kConfigKey_SoftwareVersionString, softwareVersionString.data(), softwareVersionString.size()); diff --git a/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp b/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp index 474117680ddeff..cb44bfc140341f 100644 --- a/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp +++ b/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp @@ -42,19 +42,15 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetVendorName(char * size_t vendorNameLen = 0; // without counting null-terminator err = mGenericConfigManager.ReadConfigValueStr(ConfigClass::kConfigKey_VendorName, buf, bufSize, vendorNameLen); -#ifdef CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME - if (CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME[0] != 0 && err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + + if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) { ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME), CHIP_ERROR_BUFFER_TOO_SMALL); memcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME, sizeof(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME)); - vendorNameLen = sizeof(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME) - 1; - err = CHIP_NO_ERROR; + err = CHIP_NO_ERROR; } -#endif - ReturnErrorOnFailure(err); - ReturnErrorCodeIf(vendorNameLen >= bufSize, CHIP_ERROR_BUFFER_TOO_SMALL); - ReturnErrorCodeIf(buf[vendorNameLen] != 0, CHIP_ERROR_INVALID_STRING_LENGTH); + VerifyOrReturnError(err == CHIP_NO_ERROR, CHIP_ERROR_INTERNAL); return err; } @@ -67,19 +63,14 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetProductName(char * err = mGenericConfigManager.ReadConfigValueStr(ConfigClass::kConfigKey_ProductName, buf, bufSize, productNameLen); -#ifdef CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME - if (CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME[0] != 0 && err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) { ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME), CHIP_ERROR_BUFFER_TOO_SMALL); memcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME, sizeof(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME)); - productNameLen = sizeof(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME) - 1; - err = CHIP_NO_ERROR; + err = CHIP_NO_ERROR; } -#endif - ReturnErrorOnFailure(err); - ReturnErrorCodeIf(productNameLen >= bufSize, CHIP_ERROR_BUFFER_TOO_SMALL); - ReturnErrorCodeIf(buf[productNameLen] != 0, CHIP_ERROR_INVALID_STRING_LENGTH); + VerifyOrReturnError(err == CHIP_NO_ERROR, CHIP_ERROR_INTERNAL); return err; } @@ -128,19 +119,15 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetSerialNumber(char err = mGenericConfigManager.ReadConfigValueStr(ConfigClass::kConfigKey_SerialNum, buf, bufSize, serialNumLen); -#ifdef CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER - if (CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER[0] != 0 && err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) { ReturnErrorCodeIf(sizeof(CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER) > bufSize, CHIP_ERROR_BUFFER_TOO_SMALL); memcpy(buf, CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER, sizeof(CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER)); - serialNumLen = sizeof(CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER) - 1; - err = CHIP_NO_ERROR; + + err = CHIP_NO_ERROR; } -#endif // CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER - ReturnErrorOnFailure(err); - ReturnErrorCodeIf(serialNumLen >= bufSize, CHIP_ERROR_BUFFER_TOO_SMALL); - ReturnErrorCodeIf(buf[serialNumLen] != 0, CHIP_ERROR_INVALID_STRING_LENGTH); + VerifyOrReturnError(err == CHIP_NO_ERROR, CHIP_ERROR_INTERNAL); return err; } @@ -214,20 +201,15 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetHardwareVersionStr err = mGenericConfigManager.ReadConfigValueStr(ConfigClass::kConfigKey_HardwareVersionString, buf, bufSize, hardwareVersionStringLen); -#ifdef CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING - if (CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING[0] != 0 && err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) + if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) { ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING), CHIP_ERROR_BUFFER_TOO_SMALL); memcpy(buf, CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING, sizeof(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING)); - hardwareVersionStringLen = sizeof(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING) - 1; - err = CHIP_NO_ERROR; + err = CHIP_NO_ERROR; } -#endif - ReturnErrorOnFailure(err); - ReturnErrorCodeIf(hardwareVersionStringLen >= bufSize, CHIP_ERROR_BUFFER_TOO_SMALL); - ReturnErrorCodeIf(buf[hardwareVersionStringLen] != 0, CHIP_ERROR_INVALID_STRING_LENGTH); + VerifyOrReturnError(err == CHIP_NO_ERROR, CHIP_ERROR_INTERNAL); return err; } diff --git a/src/platform/ASR/ASRConfig.h b/src/platform/ASR/ASRConfig.h index 71c90a3a79b242..b27f77dd5ffd10 100755 --- a/src/platform/ASR/ASRConfig.h +++ b/src/platform/ASR/ASRConfig.h @@ -91,6 +91,11 @@ class ASRConfig static const Key kCounterKey_UpTime; static const Key kCounterKey_TotalOperationalHours; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + // Config value accessors. static CHIP_ERROR ReadConfigValue(Key key, bool & val); static CHIP_ERROR ReadConfigValue(Key key, uint32_t & val); diff --git a/src/platform/Ameba/AmebaConfig.h b/src/platform/Ameba/AmebaConfig.h index 0c78e0e3a742bd..0c100b4713bd05 100755 --- a/src/platform/Ameba/AmebaConfig.h +++ b/src/platform/Ameba/AmebaConfig.h @@ -74,6 +74,11 @@ class AmebaConfig static const Key kCounterKey_TotalOperationalHours; static const Key kCounterKey_BootReason; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + // Config value accessors. static CHIP_ERROR ReadConfigValue(Key key, bool & val); static CHIP_ERROR ReadConfigValue(Key key, uint32_t & val); diff --git a/src/platform/Beken/BekenConfig.h b/src/platform/Beken/BekenConfig.h index 94362c092296f8..819d379267a3fd 100755 --- a/src/platform/Beken/BekenConfig.h +++ b/src/platform/Beken/BekenConfig.h @@ -74,6 +74,11 @@ class BekenConfig static const Key kCounterKey_TotalOperationalHours; static const Key kCounterKey_BootReason; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + static const char kGroupKeyNamePrefix[]; // Config value accessors. diff --git a/src/platform/Infineon/PSOC6/PSOC6Config.h b/src/platform/Infineon/PSOC6/PSOC6Config.h index 17fa896346c348..a1c77c648526f6 100644 --- a/src/platform/Infineon/PSOC6/PSOC6Config.h +++ b/src/platform/Infineon/PSOC6/PSOC6Config.h @@ -89,6 +89,11 @@ class PSOC6Config static const Key kConfigKey_YearDaySchedules; static const Key kConfigKey_HolidaySchedules; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + // CHIP Counter keys static const Key kCounterKey_RebootCount; static const Key kCounterKey_UpTime; diff --git a/src/platform/Zephyr/ZephyrConfig.cpp b/src/platform/Zephyr/ZephyrConfig.cpp index f548e95bca09a7..ceb4e54e00bd0e 100644 --- a/src/platform/Zephyr/ZephyrConfig.cpp +++ b/src/platform/Zephyr/ZephyrConfig.cpp @@ -73,6 +73,11 @@ 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_UniqueId = CONFIG_KEY(NAMESPACE_CONFIG "unique-id"); +const ZephyrConfig::Key ZephyrConfig::kConfigKey_VendorName = CONFIG_KEY(NAMESPACE_CONFIG "vendor-name"); +const ZephyrConfig::Key ZephyrConfig::kConfigKey_ProductName = CONFIG_KEY(NAMESPACE_CONFIG "product-name"); +const ZephyrConfig::Key ZephyrConfig::kConfigKey_HardwareVersionString = CONFIG_KEY(NAMESPACE_CONFIG "hardware-version-string"); +const ZephyrConfig::Key ZephyrConfig::kConfigKey_SoftwareVersionString = CONFIG_KEY(NAMESPACE_CONFIG "software-version-string"); + // Keys stored in the counters namespace const ZephyrConfig::Key ZephyrConfig::kCounterKey_RebootCount = CONFIG_KEY(NAMESPACE_COUNTERS "reboot-count"); const ZephyrConfig::Key ZephyrConfig::kCounterKey_BootReason = CONFIG_KEY(NAMESPACE_COUNTERS "boot-reason"); diff --git a/src/platform/Zephyr/ZephyrConfig.h b/src/platform/Zephyr/ZephyrConfig.h index b451d0c13997e9..7e43667a76204e 100644 --- a/src/platform/Zephyr/ZephyrConfig.h +++ b/src/platform/Zephyr/ZephyrConfig.h @@ -66,6 +66,11 @@ class ZephyrConfig static const Key kConfigKey_Spake2pVerifier; static const Key kConfigKey_CertificationDeclaration; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + static const Key kCounterKey_RebootCount; static const Key kCounterKey_BootReason; static const Key kCounterKey_TotalOperationalHours; diff --git a/src/platform/bouffalolab/common/BLConfig.h b/src/platform/bouffalolab/common/BLConfig.h index bb9f57fd01b639..c665273a6ce349 100644 --- a/src/platform/bouffalolab/common/BLConfig.h +++ b/src/platform/bouffalolab/common/BLConfig.h @@ -77,6 +77,11 @@ class BLConfig static constexpr char kBLKey_factoryResetFlag[] = ("__factory_reset_pending"); + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + static void Init(void); // Config value accessors. diff --git a/src/platform/cc13xx_26xx/CC13XX_26XXConfig.h b/src/platform/cc13xx_26xx/CC13XX_26XXConfig.h index 2450c0f8c50544..0dcc405fc19553 100644 --- a/src/platform/cc13xx_26xx/CC13XX_26XXConfig.h +++ b/src/platform/cc13xx_26xx/CC13XX_26XXConfig.h @@ -82,6 +82,11 @@ class CC13XX_26XXConfig static const Key kConfigKey_TotalOperationalHours; static const Key kConfigKey_LifeTimeCounter; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + static CHIP_ERROR Init(void); // Config value accessors. diff --git a/src/platform/cc32xx/CC32XXConfig.h b/src/platform/cc32xx/CC32XXConfig.h index 8179d9877a4489..73c503b929d4c8 100644 --- a/src/platform/cc32xx/CC32XXConfig.h +++ b/src/platform/cc32xx/CC32XXConfig.h @@ -57,6 +57,11 @@ class CC32XXConfig static const Key kConfigKey_Breadcrumb; static const Key kConfigKey_UniqueId; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + static const Key kConfigKey_Spake2pIterationCount; static const Key kConfigKey_Spake2pSalt; static const Key kConfigKey_Spake2pVerifier; diff --git a/src/platform/fake/ConfigurationManagerImpl.h b/src/platform/fake/ConfigurationManagerImpl.h index 98da2c3c88ee22..25867fa68bdc87 100644 --- a/src/platform/fake/ConfigurationManagerImpl.h +++ b/src/platform/fake/ConfigurationManagerImpl.h @@ -49,7 +49,7 @@ class ConfigurationManagerImpl : public ConfigurationManager } CHIP_ERROR GetSoftwareVersion(uint32_t & softwareVer) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR StoreSoftwareVersion(uint32_t softwareVer) override { return CHIP_ERROR_NOT_IMPLEMENTED; } - CHIP_ERROR StoreSerialNumber(chip::Span serialNumber) override { return CHIP_ERROR_NOT_IMPLEMENTED; } + CHIP_ERROR StoreSerialNumber(CharSpan serialNumber) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetPrimaryMACAddress(MutableByteSpan buf) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetPrimaryWiFiMACAddress(uint8_t * buf) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetPrimary802154MACAddress(uint8_t * buf) override { return CHIP_ERROR_NOT_IMPLEMENTED; } diff --git a/src/platform/mbed/MbedConfig.h b/src/platform/mbed/MbedConfig.h index 70b1dfa6890a24..8482cd6866165c 100644 --- a/src/platform/mbed/MbedConfig.h +++ b/src/platform/mbed/MbedConfig.h @@ -72,6 +72,11 @@ class MbedConfig static const Key kConfigKey_Spake2pSalt; static const Key kConfigKey_Spake2pVerifier; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + // CHIP Counter keys static const Key kCounterKey_RebootCount; static const Key kCounterKey_UpTime; diff --git a/src/platform/nxp/common/NXPConfig.h b/src/platform/nxp/common/NXPConfig.h index 7de3beab2b37ed..781e476950983f 100644 --- a/src/platform/nxp/common/NXPConfig.h +++ b/src/platform/nxp/common/NXPConfig.h @@ -100,6 +100,11 @@ class NXPConfig static constexpr Key kConfigKey_Spake2pSalt = config_key(kFileId_ChipFactory, 0x0B); static constexpr Key kConfigKey_Spake2pVerifier = config_key(kFileId_ChipFactory, 0x0C); + static constexpr Key kConfigKey_VendorName = config_key(kFileId_ChipFactory, 0x0D); + static constexpr Key kConfigKey_ProductName = config_key(kFileId_ChipFactory, 0x0E); + static constexpr Key kConfigKey_HardwareVersionString = config_key(kFileId_ChipFactory, 0x0F); + static constexpr Key kConfigKey_SoftwareVersionString = config_key(kFileId_ChipFactory, 0x10); + // CHIP Config Keys static constexpr Key kConfigKey_FabricId = config_key(kFileId_ChipConfig, 0x00); static constexpr Key kConfigKey_ServiceConfig = config_key(kFileId_ChipConfig, 0x01); diff --git a/src/platform/nxp/k32w0/K32W0Config.cpp b/src/platform/nxp/k32w0/K32W0Config.cpp index 2054ef5da619bf..ac68c1d5d7c761 100644 --- a/src/platform/nxp/k32w0/K32W0Config.cpp +++ b/src/platform/nxp/k32w0/K32W0Config.cpp @@ -64,6 +64,11 @@ const K32WConfig::Key K32WConfig::kConfigKey_UniqueId{ &K32WConfig::sConfigStora const K32WConfig::Key K32WConfig::kConfigKey_SoftwareVersion{ &K32WConfig::sConfigStorage, kKeyId_Config, 0x0B }; const K32WConfig::Key K32WConfig::kConfigKey_SoftwareUpdateCompleted{ &K32WConfig::sConfigStorage, kKeyId_Config, 0x0C }; +const K32WConfig::Key K32WConfig::kConfigKey_VendorName{ &K32WConfig::sConfigStorage, kKeyId_Config, 0x0D }; +const K32WConfig::Key K32WConfig::kConfigKey_ProductName{ &K32WConfig::sConfigStorage, kKeyId_Config, 0x0E }; +const K32WConfig::Key K32WConfig::kConfigKey_HardwareVersionString{ &K32WConfig::sConfigStorage, kKeyId_Config, 0x0F }; +const K32WConfig::Key K32WConfig::kConfigKey_SoftwareVersionString{ &K32WConfig::sConfigStorage, kKeyId_Config, 0x10 }; + const K32WConfig::Key K32WConfig::kCounterKey_RebootCount{ &K32WConfig::sCounterStorage, kKeyId_Counter, 0x00 }; const K32WConfig::Key K32WConfig::kCounterKey_UpTime{ &K32WConfig::sCounterStorage, kKeyId_Counter, 0x01 }; const K32WConfig::Key K32WConfig::kCounterKey_TotalOperationalHours{ &K32WConfig::sCounterStorage, kKeyId_Counter, 0x02 }; diff --git a/src/platform/nxp/k32w0/K32W0Config.h b/src/platform/nxp/k32w0/K32W0Config.h index 7080e62e747bf1..1a42ea4a60f21e 100644 --- a/src/platform/nxp/k32w0/K32W0Config.h +++ b/src/platform/nxp/k32w0/K32W0Config.h @@ -75,6 +75,11 @@ class K32WConfig static const Key kConfigKey_SoftwareVersion; static const Key kConfigKey_SoftwareUpdateCompleted; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + // CHIP Counter Keys static const Key kCounterKey_RebootCount; static const Key kCounterKey_UpTime; diff --git a/src/platform/nxp/mcxw71_k32w1/K32W1Config.h b/src/platform/nxp/mcxw71_k32w1/K32W1Config.h index ceeae82a8dc273..83f9508d93a2f2 100644 --- a/src/platform/nxp/mcxw71_k32w1/K32W1Config.h +++ b/src/platform/nxp/mcxw71_k32w1/K32W1Config.h @@ -92,6 +92,11 @@ class NXPConfig static constexpr Key kConfigKey_UniqueId = K32WConfigKey(kFileId_ChipConfig, 0x0A); static constexpr Key kConfigKey_SoftwareVersion = K32WConfigKey(kFileId_ChipConfig, 0x0B); + static constexpr Key kConfigKey_VendorName = K32WConfigKey(kFileId_ChipConfig, 0x0C); + static constexpr Key kConfigKey_ProductName = K32WConfigKey(kFileId_ChipConfig, 0x0D); + static constexpr Key kConfigKey_HardwareVersionString = K32WConfigKey(kFileId_ChipConfig, 0x0E); + static constexpr Key kConfigKey_SoftwareVersionString = K32WConfigKey(kFileId_ChipConfig, 0x0F); + // CHIP Counter Keys static constexpr Key kCounterKey_RebootCount = K32WConfigKey(kFileId_ChipCounter, 0x00); static constexpr Key kCounterKey_UpTime = K32WConfigKey(kFileId_ChipCounter, 0x01); diff --git a/src/platform/nxp/mw320/MW320Config.h b/src/platform/nxp/mw320/MW320Config.h index fbe66f66875061..8e7924667902eb 100644 --- a/src/platform/nxp/mw320/MW320Config.h +++ b/src/platform/nxp/mw320/MW320Config.h @@ -81,6 +81,11 @@ class MW320Config static constexpr Key kConfigKey_Spake2pSalt = ConfigKey(kFileId_ChipFactory, 0x0A); static constexpr Key kConfigKey_Spake2pVerifier = ConfigKey(kFileId_ChipFactory, 0x0B); + static constexpr Key kConfigKey_VendorName = ConfigKey(kFileId_ChipFactory, 0x0C); + static constexpr Key kConfigKey_ProductName = ConfigKey(kFileId_ChipFactory, 0x0D); + static constexpr Key kConfigKey_HardwareVersionString = ConfigKey(kFileId_ChipFactory, 0x0E); + static constexpr Key kConfigKey_SoftwareVersionString = ConfigKey(kFileId_ChipFactory, 0x0F); + // CHIP Config Keys static constexpr Key kConfigKey_FabricId = ConfigKey(kFileId_ChipConfig, 0x00); static constexpr Key kConfigKey_ServiceConfig = ConfigKey(kFileId_ChipConfig, 0x01); diff --git a/src/platform/openiotsdk/KVPsaPsStore.h b/src/platform/openiotsdk/KVPsaPsStore.h index acd3f695765650..297f6e24514f8a 100644 --- a/src/platform/openiotsdk/KVPsaPsStore.h +++ b/src/platform/openiotsdk/KVPsaPsStore.h @@ -89,6 +89,11 @@ class KVPsaPsStore static const Key kConfigKey_VendorId; static const Key kConfigKey_ProductId; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + // Config Keys static const Key kConfigKey_ServiceConfig; static const Key kConfigKey_PairedAccountId; diff --git a/src/platform/qpg/qpgConfig.h b/src/platform/qpg/qpgConfig.h index bc3e943926f7b5..47867112b5319c 100644 --- a/src/platform/qpg/qpgConfig.h +++ b/src/platform/qpg/qpgConfig.h @@ -76,6 +76,11 @@ class QPGConfig static constexpr Key kConfigKey_Spake2pSalt = QorvoConfigKey(kFileId_ChipFactory, 0x09); static constexpr Key kConfigKey_Spake2pVerifier = QorvoConfigKey(kFileId_ChipFactory, 0x0A); + static constexpr Key kConfigKey_VendorName = QorvoConfigKey(kFileId_ChipFactory, 0x0B); + static constexpr Key kConfigKey_ProductName = QorvoConfigKey(kFileId_ChipFactory, 0x0C); + static constexpr Key kConfigKey_HardwareVersionString = QorvoConfigKey(kFileId_ChipFactory, 0x0D); + static constexpr Key kConfigKey_SoftwareVersionString = QorvoConfigKey(kFileId_ChipFactory, 0x0E); + static constexpr Key kConfigKey_ServiceConfig = QorvoConfigKey(kFileId_ChipConfig, 0x01); static constexpr Key kConfigKey_PairedAccountId = QorvoConfigKey(kFileId_ChipConfig, 0x02); static constexpr Key kConfigKey_ServiceId = QorvoConfigKey(kFileId_ChipConfig, 0x03); diff --git a/src/platform/silabs/SilabsConfig.h b/src/platform/silabs/SilabsConfig.h index cef9ca323f74d2..5bcb80fd00bb54 100644 --- a/src/platform/silabs/SilabsConfig.h +++ b/src/platform/silabs/SilabsConfig.h @@ -132,7 +132,8 @@ class SilabsConfig static constexpr Key kConfigKey_Provision_Request = SilabsConfigKey(kMatterFactory_KeyBase, 0x28); static constexpr Key kConfigKey_Provision_Version = SilabsConfigKey(kMatterFactory_KeyBase, 0x29); - static constexpr Key kOtaTlvEncryption_KeyId = SilabsConfigKey(kMatterFactory_KeyBase, 0x30); + static constexpr Key kOtaTlvEncryption_KeyId = SilabsConfigKey(kMatterFactory_KeyBase, 0x30); + static constexpr Key kConfigKey_SoftwareVersionString = SilabsConfigKey(kMatterFactory_KeyBase, 0x31); // Matter Config Keys static constexpr Key kConfigKey_ServiceConfig = SilabsConfigKey(kMatterConfig_KeyBase, 0x01); diff --git a/src/platform/tests/TestConfigurationMgr.cpp b/src/platform/tests/TestConfigurationMgr.cpp index 36530dfccc3373..139569eb79cd83 100644 --- a/src/platform/tests/TestConfigurationMgr.cpp +++ b/src/platform/tests/TestConfigurationMgr.cpp @@ -83,20 +83,18 @@ TEST_F(TestConfigurationMgr, SerialNumber) CHIP_ERROR err = CHIP_NO_ERROR; char buf[64]; - const char * serialNumber = "89051AAZZ236"; - chip::Span serial_number(serialNumber.Value().c_str(), serialNumber.Value().size()); + CharSpan serialNumber = "89051AAZZ236"_span; - err = ConfigurationMgr().StoreSerialNumber(serial_number); + err = ConfigurationMgr().StoreSerialNumber(serialNumber); EXPECT_EQ(err, CHIP_NO_ERROR); err = GetDeviceInstanceInfoProvider()->GetSerialNumber(buf, 64); EXPECT_EQ(err, CHIP_NO_ERROR); EXPECT_EQ(strlen(buf), 12u); - EXPECT_STREQ(buf, serialNumber); + EXPECT_STREQ(buf, serialNumber.data()); - chip::Span serial_number(serialNumber.Value().c_str(), 5); - err = ConfigurationMgr().StoreSerialNumber(serial_number); + err = ConfigurationMgr().StoreSerialNumber(serialNumber.SubSpan(5)); EXPECT_EQ(err, CHIP_NO_ERROR); err = GetDeviceInstanceInfoProvider()->GetSerialNumber(buf, 64); From 2bf83ef0682c4e0fbf589d235645a072656fba2d Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Mon, 8 Jul 2024 14:21:05 -0700 Subject: [PATCH 17/32] add the new config params to different platforms --- src/platform/ASR/ASRConfig.cpp | 5 +++++ src/platform/Ameba/AmebaConfig.cpp | 5 +++++ src/platform/Beken/BekenConfig.cpp | 5 +++++ src/platform/ESP32/ESP32Config.cpp | 2 ++ src/platform/ESP32/ESP32Config.h | 2 ++ src/platform/Infineon/PSOC6/PSOC6Config.cpp | 9 +++++++++ src/platform/NuttX/PosixConfig.cpp | 5 +++++ src/platform/NuttX/PosixConfig.h | 5 +++++ src/platform/Tizen/PosixConfig.cpp | 9 +++++++++ src/platform/Tizen/PosixConfig.h | 5 +++++ src/platform/bouffalolab/common/BLConfig.h | 8 ++++---- src/platform/cc13xx_26xx/CC13XX_26XXConfig.cpp | 12 ++++++++++++ src/platform/cc32xx/CC32XXConfig.cpp | 5 +++++ src/platform/mbed/MbedConfig.cpp | 10 ++++++++++ src/platform/mt793x/MT793XConfig.cpp | 8 ++++++++ src/platform/mt793x/MT793XConfig.h | 5 +++++ src/platform/stm32/STM32Config.h | 6 ++++++ src/platform/webos/PosixConfig.cpp | 5 +++++ src/platform/webos/PosixConfig.h | 5 +++++ 19 files changed, 112 insertions(+), 4 deletions(-) diff --git a/src/platform/ASR/ASRConfig.cpp b/src/platform/ASR/ASRConfig.cpp index 1e87f3af518804..2a07f631384a29 100644 --- a/src/platform/ASR/ASRConfig.cpp +++ b/src/platform/ASR/ASRConfig.cpp @@ -80,6 +80,11 @@ const ASRConfig::Key ASRConfig::kConfigKey_WiFiSecurity = { kConfigNamespa const ASRConfig::Key ASRConfig::kConfigKey_WiFiMode = { kConfigNamespace_ChipConfig, "wifimode" }; const ASRConfig::Key ASRConfig::kConfigKey_UniqueId = { kConfigNamespace_ChipConfig, "unique-id" }; +const ASRConfig::Key ASRConfig::kConfigKey_VendorName = { kConfigNamespace_ChipConfig, "vendor-name" }; +const ASRConfig::Key ASRConfig::kConfigKey_ProductName = { kConfigNamespace_ChipConfig, "product-name" }; +const ASRConfig::Key ASRConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipConfig, "hardware-version-string" }; +const ASRConfig::Key ASRConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipConfig, "software-version-string" }; + // Keys stored in the Chip-counters namespace const ASRConfig::Key ASRConfig::kCounterKey_RebootCount = { kConfigNamespace_ChipCounters, "reboot-count" }; const ASRConfig::Key ASRConfig::kCounterKey_UpTime = { kConfigNamespace_ChipCounters, "up-time" }; diff --git a/src/platform/Ameba/AmebaConfig.cpp b/src/platform/Ameba/AmebaConfig.cpp index 6ac7948da07794..c59221ddbcf710 100644 --- a/src/platform/Ameba/AmebaConfig.cpp +++ b/src/platform/Ameba/AmebaConfig.cpp @@ -79,6 +79,11 @@ const AmebaConfig::Key AmebaConfig::kConfigKey_RegulatoryLocation = { k const AmebaConfig::Key AmebaConfig::kConfigKey_LocationCapability = { kConfigNamespace_ChipConfig, "location-capability" }; const AmebaConfig::Key AmebaConfig::kConfigKey_CountryCode = { kConfigNamespace_ChipConfig, "country-code" }; +const AmebaConfig::Key AmebaConfig::kConfigKey_VendorName = { kConfigNamespace_ChipConfig, "vendor-name" }; +const AmebaConfig::Key AmebaConfig::kConfigKey_ProductName = { kConfigNamespace_ChipConfig, "product-name" }; +const AmebaConfig::Key AmebaConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipConfig, "hardware-version-string" }; +const AmebaConfig::Key AmebaConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipConfig, "software-version-string" }; + // Keys stored in the Chip-counters namespace const AmebaConfig::Key AmebaConfig::kCounterKey_RebootCount = { kConfigNamespace_ChipCounters, "reboot-count" }; const AmebaConfig::Key AmebaConfig::kCounterKey_UpTime = { kConfigNamespace_ChipCounters, "up-time" }; diff --git a/src/platform/Beken/BekenConfig.cpp b/src/platform/Beken/BekenConfig.cpp index 60e2cdb09645f7..593001f9c8c73e 100644 --- a/src/platform/Beken/BekenConfig.cpp +++ b/src/platform/Beken/BekenConfig.cpp @@ -79,6 +79,11 @@ const BekenConfig::Key BekenConfig::kConfigKey_RegulatoryLocation = { k const BekenConfig::Key BekenConfig::kConfigKey_CountryCode = { kConfigNamespace_ChipConfig, "country-code" }; const BekenConfig::Key BekenConfig::kConfigKey_Breadcrumb = { kConfigNamespace_ChipConfig, "breadcrumb" }; +const BekenConfig::Key BekenConfig::kConfigKey_VendorName = { kConfigNamespace_ChipConfig, "vendor-name" }; +const BekenConfig::Key BekenConfig::kConfigKey_ProductName = { kConfigNamespace_ChipConfig, "product-name" }; +const BekenConfig::Key BekenConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipConfig, "hardware-version-string" }; +const BekenConfig::Key BekenConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipConfig, "software-version-string" }; + // Keys stored in the Chip-counters namespace const BekenConfig::Key BekenConfig::kCounterKey_RebootCount = { kConfigNamespace_ChipCounters, "reboot-count" }; const BekenConfig::Key BekenConfig::kCounterKey_UpTime = { kConfigNamespace_ChipCounters, "up-time" }; diff --git a/src/platform/ESP32/ESP32Config.cpp b/src/platform/ESP32/ESP32Config.cpp index df48f5f2955793..1d4528ad00584e 100644 --- a/src/platform/ESP32/ESP32Config.cpp +++ b/src/platform/ESP32/ESP32Config.cpp @@ -101,6 +101,8 @@ const ESP32Config::Key ESP32Config::kConfigKey_WeekDaySchedules = { kConfigNam const ESP32Config::Key ESP32Config::kConfigKey_YearDaySchedules = { kConfigNamespace_ChipConfig, "year-day-sched" }; const ESP32Config::Key ESP32Config::kConfigKey_HolidaySchedules = { kConfigNamespace_ChipConfig, "holiday-sched" }; +const ESP32Config::Key ESP32Config::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipConfig, "sw-ver-str" }; + // Keys stored in the Chip-counters namespace const ESP32Config::Key ESP32Config::kCounterKey_RebootCount = { kConfigNamespace_ChipCounters, "reboot-count" }; const ESP32Config::Key ESP32Config::kCounterKey_UpTime = { kConfigNamespace_ChipCounters, "up-time" }; diff --git a/src/platform/ESP32/ESP32Config.h b/src/platform/ESP32/ESP32Config.h index f2f03cf7f9074b..c3e7a26bf15792 100644 --- a/src/platform/ESP32/ESP32Config.h +++ b/src/platform/ESP32/ESP32Config.h @@ -103,6 +103,8 @@ class ESP32Config static const Key kConfigKey_YearDaySchedules; static const Key kConfigKey_HolidaySchedules; + static const Key kConfigKey_SoftwareVersionString; + // CHIP Counter keys static const Key kCounterKey_RebootCount; static const Key kCounterKey_UpTime; diff --git a/src/platform/Infineon/PSOC6/PSOC6Config.cpp b/src/platform/Infineon/PSOC6/PSOC6Config.cpp index 1c040811686fa3..37ae030559a38a 100644 --- a/src/platform/Infineon/PSOC6/PSOC6Config.cpp +++ b/src/platform/Infineon/PSOC6/PSOC6Config.cpp @@ -88,6 +88,15 @@ const PSOC6Config::Key PSOC6Config::kConfigKey_YearDaySchedules = { kConfigNames const PSOC6Config::Key PSOC6Config::kConfigKey_HolidaySchedules = { kConfigNamespace_ChipConfig, "holiday-schedules" }; ; +const P6Config::Key P6Config::kConfigKey_VendorName = { kConfigNamespace_ChipConfig, "vendor-name" }; +; +const P6Config::Key P6Config::kConfigKey_ProductName = { kConfigNamespace_ChipConfig, "product-name" }; +; +const P6Config::Key P6Config::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipConfig, "hardware-version-string" }; +; +const P6Config::Key P6Config::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipConfig, "software-version-string" }; +; + // Keys stored in the Chip-counters namespace const PSOC6Config::Key PSOC6Config::kCounterKey_RebootCount = { kConfigNamespace_ChipCounters, "reboot-count" }; const PSOC6Config::Key PSOC6Config::kCounterKey_UpTime = { kConfigNamespace_ChipCounters, "up-time" }; diff --git a/src/platform/NuttX/PosixConfig.cpp b/src/platform/NuttX/PosixConfig.cpp index 8e8feda20de202..d357ff24e363e2 100644 --- a/src/platform/NuttX/PosixConfig.cpp +++ b/src/platform/NuttX/PosixConfig.cpp @@ -74,6 +74,11 @@ const PosixConfig::Key PosixConfig::kConfigKey_CountryCode = { kConfigNam const PosixConfig::Key PosixConfig::kConfigKey_LocationCapability = { kConfigNamespace_ChipConfig, "location-capability" }; const PosixConfig::Key PosixConfig::kConfigKey_UniqueId = { kConfigNamespace_ChipFactory, "unique-id" }; +const PosixConfig::Key PosixConfig::kConfigKey_VendorName = { kConfigNamespace_ChipFactory, "vendor-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_ProductName = { kConfigNamespace_ChipFactory, "product-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipFactory, "hardware-version-string" }; +const PosixConfig::Key PosixConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipFactory, "software-version-string" }; + // Keys stored in the Chip-counters namespace const PosixConfig::Key PosixConfig::kCounterKey_RebootCount = { kConfigNamespace_ChipCounters, "reboot-count" }; const PosixConfig::Key PosixConfig::kCounterKey_UpTime = { kConfigNamespace_ChipCounters, "up-time" }; diff --git a/src/platform/NuttX/PosixConfig.h b/src/platform/NuttX/PosixConfig.h index c04d4a9be1093f..d0594cf69ed788 100644 --- a/src/platform/NuttX/PosixConfig.h +++ b/src/platform/NuttX/PosixConfig.h @@ -78,6 +78,11 @@ class PosixConfig static const Key kConfigKey_VendorId; static const Key kConfigKey_ProductId; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + 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 e6f18834ef6396..9b10ade642422e 100644 --- a/src/platform/Tizen/PosixConfig.cpp +++ b/src/platform/Tizen/PosixConfig.cpp @@ -66,6 +66,15 @@ const PosixConfig::Key PosixConfig::kConfigKey_RegulatoryLocation = { kConfigNam const PosixConfig::Key PosixConfig::kConfigKey_CountryCode = { kConfigNamespace_ChipConfig, "country-code" }; const PosixConfig::Key PosixConfig::kConfigKey_UniqueId = { kConfigNamespace_ChipConfig, "unique-id" }; +const PosixConfig::Key PosixConfig::kConfigKey_VendorName = { kConfigNamespace_ChipConfig, "vendor-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_ProductName = { kConfigNamespace_ChipConfig, "product-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipConfig, "hardware-version-string" }; +const PosixConfig::Key PosixConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipConfig, "software-version-string" }; + +static const Key kConfigKey_; +static const Key kConfigKey_; +static const Key kConfigKey_; +static const Key kConfigKey_; // Keys stored in the Chip-counters namespace const PosixConfig::Key PosixConfig::kCounterKey_TotalOperationalHours = { kConfigNamespace_ChipCounters, "total-operational-hours" }; diff --git a/src/platform/Tizen/PosixConfig.h b/src/platform/Tizen/PosixConfig.h index a5d8d6a6a8d45d..68353b2b4131ca 100644 --- a/src/platform/Tizen/PosixConfig.h +++ b/src/platform/Tizen/PosixConfig.h @@ -75,6 +75,11 @@ class PosixConfig static const Key kConfigKey_VendorId; static const Key kConfigKey_ProductId; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + static const Key kCounterKey_TotalOperationalHours; static const Key kCounterKey_BootReason; diff --git a/src/platform/bouffalolab/common/BLConfig.h b/src/platform/bouffalolab/common/BLConfig.h index c665273a6ce349..7f9885731b2136 100644 --- a/src/platform/bouffalolab/common/BLConfig.h +++ b/src/platform/bouffalolab/common/BLConfig.h @@ -77,10 +77,10 @@ class BLConfig static constexpr char kBLKey_factoryResetFlag[] = ("__factory_reset_pending"); - static const Key kConfigKey_VendorName; - static const Key kConfigKey_ProductName; - static const Key kConfigKey_HardwareVersionString; - static const Key kConfigKey_SoftwareVersionString; + static constexpr char kConfigKey_VendorName[] = ("vendor-name"); + static constexpr char kConfigKey_ProductName[] = ("product-name"); + static constexpr char kConfigKey_HardwareVersionString[] = ("hardware-version-string"); + static constexpr char kConfigKey_SoftwareVersionString[] = ("software-version-string"); static void Init(void); diff --git a/src/platform/cc13xx_26xx/CC13XX_26XXConfig.cpp b/src/platform/cc13xx_26xx/CC13XX_26XXConfig.cpp index b4ea1ec2924378..d983b3b19ea6e7 100644 --- a/src/platform/cc13xx_26xx/CC13XX_26XXConfig.cpp +++ b/src/platform/cc13xx_26xx/CC13XX_26XXConfig.cpp @@ -123,6 +123,18 @@ const CC13XX_26XXConfig::Key CC13XX_26XXConfig::kConfigKey_UniqueId = { { .systemID = kCC13XX_26XXMatter_SysID, .itemID = kCC13XX_26XXMatter_ItemID_ChipConfig, .subID = 0x0001d } }; +const CC13XX_26XXConfig::Key CC13XX_26XXConfig::kConfigKey_VendorName = { + { .systemID = kCC13XX_26XXMatter_SysID, .itemID = kCC13XX_26XXMatter_ItemID_ChipConfig, .subID = 0x0001e } +}; +const CC13XX_26XXConfig::Key CC13XX_26XXConfig::kConfigKey_ProductName = { + { .systemID = kCC13XX_26XXMatter_SysID, .itemID = kCC13XX_26XXMatter_ItemID_ChipConfig, .subID = 0x0001f } +}; +const CC13XX_26XXConfig::Key CC13XX_26XXConfig::kConfigKey_HardwareVersionString = { + { .systemID = kCC13XX_26XXMatter_SysID, .itemID = kCC13XX_26XXMatter_ItemID_ChipConfig, .subID = 0x00020 } +}; +const CC13XX_26XXConfig::Key CC13XX_26XXConfig::kConfigKey_SoftwareVersionString = { + { .systemID = kCC13XX_26XXMatter_SysID, .itemID = kCC13XX_26XXMatter_ItemID_ChipConfig, .subID = 0x00021 } +}; /* Internal for the KVS interface. */ const CC13XX_26XXConfig::Key CC13XX_26XXConfig::kConfigKey_KVS_key = { { .systemID = kCC13XX_26XXMatter_SysID, .itemID = kCC13XX_26XXMatter_ItemID_ChipKVS_key } }; diff --git a/src/platform/cc32xx/CC32XXConfig.cpp b/src/platform/cc32xx/CC32XXConfig.cpp index 7eace22b7dbc5e..1dcfc9f37ef43a 100644 --- a/src/platform/cc32xx/CC32XXConfig.cpp +++ b/src/platform/cc32xx/CC32XXConfig.cpp @@ -318,6 +318,11 @@ const CC32XXConfig::Key CC32XXConfig::kConfigKey_Spake2pIterationCount = { "TI_k const CC32XXConfig::Key CC32XXConfig::kConfigKey_Spake2pSalt = { "TI_kConfigKey_Spake2pSalt" }; const CC32XXConfig::Key CC32XXConfig::kConfigKey_Spake2pVerifier = { "TI_kConfigKey_Spake2pVerifier" }; +const CC32XXConfig::Key CC32XXConfig::kConfigKey_VendorName = { "TI_kConfigKey_VendorName" }; +const CC32XXConfig::Key CC32XXConfig::kConfigKey_ProductName = { "TI_kConfigKey_ProductName" }; +const CC32XXConfig::Key CC32XXConfig::kConfigKey_HardwareVersionString = { "TI_kConfigKey_HardwareVersionString" }; +const CC32XXConfig::Key CC32XXConfig::kConfigKey_SoftwareVersionString = { "TI_kConfigKey_SoftwareVersionString" }; + CC32XXKVSList * pList; CHIP_ERROR CC32XXConfig::Init() diff --git a/src/platform/mbed/MbedConfig.cpp b/src/platform/mbed/MbedConfig.cpp index 63d5f87295c145..df7d569547c5ab 100644 --- a/src/platform/mbed/MbedConfig.cpp +++ b/src/platform/mbed/MbedConfig.cpp @@ -85,6 +85,16 @@ const MbedConfig::Key MbedConfig::kConfigKey_RegulatoryLocation = { CONFIG_KEY(" const MbedConfig::Key MbedConfig::kConfigKey_CountryCode = { CONFIG_KEY("country-code") }; const MbedConfig::Key MbedConfig::kConfigKey_UniqueId = { CONFIG_KEY("unique-id") }; +const MbedConfig::Key MbedConfig::kConfigKey_VendorName = { CONFIG_KEY("vendor-name") }; +const MbedConfig::Key MbedConfig::kConfigKey_ProductName = { CONFIG_KEY("product-name") }; +const MbedConfig::Key MbedConfig::kConfigKey_HardwareVersionString = { CONFIG_KEY("hardware-version-string") }; +const MbedConfig::Key MbedConfig::kConfigKey_SoftwareVersionString = { CONFIG_KEY("software-version-string") }; + +static const Key kConfigKey_; +static const Key kConfigKey_; +static const Key kConfigKey_; +static const Key kConfigKey_; + // Keys stored in the Chip-counters namespace const MbedConfig::Key MbedConfig::kCounterKey_RebootCount = { COUNTER_KEY("reboot-count") }; const MbedConfig::Key MbedConfig::kCounterKey_UpTime = { COUNTER_KEY("up-time") }; diff --git a/src/platform/mt793x/MT793XConfig.cpp b/src/platform/mt793x/MT793XConfig.cpp index a524315657a762..12b303f93b1bc1 100644 --- a/src/platform/mt793x/MT793XConfig.cpp +++ b/src/platform/mt793x/MT793XConfig.cpp @@ -100,6 +100,14 @@ const MT793XConfig::Key MT793XConfig::kConfigKey_YearDaySchedules = { .Namespace .Name = "yearday-sched" }; const MT793XConfig::Key MT793XConfig::kConfigKey_HolidaySchedules = { .Namespace = kConfigNamespace_ChipConfig, .Name = "holiday-sched" }; + +const MT793XConfig::Key MT793XConfig::kConfigKey_VendorName = { .Namespace = kConfigNamespace_ChipConfig, .Name = "vendor-name" }; +const MT793XConfig::Key MT793XConfig::kConfigKey_ProductName = { .Namespace = kConfigNamespace_ChipConfig, .Name = "product-name" }; +const MT793XConfig::Key MT793XConfig::kConfigKey_HardwareVersionString = { .Namespace = kConfigNamespace_ChipConfig, + .Name = "hardware-version-string" }; +const MT793XConfig::Key MT793XConfig::kConfigKey_SoftwareVersionString = { .Namespace = kConfigNamespace_ChipConfig, + .Name = "software-version-string" }; + // CHIP Counter Keys const MT793XConfig::Key MT793XConfig::kConfigKey_BootCount = { .Namespace = kConfigNamespace_ChipCounters, .Name = "boot-count" }; const MT793XConfig::Key MT793XConfig::kConfigKey_TotalOperationalHours = { .Namespace = kConfigNamespace_ChipCounters, diff --git a/src/platform/mt793x/MT793XConfig.h b/src/platform/mt793x/MT793XConfig.h index 33358d4d064f4a..8e922f47265999 100644 --- a/src/platform/mt793x/MT793XConfig.h +++ b/src/platform/mt793x/MT793XConfig.h @@ -101,6 +101,11 @@ class MT793XConfig static const Key kConfigKey_WeekDaySchedules; static const Key kConfigKey_YearDaySchedules; static const Key kConfigKey_HolidaySchedules; + + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; // CHIP Counter Keys static const Key kConfigKey_BootCount; static const Key kConfigKey_TotalOperationalHours; diff --git a/src/platform/stm32/STM32Config.h b/src/platform/stm32/STM32Config.h index f1df1dc7638861..2d1d38261f4e13 100644 --- a/src/platform/stm32/STM32Config.h +++ b/src/platform/stm32/STM32Config.h @@ -67,6 +67,12 @@ class STM32Config static constexpr Key kConfigKey_Breadcrumb = 22; static constexpr Key kConfigKey_UniqueId = 23; static constexpr Key kConfigKey_ProductRevision = 24; + + static constexpr Key kConfigKey_VendorName = 25; + static constexpr Key kConfigKey_ProductName = 26; + static constexpr Key kConfigKey_HardwareVersionString = 27; + static constexpr Key kConfigKey_SoftwareVersionString = 28; + // Set key id limits for each group. static constexpr Key kConfigKey_Base = kConfigKey_SerialNum; static constexpr Key kConfigKey_Max = kConfigKey_UniqueId; diff --git a/src/platform/webos/PosixConfig.cpp b/src/platform/webos/PosixConfig.cpp index 79cbd2e0eaa49b..5675bf6bba7ffe 100644 --- a/src/platform/webos/PosixConfig.cpp +++ b/src/platform/webos/PosixConfig.cpp @@ -78,6 +78,11 @@ const PosixConfig::Key PosixConfig::kConfigKey_Breadcrumb = { kConfigNam const PosixConfig::Key PosixConfig::kConfigKey_LocationCapability = { kConfigNamespace_ChipConfig, "location-capability" }; const PosixConfig::Key PosixConfig::kConfigKey_UniqueId = { kConfigNamespace_ChipFactory, "unique-id" }; +const PosixConfig::Key PosixConfig::kConfigKey_VendorName = { kConfigNamespace_ChipFactory, "vendor-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_ProductName = { kConfigNamespace_ChipFactory, "product-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipFactory, "hardware-version-string" }; +const PosixConfig::Key PosixConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipFactory, "software-version-string" }; + // Keys stored in the Chip-counters namespace const PosixConfig::Key PosixConfig::kCounterKey_RebootCount = { kConfigNamespace_ChipCounters, "reboot-count" }; const PosixConfig::Key PosixConfig::kCounterKey_UpTime = { kConfigNamespace_ChipCounters, "up-time" }; diff --git a/src/platform/webos/PosixConfig.h b/src/platform/webos/PosixConfig.h index 8835bd04c60310..e948f381f6cab5 100644 --- a/src/platform/webos/PosixConfig.h +++ b/src/platform/webos/PosixConfig.h @@ -82,6 +82,11 @@ class PosixConfig static const Key kConfigKey_VendorId; static const Key kConfigKey_ProductId; + static const Key kConfigKey_VendorName; + static const Key kConfigKey_ProductName; + static const Key kConfigKey_HardwareVersionString; + static const Key kConfigKey_SoftwareVersionString; + static const Key kCounterKey_RebootCount; static const Key kCounterKey_UpTime; static const Key kCounterKey_TotalOperationalHours; From 4268b10ccbf323d6081a20284e7f0fb0a0c885f3 Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Mon, 8 Jul 2024 16:33:23 -0700 Subject: [PATCH 18/32] fix compilation errors --- src/platform/Infineon/CYW30739/CYW30739Config.h | 2 ++ src/platform/Tizen/PosixConfig.cpp | 4 ---- src/platform/android/AndroidConfig.cpp | 1 + src/platform/android/AndroidConfig.h | 2 ++ src/platform/mbed/MbedConfig.cpp | 5 ----- src/platform/openiotsdk/KVPsaPsStore.cpp | 5 +++++ src/platform/tests/TestConfigurationMgr.cpp | 4 ++-- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/platform/Infineon/CYW30739/CYW30739Config.h b/src/platform/Infineon/CYW30739/CYW30739Config.h index 24b074689d0ecf..47079943908b2a 100644 --- a/src/platform/Infineon/CYW30739/CYW30739Config.h +++ b/src/platform/Infineon/CYW30739/CYW30739Config.h @@ -71,6 +71,8 @@ class CYW30739Config static constexpr Key kConfigKey_DACKey = CYW30739ConfigKey(kChipFactory_KeyBase, 0x21); static constexpr Key kConfigKey_PAICert = CYW30739ConfigKey(kChipFactory_KeyBase, 0x22); static constexpr Key kConfigKey_CertDeclaration = CYW30739ConfigKey(kChipFactory_KeyBase, 0x23); + static constexpr Key kConfigKey_SoftwareVersionString = CYW30739ConfigKey(kChipFactory_KeyBase, 0x24); + // CHIP Config Keys static constexpr Key kConfigKey_ServiceConfig = CYW30739ConfigKey(kChipConfig_KeyBase, 0x00); static constexpr Key kConfigKey_PairedAccountId = CYW30739ConfigKey(kChipConfig_KeyBase, 0x01); diff --git a/src/platform/Tizen/PosixConfig.cpp b/src/platform/Tizen/PosixConfig.cpp index 9b10ade642422e..046d40a9c7a303 100644 --- a/src/platform/Tizen/PosixConfig.cpp +++ b/src/platform/Tizen/PosixConfig.cpp @@ -71,10 +71,6 @@ const PosixConfig::Key PosixConfig::kConfigKey_ProductName = { kConfig const PosixConfig::Key PosixConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipConfig, "hardware-version-string" }; const PosixConfig::Key PosixConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipConfig, "software-version-string" }; -static const Key kConfigKey_; -static const Key kConfigKey_; -static const Key kConfigKey_; -static const Key kConfigKey_; // Keys stored in the Chip-counters namespace const PosixConfig::Key PosixConfig::kCounterKey_TotalOperationalHours = { kConfigNamespace_ChipCounters, "total-operational-hours" }; diff --git a/src/platform/android/AndroidConfig.cpp b/src/platform/android/AndroidConfig.cpp index afca2b43f3e96b..4ee83f18bec90a 100644 --- a/src/platform/android/AndroidConfig.cpp +++ b/src/platform/android/AndroidConfig.cpp @@ -82,6 +82,7 @@ const AndroidConfig::Key AndroidConfig::kConfigKey_Spake2pSalt = { kCo const AndroidConfig::Key AndroidConfig::kConfigKey_Spake2pVerifier = { kConfigNamespace_ChipFactory, "verifier" }; const AndroidConfig::Key AndroidConfig::kConfigKey_DeviceTypeId = { kConfigNamespace_ChipFactory, "device-type-id" }; const AndroidConfig::Key AndroidConfig::kConfigKey_DeviceName = { kConfigNamespace_ChipFactory, "device-name" }; +const AndroidConfig::Key AndroidConfig::kConfigKey_VendorName = { kConfigNamespace_ChipFactory, "vendor-name" }; // Keys stored in the Chip-config namespace const AndroidConfig::Key AndroidConfig::kConfigKey_ServiceConfig = { kConfigNamespace_ChipConfig, "service-config" }; diff --git a/src/platform/android/AndroidConfig.h b/src/platform/android/AndroidConfig.h index 507a2b62e87da8..4d3d03638943e4 100644 --- a/src/platform/android/AndroidConfig.h +++ b/src/platform/android/AndroidConfig.h @@ -84,6 +84,8 @@ class AndroidConfig static const Key kConfigKey_DeviceTypeId; static const Key kConfigKey_DeviceName; + static const Key kConfigKey_VendorName; + static CHIP_ERROR Init(); // Config value accessors. diff --git a/src/platform/mbed/MbedConfig.cpp b/src/platform/mbed/MbedConfig.cpp index df7d569547c5ab..39ddacea059a29 100644 --- a/src/platform/mbed/MbedConfig.cpp +++ b/src/platform/mbed/MbedConfig.cpp @@ -90,11 +90,6 @@ const MbedConfig::Key MbedConfig::kConfigKey_ProductName = { CONFIG_KE const MbedConfig::Key MbedConfig::kConfigKey_HardwareVersionString = { CONFIG_KEY("hardware-version-string") }; const MbedConfig::Key MbedConfig::kConfigKey_SoftwareVersionString = { CONFIG_KEY("software-version-string") }; -static const Key kConfigKey_; -static const Key kConfigKey_; -static const Key kConfigKey_; -static const Key kConfigKey_; - // Keys stored in the Chip-counters namespace const MbedConfig::Key MbedConfig::kCounterKey_RebootCount = { COUNTER_KEY("reboot-count") }; const MbedConfig::Key MbedConfig::kCounterKey_UpTime = { COUNTER_KEY("up-time") }; diff --git a/src/platform/openiotsdk/KVPsaPsStore.cpp b/src/platform/openiotsdk/KVPsaPsStore.cpp index 26215bf2e4431a..88083c37372abe 100644 --- a/src/platform/openiotsdk/KVPsaPsStore.cpp +++ b/src/platform/openiotsdk/KVPsaPsStore.cpp @@ -67,6 +67,11 @@ const KVPsaPsStore::Key KVPsaPsStore::kConfigKey_CountryCode = GetPsaPaKe const KVPsaPsStore::Key KVPsaPsStore::kConfigKey_LocationCapability = GetPsaPaKey(kMatterConfig_KeyOffset, 0x08); const KVPsaPsStore::Key KVPsaPsStore::kConfigKey_UniqueId = GetPsaPaKey(kMatterConfig_KeyOffset, 0x09); +const KVPsaPsStore::Key KVPsaPsStore::kConfigKey_VendorName = GetPsaPaKey(kMatterConfig_KeyOffset, 0x0A); +const KVPsaPsStore::Key KVPsaPsStore::kConfigKey_ProductName = GetPsaPaKey(kMatterConfig_KeyOffset, 0x0B); +const KVPsaPsStore::Key KVPsaPsStore::kConfigKey_HardwareVersionString = GetPsaPaKey(kMatterConfig_KeyOffset, 0x0C); +const KVPsaPsStore::Key KVPsaPsStore::kConfigKey_SoftwareVersionString = GetPsaPaKey(kMatterConfig_KeyOffset, 0x0D); + // Keys stored in the Matter counters group const KVPsaPsStore::Key KVPsaPsStore::kCounterKey_RebootCount = GetPsaPaKey(kMatterCounter_KeyOffset, 0x00); const KVPsaPsStore::Key KVPsaPsStore::kCounterKey_UpTime = GetPsaPaKey(kMatterCounter_KeyOffset, 0x01); diff --git a/src/platform/tests/TestConfigurationMgr.cpp b/src/platform/tests/TestConfigurationMgr.cpp index 139569eb79cd83..43c55efd786e7b 100644 --- a/src/platform/tests/TestConfigurationMgr.cpp +++ b/src/platform/tests/TestConfigurationMgr.cpp @@ -100,8 +100,8 @@ TEST_F(TestConfigurationMgr, SerialNumber) err = GetDeviceInstanceInfoProvider()->GetSerialNumber(buf, 64); EXPECT_EQ(err, CHIP_NO_ERROR); - EXPECT_EQ(strlen(buf), 5u); - EXPECT_STREQ(buf, "89051"); + EXPECT_EQ(strlen(buf), 7u); + EXPECT_STREQ(buf, "AAZZ236"); } TEST_F(TestConfigurationMgr, UniqueId) From 2242d54283a240c3644aba5fdb10808b06dd1903 Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Tue, 9 Jul 2024 11:11:47 -0700 Subject: [PATCH 19/32] updated command line arg comments --- examples/platform/linux/Options.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/platform/linux/Options.cpp b/examples/platform/linux/Options.cpp index e0afe54b0a0201..f39d115f2f841b 100644 --- a/examples/platform/linux/Options.cpp +++ b/examples/platform/linux/Options.cpp @@ -251,10 +251,10 @@ const char * sDeviceOptionHelp = " The product name specified by vendor.\n" "\n" " --hardware-version-string \n" - " The HardwareVersionString to use in the basic information cluster.\n" + " The HardwareVersionString used in the basic information cluster.\n" "\n" " --software-version-string \n" - " The SoftwareVersionString to use in the basic information cluster.\n" + " The SoftwareVersionString used in the basic information cluster.\n" "\n" " --serial-number \n" " The serial number specified by vendor.\n" From 9fcc3432221580dafa5a02b4b7f99614277f3ceb Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Tue, 9 Jul 2024 21:53:35 -0700 Subject: [PATCH 20/32] fix fake and tizen platform test errors --- .../Tizen/DeviceInstanceInfoProviderImpl.cpp | 12 ++++++++++++ src/platform/Tizen/DeviceInstanceInfoProviderImpl.h | 2 ++ src/platform/fake/ConfigurationManagerImpl.h | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/src/platform/Tizen/DeviceInstanceInfoProviderImpl.cpp b/src/platform/Tizen/DeviceInstanceInfoProviderImpl.cpp index 93ad7a18015762..022e40a0f491d5 100644 --- a/src/platform/Tizen/DeviceInstanceInfoProviderImpl.cpp +++ b/src/platform/Tizen/DeviceInstanceInfoProviderImpl.cpp @@ -33,5 +33,17 @@ CHIP_ERROR DeviceInstanceInfoProviderImpl::GetProductId(uint16_t & productId) return Internal::PosixConfig::ReadConfigValue(Internal::PosixConfig::kConfigKey_ProductId, productId); } +CHIP_ERROR DeviceInstanceInfoProviderImpl::GetVendorName(char * buf, size_t bufSize) +{ + size_t vendorNameLen = 0; + return Internal::PosixConfig::ReadConfigValueStr(Internal::PosixConfig::kConfigKey_VendorName, buf, bufSize, vendorNameLen); +} + +CHIP_ERROR DeviceInstanceInfoProviderImpl::GetProductName(char * buf, size_t bufSize) +{ + size_t productNameLen = 0; + return Internal::PosixConfig::ReadConfigValueStr(Internal::PosixConfig::kConfigKey_ProductName, buf, bufSize, productNameLen); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/Tizen/DeviceInstanceInfoProviderImpl.h b/src/platform/Tizen/DeviceInstanceInfoProviderImpl.h index 32e6a2cc5abec0..13f8045f6e4cbe 100644 --- a/src/platform/Tizen/DeviceInstanceInfoProviderImpl.h +++ b/src/platform/Tizen/DeviceInstanceInfoProviderImpl.h @@ -34,6 +34,8 @@ class DeviceInstanceInfoProviderImpl : public Internal::GenericDeviceInstanceInf public: CHIP_ERROR GetVendorId(uint16_t & vendorId) override; CHIP_ERROR GetProductId(uint16_t & productId) override; + CHIP_ERROR GetVendorName(char * buf, size_t bufSize) override; + CHIP_ERROR GetProductName(char * buf, size_t bufSize) override; DeviceInstanceInfoProviderImpl(ConfigurationManagerImpl & configManager) : Internal::GenericDeviceInstanceInfoProvider(configManager) diff --git a/src/platform/fake/ConfigurationManagerImpl.h b/src/platform/fake/ConfigurationManagerImpl.h index 25867fa68bdc87..11f44f9e1c4c0f 100644 --- a/src/platform/fake/ConfigurationManagerImpl.h +++ b/src/platform/fake/ConfigurationManagerImpl.h @@ -50,6 +50,10 @@ class ConfigurationManagerImpl : public ConfigurationManager CHIP_ERROR GetSoftwareVersion(uint32_t & softwareVer) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR StoreSoftwareVersion(uint32_t softwareVer) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR StoreSerialNumber(CharSpan serialNumber) override { return CHIP_ERROR_NOT_IMPLEMENTED; } + CHIP_ERROR StoreVendorName(CharSpan vendorName) override { return CHIP_ERROR_NOT_IMPLEMENTED; } + CHIP_ERROR StoreProductName(CharSpan productName) override { return CHIP_ERROR_NOT_IMPLEMENTED; } + CHIP_ERROR StoreHardwareVersionString(CharSpan hardwareVersionString) override { return CHIP_ERROR_NOT_IMPLEMENTED; } + CHIP_ERROR StoreSoftwareVersionString(CharSpan softwareVersionString) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetPrimaryMACAddress(MutableByteSpan buf) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetPrimaryWiFiMACAddress(uint8_t * buf) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetPrimary802154MACAddress(uint8_t * buf) override { return CHIP_ERROR_NOT_IMPLEMENTED; } From 40d1a1a7842e5366cf6b62ab68328f7a3afd60e7 Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Tue, 16 Jul 2024 10:10:17 +0200 Subject: [PATCH 21/32] [Tizen] Initialize vendor and product names --- src/platform/Tizen/ConfigurationManagerImpl.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/platform/Tizen/ConfigurationManagerImpl.cpp b/src/platform/Tizen/ConfigurationManagerImpl.cpp index 8efe079993b7aa..dd6a33fac62fc7 100644 --- a/src/platform/Tizen/ConfigurationManagerImpl.cpp +++ b/src/platform/Tizen/ConfigurationManagerImpl.cpp @@ -26,6 +26,7 @@ #include "ConfigurationManagerImpl.h" #include +#include #include #include #include @@ -59,12 +60,24 @@ CHIP_ERROR ConfigurationManagerImpl::Init() SuccessOrExit(error); } + if (!Internal::PosixConfig::ConfigValueExists(Internal::PosixConfig::kConfigKey_VendorName)) + { + error = StoreVendorName(chip::CharSpan::fromCharString(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME)); + SuccessOrExit(error); + } + if (!Internal::PosixConfig::ConfigValueExists(Internal::PosixConfig::kConfigKey_ProductId)) { error = StoreProductId(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID); SuccessOrExit(error); } + if (!Internal::PosixConfig::ConfigValueExists(Internal::PosixConfig::kConfigKey_ProductName)) + { + error = StoreProductName(chip::CharSpan::fromCharString(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME)); + SuccessOrExit(error); + } + error = CHIP_NO_ERROR; exit: From 399ddb7daabfcefd8a3d63496c9537cf8e4de308 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 16 Jul 2024 08:17:36 +0000 Subject: [PATCH 22/32] Restyled by clang-format --- src/platform/Darwin/PosixConfig.cpp | 8 ++++---- src/platform/Linux/PosixConfig.cpp | 9 ++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/platform/Darwin/PosixConfig.cpp b/src/platform/Darwin/PosixConfig.cpp index d59431deeb2269..4fbd4da4671883 100644 --- a/src/platform/Darwin/PosixConfig.cpp +++ b/src/platform/Darwin/PosixConfig.cpp @@ -56,10 +56,10 @@ const PosixConfig::Key PosixConfig::kConfigKey_Spake2pVerifier = { kConfig const PosixConfig::Key PosixConfig::kConfigKey_VendorId = { kConfigNamespace_ChipFactory, "vendor-id" }; const PosixConfig::Key PosixConfig::kConfigKey_ProductId = { kConfigNamespace_ChipFactory, "product-id" }; -const PosixConfig::Key PosixConfig::kConfigKey_VendorName = { kConfigNamespace_ChipFactory, "vendor-name" }; -const PosixConfig::Key PosixConfig::kConfigKey_ProductName = { kConfigNamespace_ChipFactory, "product-name" }; -const PosixConfig::Key PosixConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipFactory, "hardware-version-string" }; -const PosixConfig::Key PosixConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipFactory, "software-version-string" }; +const PosixConfig::Key PosixConfig::kConfigKey_VendorName = { kConfigNamespace_ChipFactory, "vendor-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_ProductName = { kConfigNamespace_ChipFactory, "product-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipFactory, "hardware-version-string" }; +const PosixConfig::Key PosixConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipFactory, "software-version-string" }; // Keys stored in the Chip-config namespace const PosixConfig::Key PosixConfig::kConfigKey_FailSafeArmed = { kConfigNamespace_ChipConfig, "fail-safe-armed" }; diff --git a/src/platform/Linux/PosixConfig.cpp b/src/platform/Linux/PosixConfig.cpp index 937a02b7b6ee1b..c44a67d4fb3d23 100644 --- a/src/platform/Linux/PosixConfig.cpp +++ b/src/platform/Linux/PosixConfig.cpp @@ -63,11 +63,10 @@ const PosixConfig::Key PosixConfig::kConfigKey_Spake2pVerifier = { kConfig const PosixConfig::Key PosixConfig::kConfigKey_VendorId = { kConfigNamespace_ChipFactory, "vendor-id" }; const PosixConfig::Key PosixConfig::kConfigKey_ProductId = { kConfigNamespace_ChipFactory, "product-id" }; -const PosixConfig::Key PosixConfig::kConfigKey_VendorName = { kConfigNamespace_ChipFactory, "vendor-name" }; -const PosixConfig::Key PosixConfig::kConfigKey_ProductName = { kConfigNamespace_ChipFactory, "product-name" }; -const PosixConfig::Key PosixConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipFactory, "hardware-version-string" }; -const PosixConfig::Key PosixConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipFactory, "software-version-string" }; - +const PosixConfig::Key PosixConfig::kConfigKey_VendorName = { kConfigNamespace_ChipFactory, "vendor-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_ProductName = { kConfigNamespace_ChipFactory, "product-name" }; +const PosixConfig::Key PosixConfig::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipFactory, "hardware-version-string" }; +const PosixConfig::Key PosixConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipFactory, "software-version-string" }; // Keys stored in the Chip-config namespace const PosixConfig::Key PosixConfig::kConfigKey_ServiceConfig = { kConfigNamespace_ChipConfig, "service-config" }; From 21328d8b29e2bf6880959af9bb1368585cc9d648 Mon Sep 17 00:00:00 2001 From: chaitanya Date: Wed, 9 Oct 2024 15:14:49 -0700 Subject: [PATCH 23/32] fixed a merge conflict --- examples/platform/linux/Options.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/platform/linux/Options.cpp b/examples/platform/linux/Options.cpp index 3f147db1ee7806..56ca139b2e4bca 100644 --- a/examples/platform/linux/Options.cpp +++ b/examples/platform/linux/Options.cpp @@ -706,7 +706,6 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier, break; } #endif -<<<<<<< HEAD #if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF case kDeviceOption_WiFi_PAF: { LinuxDeviceOptions::GetInstance().mWiFiPAF = true; @@ -714,8 +713,6 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier, break; } #endif -======= ->>>>>>> b19ffdfdca4e1cbaddbd0c737676d54b86a7c37a case kDeviceOption_VendorName: LinuxDeviceOptions::GetInstance().vendorName.SetValue(std::string{ aValue }); break; From e217a7f5e124ed7e02dc6187dc6683c251affe95 Mon Sep 17 00:00:00 2001 From: chaitanya Date: Thu, 2 May 2024 17:06:23 -0700 Subject: [PATCH 24/32] added code to read vendor_name, product_name, hardware_version_string and software_version_string to read from config in reference linux and darwin platform --- .../platform/linux/CommissionableInit.cpp | 1 + examples/platform/linux/Options.cpp | 16 +++++++++++++ src/include/platform/ConfigurationManager.h | 5 ++++ .../GenericConfigurationManagerImpl.h | 1 + .../GenericConfigurationManagerImpl.ipp | 24 +++++++++++++++++++ .../GenericDeviceInstanceInfoProvider.ipp | 2 ++ 6 files changed, 49 insertions(+) diff --git a/examples/platform/linux/CommissionableInit.cpp b/examples/platform/linux/CommissionableInit.cpp index 2418c64d8fc0a7..2669f52cf492ff 100644 --- a/examples/platform/linux/CommissionableInit.cpp +++ b/examples/platform/linux/CommissionableInit.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "CommissionableInit.h" diff --git a/examples/platform/linux/Options.cpp b/examples/platform/linux/Options.cpp index 56ca139b2e4bca..91db5c3b0d9175 100644 --- a/examples/platform/linux/Options.cpp +++ b/examples/platform/linux/Options.cpp @@ -150,7 +150,11 @@ OptionDef sDeviceOptionDefs[] = { { "product-id", kArgumentRequired, kDeviceOption_ProductID }, { "vendor-name", kArgumentRequired, kDeviceOption_VendorName }, { "product-name", kArgumentRequired, kDeviceOption_ProductName }, +<<<<<<< HEAD { "hardware-version-string", kArgumentRequired, kDeviceOption_HardwareVersionString }, +======= + { "harware-version-string", kArgumentRequired, kDeviceOption_HardwareVersionString }, +>>>>>>> b310e8c9f1 (added code to read vendor_name, product_name, hardware_version_string and software_version_string to read from config in reference linux and darwin platform) { "software-version-string", kArgumentRequired, kDeviceOption_SoftwareVersionString }, { "serial-number", kArgumentRequired, kDeviceOption_SerialNumber }, { "custom-flow", kArgumentRequired, kDeviceOption_CustomFlow }, @@ -724,6 +728,7 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier, case kDeviceOption_HardwareVersionString: LinuxDeviceOptions::GetInstance().hardwareVersionString.SetValue(std::string{ aValue }); break; +<<<<<<< HEAD case kDeviceOption_SoftwareVersionString: LinuxDeviceOptions::GetInstance().softwareVersionString.SetValue(std::string{ aValue }); @@ -733,6 +738,17 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier, LinuxDeviceOptions::GetInstance().serialNumber.SetValue(std::string{ aValue }); break; +======= + + case kDeviceOption_SoftwareVersionString: + LinuxDeviceOptions::GetInstance().softwareVersionString.SetValue(std::string{ aValue }); + break; + + case kDeviceOption_SerialNumber: + LinuxDeviceOptions::GetInstance().serialNumber.SetValue(std::string{ aValue }); + break; + +>>>>>>> b310e8c9f1 (added code to read vendor_name, product_name, hardware_version_string and software_version_string to read from config in reference linux and darwin platform) default: PrintArgError("%s: INTERNAL ERROR: Unhandled option: %s\n", aProgram, aName); retval = false; diff --git a/src/include/platform/ConfigurationManager.h b/src/include/platform/ConfigurationManager.h index d54e044b82d66a..7c549ecffec7cd 100644 --- a/src/include/platform/ConfigurationManager.h +++ b/src/include/platform/ConfigurationManager.h @@ -138,6 +138,11 @@ class ConfigurationManager virtual CHIP_ERROR StoreHardwareVersionString(CharSpan hardwareVersionString) = 0; virtual CHIP_ERROR StoreSoftwareVersionString(CharSpan softwareVersionString) = 0; + virtual CHIP_ERROR StoreVendorName(const char * vendorName, size_t vendorNameLen) = 0; + virtual CHIP_ERROR StoreProductName(const char * productName, size_t productNameLen) = 0; + virtual CHIP_ERROR StoreHardwareVersionString(const char * hardwareVersionString, size_t hardwareVersionStringLen) = 0; + virtual CHIP_ERROR StoreSoftwareVersionString(const char * softwareVersionString, size_t softwareVersionStringLen) = 0; + #if CHIP_CONFIG_TEST virtual void RunUnitTests() = 0; #endif diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.h b/src/include/platform/internal/GenericConfigurationManagerImpl.h index faa8dfc79fa7ca..e56419088e4ce1 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.h +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.h @@ -108,6 +108,7 @@ class GenericConfigurationManagerImpl : public ConfigurationManager CHIP_ERROR StoreProductName(CharSpan productName) override; CHIP_ERROR StoreHardwareVersionString(CharSpan hardwareVersionString) override; CHIP_ERROR StoreSoftwareVersionString(CharSpan softwareVersionString) override; + #if CHIP_CONFIG_TEST void RunUnitTests() override; #endif diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.ipp b/src/include/platform/internal/GenericConfigurationManagerImpl.ipp index 4ef3893cd91238..bdd63365d38aef 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.ipp +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.ipp @@ -351,6 +351,7 @@ CHIP_ERROR GenericConfigurationManagerImpl::GetSecondaryPairingHint template CHIP_ERROR GenericConfigurationManagerImpl::GetSoftwareVersionString(char * buf, size_t bufSize) { + CHIP_ERROR err = CHIP_NO_ERROR; size_t softwareVersionStringLen = 0; // without counting null-terminator @@ -365,6 +366,7 @@ CHIP_ERROR GenericConfigurationManagerImpl::GetSoftwareVersionStrin } VerifyOrReturnError(err == CHIP_NO_ERROR, CHIP_ERROR_INTERNAL); + return err; } @@ -396,6 +398,28 @@ CHIP_ERROR GenericConfigurationManagerImpl::StoreSoftwareVersionStr return WriteConfigValueStr(ConfigClass::kConfigKey_SoftwareVersionString, softwareVersionString.data(), softwareVersionString.size()); } +template +CHIP_ERROR GenericConfigurationManagerImpl::StoreVendorName(const char * vendorName, size_t vendorNameLen) +{ + return WriteConfigValueStr(ConfigClass::kConfigKey_VendorName, vendorName, vendorNameLen); +} +template +CHIP_ERROR GenericConfigurationManagerImpl::StoreProductName(const char * productName, size_t productNameLen) +{ + return WriteConfigValueStr(ConfigClass::kConfigKey_ProductName, productName, productNameLen); +} +template +CHIP_ERROR GenericConfigurationManagerImpl::StoreHardwareVersionString(const char * hardwareVersionString, + size_t hardwareVersionStringLen) +{ + return WriteConfigValueStr(ConfigClass::kConfigKey_HardwareVersionString, hardwareVersionString, hardwareVersionStringLen); +} +template +CHIP_ERROR GenericConfigurationManagerImpl::StoreSoftwareVersionString(const char * softwareVersionString, + size_t softwareVersionStringLen) +{ + return WriteConfigValueStr(ConfigClass::kConfigKey_SoftwareVersionString, softwareVersionString, softwareVersionStringLen); +} template CHIP_ERROR GenericConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf) diff --git a/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp b/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp index cb44bfc140341f..af05ac4d3b134b 100644 --- a/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp +++ b/src/include/platform/internal/GenericDeviceInstanceInfoProvider.ipp @@ -58,6 +58,7 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetVendorName(char * template CHIP_ERROR GenericDeviceInstanceInfoProvider::GetProductName(char * buf, size_t bufSize) { + ChipError err = CHIP_NO_ERROR; size_t productNameLen = 0; // without counting null-terminator @@ -195,6 +196,7 @@ CHIP_ERROR GenericDeviceInstanceInfoProvider::GetHardwareVersion(ui template CHIP_ERROR GenericDeviceInstanceInfoProvider::GetHardwareVersionString(char * buf, size_t bufSize) { + ChipError err = CHIP_NO_ERROR; size_t hardwareVersionStringLen = 0; // without counting null-terminator From 67e1c3d39380b96b8e765026c516d737177b131a Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Fri, 3 May 2024 15:11:43 -0700 Subject: [PATCH 25/32] fixed few typos --- examples/platform/linux/Options.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/examples/platform/linux/Options.cpp b/examples/platform/linux/Options.cpp index 91db5c3b0d9175..56ca139b2e4bca 100644 --- a/examples/platform/linux/Options.cpp +++ b/examples/platform/linux/Options.cpp @@ -150,11 +150,7 @@ OptionDef sDeviceOptionDefs[] = { { "product-id", kArgumentRequired, kDeviceOption_ProductID }, { "vendor-name", kArgumentRequired, kDeviceOption_VendorName }, { "product-name", kArgumentRequired, kDeviceOption_ProductName }, -<<<<<<< HEAD { "hardware-version-string", kArgumentRequired, kDeviceOption_HardwareVersionString }, -======= - { "harware-version-string", kArgumentRequired, kDeviceOption_HardwareVersionString }, ->>>>>>> b310e8c9f1 (added code to read vendor_name, product_name, hardware_version_string and software_version_string to read from config in reference linux and darwin platform) { "software-version-string", kArgumentRequired, kDeviceOption_SoftwareVersionString }, { "serial-number", kArgumentRequired, kDeviceOption_SerialNumber }, { "custom-flow", kArgumentRequired, kDeviceOption_CustomFlow }, @@ -728,7 +724,6 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier, case kDeviceOption_HardwareVersionString: LinuxDeviceOptions::GetInstance().hardwareVersionString.SetValue(std::string{ aValue }); break; -<<<<<<< HEAD case kDeviceOption_SoftwareVersionString: LinuxDeviceOptions::GetInstance().softwareVersionString.SetValue(std::string{ aValue }); @@ -738,17 +733,6 @@ bool HandleOption(const char * aProgram, OptionSet * aOptions, int aIdentifier, LinuxDeviceOptions::GetInstance().serialNumber.SetValue(std::string{ aValue }); break; -======= - - case kDeviceOption_SoftwareVersionString: - LinuxDeviceOptions::GetInstance().softwareVersionString.SetValue(std::string{ aValue }); - break; - - case kDeviceOption_SerialNumber: - LinuxDeviceOptions::GetInstance().serialNumber.SetValue(std::string{ aValue }); - break; - ->>>>>>> b310e8c9f1 (added code to read vendor_name, product_name, hardware_version_string and software_version_string to read from config in reference linux and darwin platform) default: PrintArgError("%s: INTERNAL ERROR: Unhandled option: %s\n", aProgram, aName); retval = false; From 009b9342ff04b1f32e73695c09b5c4bb9cdea6d7 Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Wed, 9 Oct 2024 22:57:45 -0700 Subject: [PATCH 26/32] updated PSOC6 and K32W0 Configs --- src/platform/Infineon/PSOC6/PSOC6Config.cpp | 16 ++++++++-------- src/platform/nxp/k32w0/K32W0Config.cpp | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/platform/Infineon/PSOC6/PSOC6Config.cpp b/src/platform/Infineon/PSOC6/PSOC6Config.cpp index cc10263de1820f..53e96cd462150d 100644 --- a/src/platform/Infineon/PSOC6/PSOC6Config.cpp +++ b/src/platform/Infineon/PSOC6/PSOC6Config.cpp @@ -88,22 +88,22 @@ const PSOC6Config::Key PSOC6Config::kConfigKey_YearDaySchedules = { kConfigNames const PSOC6Config::Key PSOC6Config::kConfigKey_HolidaySchedules = { kConfigNamespace_ChipConfig, "holiday-schedules" }; ; -const P6Config::Key P6Config::kConfigKey_VendorName = { kConfigNamespace_ChipConfig, "vendor-name" }; +const PSOC6Config::Key PSOC6Config::kConfigKey_VendorName = { kConfigNamespace_ChipConfig, "vendor-name" }; ; -const P6Config::Key P6Config::kConfigKey_ProductName = { kConfigNamespace_ChipConfig, "product-name" }; +const PSOC6Config::Key PSOC6Config::kConfigKey_ProductName = { kConfigNamespace_ChipConfig, "product-name" }; ; -const P6Config::Key P6Config::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipConfig, "hardware-version-string" }; +const PSOC6Config::Key PSOC6Config::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipConfig, "hardware-version-string" }; ; -const P6Config::Key P6Config::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipConfig, "software-version-string" }; +const PSOC6Config::Key PSOC6Config::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipConfig, "software-version-string" }; ; -const P6Config::Key P6Config::kConfigKey_VendorName = { kConfigNamespace_ChipConfig, "vendor-name" }; +const PSOC6Config::Key PSOC6Config::kConfigKey_VendorName = { kConfigNamespace_ChipConfig, "vendor-name" }; ; -const P6Config::Key P6Config::kConfigKey_ProductName = { kConfigNamespace_ChipConfig, "product-name" }; +const PSOC6Config::Key PSOC6Config::kConfigKey_ProductName = { kConfigNamespace_ChipConfig, "product-name" }; ; -const P6Config::Key P6Config::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipConfig, "hardware-version-string" }; +const PSOC6Config::Key PSOC6Config::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipConfig, "hardware-version-string" }; ; -const P6Config::Key P6Config::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipConfig, "software-version-string" }; +const PSOC6Config::Key PSOC6Config::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipConfig, "software-version-string" }; ; // Keys stored in the Chip-counters namespace diff --git a/src/platform/nxp/k32w0/K32W0Config.cpp b/src/platform/nxp/k32w0/K32W0Config.cpp index ac68c1d5d7c761..994327312bf701 100644 --- a/src/platform/nxp/k32w0/K32W0Config.cpp +++ b/src/platform/nxp/k32w0/K32W0Config.cpp @@ -53,6 +53,11 @@ const K32WConfig::Key K32WConfig::kConfigKey_Spake2pIterationCount{ &K32WConfig: const K32WConfig::Key K32WConfig::kConfigKey_Spake2pSalt{ &K32WConfig::sFactoryStorage, kKeyId_Factory, 0x0A }; const K32WConfig::Key K32WConfig::kConfigKey_Spake2pVerifier{ &K32WConfig::sFactoryStorage, kKeyId_Factory, 0x0B }; +const K32WConfig::Key K32WConfig::kConfigKey_VendorName{ &K32WConfig::sFactoryStorage, kKeyId_Config, 0x0C }; +const K32WConfig::Key K32WConfig::kConfigKey_ProductName{ &K32WConfig::sFactoryStorage, kKeyId_Config, 0x0D }; +const K32WConfig::Key K32WConfig::kConfigKey_HardwareVersionString{ &K32WConfig::sFactoryStorage, kKeyId_Config, 0x0E }; +const K32WConfig::Key K32WConfig::kConfigKey_SoftwareVersionString{ &K32WConfig::sFactoryStorage, kKeyId_Config, 0x0F }; + const K32WConfig::Key K32WConfig::kConfigKey_ServiceConfig{ &K32WConfig::sConfigStorage, kKeyId_Config, 0x01 }; const K32WConfig::Key K32WConfig::kConfigKey_PairedAccountId{ &K32WConfig::sConfigStorage, kKeyId_Config, 0x02 }; const K32WConfig::Key K32WConfig::kConfigKey_ServiceId{ &K32WConfig::sConfigStorage, kKeyId_Config, 0x03 }; @@ -64,11 +69,6 @@ const K32WConfig::Key K32WConfig::kConfigKey_UniqueId{ &K32WConfig::sConfigStora const K32WConfig::Key K32WConfig::kConfigKey_SoftwareVersion{ &K32WConfig::sConfigStorage, kKeyId_Config, 0x0B }; const K32WConfig::Key K32WConfig::kConfigKey_SoftwareUpdateCompleted{ &K32WConfig::sConfigStorage, kKeyId_Config, 0x0C }; -const K32WConfig::Key K32WConfig::kConfigKey_VendorName{ &K32WConfig::sConfigStorage, kKeyId_Config, 0x0D }; -const K32WConfig::Key K32WConfig::kConfigKey_ProductName{ &K32WConfig::sConfigStorage, kKeyId_Config, 0x0E }; -const K32WConfig::Key K32WConfig::kConfigKey_HardwareVersionString{ &K32WConfig::sConfigStorage, kKeyId_Config, 0x0F }; -const K32WConfig::Key K32WConfig::kConfigKey_SoftwareVersionString{ &K32WConfig::sConfigStorage, kKeyId_Config, 0x10 }; - const K32WConfig::Key K32WConfig::kCounterKey_RebootCount{ &K32WConfig::sCounterStorage, kKeyId_Counter, 0x00 }; const K32WConfig::Key K32WConfig::kCounterKey_UpTime{ &K32WConfig::sCounterStorage, kKeyId_Counter, 0x01 }; const K32WConfig::Key K32WConfig::kCounterKey_TotalOperationalHours{ &K32WConfig::sCounterStorage, kKeyId_Counter, 0x02 }; From 9accc81edf90a97d27e39b0d6ec09d05faca53bf Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Fri, 11 Oct 2024 16:58:32 -0700 Subject: [PATCH 27/32] updated virtual functions to override --- .../platform/internal/GenericConfigurationManagerImpl.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.h b/src/include/platform/internal/GenericConfigurationManagerImpl.h index e56419088e4ce1..ecfc9cc78c431f 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.h +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.h @@ -109,6 +109,11 @@ class GenericConfigurationManagerImpl : public ConfigurationManager CHIP_ERROR StoreHardwareVersionString(CharSpan hardwareVersionString) override; CHIP_ERROR StoreSoftwareVersionString(CharSpan softwareVersionString) override; + CHIP_ERROR StoreVendorName(const char * vendorName, size_t vendorNameLen) override; + CHIP_ERROR StoreProductName(const char * productName, size_t productNameLen) override; + CHIP_ERROR StoreHardwareVersionString(const char * hardwareVersionString, size_t hardwareVersionStringLen) override; + CHIP_ERROR StoreSoftwareVersionString(const char * softwareVersionString, size_t softwareVersionStringLen) override; + #if CHIP_CONFIG_TEST void RunUnitTests() override; #endif From 97367912b611985628fe3283b0c393e08eedeefa Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Fri, 11 Oct 2024 17:25:27 -0700 Subject: [PATCH 28/32] fix restyle comments and compilation errors --- src/include/platform/ConfigurationManager.h | 8 ++++---- src/platform/Infineon/PSOC6/PSOC6Config.cpp | 17 ----------------- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/src/include/platform/ConfigurationManager.h b/src/include/platform/ConfigurationManager.h index 7c549ecffec7cd..b808f0c40d8062 100644 --- a/src/include/platform/ConfigurationManager.h +++ b/src/include/platform/ConfigurationManager.h @@ -138,10 +138,10 @@ class ConfigurationManager virtual CHIP_ERROR StoreHardwareVersionString(CharSpan hardwareVersionString) = 0; virtual CHIP_ERROR StoreSoftwareVersionString(CharSpan softwareVersionString) = 0; - virtual CHIP_ERROR StoreVendorName(const char * vendorName, size_t vendorNameLen) = 0; - virtual CHIP_ERROR StoreProductName(const char * productName, size_t productNameLen) = 0; - virtual CHIP_ERROR StoreHardwareVersionString(const char * hardwareVersionString, size_t hardwareVersionStringLen) = 0; - virtual CHIP_ERROR StoreSoftwareVersionString(const char * softwareVersionString, size_t softwareVersionStringLen) = 0; + virtual CHIP_ERROR StoreVendorName(const char * vendorName, size_t vendorNameLen) = 0; + virtual CHIP_ERROR StoreProductName(const char * productName, size_t productNameLen) = 0; + virtual CHIP_ERROR StoreHardwareVersionString(const char * hardwareVersionString, size_t hardwareVersionStringLen) = 0; + virtual CHIP_ERROR StoreSoftwareVersionString(const char * softwareVersionString, size_t softwareVersionStringLen) = 0; #if CHIP_CONFIG_TEST virtual void RunUnitTests() = 0; diff --git a/src/platform/Infineon/PSOC6/PSOC6Config.cpp b/src/platform/Infineon/PSOC6/PSOC6Config.cpp index 53e96cd462150d..a097a6a41b48c7 100644 --- a/src/platform/Infineon/PSOC6/PSOC6Config.cpp +++ b/src/platform/Infineon/PSOC6/PSOC6Config.cpp @@ -82,30 +82,13 @@ const PSOC6Config::Key PSOC6Config::kConfigKey_LockUserName = { kConfigNam const PSOC6Config::Key PSOC6Config::kConfigKey_CredentialData = { kConfigNamespace_ChipConfig, "credential-data" }; const PSOC6Config::Key PSOC6Config::kConfigKey_UserCredentials = { kConfigNamespace_ChipConfig, "user-credentials" }; const PSOC6Config::Key PSOC6Config::kConfigKey_WeekDaySchedules = { kConfigNamespace_ChipConfig, "weekday-schedules" }; -; const PSOC6Config::Key PSOC6Config::kConfigKey_YearDaySchedules = { kConfigNamespace_ChipConfig, "yearday-schedules" }; -; const PSOC6Config::Key PSOC6Config::kConfigKey_HolidaySchedules = { kConfigNamespace_ChipConfig, "holiday-schedules" }; -; const PSOC6Config::Key PSOC6Config::kConfigKey_VendorName = { kConfigNamespace_ChipConfig, "vendor-name" }; -; const PSOC6Config::Key PSOC6Config::kConfigKey_ProductName = { kConfigNamespace_ChipConfig, "product-name" }; -; const PSOC6Config::Key PSOC6Config::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipConfig, "hardware-version-string" }; -; const PSOC6Config::Key PSOC6Config::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipConfig, "software-version-string" }; -; - -const PSOC6Config::Key PSOC6Config::kConfigKey_VendorName = { kConfigNamespace_ChipConfig, "vendor-name" }; -; -const PSOC6Config::Key PSOC6Config::kConfigKey_ProductName = { kConfigNamespace_ChipConfig, "product-name" }; -; -const PSOC6Config::Key PSOC6Config::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipConfig, "hardware-version-string" }; -; -const PSOC6Config::Key PSOC6Config::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipConfig, "software-version-string" }; -; - // Keys stored in the Chip-counters namespace const PSOC6Config::Key PSOC6Config::kCounterKey_RebootCount = { kConfigNamespace_ChipCounters, "reboot-count" }; const PSOC6Config::Key PSOC6Config::kCounterKey_UpTime = { kConfigNamespace_ChipCounters, "up-time" }; From 08b74794e451946dcda076b5165e6cc76a590599 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sat, 12 Oct 2024 00:26:23 +0000 Subject: [PATCH 29/32] Restyled by clang-format --- src/platform/Infineon/PSOC6/PSOC6Config.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/platform/Infineon/PSOC6/PSOC6Config.cpp b/src/platform/Infineon/PSOC6/PSOC6Config.cpp index a097a6a41b48c7..0e64767b0847af 100644 --- a/src/platform/Infineon/PSOC6/PSOC6Config.cpp +++ b/src/platform/Infineon/PSOC6/PSOC6Config.cpp @@ -82,11 +82,11 @@ const PSOC6Config::Key PSOC6Config::kConfigKey_LockUserName = { kConfigNam const PSOC6Config::Key PSOC6Config::kConfigKey_CredentialData = { kConfigNamespace_ChipConfig, "credential-data" }; const PSOC6Config::Key PSOC6Config::kConfigKey_UserCredentials = { kConfigNamespace_ChipConfig, "user-credentials" }; const PSOC6Config::Key PSOC6Config::kConfigKey_WeekDaySchedules = { kConfigNamespace_ChipConfig, "weekday-schedules" }; -const PSOC6Config::Key PSOC6Config::kConfigKey_YearDaySchedules = { kConfigNamespace_ChipConfig, "yearday-schedules" }; -const PSOC6Config::Key PSOC6Config::kConfigKey_HolidaySchedules = { kConfigNamespace_ChipConfig, "holiday-schedules" }; +const PSOC6Config::Key PSOC6Config::kConfigKey_YearDaySchedules = { kConfigNamespace_ChipConfig, "yearday-schedules" }; +const PSOC6Config::Key PSOC6Config::kConfigKey_HolidaySchedules = { kConfigNamespace_ChipConfig, "holiday-schedules" }; -const PSOC6Config::Key PSOC6Config::kConfigKey_VendorName = { kConfigNamespace_ChipConfig, "vendor-name" }; -const PSOC6Config::Key PSOC6Config::kConfigKey_ProductName = { kConfigNamespace_ChipConfig, "product-name" }; +const PSOC6Config::Key PSOC6Config::kConfigKey_VendorName = { kConfigNamespace_ChipConfig, "vendor-name" }; +const PSOC6Config::Key PSOC6Config::kConfigKey_ProductName = { kConfigNamespace_ChipConfig, "product-name" }; const PSOC6Config::Key PSOC6Config::kConfigKey_HardwareVersionString = { kConfigNamespace_ChipConfig, "hardware-version-string" }; const PSOC6Config::Key PSOC6Config::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipConfig, "software-version-string" }; // Keys stored in the Chip-counters namespace From 84b9f519f4605ed6a9b427ae774ecff5e399c1e3 Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Mon, 14 Oct 2024 13:51:08 -0700 Subject: [PATCH 30/32] fix compilation errors --- src/platform/fake/ConfigurationManagerImpl.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/platform/fake/ConfigurationManagerImpl.h b/src/platform/fake/ConfigurationManagerImpl.h index 11f44f9e1c4c0f..eb8a57eb678f2d 100644 --- a/src/platform/fake/ConfigurationManagerImpl.h +++ b/src/platform/fake/ConfigurationManagerImpl.h @@ -89,6 +89,23 @@ class ConfigurationManagerImpl : public ConfigurationManager CHIP_ERROR GetUniqueId(char * buf, size_t bufSize) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR StoreUniqueId(const char * uniqueId, size_t uniqueIdLen) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GenerateUniqueId(char * buf, size_t bufSize) override { return CHIP_ERROR_NOT_IMPLEMENTED; } + + CHIP_ERROR GenerateUniqueId(char * buf, size_t bufSize) override { return CHIP_ERROR_NOT_IMPLEMENTED; } + CHIP_ERROR GenerateUniqueId(char * buf, size_t bufSize) override { return CHIP_ERROR_NOT_IMPLEMENTED; } + CHIP_ERROR GenerateUniqueId(char * buf, size_t bufSize) override { return CHIP_ERROR_NOT_IMPLEMENTED; } + CHIP_ERROR GenerateUniqueId(char * buf, size_t bufSize) override { return CHIP_ERROR_NOT_IMPLEMENTED; } + + CHIP_ERROR StoreVendorName(const char * vendorName, size_t vendorNameLen) override { return CHIP_ERROR_NOT_IMPLEMENTED; } + CHIP_ERROR StoreProductName(const char * productName, size_t productNameLen) override { return CHIP_ERROR_NOT_IMPLEMENTED; } + CHIP_ERROR StoreHardwareVersionString(const char * hardwareVersionString, size_t hardwareVersionStringLen) override + { + return CHIP_ERROR_NOT_IMPLEMENTED; + } + CHIP_ERROR StoreSoftwareVersionString(const char * softwareVersionString, size_t softwareVersionStringLen) override + { + return CHIP_ERROR_NOT_IMPLEMENTED; + } + #if CHIP_CONFIG_TEST void RunUnitTests() override {} #endif From bb8b3c6e7896f6e63dc0ce5317d01a4baee6997b Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Mon, 14 Oct 2024 16:08:13 -0700 Subject: [PATCH 31/32] fix compilation error on fake platform --- src/platform/fake/ConfigurationManagerImpl.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/platform/fake/ConfigurationManagerImpl.h b/src/platform/fake/ConfigurationManagerImpl.h index eb8a57eb678f2d..89e0c59c0d7df4 100644 --- a/src/platform/fake/ConfigurationManagerImpl.h +++ b/src/platform/fake/ConfigurationManagerImpl.h @@ -90,11 +90,6 @@ class ConfigurationManagerImpl : public ConfigurationManager CHIP_ERROR StoreUniqueId(const char * uniqueId, size_t uniqueIdLen) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GenerateUniqueId(char * buf, size_t bufSize) override { return CHIP_ERROR_NOT_IMPLEMENTED; } - CHIP_ERROR GenerateUniqueId(char * buf, size_t bufSize) override { return CHIP_ERROR_NOT_IMPLEMENTED; } - CHIP_ERROR GenerateUniqueId(char * buf, size_t bufSize) override { return CHIP_ERROR_NOT_IMPLEMENTED; } - CHIP_ERROR GenerateUniqueId(char * buf, size_t bufSize) override { return CHIP_ERROR_NOT_IMPLEMENTED; } - CHIP_ERROR GenerateUniqueId(char * buf, size_t bufSize) override { return CHIP_ERROR_NOT_IMPLEMENTED; } - CHIP_ERROR StoreVendorName(const char * vendorName, size_t vendorNameLen) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR StoreProductName(const char * productName, size_t productNameLen) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR StoreHardwareVersionString(const char * hardwareVersionString, size_t hardwareVersionStringLen) override From 16406e31c454d706ba0ad6b6698c8a4e84d3c2cf Mon Sep 17 00:00:00 2001 From: chaitanya jandhyala Date: Tue, 15 Oct 2024 10:42:33 -0700 Subject: [PATCH 32/32] fix compilation error on k32w0 platform, disabled chip logging --- src/platform/nxp/k32w0/args.gni | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/platform/nxp/k32w0/args.gni b/src/platform/nxp/k32w0/args.gni index fda52672cf50e0..4dd218a0c65a77 100644 --- a/src/platform/nxp/k32w0/args.gni +++ b/src/platform/nxp/k32w0/args.gni @@ -56,6 +56,8 @@ chip_mdns = "platform" #chip_automation_logging = true #chip_error_logging = true +chip_progress_logging = false + chip_system_config_use_open_thread_inet_endpoints = true chip_with_lwip = false