From 49462581b024b8f6cfd83626773770595dc408dd Mon Sep 17 00:00:00 2001 From: Song Guo Date: Tue, 10 Oct 2023 14:43:17 +0800 Subject: [PATCH] Update --- src/controller/AutoCommissioner.cpp | 8 ++--- src/controller/CHIPDeviceController.cpp | 39 ++++++++++++++++-------- src/controller/CommissioningDelegate.cpp | 8 ++--- src/controller/CommissioningDelegate.h | 8 ++--- 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/src/controller/AutoCommissioner.cpp b/src/controller/AutoCommissioner.cpp index 277ee80ff703d1..5e079188a5e699 100644 --- a/src/controller/AutoCommissioner.cpp +++ b/src/controller/AutoCommissioner.cpp @@ -273,12 +273,8 @@ CommissioningStage AutoCommissioner::GetNextCommissioningStageInternal(Commissio // Per the spec, we restart from after adding the NOC. return GetNextCommissioningStage(CommissioningStage::kSendNOC, lastErr); } - if (mParams.GetCheckForMatchingFabric()) - { - return CommissioningStage::kCheckForMatchingFabric; - } - return CommissioningStage::kArmFailsafe; - case CommissioningStage::kCheckForMatchingFabric: + return CommissioningStage::kReadCommissioningInfo2; + case CommissioningStage::kReadCommissioningInfo2: return CommissioningStage::kArmFailsafe; case CommissioningStage::kArmFailsafe: return CommissioningStage::kConfigRegulatory; diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index bed904076e9919..8560b3eca38b70 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -1877,11 +1877,15 @@ void DeviceCommissioner::OnDone(app::ReadClient *) case CommissioningStage::kReadCommissioningInfo: ParseCommissioningInfo(); break; - case CommissioningStage::kCheckForMatchingFabric: - ParseFabrics(); - break; - case CommissioningStage::kICDIdentification: - ParseICDInfo(); + case CommissioningStage::kReadCommissioningInfo2: + if (param.GetCheckForMatchingFabric()) + { + ParseFabrics(); + } + if (param.GetICDRegistrationStrategy() != ICDRegistrationStrategy::kIgnore) + { + ParseICDInfo(); + } break; default: // We're not trying to read anything here, just exit @@ -2184,7 +2188,6 @@ void DeviceCommissioner::ParseICDInfo() IcdInfo info; IcdManagement::Attributes::FeatureMap::TypeInfo::DecodableType featureMap; - // TODO(#29382): We probably want to read "ActiveMode" attribute (to be implemented) for ICD. err = mAttributeCache->Get(kRootEndpointId, featureMap); if (err == CHIP_NO_ERROR) { @@ -2456,19 +2459,31 @@ void DeviceCommissioner::PerformCommissioningStep(DeviceProxy * proxy, Commissio SendCommissioningReadRequest(proxy, timeout, readPaths, 9); } break; - case CommissioningStage::kCheckForMatchingFabric: { + case CommissioningStage::kReadCommissioningInfo: { + ChipLogProgress(Controller, "Sending request for commissioning information -- Part 2"); + + size_t numberOfAttributes = 0; + // This is done in a separate step since we've already used up all the available read paths in the previous read step + app::AttributePathParams readPaths[9]; + // Read the current fabrics - if (!params.GetCheckForMatchingFabric()) + if (params.GetCheckForMatchingFabric()) { + readPaths[numberOfAttributes++] = app::AttributePathParams(OperationalCredentials::Id, OperationalCredentials::Attributes::Fabrics::Id); + } + + if (params.GetICDRegistrationStrategy() != ICDRegistrationStrategy::kIgnore) + { + readPaths[numberOfAttributes++] = app::AttributePathParams(endpoint, IcdManagement::Id, IcdManagement::Attributes::FeatureMap::Id); + } + + if (numberOfAttributes == 0) // We don't actually want to do this step, so just bypass it ChipLogProgress(Controller, "kCheckForMatchingFabric step called without parameter set, skipping"); CommissioningStageComplete(CHIP_NO_ERROR); } - // This is done in a separate step since we've already used up all the available read paths in the previous read step - app::AttributePathParams readPaths[1]; - readPaths[0] = app::AttributePathParams(OperationalCredentials::Id, OperationalCredentials::Attributes::Fabrics::Id); - SendCommissioningReadRequest(proxy, timeout, readPaths, 1); + SendCommissioningReadRequest(proxy, timeout, readPaths, numberOfAttributes); } break; case CommissioningStage::kConfigureUTCTime: { diff --git a/src/controller/CommissioningDelegate.cpp b/src/controller/CommissioningDelegate.cpp index 8924c313d00131..e19727be9e510b 100644 --- a/src/controller/CommissioningDelegate.cpp +++ b/src/controller/CommissioningDelegate.cpp @@ -37,8 +37,8 @@ const char * StageToString(CommissioningStage stage) return "ReadCommissioningInfo"; break; - case kCheckForMatchingFabric: - return "CheckForMatchingFabric"; + case kReadCommissioningInfo2: + return "ReadCommissioningInfo2"; break; case kArmFailsafe: @@ -137,10 +137,6 @@ const char * StageToString(CommissioningStage stage) return "FindOperational"; break; - case kICDIdentification: - return "ICDIdentification"; - break; - case kSendComplete: return "SendComplete"; break; diff --git a/src/controller/CommissioningDelegate.h b/src/controller/CommissioningDelegate.h index 2b6a0e12704c58..e6a23d7741a204 100644 --- a/src/controller/CommissioningDelegate.h +++ b/src/controller/CommissioningDelegate.h @@ -35,7 +35,7 @@ enum CommissioningStage : uint8_t kError, kSecurePairing, ///< Establish a PASE session with the device kReadCommissioningInfo, ///< Query General Commissioning Attributes, Network Features and Time Synchronization Cluster - kCheckForMatchingFabric, ///< Read the current fabrics on the commissionee + kReadCommissioningInfo2, ///< Query ICD state, check for matching fabric kArmFailsafe, ///< Send ArmFailSafe (0x30:0) command to the device kConfigRegulatory, ///< Send SetRegulatoryConfig (0x30:2) command to the device kConfigureUTCTime, ///< SetUTCTime if the DUT has a time cluster @@ -59,10 +59,6 @@ enum CommissioningStage : uint8_t kWiFiNetworkEnable, ///< Send ConnectNetwork (0x31:6) command to the device for the WiFi network kThreadNetworkEnable, ///< Send ConnectNetwork (0x31:6) command to the device for the Thread network kFindOperational, ///< Perform operational discovery and establish a CASE session with the device - /// Optional steps for ICD - kICDIdentification, ///< Check whether the device is an ICD - /// TODO(#29384): Finish ICD registration implementation in commissioner - /// End of optional steps for ICD kSendComplete, ///< Send CommissioningComplete (0x30:4) command to the device kCleanup, ///< Call delegates with status, free memory, clear timers and state /// Send ScanNetworks (0x31:0) command to the device. @@ -570,7 +566,7 @@ class CommissioningParameters Optional mAttemptWiFiNetworkScan; Optional mAttemptThreadNetworkScan; // This automatically gets set to false when a ThreadOperationalDataset is set Optional mSkipCommissioningComplete; - ICDRegistrationStrategy mICDRegistrationStrategy = ICDRegistrationStrategy::kBeforeComplete; + ICDRegistrationStrategy mICDRegistrationStrategy = ICDRegistrationStrategy::kIgnore; bool mCheckForMatchingFabric = false; };