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 4efdb66cb8c91c..2be3f9c90851a0 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 30c630bccf63c5..e471c6a0efbc31 100644 --- a/examples/platform/linux/Options.h +++ b/examples/platform/linux/Options.h @@ -80,9 +80,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 2d6b710463029a..00207ea09034b6 100644 --- a/src/platform/tests/TestConfigurationMgr.cpp +++ b/src/platform/tests/TestConfigurationMgr.cpp @@ -82,20 +82,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);