From 1dd1e806723d334583fbfaa99697480400b41836 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 27 Apr 2022 12:18:05 -0400 Subject: [PATCH] Stop trying to get NodeLabel and LocalConfigDisabled from configuration manager (#17758) * Stop trying to get NodeLabel and LocalConfigDisabled from configuration manager. We're never _storing_ these in the configuration manager, so getting them from there, on startup only, makes no sense. The added tests verify that we are in fact properly storing them in NVM. * Address review comments. --- .../chip-tool-darwin/templates/tests/tests.js | 3 +- src/app/clusters/basic/basic.cpp | 30 ++- src/app/clusters/basic/basic.h | 15 ++ .../ota-requestor/DefaultOTARequestor.cpp | 3 +- .../ExtendedOTARequestorDriver.cpp | 7 +- .../tests/suites/TestBasicInformation.yaml | 72 ++++++ .../Framework/CHIP/templates/tests/tests.js | 3 +- .../Framework/CHIPTests/CHIPClustersTests.m | 149 ------------ src/include/platform/ConfigurationManager.h | 4 - .../GenericConfigurationManagerImpl.h | 3 - .../GenericConfigurationManagerImpl.ipp | 18 -- src/platform/android/AndroidConfig.cpp | 4 +- src/platform/android/AndroidConfig.h | 2 - .../android/ConfigurationManagerImpl.cpp | 16 -- .../android/ConfigurationManagerImpl.h | 3 - .../chip/platform/ConfigurationManager.java | 2 - src/platform/fake/ConfigurationManagerImpl.h | 3 - .../zap-generated/test/Commands.h | 223 ------------------ .../chip-tool/zap-generated/test/Commands.h | 128 +++++++++- 19 files changed, 236 insertions(+), 452 deletions(-) diff --git a/examples/chip-tool-darwin/templates/tests/tests.js b/examples/chip-tool-darwin/templates/tests/tests.js index 94d0d32c70cd38..8439bed5f3dec6 100644 --- a/examples/chip-tool-darwin/templates/tests/tests.js +++ b/examples/chip-tool-darwin/templates/tests/tests.js @@ -275,7 +275,8 @@ function getTests() 'TestConstraints', 'TestDelayCommands', 'TestDescriptorCluster', - 'TestBasicInformation', + // TestBasicInformation needs Reboot + //'TestBasicInformation', 'TestGeneralCommissioning', 'TestGroupsCluster', 'TestGroupKeyManagementCluster', diff --git a/src/app/clusters/basic/basic.cpp b/src/app/clusters/basic/basic.cpp index 32dd9f00443e7a..0d5b9a91a812b3 100644 --- a/src/app/clusters/basic/basic.cpp +++ b/src/app/clusters/basic/basic.cpp @@ -389,24 +389,22 @@ PlatformMgrDelegate gPlatformMgrDelegate; } // anonymous namespace -void emberAfBasicClusterServerInitCallback(chip::EndpointId endpoint) +namespace chip { +namespace app { +namespace Clusters { +namespace Basic { +bool IsLocalConfigDisabled() { - EmberAfStatus status; - - char nodeLabel[DeviceLayer::ConfigurationManager::kMaxNodeLabelLength + 1]; - if (ConfigurationMgr().GetNodeLabel(nodeLabel, sizeof(nodeLabel)) == CHIP_NO_ERROR) - { - status = Attributes::NodeLabel::Set(endpoint, chip::CharSpan::fromCharString(nodeLabel)); - VerifyOrdo(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Error setting Node 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 disabled = false; + EmberAfStatus status = LocalConfigDisabled::Get(0, &disabled); + return status == EMBER_ZCL_STATUS_SUCCESS && disabled; } +} // namespace Basic +} // namespace Clusters +} // namespace app +} // namespace chip + +void emberAfBasicClusterServerInitCallback(chip::EndpointId endpoint) {} void MatterBasicPluginServerInitCallback() { diff --git a/src/app/clusters/basic/basic.h b/src/app/clusters/basic/basic.h index 712a1dcce398a8..16d1f1e6b08624 100644 --- a/src/app/clusters/basic/basic.h +++ b/src/app/clusters/basic/basic.h @@ -19,6 +19,21 @@ #include +namespace chip { +namespace app { +namespace Clusters { +namespace Basic { +/** + * Check whether LocalConfigDisabled is set (on endpoint 0, which is the only + * place the Basic Information cluster exists and can have the attribute be + * set). + */ +bool IsLocalConfigDisabled(); +} // namespace Basic +} // namespace Clusters +} // namespace app +} // namespace chip + /** @brief Basic Cluster Server Init * * This function is called at startup for a given endpoint to initialize diff --git a/src/app/clusters/ota-requestor/DefaultOTARequestor.cpp b/src/app/clusters/ota-requestor/DefaultOTARequestor.cpp index d53a4466cdcc07..cb1017100e8092 100644 --- a/src/app/clusters/ota-requestor/DefaultOTARequestor.cpp +++ b/src/app/clusters/ota-requestor/DefaultOTARequestor.cpp @@ -20,6 +20,7 @@ * OTA Requestor logic is contained in this class. */ +#include #include #include #include @@ -733,7 +734,7 @@ CHIP_ERROR DefaultOTARequestor::SendQueryImageRequest(OperationalDeviceProxy & d ReturnErrorOnFailure(DeviceLayer::ConfigurationMgr().GetSoftwareVersion(args.softwareVersion)); args.protocolsSupported = kProtocolsSupported; - args.requestorCanConsent.SetValue(mOtaRequestorDriver->CanConsent()); + args.requestorCanConsent.SetValue(!Basic::IsLocalConfigDisabled() && mOtaRequestorDriver->CanConsent()); uint16_t hardwareVersion; if (DeviceLayer::ConfigurationMgr().GetHardwareVersion(hardwareVersion) == CHIP_NO_ERROR) diff --git a/src/app/clusters/ota-requestor/ExtendedOTARequestorDriver.cpp b/src/app/clusters/ota-requestor/ExtendedOTARequestorDriver.cpp index 07f96e9e00041e..e1218cb60f3000 100644 --- a/src/app/clusters/ota-requestor/ExtendedOTARequestorDriver.cpp +++ b/src/app/clusters/ota-requestor/ExtendedOTARequestorDriver.cpp @@ -30,12 +30,7 @@ constexpr System::Clock::Seconds32 kUserConsentPollInterval = System::Clock::Sec bool ExtendedOTARequestorDriver::CanConsent() { - bool localConfigDisabled = false; - VerifyOrdo(DeviceLayer::ConfigurationMgr().GetLocalConfigDisabled(localConfigDisabled) == CHIP_NO_ERROR, - ChipLogProgress(SoftwareUpdate, "Failed to get local config disabled, assuming not disabled")); - - // User consent delegation SHALL NOT be used if a Node is configured with the LocalConfigDisabled attribute set to True - return localConfigDisabled == false; + return mUserConsentDelegate != nullptr; } void ExtendedOTARequestorDriver::UpdateAvailable(const UpdateDescription & update, System::Clock::Seconds32 delay) diff --git a/src/app/tests/suites/TestBasicInformation.yaml b/src/app/tests/suites/TestBasicInformation.yaml index 133a7aa2fe03d8..8d312219b5ed13 100644 --- a/src/app/tests/suites/TestBasicInformation.yaml +++ b/src/app/tests/suites/TestBasicInformation.yaml @@ -82,3 +82,75 @@ tests: 0xFFFB, # AttributeList 0xFFFD, # ClusterRevision ] + + - label: "Read NodeLabel" + command: "readAttribute" + attribute: "NodeLabel" + response: + value: "" + + - label: "Write NodeLabel" + command: "writeAttribute" + attribute: "NodeLabel" + arguments: + value: "My node" + + - label: "Read back NodeLabel" + command: "readAttribute" + attribute: "NodeLabel" + response: + value: "My node" + + - label: "Read LocalConfigDisabled" + command: "readAttribute" + attribute: "LocalConfigDisabled" + response: + value: false + + - label: "Write LocalConfigDisabled" + command: "writeAttribute" + attribute: "LocalConfigDisabled" + arguments: + value: true + + - label: "Read back LocalConfigDisabled" + command: "readAttribute" + attribute: "LocalConfigDisabled" + response: + value: true + + - label: "Reboot the device" + cluster: "SystemCommands" + command: "Reboot" + + - label: "Connect to the device again" + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId + + - label: "Read back NodeLabel after reboot" + command: "readAttribute" + attribute: "NodeLabel" + response: + value: "My node" + + - label: "Restore initial NodeLabel value" + command: "writeAttribute" + attribute: "NodeLabel" + arguments: + value: "" + + - label: "Read back LocalConfigDisabled after reboot" + command: "readAttribute" + attribute: "LocalConfigDisabled" + response: + value: true + + - label: "Restore initial LocalConfigDisabled value" + command: "writeAttribute" + attribute: "LocalConfigDisabled" + arguments: + value: false diff --git a/src/darwin/Framework/CHIP/templates/tests/tests.js b/src/darwin/Framework/CHIP/templates/tests/tests.js index 278ed1896d3039..aa54647a79220b 100644 --- a/src/darwin/Framework/CHIP/templates/tests/tests.js +++ b/src/darwin/Framework/CHIP/templates/tests/tests.js @@ -271,7 +271,8 @@ function getTests() 'TestConstraints', 'TestDelayCommands', 'TestDescriptorCluster', - 'TestBasicInformation', + // TestBasicInformation needs support for Reboot with no discriminator + //'TestBasicInformation', 'TestGeneralCommissioning', 'TestGroupsCluster', 'TestGroupKeyManagementCluster', diff --git a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m index 40f2321c3f51c6..e656b0acbc87a6 100644 --- a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m +++ b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m @@ -48858,155 +48858,6 @@ - (void)testSendClusterTestDescriptorCluster_000004_ReadAttribute [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)testSendClusterTestBasicInformation_000000_WaitForCommissionee -{ - XCTestExpectation * expectation = [self expectationWithDescription:@"Wait for the commissioned device to be retrieved"]; - - dispatch_queue_t queue = dispatch_get_main_queue(); - WaitForCommissionee(expectation, queue, 305414945); - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; -} -- (void)testSendClusterTestBasicInformation_000001_ReadAttribute -{ - XCTestExpectation * expectation = [self expectationWithDescription:@"Read location"]; - - CHIPDevice * device = GetConnectedDevice(); - dispatch_queue_t queue = dispatch_get_main_queue(); - CHIPTestBasic * cluster = [[CHIPTestBasic alloc] initWithDevice:device endpoint:0 queue:queue]; - XCTAssertNotNil(cluster); - - [cluster readAttributeLocationWithCompletionHandler:^(NSString * _Nullable value, NSError * _Nullable err) { - NSLog(@"Read location Error: %@", err); - - XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); - - { - id actualValue = value; - XCTAssertTrue([actualValue isEqualToString:@"XX"]); - } - - [expectation fulfill]; - }]; - - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; -} -- (void)testSendClusterTestBasicInformation_000002_WriteAttribute -{ - XCTestExpectation * expectation = [self expectationWithDescription:@"Write location"]; - - CHIPDevice * device = GetConnectedDevice(); - dispatch_queue_t queue = dispatch_get_main_queue(); - CHIPTestBasic * cluster = [[CHIPTestBasic alloc] initWithDevice:device endpoint:0 queue:queue]; - XCTAssertNotNil(cluster); - - id locationArgument; - locationArgument = @"US"; - [cluster writeAttributeLocationWithValue:locationArgument - completionHandler:^(NSError * _Nullable err) { - NSLog(@"Write location Error: %@", err); - - XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); - - [expectation fulfill]; - }]; - - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; -} -- (void)testSendClusterTestBasicInformation_000003_ReadAttribute -{ - XCTestExpectation * expectation = [self expectationWithDescription:@"Read back location"]; - - CHIPDevice * device = GetConnectedDevice(); - dispatch_queue_t queue = dispatch_get_main_queue(); - CHIPTestBasic * cluster = [[CHIPTestBasic alloc] initWithDevice:device endpoint:0 queue:queue]; - XCTAssertNotNil(cluster); - - [cluster readAttributeLocationWithCompletionHandler:^(NSString * _Nullable value, NSError * _Nullable err) { - NSLog(@"Read back location Error: %@", err); - - XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); - - { - id actualValue = value; - XCTAssertTrue([actualValue isEqualToString:@"US"]); - } - - [expectation fulfill]; - }]; - - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; -} -- (void)testSendClusterTestBasicInformation_000004_WriteAttribute -{ - XCTestExpectation * expectation = [self expectationWithDescription:@"Restore initial location value"]; - - CHIPDevice * device = GetConnectedDevice(); - dispatch_queue_t queue = dispatch_get_main_queue(); - CHIPTestBasic * cluster = [[CHIPTestBasic alloc] initWithDevice:device endpoint:0 queue:queue]; - XCTAssertNotNil(cluster); - - id locationArgument; - locationArgument = @"XX"; - [cluster writeAttributeLocationWithValue:locationArgument - completionHandler:^(NSError * _Nullable err) { - NSLog(@"Restore initial location value Error: %@", err); - - XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); - - [expectation fulfill]; - }]; - - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; -} -- (void)testSendClusterTestBasicInformation_000005_ReadAttribute -{ - XCTestExpectation * expectation = [self expectationWithDescription:@"Read AttributeList value"]; - - CHIPDevice * device = GetConnectedDevice(); - dispatch_queue_t queue = dispatch_get_main_queue(); - CHIPTestBasic * cluster = [[CHIPTestBasic alloc] initWithDevice:device endpoint:0 queue:queue]; - XCTAssertNotNil(cluster); - - [cluster readAttributeAttributeListWithCompletionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { - NSLog(@"Read AttributeList value Error: %@", err); - - XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); - - { - id actualValue = value; - XCTAssertEqual([actualValue count], 24); - XCTAssertEqual([actualValue[0] unsignedIntValue], 0UL); - XCTAssertEqual([actualValue[1] unsignedIntValue], 1UL); - XCTAssertEqual([actualValue[2] unsignedIntValue], 2UL); - XCTAssertEqual([actualValue[3] unsignedIntValue], 3UL); - XCTAssertEqual([actualValue[4] unsignedIntValue], 4UL); - XCTAssertEqual([actualValue[5] unsignedIntValue], 5UL); - XCTAssertEqual([actualValue[6] unsignedIntValue], 6UL); - XCTAssertEqual([actualValue[7] unsignedIntValue], 7UL); - XCTAssertEqual([actualValue[8] unsignedIntValue], 8UL); - XCTAssertEqual([actualValue[9] unsignedIntValue], 9UL); - XCTAssertEqual([actualValue[10] unsignedIntValue], 10UL); - XCTAssertEqual([actualValue[11] unsignedIntValue], 11UL); - XCTAssertEqual([actualValue[12] unsignedIntValue], 12UL); - XCTAssertEqual([actualValue[13] unsignedIntValue], 13UL); - XCTAssertEqual([actualValue[14] unsignedIntValue], 14UL); - XCTAssertEqual([actualValue[15] unsignedIntValue], 15UL); - XCTAssertEqual([actualValue[16] unsignedIntValue], 16UL); - XCTAssertEqual([actualValue[17] unsignedIntValue], 17UL); - XCTAssertEqual([actualValue[18] unsignedIntValue], 18UL); - XCTAssertEqual([actualValue[19] unsignedIntValue], 19UL); - XCTAssertEqual([actualValue[20] unsignedIntValue], 65528UL); - XCTAssertEqual([actualValue[21] unsignedIntValue], 65529UL); - XCTAssertEqual([actualValue[22] unsignedIntValue], 65531UL); - XCTAssertEqual([actualValue[23] unsignedIntValue], 65533UL); - } - - [expectation fulfill]; - }]; - - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; -} - - (void)testSendClusterTestGeneralCommissioning_000000_WaitForCommissionee { XCTestExpectation * expectation = [self expectationWithDescription:@"Wait for the commissioned device to be retrieved"]; diff --git a/src/include/platform/ConfigurationManager.h b/src/include/platform/ConfigurationManager.h index fc120d686505bd..d4779dd46f305d 100644 --- a/src/include/platform/ConfigurationManager.h +++ b/src/include/platform/ConfigurationManager.h @@ -63,7 +63,6 @@ class ConfigurationManager { kMaxVendorNameLength = 32, kMaxProductNameLength = 32, - kMaxNodeLabelLength = 32, kMaxLocationLength = 2, kMaxHardwareVersionStringLength = 64, kMaxSoftwareVersionStringLength = 64, @@ -123,12 +122,9 @@ 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 GetUniqueId(char * buf, size_t bufSize) = 0; virtual CHIP_ERROR StoreUniqueId(const char * uniqueId, size_t uniqueIdLen) = 0; virtual CHIP_ERROR GenerateUniqueId(char * buf, size_t bufSize) = 0; diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.h b/src/include/platform/internal/GenericConfigurationManagerImpl.h index 71ebcda397477b..5e33e04e2088e0 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.h +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.h @@ -104,12 +104,9 @@ 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 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; diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.ipp b/src/include/platform/internal/GenericConfigurationManagerImpl.ipp index 1eda6d47ba914e..91423c452ebc49 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.ipp +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.ipp @@ -590,18 +590,6 @@ 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) { @@ -620,12 +608,6 @@ CHIP_ERROR GenericConfigurationManagerImpl::GetProductLabel(char * return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; } -template -CHIP_ERROR GenericConfigurationManagerImpl::GetLocalConfigDisabled(bool & disabled) -{ - return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; -} - template CHIP_ERROR GenericConfigurationManagerImpl::GetUniqueId(char * buf, size_t bufSize) { diff --git a/src/platform/android/AndroidConfig.cpp b/src/platform/android/AndroidConfig.cpp index 98040a81ef38fb..ef6b298b8581ae 100644 --- a/src/platform/android/AndroidConfig.cpp +++ b/src/platform/android/AndroidConfig.cpp @@ -71,12 +71,10 @@ 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_UniqueId = { kConfigNamespace_ChipFactory, "uniqueId" }; +const AndroidConfig::Key AndroidConfig::kConfigKey_UniqueId = { kConfigNamespace_ChipFactory, "uniqueId" }; const AndroidConfig::Key AndroidConfig::kConfigKey_Spake2pIterationCount = { kConfigNamespace_ChipFactory, "iteration-count" }; const AndroidConfig::Key AndroidConfig::kConfigKey_Spake2pSalt = { kConfigNamespace_ChipFactory, "salt" }; const AndroidConfig::Key AndroidConfig::kConfigKey_Spake2pVerifier = { kConfigNamespace_ChipFactory, "verifier" }; diff --git a/src/platform/android/AndroidConfig.h b/src/platform/android/AndroidConfig.h index e71bc189fa42eb..3f53259432a9f8 100644 --- a/src/platform/android/AndroidConfig.h +++ b/src/platform/android/AndroidConfig.h @@ -79,11 +79,9 @@ 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_UniqueId; static const Key kConfigKey_Spake2pIterationCount; static const Key kConfigKey_Spake2pSalt; diff --git a/src/platform/android/ConfigurationManagerImpl.cpp b/src/platform/android/ConfigurationManagerImpl.cpp index 9ffd720cfa729f..a34fc504e2c50d 100644 --- a/src/platform/android/ConfigurationManagerImpl.cpp +++ b/src/platform/android/ConfigurationManagerImpl.cpp @@ -237,17 +237,6 @@ 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; @@ -266,11 +255,6 @@ CHIP_ERROR ConfigurationManagerImpl::GetProductLabel(char * buf, size_t bufSize) return ReadConfigValueStr(AndroidConfig::kConfigKey_ProductLabel, buf, bufSize, dateLen); } -CHIP_ERROR ConfigurationManagerImpl::GetLocalConfigDisabled(bool & disabled) -{ - return ReadConfigValue(AndroidConfig::kConfigKey_LocalConfigDisabled, disabled); -} - CHIP_ERROR ConfigurationManagerImpl::GetUniqueId(char * buf, size_t bufSize) { size_t dateLen; diff --git a/src/platform/android/ConfigurationManagerImpl.h b/src/platform/android/ConfigurationManagerImpl.h index 25ea7c4681f37c..42c5c30c4b174c 100644 --- a/src/platform/android/ConfigurationManagerImpl.h +++ b/src/platform/android/ConfigurationManagerImpl.h @@ -45,12 +45,9 @@ 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(uint32_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 GetUniqueId(char * buf, size_t bufSize) override; private: diff --git a/src/platform/android/java/chip/platform/ConfigurationManager.java b/src/platform/android/java/chip/platform/ConfigurationManager.java index 38d6dd71973d1f..ae35caed7b4401 100644 --- a/src/platform/android/java/chip/platform/ConfigurationManager.java +++ b/src/platform/android/java/chip/platform/ConfigurationManager.java @@ -39,11 +39,9 @@ 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_UniqueId = "uniqueId"; String kConfigKey_Spake2pIterationCount = "iteration-count"; String kConfigKey_Spake2pSalt = "salt"; diff --git a/src/platform/fake/ConfigurationManagerImpl.h b/src/platform/fake/ConfigurationManagerImpl.h index 127cff6ff51368..e7ebe3ffefa752 100644 --- a/src/platform/fake/ConfigurationManagerImpl.h +++ b/src/platform/fake/ConfigurationManagerImpl.h @@ -86,12 +86,9 @@ class ConfigurationManagerImpl : public ConfigurationManager CHIP_ERROR StoreTotalOperationalHours(uint32_t totalOperationalHours) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetBootReason(uint32_t & bootReason) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR StoreBootReason(uint32_t bootReason) override { return CHIP_ERROR_NOT_IMPLEMENTED; } - CHIP_ERROR GetNodeLabel(char * buf, size_t bufSize) override { return CHIP_ERROR_NOT_IMPLEMENTED; } - CHIP_ERROR StoreNodeLabel(const char * buf, size_t bufSize) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetPartNumber(char * buf, size_t bufSize) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetProductURL(char * buf, size_t bufSize) override { return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR GetProductLabel(char * buf, size_t bufSize) override { return CHIP_ERROR_NOT_IMPLEMENTED; } - CHIP_ERROR GetLocalConfigDisabled(bool & disabled) override { return CHIP_ERROR_NOT_IMPLEMENTED; } 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; } diff --git a/zzz_generated/chip-tool-darwin/zap-generated/test/Commands.h b/zzz_generated/chip-tool-darwin/zap-generated/test/Commands.h index e6bb84ddf4b0fc..e11d010f474978 100644 --- a/zzz_generated/chip-tool-darwin/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool-darwin/zap-generated/test/Commands.h @@ -179,7 +179,6 @@ class TestList : public Command { printf("TestConstraints\n"); printf("TestDelayCommands\n"); printf("TestDescriptorCluster\n"); - printf("TestBasicInformation\n"); printf("TestGeneralCommissioning\n"); printf("TestGroupsCluster\n"); printf("TestGroupKeyManagementCluster\n"); @@ -61457,227 +61456,6 @@ class TestDescriptorCluster : public TestCommandBridge { } }; -class TestBasicInformation : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestBasicInformation() - : TestCommandBridge("TestBasicInformation") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestBasicInformation() {} - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestBasicInformation\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestBasicInformation\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read location\n"); - err = TestReadLocation_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Write location\n"); - err = TestWriteLocation_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read back location\n"); - err = TestReadBackLocation_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Restore initial location value\n"); - err = TestRestoreInitialLocationValue_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read AttributeList value\n"); - err = TestReadAttributeListValue_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - chip::System::Clock::Timeout GetWaitDuration() const override - { - return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); - } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - WaitForCommissionee(mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL); - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadLocation_1() - { - CHIPDevice * device = GetConnectedDevice(); - CHIPTestBasic * cluster = [[CHIPTestBasic alloc] initWithDevice:device endpoint:0 queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLocationWithCompletionHandler:^(NSString * _Nullable value, NSError * _Nullable err) { - NSLog(@"Read location Error: %@", err); - - VerifyOrReturn(CheckValue("status", err, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("Location", actualValue, @"XX")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteLocation_2() - { - CHIPDevice * device = GetConnectedDevice(); - CHIPTestBasic * cluster = [[CHIPTestBasic alloc] initWithDevice:device endpoint:0 queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id locationArgument; - locationArgument = @"US"; - [cluster writeAttributeLocationWithValue:locationArgument - completionHandler:^(NSError * _Nullable err) { - NSLog(@"Write location Error: %@", err); - - VerifyOrReturn(CheckValue("status", err, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackLocation_3() - { - CHIPDevice * device = GetConnectedDevice(); - CHIPTestBasic * cluster = [[CHIPTestBasic alloc] initWithDevice:device endpoint:0 queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLocationWithCompletionHandler:^(NSString * _Nullable value, NSError * _Nullable err) { - NSLog(@"Read back location Error: %@", err); - - VerifyOrReturn(CheckValue("status", err, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("Location", actualValue, @"US")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRestoreInitialLocationValue_4() - { - CHIPDevice * device = GetConnectedDevice(); - CHIPTestBasic * cluster = [[CHIPTestBasic alloc] initWithDevice:device endpoint:0 queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id locationArgument; - locationArgument = @"XX"; - [cluster writeAttributeLocationWithValue:locationArgument - completionHandler:^(NSError * _Nullable err) { - NSLog(@"Restore initial location value Error: %@", err); - - VerifyOrReturn(CheckValue("status", err, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListValue_5() - { - CHIPDevice * device = GetConnectedDevice(); - CHIPTestBasic * cluster = [[CHIPTestBasic alloc] initWithDevice:device endpoint:0 queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { - NSLog(@"Read AttributeList value Error: %@", err); - - VerifyOrReturn(CheckValue("status", err, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AttributeList", [actualValue count], static_cast(24))); - VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); - VerifyOrReturn(CheckValue("", actualValue[1], 1UL)); - VerifyOrReturn(CheckValue("", actualValue[2], 2UL)); - VerifyOrReturn(CheckValue("", actualValue[3], 3UL)); - VerifyOrReturn(CheckValue("", actualValue[4], 4UL)); - VerifyOrReturn(CheckValue("", actualValue[5], 5UL)); - VerifyOrReturn(CheckValue("", actualValue[6], 6UL)); - VerifyOrReturn(CheckValue("", actualValue[7], 7UL)); - VerifyOrReturn(CheckValue("", actualValue[8], 8UL)); - VerifyOrReturn(CheckValue("", actualValue[9], 9UL)); - VerifyOrReturn(CheckValue("", actualValue[10], 10UL)); - VerifyOrReturn(CheckValue("", actualValue[11], 11UL)); - VerifyOrReturn(CheckValue("", actualValue[12], 12UL)); - VerifyOrReturn(CheckValue("", actualValue[13], 13UL)); - VerifyOrReturn(CheckValue("", actualValue[14], 14UL)); - VerifyOrReturn(CheckValue("", actualValue[15], 15UL)); - VerifyOrReturn(CheckValue("", actualValue[16], 16UL)); - VerifyOrReturn(CheckValue("", actualValue[17], 17UL)); - VerifyOrReturn(CheckValue("", actualValue[18], 18UL)); - VerifyOrReturn(CheckValue("", actualValue[19], 19UL)); - VerifyOrReturn(CheckValue("", actualValue[20], 65528UL)); - VerifyOrReturn(CheckValue("", actualValue[21], 65529UL)); - VerifyOrReturn(CheckValue("", actualValue[22], 65531UL)); - VerifyOrReturn(CheckValue("", actualValue[23], 65533UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - class TestGeneralCommissioning : public TestCommandBridge { public: // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced @@ -64940,7 +64718,6 @@ void registerCommandsTests(Commands & commands) make_unique(), make_unique(), make_unique(), - make_unique(), make_unique(), make_unique(), make_unique(), diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index db857b603dde5c..d9b9cd7da43def 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -40216,7 +40216,7 @@ class TestBasicInformationSuite : public TestCommand { public: TestBasicInformationSuite(CredentialIssuerCommands * credsIssuerConfig) : - TestCommand("TestBasicInformation", 6, credsIssuerConfig) + TestCommand("TestBasicInformation", 18, credsIssuerConfig) { AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); AddArgument("cluster", &mCluster); @@ -40334,6 +40334,74 @@ class TestBasicInformationSuite : public TestCommand } } break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::CharSpan value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValueAsString("nodeLabel", value, chip::CharSpan("", 0))); + } + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::CharSpan value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValueAsString("nodeLabel", value, chip::CharSpan("My node", 7))); + } + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + bool value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValue("localConfigDisabled", value, false)); + } + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + bool value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValue("localConfigDisabled", value, true)); + } + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + shouldContinue = true; + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + shouldContinue = true; + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::CharSpan value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValueAsString("nodeLabel", value, chip::CharSpan("My node", 7))); + } + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + bool value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValue("localConfigDisabled", value, true)); + } + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; default: LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); } @@ -40378,6 +40446,64 @@ class TestBasicInformationSuite : public TestCommand LogStep(5, "Read AttributeList value"); return ReadAttribute(kIdentityAlpha, GetEndpoint(0), Basic::Id, Basic::Attributes::AttributeList::Id); } + case 6: { + LogStep(6, "Read NodeLabel"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(0), Basic::Id, Basic::Attributes::NodeLabel::Id); + } + case 7: { + LogStep(7, "Write NodeLabel"); + chip::CharSpan value; + value = chip::Span("My nodegarbage: not in length on purpose", 7); + return WriteAttribute(kIdentityAlpha, GetEndpoint(0), Basic::Id, Basic::Attributes::NodeLabel::Id, value); + } + case 8: { + LogStep(8, "Read back NodeLabel"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(0), Basic::Id, Basic::Attributes::NodeLabel::Id); + } + case 9: { + LogStep(9, "Read LocalConfigDisabled"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(0), Basic::Id, Basic::Attributes::LocalConfigDisabled::Id); + } + case 10: { + LogStep(10, "Write LocalConfigDisabled"); + bool value; + value = true; + return WriteAttribute(kIdentityAlpha, GetEndpoint(0), Basic::Id, Basic::Attributes::LocalConfigDisabled::Id, value); + } + case 11: { + LogStep(11, "Read back LocalConfigDisabled"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(0), Basic::Id, Basic::Attributes::LocalConfigDisabled::Id); + } + case 12: { + LogStep(12, "Reboot the device"); + SetIdentity(kIdentityAlpha); + return Reboot(); + } + case 13: { + LogStep(13, "Connect to the device again"); + SetIdentity(kIdentityAlpha); + return WaitForCommissionee(mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL); + } + case 14: { + LogStep(14, "Read back NodeLabel after reboot"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(0), Basic::Id, Basic::Attributes::NodeLabel::Id); + } + case 15: { + LogStep(15, "Restore initial NodeLabel value"); + chip::CharSpan value; + value = chip::Span("garbage: not in length on purpose", 0); + return WriteAttribute(kIdentityAlpha, GetEndpoint(0), Basic::Id, Basic::Attributes::NodeLabel::Id, value); + } + case 16: { + LogStep(16, "Read back LocalConfigDisabled after reboot"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(0), Basic::Id, Basic::Attributes::LocalConfigDisabled::Id); + } + case 17: { + LogStep(17, "Restore initial LocalConfigDisabled value"); + bool value; + value = false; + return WriteAttribute(kIdentityAlpha, GetEndpoint(0), Basic::Id, Basic::Attributes::LocalConfigDisabled::Id, value); + } } return CHIP_NO_ERROR; }