From 30d5e4d2cfa3b1aa147bf1a91d56fd5e955d4074 Mon Sep 17 00:00:00 2001 From: James Swan <122404367+swan-amazon@users.noreply.github.com> Date: Thu, 29 Aug 2024 19:31:40 +0000 Subject: [PATCH 01/12] Add Terms and Conditions (T&C) Feature Support for Commissioning This commit introduces comprehensive support for handling Terms and Conditions (T&C) during the commissioning process, enhancing compatibility with Matter device certification requirements. Key changes include: 1. **Commissioning Process Updates**: - Introduced `SetRequireTermsAndConditionsAcknowledgement`, `SetTermsAcknowledgements`, and `SetSkipCommissioningComplete` APIs in the commissioning library. - Updated commissioning stages to include `kGetTCAcknowledgments` and `kConfigureTCAcknowledgments` for seamless integration of T&C acknowledgements. - Added methods for processing T&C acknowledgements and advancing commissioning stages upon user response. 2. **Test Framework Enhancements**: - Added arguments (`tc_version`, `tc_user_response`, `in_test_commissioning_method`) for specifying T&C configuration in tests. - Enhanced `populate_commissioning_args` to manage new T&C-related arguments. - Updated Python test bindings and Matter test infrastructure to support T&C workflows. 3. **Chip-Tool Improvements**: - Extended `PairingCommand` to handle T&C-related arguments (`require-tc-acknowledgements`, `tc-acknowledgements`, `tc-acknowledgements-version`) for test scenarios. - Ensured backward compatibility by defaulting new parameters to preserve pre-1.4 behavior. --- .../commands/pairing/PairingCommand.cpp | 16 +++- .../commands/pairing/PairingCommand.h | 17 ++++- src/controller/AutoCommissioner.cpp | 6 +- src/controller/CHIPDeviceController.cpp | 74 ++++++++++++++++++- src/controller/CHIPDeviceController.h | 24 +++++- src/controller/CommissioningDelegate.cpp | 6 ++ src/controller/CommissioningDelegate.h | 37 +++++++++- .../ChipDeviceController-ScriptBinding.cpp | 25 +++++++ src/controller/python/chip/ChipDeviceCtrl.py | 30 ++++++++ .../python/chip/commissioning/__init__.py | 7 ++ .../commissioning_flow_blocks.py | 9 +++ .../chip/testing/matter_testing.py | 52 ++++++++++--- 12 files changed, 284 insertions(+), 19 deletions(-) diff --git a/examples/chip-tool/commands/pairing/PairingCommand.cpp b/examples/chip-tool/commands/pairing/PairingCommand.cpp index 7e762bd690c292..2862a3fa432425 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.cpp +++ b/examples/chip-tool/commands/pairing/PairingCommand.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2024 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -129,6 +129,20 @@ CommissioningParameters PairingCommand::GetCommissioningParameters() params.SetCountryCode(CharSpan::fromCharString(mCountryCode.Value())); } + // Default requiring TCs to false, to preserve release 1.3 chip-tool behavior + params.SetRequireTermsAndConditionsAcknowledgement(mRequireTCAcknowledgements.ValueOr(false)); + + // mTCAcknowledgements and mTCAcknowledgementVersion are optional, but related. When one is missing, default the value to 0, to + // increase the test tools ability to test the applications. + if (mTCAcknowledgements.HasValue() || mTCAcknowledgementVersion.HasValue()) + { + TermsAndConditionsAcknowledgement termsAndConditionsAcknowledgement = { + .acceptedTermsAndConditions = mTCAcknowledgements.ValueOr(0), + .acceptedTermsAndConditionsVersion = mTCAcknowledgementVersion.ValueOr(0), + }; + params.SetTermsAndConditionsAcknowledgement(termsAndConditionsAcknowledgement); + } + // mTimeZoneList is an optional argument managed by TypedComplexArgument mComplex_TimeZones. // Since optional Complex arguments are not currently supported via the class, // we will use mTimeZoneList.data() value to determine if the argument was provided. diff --git a/examples/chip-tool/commands/pairing/PairingCommand.h b/examples/chip-tool/commands/pairing/PairingCommand.h index 66c45d5dfe3143..5d3363a7d86f55 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.h +++ b/examples/chip-tool/commands/pairing/PairingCommand.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2024 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -202,6 +202,18 @@ class PairingCommand : public CHIPCommand, AddArgument("dst-offset", &mComplex_DSTOffsets, "DSTOffset list to use when setting Time Synchronization cluster's DSTOffset attribute", Argument::kOptional); + + AddArgument("require-tc-acknowledgements", 0, 1, &mRequireTCAcknowledgements, + "Terms and Conditions acknowledgements is known to be required or not, (when required, the commissioner " + "will wait until they are provided)"); + + AddArgument("tc-acknowledgements", 0, UINT16_MAX, &mTCAcknowledgements, + "Terms and Conditions acknowledgements to use to set the General Commissioning cluster's TC " + "Acknowledgements bit-field"); + + AddArgument("tc-acknowledgements-version", 0, UINT16_MAX, &mTCAcknowledgementVersion, + "Terms and Conditions acknowledgement version to use to set the General Commissioning cluster's TC " + "Acknowledgement version"); } AddArgument("timeout", 0, UINT16_MAX, &mTimeout); @@ -259,6 +271,9 @@ class PairingCommand : public CHIPCommand, chip::Optional mICDMonitoredSubject; chip::Optional mICDClientType; chip::Optional mICDStayActiveDurationMsec; + chip::Optional mRequireTCAcknowledgements; + chip::Optional mTCAcknowledgements; + chip::Optional mTCAcknowledgementVersion; chip::app::DataModel::List mTimeZoneList; TypedComplexArgument> mComplex_TimeZones; diff --git a/src/controller/AutoCommissioner.cpp b/src/controller/AutoCommissioner.cpp index a373b6b34af13f..b0455737ca0a5f 100644 --- a/src/controller/AutoCommissioner.cpp +++ b/src/controller/AutoCommissioner.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2021-2024 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -363,6 +363,10 @@ CommissioningStage AutoCommissioner::GetNextCommissioningStageInternal(Commissio case CommissioningStage::kArmFailsafe: return CommissioningStage::kConfigRegulatory; case CommissioningStage::kConfigRegulatory: + return CommissioningStage::kGetTCAcknowledgments; + case CommissioningStage::kGetTCAcknowledgments: + return CommissioningStage::kConfigureTCAcknowledgments; + case CommissioningStage::kConfigureTCAcknowledgments: if (mDeviceCommissioningInfo.requiresUTC) { return CommissioningStage::kConfigureUTCTime; diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index e4b566f43b89db..a5c673eb324093 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020-2022 Project CHIP Authors + * Copyright (c) 2020-2024 Project CHIP Authors * Copyright (c) 2013-2017 Nest Labs, Inc. * All rights reserved. * @@ -2795,6 +2795,22 @@ void DeviceCommissioner::OnSetRegulatoryConfigResponse( commissioner->CommissioningStageComplete(err, report); } +void DeviceCommissioner::OnSetTCAcknowledgementsResponse( + void * context, const GeneralCommissioning::Commands::SetTCAcknowledgementsResponse::DecodableType & data) +{ + CommissioningDelegate::CommissioningReport report; + CHIP_ERROR err = CHIP_NO_ERROR; + + ChipLogProgress(Controller, "Received SetTCAcknowledgements response errorCode=%u", to_underlying(data.errorCode)); + if (data.errorCode != GeneralCommissioning::CommissioningErrorEnum::kOk) + { + err = CHIP_ERROR_INTERNAL; + report.Set(data.errorCode); + } + DeviceCommissioner * commissioner = static_cast(context); + commissioner->CommissioningStageComplete(err, report); +} + void DeviceCommissioner::OnSetTimeZoneResponse(void * context, const TimeSynchronization::Commands::SetTimeZoneResponse::DecodableType & data) { @@ -2870,6 +2886,16 @@ CHIP_ERROR DeviceCommissioner::ICDRegistrationInfoReady() return CHIP_NO_ERROR; } +CHIP_ERROR DeviceCommissioner::TermsAndConditionsAcknowledgementsReady() +{ + VerifyOrReturnError(mCommissioningStage == CommissioningStage::kGetTCAcknowledgments, CHIP_ERROR_INCORRECT_STATE); + + // need to advance to next step + CommissioningStageComplete(CHIP_NO_ERROR); + + return CHIP_NO_ERROR; +} + void DeviceCommissioner::OnNetworkConfigResponse(void * context, const NetworkCommissioning::Commands::NetworkConfigResponse::DecodableType & data) { @@ -3207,6 +3233,52 @@ void DeviceCommissioner::PerformCommissioningStep(DeviceProxy * proxy, Commissio } } break; + case CommissioningStage::kGetTCAcknowledgments: { + ChipLogProgress(Controller, "Get Terms and Conditions Acknowledgments"); + + // If terms and conditions acknowledgements are not required, or have already been provided, then proceed + if (!params.GetRequireTermsAndConditionsAcknowledgement() || params.GetTermsAndConditionsAcknowledgement().HasValue()) + { + TermsAndConditionsAcknowledgementsReady(); + return; + } + + ChipLogProgress(Controller, "Waiting for Terms and Conditions"); + break; + } + case CommissioningStage::kConfigureTCAcknowledgments: { + ChipLogProgress(Controller, "Setting Terms and Conditions"); + + if (!params.GetRequireTermsAndConditionsAcknowledgement()) + { + ChipLogProgress(Controller, "Setting Terms and Conditions: Skipped"); + CommissioningStageComplete(CHIP_NO_ERROR); + return; + } + + if (!params.GetTermsAndConditionsAcknowledgement().HasValue()) + { + ChipLogError(Controller, "No acknowledgements provided"); + CommissioningStageComplete(CHIP_ERROR_INCORRECT_STATE); + return; + } + + GeneralCommissioning::Commands::SetTCAcknowledgements::Type request; + TermsAndConditionsAcknowledgement termsAndConditionsAcknowledgement = params.GetTermsAndConditionsAcknowledgement().Value(); + request.TCUserResponse = termsAndConditionsAcknowledgement.acceptedTermsAndConditions; + request.TCVersion = termsAndConditionsAcknowledgement.acceptedTermsAndConditionsVersion; + + ChipLogProgress(Controller, "Setting Terms and Conditions: %hu, %hu", request.TCUserResponse, request.TCVersion); + CHIP_ERROR err = + SendCommissioningCommand(proxy, request, OnSetTCAcknowledgementsResponse, OnBasicFailure, endpoint, timeout); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Controller, "Failed to send SetTCAcknowledgements command: %" CHIP_ERROR_FORMAT, err.Format()); + CommissioningStageComplete(err); + return; + } + break; + } case CommissioningStage::kSendPAICertificateRequest: { ChipLogProgress(Controller, "Sending request for PAI certificate"); CHIP_ERROR err = SendCertificateChainRequestCommand(proxy, CertificateType::kPAI, timeout); diff --git a/src/controller/CHIPDeviceController.h b/src/controller/CHIPDeviceController.h index cf22b70d1f487f..4eb8744ad2bffc 100644 --- a/src/controller/CHIPDeviceController.h +++ b/src/controller/CHIPDeviceController.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020-2022 Project CHIP Authors + * Copyright (c) 2020-2024 Project CHIP Authors * Copyright (c) 2013-2017 Nest Labs, Inc. * All rights reserved. * @@ -706,6 +706,25 @@ class DLL_EXPORT DeviceCommissioner : public DeviceController, */ CHIP_ERROR ICDRegistrationInfoReady(); + /** + * @brief + * This function is called by the upper layer application to indicate that the required terms and conditions + * acknowledgements have been set. This function should be called after the terms and conditions bitmask and version + * have been defined using the appropriate configuration macros and the application has gathered the necessary + * acknowledgements from the user. + * + * The upper layer application should call this method once it has successfully presented and obtained acknowledgements + * for the required terms and conditions from the user. This indicates that the commissioning process can advance to the + * next stage. + * + * When the terms and conditions acknowledgements process is completed, this function will signal the readiness to proceed + * to the next step in the commissioning process. + * + * @return CHIP_ERROR The return status. Returns CHIP_ERROR_INCORRECT_STATE if the function is called when the device + * is not in the correct state to accept terms and conditions acknowledgements. + */ + CHIP_ERROR TermsAndConditionsAcknowledgementsReady(); + /** * @brief * This function returns the current CommissioningStage for this commissioner. @@ -960,6 +979,9 @@ class DLL_EXPORT DeviceCommissioner : public DeviceController, static void OnSetRegulatoryConfigResponse( void * context, const chip::app::Clusters::GeneralCommissioning::Commands::SetRegulatoryConfigResponse::DecodableType & data); + static void OnSetTCAcknowledgementsResponse( + void * context, + const chip::app::Clusters::GeneralCommissioning::Commands::SetTCAcknowledgementsResponse::DecodableType & data); static void OnSetUTCError(void * context, CHIP_ERROR error); static void OnSetTimeZoneResponse(void * context, diff --git a/src/controller/CommissioningDelegate.cpp b/src/controller/CommissioningDelegate.cpp index 692b0406f9a8cc..fbb82862839013 100644 --- a/src/controller/CommissioningDelegate.cpp +++ b/src/controller/CommissioningDelegate.cpp @@ -43,6 +43,12 @@ const char * StageToString(CommissioningStage stage) case kConfigRegulatory: return "ConfigRegulatory"; + case kGetTCAcknowledgments: + return "GetTCAcknowledgments"; + + case kConfigureTCAcknowledgments: + return "ConfigureTCAcknowledgments"; + case kConfigureUTCTime: return "ConfigureUTCTime"; diff --git a/src/controller/CommissioningDelegate.h b/src/controller/CommissioningDelegate.h index 99d404c759f46a..c7bd3ae8fcdafd 100644 --- a/src/controller/CommissioningDelegate.h +++ b/src/controller/CommissioningDelegate.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2021-2024 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -69,7 +69,6 @@ enum CommissioningStage : uint8_t ///< Commissioning Complete command kSendComplete, ///< Send CommissioningComplete (0x30:4) command to the device kICDSendStayActive, ///< Send Keep Alive to ICD - kCleanup, ///< Call delegates with status, free memory, clear timers and state /// Send ScanNetworks (0x31:0) command to the device. /// ScanNetworks can happen anytime after kArmFailsafe. /// However, the cirque tests fail if it is earlier in the list @@ -81,7 +80,10 @@ enum CommissioningStage : uint8_t kPrimaryOperationalNetworkFailed, ///< Indicate that the primary operational network (on root endpoint) failed, should remove ///< the primary network config later. kRemoveWiFiNetworkConfig, ///< Remove Wi-Fi network config. - kRemoveThreadNetworkConfig ///< Remove Thread network config. + kRemoveThreadNetworkConfig, ///< Remove Thread network config. + kGetTCAcknowledgments, ///< Waiting for the higher layer to provide terms and conditions acknowledgements. + kConfigureTCAcknowledgments, ///< Send SetTCAcknowledgements (0x30:6) command to the device + kCleanup, ///< Call delegates with status, free memory, clear timers and state }; enum class ICDRegistrationStrategy : uint8_t @@ -104,6 +106,12 @@ struct WiFiCredentials WiFiCredentials(ByteSpan newSsid, ByteSpan newCreds) : ssid(newSsid), credentials(newCreds) {} }; +struct TermsAndConditionsAcknowledgement +{ + uint16_t acceptedTermsAndConditions; + uint16_t acceptedTermsAndConditionsVersion; +}; + struct NOCChainGenerationParameters { ByteSpan nocsrElements; @@ -168,6 +176,13 @@ class CommissioningParameters // The country code to be used for the node, if set. Optional GetCountryCode() const { return mCountryCode; } + bool GetRequireTermsAndConditionsAcknowledgement() const { return mRequireTermsAndConditionsAcknowledgement; } + + Optional GetTermsAndConditionsAcknowledgement() const + { + return mTermsAndConditionsAcknowledgement; + } + // Time zone to set for the node // If required, this will be truncated to fit the max size allowable on the node Optional> GetTimeZone() const @@ -340,6 +355,19 @@ class CommissioningParameters return *this; } + CommissioningParameters & SetRequireTermsAndConditionsAcknowledgement(bool requireTermsAndConditionsAcknowledgement) + { + mRequireTermsAndConditionsAcknowledgement = requireTermsAndConditionsAcknowledgement; + return *this; + } + + CommissioningParameters & + SetTermsAndConditionsAcknowledgement(TermsAndConditionsAcknowledgement termsAndConditionsAcknowledgement) + { + mTermsAndConditionsAcknowledgement.SetValue(termsAndConditionsAcknowledgement); + return *this; + } + // The lifetime of the list buffer needs to exceed the lifetime of the CommissioningParameters object. CommissioningParameters & SetTimeZone(app::DataModel::List timeZone) @@ -581,6 +609,7 @@ class CommissioningParameters mAttestationNonce.ClearValue(); mWiFiCreds.ClearValue(); mCountryCode.ClearValue(); + mTermsAndConditionsAcknowledgement.ClearValue(); mThreadOperationalDataset.ClearValue(); mNOCChainGenerationParameters.ClearValue(); mRootCert.ClearValue(); @@ -611,6 +640,7 @@ class CommissioningParameters Optional mAttestationNonce; Optional mWiFiCreds; Optional mCountryCode; + Optional mTermsAndConditionsAcknowledgement; Optional mThreadOperationalDataset; Optional mNOCChainGenerationParameters; Optional mRootCert; @@ -643,6 +673,7 @@ class CommissioningParameters Optional mICDStayActiveDurationMsec; ICDRegistrationStrategy mICDRegistrationStrategy = ICDRegistrationStrategy::kIgnore; bool mCheckForMatchingFabric = false; + bool mRequireTermsAndConditionsAcknowledgement = false; }; struct RequestedCertificate diff --git a/src/controller/python/ChipDeviceController-ScriptBinding.cpp b/src/controller/python/ChipDeviceController-ScriptBinding.cpp index f4c469fbef33af..536e55364674f7 100644 --- a/src/controller/python/ChipDeviceController-ScriptBinding.cpp +++ b/src/controller/python/ChipDeviceController-ScriptBinding.cpp @@ -183,6 +183,12 @@ PyChipError pychip_DeviceController_OpenCommissioningWindow(chip::Controller::De bool pychip_DeviceController_GetIPForDiscoveredDevice(chip::Controller::DeviceCommissioner * devCtrl, int idx, char * addrStr, uint32_t len); +PyChipError pychip_DeviceController_SetRequireTermsAndConditionsAcknowledgement(bool tcRequired); + +PyChipError pychip_DeviceController_SetTermsAcknowledgements(uint16_t tcVersion, uint16_t tcUserResponse); + +PyChipError pychip_DeviceController_SetSkipCommissioningComplete(bool skipCommissioningComplete); + // Pairing Delegate PyChipError pychip_ScriptDevicePairingDelegate_SetKeyExchangeCallback(chip::Controller::ScriptDevicePairingDelegate * pairingDelegate, @@ -572,6 +578,25 @@ PyChipError pychip_DeviceController_SetDefaultNtp(const char * defaultNTP) return ToPyChipError(CHIP_NO_ERROR); } +PyChipError pychip_DeviceController_SetRequireTermsAndConditionsAcknowledgement(bool tcRequired) +{ + sCommissioningParameters.SetRequireTermsAndConditionsAcknowledgement(tcRequired); + return ToPyChipError(CHIP_NO_ERROR); +} + +PyChipError pychip_DeviceController_SetTermsAcknowledgements(uint16_t tcVersion, uint16_t tcUserResponse) +{ + sCommissioningParameters.SetTermsAndConditionsAcknowledgement( + { .acceptedTermsAndConditions = tcUserResponse, .acceptedTermsAndConditionsVersion = tcVersion }); + return ToPyChipError(CHIP_NO_ERROR); +} + +PyChipError pychip_DeviceController_SetSkipCommissioningComplete(bool skipCommissioningComplete) +{ + sCommissioningParameters.SetSkipCommissioningComplete(skipCommissioningComplete); + return ToPyChipError(CHIP_NO_ERROR); +} + PyChipError pychip_DeviceController_SetTrustedTimeSource(chip::NodeId nodeId, chip::EndpointId endpoint) { chip::app::Clusters::TimeSynchronization::Structs::FabricScopedTrustedTimeSourceStruct::Type timeSource = { .nodeID = nodeId, diff --git a/src/controller/python/chip/ChipDeviceCtrl.py b/src/controller/python/chip/ChipDeviceCtrl.py index 1e8f74fbd28c7d..3bc4414b54073d 100644 --- a/src/controller/python/chip/ChipDeviceCtrl.py +++ b/src/controller/python/chip/ChipDeviceCtrl.py @@ -2005,6 +2005,15 @@ def _InitLib(self): self._dmLib.pychip_CreateManualCode.restype = PyChipError self._dmLib.pychip_CreateManualCode.argtypes = [c_uint16, c_uint32, c_char_p, c_size_t, POINTER(c_size_t)] + self._dmLib.pychip_DeviceController_SetSkipCommissioningComplete.restype = PyChipError + self._dmLib.pychip_DeviceController_SetSkipCommissioningComplete.argtypes = [c_bool] + + self._dmLib.pychip_DeviceController_SetRequireTermsAndConditionsAcknowledgement.restype = PyChipError + self._dmLib.pychip_DeviceController_SetRequireTermsAndConditionsAcknowledgement.argtypes = [c_bool] + + self._dmLib.pychip_DeviceController_SetTermsAcknowledgements.restype = PyChipError + self._dmLib.pychip_DeviceController_SetTermsAcknowledgements.argtypes = [c_uint16, c_uint16] + class ChipDeviceController(ChipDeviceControllerBase): ''' The ChipDeviceCommissioner binding, named as ChipDeviceController @@ -2133,6 +2142,27 @@ def SetDSTOffset(self, offset: int, validStarting: int, validUntil: int): lambda: self._dmLib.pychip_DeviceController_SetDSTOffset(offset, validStarting, validUntil) ).raise_on_error() + def SetTCRequired(self, tcRequired: bool): + ''' Set whether TC Acknowledgements should be set during commissioning''' + self.CheckIsActive() + self._ChipStack.Call( + lambda: self._dmLib.pychip_DeviceController_SetRequireTermsAndConditionsAcknowledgement(tcRequired) + ).raise_on_error() + + def SetTCAcknowledgements(self, tcAcceptedVersion: int, tcUserResponse: int): + ''' Set the TC acknowledgements to set during commissioning''' + self.CheckIsActive() + self._ChipStack.Call( + lambda: self._dmLib.pychip_DeviceController_SetTermsAcknowledgements(tcAcceptedVersion, tcUserResponse) + ).raise_on_error() + + def SetSkipCommissioningComplete(self, skipCommissioningComplete: bool): + ''' Set whether to skip the commissioning complete callback''' + self.CheckIsActive() + self._ChipStack.Call( + lambda: self._dmLib.pychip_DeviceController_SetSkipCommissioningComplete(skipCommissioningComplete) + ).raise_on_error() + def SetDefaultNTP(self, defaultNTP: str): ''' Set the DefaultNTP to set during commissioning''' self.CheckIsActive() diff --git a/src/controller/python/chip/commissioning/__init__.py b/src/controller/python/chip/commissioning/__init__.py index c1105511c67b85..15cbf33a770704 100644 --- a/src/controller/python/chip/commissioning/__init__.py +++ b/src/controller/python/chip/commissioning/__init__.py @@ -72,6 +72,12 @@ class WiFiCredentials: passphrase: bytes +@dataclasses.dataclass +class TermsAndConditionsParameters: + version: int + user_response: int + + @dataclasses.dataclass class Parameters: pase_param: Union[PaseOverBLEParameters, PaseOverIPParameters] @@ -80,6 +86,7 @@ class Parameters: commissionee_info: CommissioneeInfo wifi_credentials: WiFiCredentials thread_credentials: bytes + tc_acknowledgements: Optional[TermsAndConditionsParameters] = None failsafe_expiry_length_seconds: int = 600 diff --git a/src/controller/python/chip/commissioning/commissioning_flow_blocks.py b/src/controller/python/chip/commissioning/commissioning_flow_blocks.py index 7d0d11b37fab1c..cc1999167a8eed 100644 --- a/src/controller/python/chip/commissioning/commissioning_flow_blocks.py +++ b/src/controller/python/chip/commissioning/commissioning_flow_blocks.py @@ -240,6 +240,15 @@ async def send_regulatory_config(self, parameter: commissioning.Parameters, node if response.errorCode != 0: raise commissioning.CommissionFailure(repr(response)) + async def send_terms_and_conditions_acknowledgements(self, parameter: commissioning.Parameters, node_id: int): + self._logger.info("Settings Terms and Conditions") + if parameter.tc_acknowledgements: + response = await self._devCtrl.SendCommand(node_id, commissioning.ROOT_ENDPOINT_ID, Clusters.GeneralCommissioning.Commands.SetTCAcknowledgements( + TCVersion=parameter.tc_acknowledgements.version, TCUserResponse=parameter.tc_acknowledgements.user_response + )) + if response.errorCode != 0: + raise commissioning.CommissionFailure(repr(response)) + async def complete_commission(self, node_id: int): response = await self._devCtrl.SendCommand(node_id, commissioning.ROOT_ENDPOINT_ID, Clusters.GeneralCommissioning.Commands.CommissioningComplete()) if response.errorCode != 0: diff --git a/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py b/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py index 3b3fb6270b613c..30f0841c529887 100644 --- a/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py +++ b/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py @@ -630,6 +630,7 @@ class MatterTestConfig: app_pid: int = 0 commissioning_method: Optional[str] = None + in_test_commissioning_method: Optional[str] = None discriminators: List[int] = field(default_factory=list) setup_passcodes: List[int] = field(default_factory=list) commissionee_ip_address_just_for_testing: Optional[str] = None @@ -670,6 +671,10 @@ class MatterTestConfig: trace_to: List[str] = field(default_factory=list) + # Accepted Terms and Conditions if used + tc_version: int = None + tc_user_response: int = None + class ClusterMapper: """Describe clusters/attributes using schema names.""" @@ -966,6 +971,18 @@ def __init__(self, *args): # The named pipe name must be set in the derived classes self.app_pipe = None + async def commission_devices(self) -> bool: + conf = self.matter_test_config + + for commission_idx, node_id in enumerate(conf.dut_node_ids): + logging.info("Starting commissioning for root index %d, fabric ID 0x%016X, node ID 0x%016X" % + (conf.root_of_trust_index, conf.fabric_id, node_id)) + logging.info("Commissioning method: %s" % conf.commissioning_method) + + await CommissionDeviceTest.commission_device(self, commission_idx) + + return True + def get_test_steps(self, test: str) -> list[TestStep]: ''' Retrieves the test step list for the given test @@ -1772,6 +1789,7 @@ def populate_commissioning_args(args: argparse.Namespace, config: MatterTestConf config.dut_node_ids = args.dut_node_ids config.commissioning_method = args.commissioning_method + config.in_test_commissioning_method = args.in_test_commissioning_method config.commission_only = args.commission_only config.qr_code_content.extend(args.qr_code) @@ -1874,6 +1892,9 @@ def convert_args_to_matter_config(args: argparse.Namespace) -> MatterTestConfig: config.controller_node_id = args.controller_node_id config.trace_to = args.trace_to + config.tc_version = args.tc_version + config.tc_user_response = args.tc_user_response + # Accumulate all command-line-passed named args all_global_args = [] argsets = [item for item in (args.int_arg, args.float_arg, args.string_arg, args.json_arg, @@ -1932,6 +1953,10 @@ def parse_matter_test_args(argv: Optional[List[str]] = None) -> MatterTestConfig metavar='METHOD_NAME', choices=["on-network", "ble-wifi", "ble-thread", "on-network-ip"], help='Name of commissioning method to use') + commission_group.add_argument('--in-test-commissioning-method', type=str, + metavar='METHOD_NAME', + choices=["on-network", "ble-wifi", "ble-thread", "on-network-ip"], + help='Name of commissioning method to use, for commissioning tests') commission_group.add_argument('-d', '--discriminator', type=int_decimal_or_hex, metavar='LONG_DISCRIMINATOR', dest='discriminators', @@ -1967,6 +1992,10 @@ def parse_matter_test_args(argv: Optional[List[str]] = None) -> MatterTestConfig commission_group.add_argument('--commission-only', action="store_true", default=False, help="If true, test exits after commissioning without running subsequent tests") + commission_group.add_argument('--tc-version', type=int, help="Terms and conditions version") + + commission_group.add_argument('--tc-user-response', type=int, help="Terms and conditions acknowledgements") + code_group = parser.add_mutually_exclusive_group(required=False) code_group.add_argument('-q', '--qr-code', type=str, @@ -2236,20 +2265,21 @@ def __init__(self, *args): self.is_commissioning = True def test_run_commissioning(self): - conf = self.matter_test_config - for commission_idx, node_id in enumerate(conf.dut_node_ids): - logging.info("Starting commissioning for root index %d, fabric ID 0x%016X, node ID 0x%016X" % - (conf.root_of_trust_index, conf.fabric_id, node_id)) - logging.info("Commissioning method: %s" % conf.commissioning_method) + if not asyncio.run(self.commission_devices()): + raise signals.TestAbortAll("Failed to commission node") - if not asyncio.run(self._commission_device(commission_idx)): - raise signals.TestAbortAll("Failed to commission node") + async def commission_device(instance: MatterBaseTest, i) -> bool: + dev_ctrl = instance.default_controller + conf = instance.matter_test_config - async def _commission_device(self, i) -> bool: - dev_ctrl = self.default_controller - conf = self.matter_test_config + info = instance.get_setup_payload_info()[i] - info = self.get_setup_payload_info()[i] + if conf.tc_version is not None and conf.tc_user_response is not None: + logging.debug(f"Setting TC Acknowledgements to version {conf.tc_version} with user response {conf.tc_user_response}.") + dev_ctrl.SetTCAcknowledgements(conf.tc_version, conf.tc_user_response) + dev_ctrl.SetTCRequired(True) + else: + dev_ctrl.SetTCRequired(False) if conf.commissioning_method == "on-network": try: From 42a8f21ae4f7dcc1d36780525e3996f593ccb5b9 Mon Sep 17 00:00:00 2001 From: James Swan <122404367+swan-amazon@users.noreply.github.com> Date: Thu, 19 Dec 2024 19:43:17 +0000 Subject: [PATCH 02/12] Removed the "wait for terms and conditions stage" The wait-stage is not required. The user input availability must be a pre-condition for starting the AutoCommissioner process. The wait stage was previously to support requesting user input after identifying the device VID/PID using a different channel than within the pairing payload. --- src/controller/AutoCommissioner.cpp | 2 -- src/controller/CHIPDeviceController.cpp | 23 ----------------------- src/controller/CHIPDeviceController.h | 19 ------------------- src/controller/CommissioningDelegate.cpp | 3 --- src/controller/CommissioningDelegate.h | 1 - 5 files changed, 48 deletions(-) diff --git a/src/controller/AutoCommissioner.cpp b/src/controller/AutoCommissioner.cpp index b0455737ca0a5f..8d75c1361c14ed 100644 --- a/src/controller/AutoCommissioner.cpp +++ b/src/controller/AutoCommissioner.cpp @@ -363,8 +363,6 @@ CommissioningStage AutoCommissioner::GetNextCommissioningStageInternal(Commissio case CommissioningStage::kArmFailsafe: return CommissioningStage::kConfigRegulatory; case CommissioningStage::kConfigRegulatory: - return CommissioningStage::kGetTCAcknowledgments; - case CommissioningStage::kGetTCAcknowledgments: return CommissioningStage::kConfigureTCAcknowledgments; case CommissioningStage::kConfigureTCAcknowledgments: if (mDeviceCommissioningInfo.requiresUTC) diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index a5c673eb324093..c7988103a902c6 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -2886,16 +2886,6 @@ CHIP_ERROR DeviceCommissioner::ICDRegistrationInfoReady() return CHIP_NO_ERROR; } -CHIP_ERROR DeviceCommissioner::TermsAndConditionsAcknowledgementsReady() -{ - VerifyOrReturnError(mCommissioningStage == CommissioningStage::kGetTCAcknowledgments, CHIP_ERROR_INCORRECT_STATE); - - // need to advance to next step - CommissioningStageComplete(CHIP_NO_ERROR); - - return CHIP_NO_ERROR; -} - void DeviceCommissioner::OnNetworkConfigResponse(void * context, const NetworkCommissioning::Commands::NetworkConfigResponse::DecodableType & data) { @@ -3233,19 +3223,6 @@ void DeviceCommissioner::PerformCommissioningStep(DeviceProxy * proxy, Commissio } } break; - case CommissioningStage::kGetTCAcknowledgments: { - ChipLogProgress(Controller, "Get Terms and Conditions Acknowledgments"); - - // If terms and conditions acknowledgements are not required, or have already been provided, then proceed - if (!params.GetRequireTermsAndConditionsAcknowledgement() || params.GetTermsAndConditionsAcknowledgement().HasValue()) - { - TermsAndConditionsAcknowledgementsReady(); - return; - } - - ChipLogProgress(Controller, "Waiting for Terms and Conditions"); - break; - } case CommissioningStage::kConfigureTCAcknowledgments: { ChipLogProgress(Controller, "Setting Terms and Conditions"); diff --git a/src/controller/CHIPDeviceController.h b/src/controller/CHIPDeviceController.h index 4eb8744ad2bffc..93a0a58752900a 100644 --- a/src/controller/CHIPDeviceController.h +++ b/src/controller/CHIPDeviceController.h @@ -706,25 +706,6 @@ class DLL_EXPORT DeviceCommissioner : public DeviceController, */ CHIP_ERROR ICDRegistrationInfoReady(); - /** - * @brief - * This function is called by the upper layer application to indicate that the required terms and conditions - * acknowledgements have been set. This function should be called after the terms and conditions bitmask and version - * have been defined using the appropriate configuration macros and the application has gathered the necessary - * acknowledgements from the user. - * - * The upper layer application should call this method once it has successfully presented and obtained acknowledgements - * for the required terms and conditions from the user. This indicates that the commissioning process can advance to the - * next stage. - * - * When the terms and conditions acknowledgements process is completed, this function will signal the readiness to proceed - * to the next step in the commissioning process. - * - * @return CHIP_ERROR The return status. Returns CHIP_ERROR_INCORRECT_STATE if the function is called when the device - * is not in the correct state to accept terms and conditions acknowledgements. - */ - CHIP_ERROR TermsAndConditionsAcknowledgementsReady(); - /** * @brief * This function returns the current CommissioningStage for this commissioner. diff --git a/src/controller/CommissioningDelegate.cpp b/src/controller/CommissioningDelegate.cpp index fbb82862839013..8d13e7bd63b287 100644 --- a/src/controller/CommissioningDelegate.cpp +++ b/src/controller/CommissioningDelegate.cpp @@ -43,9 +43,6 @@ const char * StageToString(CommissioningStage stage) case kConfigRegulatory: return "ConfigRegulatory"; - case kGetTCAcknowledgments: - return "GetTCAcknowledgments"; - case kConfigureTCAcknowledgments: return "ConfigureTCAcknowledgments"; diff --git a/src/controller/CommissioningDelegate.h b/src/controller/CommissioningDelegate.h index c7bd3ae8fcdafd..7661f45a637c3c 100644 --- a/src/controller/CommissioningDelegate.h +++ b/src/controller/CommissioningDelegate.h @@ -81,7 +81,6 @@ enum CommissioningStage : uint8_t ///< the primary network config later. kRemoveWiFiNetworkConfig, ///< Remove Wi-Fi network config. kRemoveThreadNetworkConfig, ///< Remove Thread network config. - kGetTCAcknowledgments, ///< Waiting for the higher layer to provide terms and conditions acknowledgements. kConfigureTCAcknowledgments, ///< Send SetTCAcknowledgements (0x30:6) command to the device kCleanup, ///< Call delegates with status, free memory, clear timers and state }; From 6c18d738e7f183a7c5230d87e2111b80e952bc0c Mon Sep 17 00:00:00 2001 From: James Swan <122404367+swan-amazon@users.noreply.github.com> Date: Thu, 19 Dec 2024 20:48:23 +0000 Subject: [PATCH 03/12] [doc] Improve Terms and Conditions commissioning arguments documentation Updated documentation for T&C-related commissioning arguments to better reflect their actual usage and purpose: - require-tc-acknowledgements: Clarified the impact on commissioning flow - tc-acknowledgements: Explained the bit-field usage for user acceptance - tc-acknowledgements-version: Added context about version tracking --- .../chip-tool/commands/pairing/PairingCommand.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/chip-tool/commands/pairing/PairingCommand.h b/examples/chip-tool/commands/pairing/PairingCommand.h index 5d3363a7d86f55..4fc0929d2bbc33 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.h +++ b/examples/chip-tool/commands/pairing/PairingCommand.h @@ -204,16 +204,17 @@ class PairingCommand : public CHIPCommand, Argument::kOptional); AddArgument("require-tc-acknowledgements", 0, 1, &mRequireTCAcknowledgements, - "Terms and Conditions acknowledgements is known to be required or not, (when required, the commissioner " - "will wait until they are provided)"); + "Indicates whether Terms and Conditions acknowledgements are required during commissioning. If set to " + "true, the commissioner must provide valid T&C acknowledgements or the commissioning will fail. If false, " + "the T&C acknowledgement step will be skipped."); AddArgument("tc-acknowledgements", 0, UINT16_MAX, &mTCAcknowledgements, - "Terms and Conditions acknowledgements to use to set the General Commissioning cluster's TC " - "Acknowledgements bit-field"); + "Bit-field value indicating which Terms and Conditions have been accepted by the user. This value is sent " + "to the device during commissioning via the General Commissioning cluster"); AddArgument("tc-acknowledgements-version", 0, UINT16_MAX, &mTCAcknowledgementVersion, - "Terms and Conditions acknowledgement version to use to set the General Commissioning cluster's TC " - "Acknowledgement version"); + "Version number of the Terms and Conditions that were accepted by the user. This value is sent to the " + "device during commissioning to indicate which T&C version was acknowledged"); } AddArgument("timeout", 0, UINT16_MAX, &mTimeout); From 3a55f1f25329e4451fc054a865587a949203f457 Mon Sep 17 00:00:00 2001 From: James Swan <122404367+swan-amazon@users.noreply.github.com> Date: Thu, 19 Dec 2024 21:40:38 +0000 Subject: [PATCH 04/12] [controller] Remove T&C acknowledgements from external buffer clearing The Terms and Conditions acknowledgements parameter was incorrectly included in ClearExternalBufferDependentValues(). This parameter contains a fixed-size struct with two uint16_t values and does not reference any external buffers. The CommissioningParameters class appears to be designed for additive-only parameter setting without explicit clear/reset functionality, so removing this inappropriate clearing operation is the correct approach. --- src/controller/CommissioningDelegate.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/controller/CommissioningDelegate.h b/src/controller/CommissioningDelegate.h index 7661f45a637c3c..c7552cb7a35a14 100644 --- a/src/controller/CommissioningDelegate.h +++ b/src/controller/CommissioningDelegate.h @@ -608,7 +608,6 @@ class CommissioningParameters mAttestationNonce.ClearValue(); mWiFiCreds.ClearValue(); mCountryCode.ClearValue(); - mTermsAndConditionsAcknowledgement.ClearValue(); mThreadOperationalDataset.ClearValue(); mNOCChainGenerationParameters.ClearValue(); mRootCert.ClearValue(); From ff8ab5f56b1c8b0167af906c24438312ba4ed348 Mon Sep 17 00:00:00 2001 From: James Swan <122404367+swan-amazon@users.noreply.github.com> Date: Thu, 19 Dec 2024 21:50:33 +0000 Subject: [PATCH 05/12] [controller] Fix CommissioningStage enum order for T&C acknowledgements Move kConfigureTCAcknowledgments before kCleanup in the CommissioningStage enum to fix cirque test failures. The tests validate that commissioning stages do not exceed kCleanup, which was causing failures when T&C acknowledgements were positioned after it. While the original comment from 2 years ago suggested the enum order was fixed, testing reveals that the stages can be reordered. The cirque tests now pass with this corrected ordering, indicating that any previous constraints on enum ordering no longer apply. --- src/controller/CommissioningDelegate.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/controller/CommissioningDelegate.h b/src/controller/CommissioningDelegate.h index c7552cb7a35a14..dcbef908c3dd4f 100644 --- a/src/controller/CommissioningDelegate.h +++ b/src/controller/CommissioningDelegate.h @@ -71,7 +71,6 @@ enum CommissioningStage : uint8_t kICDSendStayActive, ///< Send Keep Alive to ICD /// Send ScanNetworks (0x31:0) command to the device. /// ScanNetworks can happen anytime after kArmFailsafe. - /// However, the cirque tests fail if it is earlier in the list kScanNetworks, /// Waiting for the higher layer to provide network credentials before continuing the workflow. /// Call CHIPDeviceController::NetworkCredentialsReady() when CommissioningParameters is populated with From c8ff0e04bf28d280a70ab0f4d6c989ca27a0f02b Mon Sep 17 00:00:00 2001 From: James Swan <122404367+swan-amazon@users.noreply.github.com> Date: Thu, 19 Dec 2024 22:25:39 +0000 Subject: [PATCH 06/12] [doc] Clarify required arguments for T&C acknowledgements Update help text for require-tc-acknowledgements to explicitly state which arguments must be provided when T&C acknowledgements are required. Instead of the vague "valid T&C acknowledgements", now specifically mentions that both tc-acknowledgements and tc-acknowledgements-version arguments are mandatory for successful commissioning when this option is enabled. --- examples/chip-tool/commands/pairing/PairingCommand.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/chip-tool/commands/pairing/PairingCommand.h b/examples/chip-tool/commands/pairing/PairingCommand.h index 4fc0929d2bbc33..b6903e34d53529 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.h +++ b/examples/chip-tool/commands/pairing/PairingCommand.h @@ -205,8 +205,8 @@ class PairingCommand : public CHIPCommand, AddArgument("require-tc-acknowledgements", 0, 1, &mRequireTCAcknowledgements, "Indicates whether Terms and Conditions acknowledgements are required during commissioning. If set to " - "true, the commissioner must provide valid T&C acknowledgements or the commissioning will fail. If false, " - "the T&C acknowledgement step will be skipped."); + "true, the tc-acknowledgements and tc-acknowledgements-version arguments must be provided for the " + "commissioning to succeed. If false, the T&C acknowledgement step will be skipped."); AddArgument("tc-acknowledgements", 0, UINT16_MAX, &mTCAcknowledgements, "Bit-field value indicating which Terms and Conditions have been accepted by the user. This value is sent " From 4d2ff0315c26ed07c9733681bf5a5fa843d69a10 Mon Sep 17 00:00:00 2001 From: James Swan <122404367+swan-amazon@users.noreply.github.com> Date: Fri, 20 Dec 2024 12:27:23 -0800 Subject: [PATCH 07/12] Update src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py Co-authored-by: Tennessee Carmel-Veilleux --- .../chip/testing/matter_testing.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py b/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py index a68bbad2abb258..e36fc4cf98a392 100644 --- a/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py +++ b/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py @@ -976,9 +976,8 @@ async def commission_devices(self) -> bool: conf = self.matter_test_config for commission_idx, node_id in enumerate(conf.dut_node_ids): - logging.info("Starting commissioning for root index %d, fabric ID 0x%016X, node ID 0x%016X" % - (conf.root_of_trust_index, conf.fabric_id, node_id)) - logging.info("Commissioning method: %s" % conf.commissioning_method) + logging.info(f"Starting commissioning for root index {conf.root_of_trust_index}, fabric ID 0x{conf.fabric_id:016X}, node ID 0x{node_id:016X}") + logging.info(f"Commissioning method: {conf.commissioning_method}") await CommissionDeviceTest.commission_device(self, commission_idx) From 04aaf9be36f59a0f52e7405f2f0c6867aae74b98 Mon Sep 17 00:00:00 2001 From: James Swan <122404367+swan-amazon@users.noreply.github.com> Date: Fri, 20 Dec 2024 20:36:06 +0000 Subject: [PATCH 08/12] Restyle --- .../chip/testing/matter_testing.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py b/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py index e36fc4cf98a392..0630b4a56ca3f4 100644 --- a/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py +++ b/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py @@ -976,7 +976,8 @@ async def commission_devices(self) -> bool: conf = self.matter_test_config for commission_idx, node_id in enumerate(conf.dut_node_ids): - logging.info(f"Starting commissioning for root index {conf.root_of_trust_index}, fabric ID 0x{conf.fabric_id:016X}, node ID 0x{node_id:016X}") + logging.info( + f"Starting commissioning for root index {conf.root_of_trust_index}, fabric ID 0x{conf.fabric_id:016X}, node ID 0x{node_id:016X}") logging.info(f"Commissioning method: {conf.commissioning_method}") await CommissionDeviceTest.commission_device(self, commission_idx) From d633e5bd6b59bf5bc3ce46ad6f10e00e9bd027df Mon Sep 17 00:00:00 2001 From: James Swan <122404367+swan-amazon@users.noreply.github.com> Date: Fri, 20 Dec 2024 20:41:08 +0000 Subject: [PATCH 09/12] Renamed variable --- .../chip/testing/matter_testing.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py b/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py index 0630b4a56ca3f4..8db8f5a938320d 100644 --- a/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py +++ b/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py @@ -673,8 +673,8 @@ class MatterTestConfig: trace_to: List[str] = field(default_factory=list) # Accepted Terms and Conditions if used - tc_version: int = None - tc_user_response: int = None + tc_version_to_simulate: int = None + tc_user_response_to_simulate: int = None class ClusterMapper: @@ -1960,8 +1960,8 @@ def convert_args_to_matter_config(args: argparse.Namespace) -> MatterTestConfig: config.controller_node_id = args.controller_node_id config.trace_to = args.trace_to - config.tc_version = args.tc_version - config.tc_user_response = args.tc_user_response + config.tc_version_to_simulate = args.tc_version_to_simulate + config.tc_user_response_to_simulate = args.tc_user_response_to_simulate # Accumulate all command-line-passed named args all_global_args = [] @@ -2374,9 +2374,10 @@ async def commission_device(instance: MatterBaseTest, i) -> bool: info = instance.get_setup_payload_info()[i] - if conf.tc_version is not None and conf.tc_user_response is not None: - logging.debug(f"Setting TC Acknowledgements to version {conf.tc_version} with user response {conf.tc_user_response}.") - dev_ctrl.SetTCAcknowledgements(conf.tc_version, conf.tc_user_response) + if conf.tc_version_to_simulate is not None and conf.tc_user_response_to_simulate is not None: + logging.debug( + f"Setting TC Acknowledgements to version {conf.tc_version_to_simulate} with user response {conf.tc_user_response_to_simulate}.") + dev_ctrl.SetTCAcknowledgements(conf.tc_version_to_simulate, conf.tc_user_response_to_simulate) dev_ctrl.SetTCRequired(True) else: dev_ctrl.SetTCRequired(False) From accf8c880f8096b891d54b8b64de69c8fa71f827 Mon Sep 17 00:00:00 2001 From: James Swan <122404367+swan-amazon@users.noreply.github.com> Date: Fri, 20 Dec 2024 20:45:05 +0000 Subject: [PATCH 10/12] --- .../chip/testing/matter_testing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py b/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py index 8db8f5a938320d..7a3247c6f84e36 100644 --- a/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py +++ b/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py @@ -977,7 +977,7 @@ async def commission_devices(self) -> bool: for commission_idx, node_id in enumerate(conf.dut_node_ids): logging.info( - f"Starting commissioning for root index {conf.root_of_trust_index}, fabric ID 0x{conf.fabric_id:016X}, node ID 0x{node_id:016X}") + f"Starting commissioning for root index {conf.root_of_trust_index}, fabric ID 0x{conf.fabric_id:016X}, node ID 0x{node_id:016X}") logging.info(f"Commissioning method: {conf.commissioning_method}") await CommissionDeviceTest.commission_device(self, commission_idx) From 54c6291d9172a3d98783334f23a0551dbab21d05 Mon Sep 17 00:00:00 2001 From: James Swan <122404367+swan-amazon@users.noreply.github.com> Date: Fri, 20 Dec 2024 22:33:56 +0000 Subject: [PATCH 11/12] --- .../chip/testing/matter_testing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py b/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py index 7a3247c6f84e36..46c32a2e178b79 100644 --- a/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py +++ b/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py @@ -2057,9 +2057,9 @@ def parse_matter_test_args(argv: Optional[List[str]] = None) -> MatterTestConfig commission_group.add_argument('--commission-only', action="store_true", default=False, help="If true, test exits after commissioning without running subsequent tests") - commission_group.add_argument('--tc-version', type=int, help="Terms and conditions version") + commission_group.add_argument('--tc-version-to-simulate', type=int, help="Terms and conditions version") - commission_group.add_argument('--tc-user-response', type=int, help="Terms and conditions acknowledgements") + commission_group.add_argument('--tc-user-response-to-simulate', type=int, help="Terms and conditions acknowledgements") code_group = parser.add_mutually_exclusive_group(required=False) From 2f0f7c433aa1106eff83614b7258d8c73529fd15 Mon Sep 17 00:00:00 2001 From: James Swan <122404367+swan-amazon@users.noreply.github.com> Date: Sat, 21 Dec 2024 16:59:16 +0000 Subject: [PATCH 12/12]