diff --git a/src/app/clusters/basic/basic.cpp b/src/app/clusters/basic/basic.cpp index 3b5055c915018b..d5115a180d75e3 100644 --- a/src/app/clusters/basic/basic.cpp +++ b/src/app/clusters/basic/basic.cpp @@ -19,6 +19,7 @@ #include "basic.h" #include +#include #include #include @@ -32,69 +33,82 @@ void emberAfBasicClusterServerInitCallback(chip::EndpointId endpoint) { EmberAfStatus status; + char nodeLabel[DeviceLayer::ConfigurationManager::kMaxNodeLabelLength + 1]; + if (ConfigurationMgr().GetNodeLabel(nodeLabel, sizeof(nodeLabel)) == CHIP_NO_ERROR) + { + status = Attributes::NodeLabel::Set(endpoint, chip::CharSpan(nodeLabel, strlen(nodeLabel))); + VerifyOrdo(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Node Label: 0x%02x", status)); + } + + char location[DeviceLayer::ConfigurationManager::kMaxLocationLength + 1]; + size_t codeLen = 0; + if (ConfigurationMgr().GetCountryCode(location, sizeof(location), codeLen) == CHIP_NO_ERROR) + { + status = Attributes::Location::Set(endpoint, chip::CharSpan(location, strlen(location))); + VerifyOrdo(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Location: 0x%02x", status)); + } + char vendorName[DeviceLayer::ConfigurationManager::kMaxVendorNameLength + 1]; if (ConfigurationMgr().GetVendorName(vendorName, sizeof(vendorName)) == CHIP_NO_ERROR) { status = Attributes::VendorName::Set(endpoint, chip::CharSpan(vendorName, strlen(vendorName))); - VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Vendor Name: 0x%02x", status)); + VerifyOrdo(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Vendor Name: 0x%02x", status)); } uint16_t vendorId; if (ConfigurationMgr().GetVendorId(vendorId) == CHIP_NO_ERROR) { status = Attributes::VendorID::Set(endpoint, vendorId); - VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Vendor Id: 0x%02x", status)); + VerifyOrdo(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Vendor Id: 0x%02x", status)); } char productName[DeviceLayer::ConfigurationManager::kMaxProductNameLength + 1]; if (ConfigurationMgr().GetProductName(productName, sizeof(productName)) == CHIP_NO_ERROR) { status = Attributes::ProductName::Set(endpoint, chip::CharSpan(productName, strlen(productName))); - VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Product Name: 0x%02x", status)); + VerifyOrdo(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Product Name: 0x%02x", status)); } uint16_t productId; if (ConfigurationMgr().GetProductId(productId) == CHIP_NO_ERROR) { status = Attributes::ProductID::Set(endpoint, productId); - VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Product Id: 0x%02x", status)); + VerifyOrdo(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Product Id: 0x%02x", status)); } char hardwareVersionString[DeviceLayer::ConfigurationManager::kMaxHardwareVersionStringLength + 1]; if (ConfigurationMgr().GetHardwareVersionString(hardwareVersionString, sizeof(hardwareVersionString)) == CHIP_NO_ERROR) { status = Attributes::HardwareVersionString::Set(endpoint, CharSpan(hardwareVersionString, strlen(hardwareVersionString))); - VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, - ChipLogError(Zcl, "Error setting Hardware Version String: 0x%02x", status)); + VerifyOrdo(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Hardware Version String: 0x%02x", status)); } uint16_t hardwareVersion; if (ConfigurationMgr().GetHardwareVersion(hardwareVersion) == CHIP_NO_ERROR) { status = Attributes::HardwareVersion::Set(endpoint, hardwareVersion); - VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Hardware Version: 0x%02x", status)); + VerifyOrdo(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Hardware Version: 0x%02x", status)); } char softwareVersionString[DeviceLayer::ConfigurationManager::kMaxSoftwareVersionLength + 1]; if (ConfigurationMgr().GetSoftwareVersionString(softwareVersionString, sizeof(softwareVersionString)) == CHIP_NO_ERROR) { status = Attributes::SoftwareVersionString::Set(endpoint, CharSpan(softwareVersionString, strlen(softwareVersionString))); - VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, - ChipLogError(Zcl, "Error setting Software Version String: 0x%02x", status)); + VerifyOrdo(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Software Version String: 0x%02x", status)); } uint16_t softwareVersion; if (ConfigurationMgr().GetSoftwareVersion(softwareVersion) == CHIP_NO_ERROR) { status = Attributes::SoftwareVersion::Set(endpoint, softwareVersion); - VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Software Version: 0x%02x", status)); + VerifyOrdo(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Software Version: 0x%02x", status)); } char serialNumberString[DeviceLayer::ConfigurationManager::kMaxSerialNumberLength + 1]; if (ConfigurationMgr().GetSerialNumber(serialNumberString, sizeof(serialNumberString)) == CHIP_NO_ERROR) { status = Attributes::SerialNumber::Set(endpoint, CharSpan(serialNumberString, strlen(serialNumberString))); - VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Serial Number String: 0x%02x", status)); + VerifyOrdo(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Serial Number String: 0x%02x", status)); } char manufacturingDateString[DeviceLayer::ConfigurationManager::kMaxManufacturingDateLength + 1]; @@ -106,8 +120,50 @@ void emberAfBasicClusterServerInitCallback(chip::EndpointId endpoint) snprintf(manufacturingDateString, sizeof(manufacturingDateString), "%04" PRIu16 "-%02" PRIu16 "-%02" PRIu16, manufacturingYear, manufacturingMonth, manufacturingDayOfMonth); status = Attributes::ManufacturingDate::Set(endpoint, CharSpan(manufacturingDateString, strlen(manufacturingDateString))); - VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, - ChipLogError(Zcl, "Error setting Manufacturing Date String: 0x%02x", status)); + VerifyOrdo(EMBER_ZCL_STATUS_SUCCESS == status, + ChipLogError(Zcl, "Error setting Manufacturing Date String: 0x%02x", status)); + } + + char partNumber[DeviceLayer::ConfigurationManager::kMaxPartNumberLength + 1]; + if (ConfigurationMgr().GetPartNumber(partNumber, sizeof(partNumber)) == CHIP_NO_ERROR) + { + status = Attributes::PartNumber::Set(endpoint, CharSpan(partNumber, strlen(partNumber))); + VerifyOrdo(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Part Number: 0x%02x", status)); + } + + char productURL[DeviceLayer::ConfigurationManager::kMaxProductURLLength + 1]; + if (ConfigurationMgr().GetProductURL(productURL, sizeof(productURL)) == CHIP_NO_ERROR) + { + status = Attributes::ProductURL::Set(endpoint, CharSpan(productURL, strlen(productURL))); + VerifyOrdo(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Product URL: 0x%02x", status)); + } + + char productLabel[DeviceLayer::ConfigurationManager::kMaxProductURLLength + 1]; + if (ConfigurationMgr().GetProductLabel(productLabel, sizeof(productLabel)) == CHIP_NO_ERROR) + { + status = Attributes::ProductLabel::Set(endpoint, CharSpan(productLabel, strlen(productLabel))); + VerifyOrdo(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Product Label: 0x%02x", status)); + } + + bool localConfigDisabled; + if (ConfigurationMgr().GetLocalConfigDisabled(localConfigDisabled) == CHIP_NO_ERROR) + { + status = Attributes::LocalConfigDisabled::Set(endpoint, localConfigDisabled); + VerifyOrdo(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Local Config Disabled: 0x%02x", status)); + } + + bool reachable; + if (ConfigurationMgr().GetReachable(reachable) == CHIP_NO_ERROR) + { + status = Attributes::Reachable::Set(endpoint, reachable); + VerifyOrdo(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Reachable: 0x%02x", status)); + } + + char uniqueId[DeviceLayer::ConfigurationManager::kMaxUniqueIDLength + 1]; + if (ConfigurationMgr().GetUniqueId(uniqueId, sizeof(uniqueId)) == CHIP_NO_ERROR) + { + status = Attributes::UniqueID::Set(endpoint, CharSpan(uniqueId, strlen(uniqueId))); + VerifyOrdo(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Unique Id: 0x%02x", status)); } } diff --git a/src/include/platform/ConfigurationManager.h b/src/include/platform/ConfigurationManager.h index d4073181aaa0ed..fc2547b9bf57c0 100644 --- a/src/include/platform/ConfigurationManager.h +++ b/src/include/platform/ConfigurationManager.h @@ -116,6 +116,14 @@ class ConfigurationManager virtual CHIP_ERROR StoreTotalOperationalHours(uint32_t totalOperationalHours) = 0; virtual CHIP_ERROR GetBootReason(uint32_t & bootReason) = 0; virtual CHIP_ERROR StoreBootReason(uint32_t bootReason) = 0; + virtual CHIP_ERROR GetNodeLabel(char * buf, size_t bufSize) = 0; + virtual CHIP_ERROR StoreNodeLabel(const char * buf, size_t bufSize) = 0; + virtual CHIP_ERROR GetPartNumber(char * buf, size_t bufSize) = 0; + virtual CHIP_ERROR GetProductURL(char * buf, size_t bufSize) = 0; + virtual CHIP_ERROR GetProductLabel(char * buf, size_t bufSize) = 0; + virtual CHIP_ERROR GetLocalConfigDisabled(bool & disabled) = 0; + virtual CHIP_ERROR GetReachable(bool & reachable) = 0; + virtual CHIP_ERROR GetUniqueId(char * buf, size_t bufSize) = 0; virtual CHIP_ERROR GetBLEDeviceIdentificationInfo(Ble::ChipBLEDeviceIdentificationInfo & deviceIdInfo) = 0; diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.cpp b/src/include/platform/internal/GenericConfigurationManagerImpl.cpp index 9f13387b745a94..bdd4b7f771b3ed 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.cpp +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.cpp @@ -380,6 +380,54 @@ CHIP_ERROR GenericConfigurationManagerImpl::StoreBootReason(uint32_t return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; } +template +CHIP_ERROR GenericConfigurationManagerImpl::GetNodeLabel(char * buf, size_t bufSize) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +template +CHIP_ERROR GenericConfigurationManagerImpl::StoreNodeLabel(const char * buf, size_t bufSize) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +template +CHIP_ERROR GenericConfigurationManagerImpl::GetPartNumber(char * buf, size_t bufSize) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +template +CHIP_ERROR GenericConfigurationManagerImpl::GetProductURL(char * buf, size_t bufSize) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +template +CHIP_ERROR GenericConfigurationManagerImpl::GetProductLabel(char * buf, size_t bufSize) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +template +CHIP_ERROR GenericConfigurationManagerImpl::GetLocalConfigDisabled(bool & disabled) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +template +CHIP_ERROR GenericConfigurationManagerImpl::GetReachable(bool & reachable) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +template +CHIP_ERROR GenericConfigurationManagerImpl::GetUniqueId(char * buf, size_t bufSize) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + template CHIP_ERROR GenericConfigurationManagerImpl::GetLifetimeCounter(uint16_t & lifetimeCounter) { diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.h b/src/include/platform/internal/GenericConfigurationManagerImpl.h index df551b5feae87c..e8b36a54724505 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.h +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.h @@ -100,6 +100,14 @@ class GenericConfigurationManagerImpl : public ConfigurationManager CHIP_ERROR StoreTotalOperationalHours(uint32_t totalOperationalHours) override; CHIP_ERROR GetBootReason(uint32_t & bootReason) override; CHIP_ERROR StoreBootReason(uint32_t bootReason) override; + CHIP_ERROR GetNodeLabel(char * buf, size_t bufSize) override; + CHIP_ERROR StoreNodeLabel(const char * buf, size_t bufSize) override; + CHIP_ERROR GetPartNumber(char * buf, size_t bufSize) override; + CHIP_ERROR GetProductURL(char * buf, size_t bufSize) override; + CHIP_ERROR GetProductLabel(char * buf, size_t bufSize) override; + CHIP_ERROR GetLocalConfigDisabled(bool & disabled) override; + CHIP_ERROR GetReachable(bool & reachable) override; + CHIP_ERROR GetUniqueId(char * buf, size_t bufSize) override; CHIP_ERROR RunUnitTests(void) override; bool IsFullyProvisioned() override; void InitiateFactoryReset() override; diff --git a/src/lib/support/CodeUtils.h b/src/lib/support/CodeUtils.h index 60b545988724c2..7906ab7d1a6c9a 100644 --- a/src/lib/support/CodeUtils.h +++ b/src/lib/support/CodeUtils.h @@ -562,6 +562,29 @@ inline void chipDie(void) } \ } while (false) +/** + * @def VerifyOrdo(expr, ...) + * + * @brief + * do something if expression evaluates to false + * + * Example usage: + * + * @code + * VerifyOrdo(param != nullptr, LogError("param is nullptr")); + * @endcode + * + * @param[in] expr A Boolean expression to be evaluated. + */ +#define VerifyOrdo(expr, ...) \ + do \ + { \ + if (!(expr)) \ + { \ + __VA_ARGS__; \ + } \ + } while (false) + #if (__cplusplus >= 201103L) #ifndef __FINAL diff --git a/src/platform/android/AndroidConfig.cpp b/src/platform/android/AndroidConfig.cpp index 62c4ceb59fc18b..d02fe792653ef7 100644 --- a/src/platform/android/AndroidConfig.cpp +++ b/src/platform/android/AndroidConfig.cpp @@ -71,6 +71,13 @@ const AndroidConfig::Key AndroidConfig::kConfigKey_ProductId = { kCo const AndroidConfig::Key AndroidConfig::kConfigKey_ProductName = { kConfigNamespace_ChipFactory, "product-name" }; const AndroidConfig::Key AndroidConfig::kConfigKey_SoftwareVersion = { kConfigNamespace_ChipFactory, "software-version" }; const AndroidConfig::Key AndroidConfig::kConfigKey_SoftwareVersionString = { kConfigNamespace_ChipFactory, "software-version-str" }; +const AndroidConfig::Key AndroidConfig::kConfigKey_NodeLabel = { kConfigNamespace_ChipFactory, "node-label" }; +const AndroidConfig::Key AndroidConfig::kConfigKey_PartNumber = { kConfigNamespace_ChipFactory, "part-number" }; +const AndroidConfig::Key AndroidConfig::kConfigKey_ProductURL = { kConfigNamespace_ChipFactory, "product-url" }; +const AndroidConfig::Key AndroidConfig::kConfigKey_ProductLabel = { kConfigNamespace_ChipFactory, "product-label" }; +const AndroidConfig::Key AndroidConfig::kConfigKey_LocalConfigDisabled = { kConfigNamespace_ChipFactory, "local-config-disabled" }; +const AndroidConfig::Key AndroidConfig::kConfigKey_Reachable = { kConfigNamespace_ChipFactory, "reachable" }; +const AndroidConfig::Key AndroidConfig::kConfigKey_UniqueId = { kConfigNamespace_ChipFactory, "uniqueId" }; // Keys stored in the Chip-config namespace const AndroidConfig::Key AndroidConfig::kConfigKey_FabricId = { kConfigNamespace_ChipConfig, "fabric-id" }; diff --git a/src/platform/android/AndroidConfig.h b/src/platform/android/AndroidConfig.h index afe20d5be0650d..66f61930eb89ee 100644 --- a/src/platform/android/AndroidConfig.h +++ b/src/platform/android/AndroidConfig.h @@ -79,6 +79,13 @@ class AndroidConfig static const Key kConfigKey_ProductName; static const Key kConfigKey_SoftwareVersion; static const Key kConfigKey_SoftwareVersionString; + static const Key kConfigKey_NodeLabel; + static const Key kConfigKey_PartNumber; + static const Key kConfigKey_ProductURL; + static const Key kConfigKey_ProductLabel; + static const Key kConfigKey_LocalConfigDisabled; + static const Key kConfigKey_Reachable; + static const Key kConfigKey_UniqueId; static const char kGroupKeyNamePrefix[]; diff --git a/src/platform/android/ConfigurationManagerImpl.cpp b/src/platform/android/ConfigurationManagerImpl.cpp index 4920f2a3ba94d7..446d46d34be36a 100644 --- a/src/platform/android/ConfigurationManagerImpl.cpp +++ b/src/platform/android/ConfigurationManagerImpl.cpp @@ -242,5 +242,50 @@ CHIP_ERROR ConfigurationManagerImpl::GetHardwareVersionString(char * buf, size_t return CHIP_NO_ERROR; } +CHIP_ERROR ConfigurationManagerImpl::GetNodeLabel(char * buf, size_t bufSize) +{ + size_t dateLen; + return ReadConfigValueStr(AndroidConfig::kConfigKey_NodeLabel, buf, bufSize, dateLen); +} + +CHIP_ERROR ConfigurationManagerImpl::StoreNodeLabel(const char * buf, size_t bufSize) +{ + return WriteConfigValueStr(AndroidConfig::kConfigKey_NodeLabel, buf, bufSize); +} + +CHIP_ERROR ConfigurationManagerImpl::GetPartNumber(char * buf, size_t bufSize) +{ + size_t dateLen; + return ReadConfigValueStr(AndroidConfig::kConfigKey_PartNumber, buf, bufSize, dateLen); +} + +CHIP_ERROR ConfigurationManagerImpl::GetProductURL(char * buf, size_t bufSize) +{ + size_t dateLen; + return ReadConfigValueStr(AndroidConfig::kConfigKey_ProductURL, buf, bufSize, dateLen); +} + +CHIP_ERROR ConfigurationManagerImpl::GetProductLabel(char * buf, size_t bufSize) +{ + size_t dateLen; + return ReadConfigValueStr(AndroidConfig::kConfigKey_ProductLabel, buf, bufSize, dateLen); +} + +CHIP_ERROR ConfigurationManagerImpl::GetLocalConfigDisabled(bool & disabled) +{ + return ReadConfigValue(AndroidConfig::kConfigKey_LocalConfigDisabled, disabled); +} + +CHIP_ERROR ConfigurationManagerImpl::GetReachable(bool & reachable) +{ + return ReadConfigValue(AndroidConfig::kConfigKey_Reachable, reachable); +} + +CHIP_ERROR ConfigurationManagerImpl::GetUniqueId(char * buf, size_t bufSize) +{ + size_t dateLen; + return ReadConfigValueStr(AndroidConfig::kConfigKey_UniqueId, buf, bufSize, dateLen); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/android/ConfigurationManagerImpl.h b/src/platform/android/ConfigurationManagerImpl.h index 574dfeac8cfae7..75aa7b74393b45 100644 --- a/src/platform/android/ConfigurationManagerImpl.h +++ b/src/platform/android/ConfigurationManagerImpl.h @@ -45,6 +45,14 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp CHIP_ERROR GetHardwareVersionString(char * buf, size_t bufSize) override; CHIP_ERROR GetSoftwareVersionString(char * buf, size_t bufSize) override; CHIP_ERROR GetSoftwareVersion(uint16_t & softwareVer) override; + CHIP_ERROR GetNodeLabel(char * buf, size_t bufSize) override; + CHIP_ERROR StoreNodeLabel(const char * buf, size_t bufSize) override; + CHIP_ERROR GetPartNumber(char * buf, size_t bufSize) override; + CHIP_ERROR GetProductURL(char * buf, size_t bufSize) override; + CHIP_ERROR GetProductLabel(char * buf, size_t bufSize) override; + CHIP_ERROR GetLocalConfigDisabled(bool & disabled) override; + CHIP_ERROR GetReachable(bool & reachable) override; + CHIP_ERROR GetUniqueId(char * buf, size_t bufSize) override; private: // ===== Members that implement the ConfigurationManager public interface. diff --git a/src/platform/android/java/chip/platform/ConfigurationManager.java b/src/platform/android/java/chip/platform/ConfigurationManager.java index 5bec114ad5b1bf..4751974356cbae 100644 --- a/src/platform/android/java/chip/platform/ConfigurationManager.java +++ b/src/platform/android/java/chip/platform/ConfigurationManager.java @@ -39,6 +39,13 @@ public interface ConfigurationManager { String kConfigKey_ProductName = "product-name"; String kConfigKey_SoftwareVersion = "software-version"; String kConfigKey_SoftwareVersionString = "software-version-str"; + String kConfigKey_NodeLabel = "node-label"; + String kConfigKey_PartNumber = "part-number"; + String kConfigKey_ProductURL = "product-url"; + String kConfigKey_ProductLabel = "product-label"; + String kConfigKey_LocalConfigDisabled = "local-config-disabled"; + String kConfigKey_Reachable = "reachable"; + String kConfigKey_UniqueId = "uniqueId"; // Keys stored in the Chip-config namespace String kConfigKey_FabricId = "fabric-id"; diff --git a/src/platform/android/java/chip/platform/PreferencesConfigurationManager.java b/src/platform/android/java/chip/platform/PreferencesConfigurationManager.java index fffd75456c35f1..b02390f80e78aa 100644 --- a/src/platform/android/java/chip/platform/PreferencesConfigurationManager.java +++ b/src/platform/android/java/chip/platform/PreferencesConfigurationManager.java @@ -22,6 +22,7 @@ import android.util.Log; import java.util.Base64; import java.util.Map; +import java.util.UUID; /** Java interface for ConfigurationManager */ public class PreferencesConfigurationManager implements ConfigurationManager { @@ -32,6 +33,18 @@ public class PreferencesConfigurationManager implements ConfigurationManager { public PreferencesConfigurationManager(Context context) { preferences = context.getSharedPreferences(PREFERENCE_FILE_KEY, Context.MODE_PRIVATE); + + try { + String keyUniqueId = getKey(kConfigNamespace_ChipFactory, kConfigKey_UniqueId); + if (!preferences.contains(keyUniqueId)) { + preferences + .edit() + .putString(keyUniqueId, UUID.randomUUID().toString().replaceAll("-", "")) + .apply(); + } + } catch (AndroidChipPlatformException e) { + e.printStackTrace(); + } } @Override @@ -136,6 +149,34 @@ public String readConfigValueStr(String namespace, String name) */ case kConfigNamespace_ChipFactory + ":" + kConfigKey_SerialNum: return "TEST_ANDROID_SN"; + + /** + * The PartNumber attribute SHALL specify a human-readable (displayable) vendor assigned + * part number for the Node whose meaning and numbering scheme is vendor defined. Multiple + * products (and hence PartNumbers) can share a ProductID. For instance, there may be + * different packaging (with different PartNumbers) for different regions; also different + * colors of a product might share the ProductID but may have a different PartNumber. + */ + case kConfigNamespace_ChipFactory + ":" + kConfigKey_PartNumber: + return "TEST_ANDROID_PRODUCT_BLUE"; + + /** + * The ProductURL attribute SHALL specify a link to a product specific web page. The syntax + * of the ProductURL attribute SHALL follow the syntax as specified in RFC 3986. The + * specified URL SHOULD resolve to a maintained web page available for the lifetime of the + * product. The maximum length of the ProductUrl attribute is 256 ASCII characters. + */ + case kConfigNamespace_ChipFactory + ":" + kConfigKey_ProductURL: + return "https://buildwithmatter.com/"; + + /** + * The ProductLabel attribute SHALL specify a vendor specific human readable (displayable) + * product label. The ProductLabel attribute MAY be used to provide a more user-friendly + * value than that represented by the ProductName attribute. The ProductLabel attribute + * SHOULD NOT include the name of the vendor as defined within the VendorName attribute. + */ + case kConfigNamespace_ChipFactory + ":" + kConfigKey_ProductLabel: + return "X10"; } if (preferences.contains(key)) {