Skip to content

Commit 44201b4

Browse files
swan-amazontcarmelveilleux
authored andcommitted
Add Terms and Conditions (T&C) Feature Support for Commissioning (project-chip#36863)
* 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. * 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. * [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 * [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. * [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. * [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. * Update src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py Co-authored-by: Tennessee Carmel-Veilleux <tennessee.carmelveilleux@gmail.com> * Restyle * Renamed variable --------- Co-authored-by: Tennessee Carmel-Veilleux <tennessee.carmelveilleux@gmail.com>
1 parent 32fc7bc commit 44201b4

12 files changed

+237
-20
lines changed

examples/chip-tool/commands/pairing/PairingCommand.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020 Project CHIP Authors
2+
* Copyright (c) 2020-2024 Project CHIP Authors
33
* All rights reserved.
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -129,6 +129,20 @@ CommissioningParameters PairingCommand::GetCommissioningParameters()
129129
params.SetCountryCode(CharSpan::fromCharString(mCountryCode.Value()));
130130
}
131131

132+
// Default requiring TCs to false, to preserve release 1.3 chip-tool behavior
133+
params.SetRequireTermsAndConditionsAcknowledgement(mRequireTCAcknowledgements.ValueOr(false));
134+
135+
// mTCAcknowledgements and mTCAcknowledgementVersion are optional, but related. When one is missing, default the value to 0, to
136+
// increase the test tools ability to test the applications.
137+
if (mTCAcknowledgements.HasValue() || mTCAcknowledgementVersion.HasValue())
138+
{
139+
TermsAndConditionsAcknowledgement termsAndConditionsAcknowledgement = {
140+
.acceptedTermsAndConditions = mTCAcknowledgements.ValueOr(0),
141+
.acceptedTermsAndConditionsVersion = mTCAcknowledgementVersion.ValueOr(0),
142+
};
143+
params.SetTermsAndConditionsAcknowledgement(termsAndConditionsAcknowledgement);
144+
}
145+
132146
// mTimeZoneList is an optional argument managed by TypedComplexArgument mComplex_TimeZones.
133147
// Since optional Complex arguments are not currently supported via the <chip::Optional> class,
134148
// we will use mTimeZoneList.data() value to determine if the argument was provided.

examples/chip-tool/commands/pairing/PairingCommand.h

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020 Project CHIP Authors
2+
* Copyright (c) 2020-2024 Project CHIP Authors
33
* All rights reserved.
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -202,6 +202,19 @@ class PairingCommand : public CHIPCommand,
202202
AddArgument("dst-offset", &mComplex_DSTOffsets,
203203
"DSTOffset list to use when setting Time Synchronization cluster's DSTOffset attribute",
204204
Argument::kOptional);
205+
206+
AddArgument("require-tc-acknowledgements", 0, 1, &mRequireTCAcknowledgements,
207+
"Indicates whether Terms and Conditions acknowledgements are required during commissioning. If set to "
208+
"true, the tc-acknowledgements and tc-acknowledgements-version arguments must be provided for the "
209+
"commissioning to succeed. If false, the T&C acknowledgement step will be skipped.");
210+
211+
AddArgument("tc-acknowledgements", 0, UINT16_MAX, &mTCAcknowledgements,
212+
"Bit-field value indicating which Terms and Conditions have been accepted by the user. This value is sent "
213+
"to the device during commissioning via the General Commissioning cluster");
214+
215+
AddArgument("tc-acknowledgements-version", 0, UINT16_MAX, &mTCAcknowledgementVersion,
216+
"Version number of the Terms and Conditions that were accepted by the user. This value is sent to the "
217+
"device during commissioning to indicate which T&C version was acknowledged");
205218
}
206219

207220
AddArgument("timeout", 0, UINT16_MAX, &mTimeout);
@@ -259,6 +272,9 @@ class PairingCommand : public CHIPCommand,
259272
chip::Optional<uint64_t> mICDMonitoredSubject;
260273
chip::Optional<chip::app::Clusters::IcdManagement::ClientTypeEnum> mICDClientType;
261274
chip::Optional<uint32_t> mICDStayActiveDurationMsec;
275+
chip::Optional<bool> mRequireTCAcknowledgements;
276+
chip::Optional<uint16_t> mTCAcknowledgements;
277+
chip::Optional<uint16_t> mTCAcknowledgementVersion;
262278
chip::app::DataModel::List<chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type> mTimeZoneList;
263279
TypedComplexArgument<chip::app::DataModel::List<chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type>>
264280
mComplex_TimeZones;

src/controller/AutoCommissioner.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (c) 2021 Project CHIP Authors
3+
* Copyright (c) 2021-2024 Project CHIP Authors
44
* All rights reserved.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -365,6 +365,8 @@ CommissioningStage AutoCommissioner::GetNextCommissioningStageInternal(Commissio
365365
case CommissioningStage::kArmFailsafe:
366366
return CommissioningStage::kConfigRegulatory;
367367
case CommissioningStage::kConfigRegulatory:
368+
return CommissioningStage::kConfigureTCAcknowledgments;
369+
case CommissioningStage::kConfigureTCAcknowledgments:
368370
if (mDeviceCommissioningInfo.requiresUTC)
369371
{
370372
return CommissioningStage::kConfigureUTCTime;

src/controller/CHIPDeviceController.cpp

+50-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (c) 2020-2022 Project CHIP Authors
3+
* Copyright (c) 2020-2024 Project CHIP Authors
44
* Copyright (c) 2013-2017 Nest Labs, Inc.
55
* All rights reserved.
66
*
@@ -2688,6 +2688,22 @@ void DeviceCommissioner::OnSetRegulatoryConfigResponse(
26882688
commissioner->CommissioningStageComplete(err, report);
26892689
}
26902690

2691+
void DeviceCommissioner::OnSetTCAcknowledgementsResponse(
2692+
void * context, const GeneralCommissioning::Commands::SetTCAcknowledgementsResponse::DecodableType & data)
2693+
{
2694+
CommissioningDelegate::CommissioningReport report;
2695+
CHIP_ERROR err = CHIP_NO_ERROR;
2696+
2697+
ChipLogProgress(Controller, "Received SetTCAcknowledgements response errorCode=%u", to_underlying(data.errorCode));
2698+
if (data.errorCode != GeneralCommissioning::CommissioningErrorEnum::kOk)
2699+
{
2700+
err = CHIP_ERROR_INTERNAL;
2701+
report.Set<CommissioningErrorInfo>(data.errorCode);
2702+
}
2703+
DeviceCommissioner * commissioner = static_cast<DeviceCommissioner *>(context);
2704+
commissioner->CommissioningStageComplete(err, report);
2705+
}
2706+
26912707
void DeviceCommissioner::OnSetTimeZoneResponse(void * context,
26922708
const TimeSynchronization::Commands::SetTimeZoneResponse::DecodableType & data)
26932709
{
@@ -3160,6 +3176,39 @@ void DeviceCommissioner::PerformCommissioningStep(DeviceProxy * proxy, Commissio
31603176
}
31613177
}
31623178
break;
3179+
case CommissioningStage::kConfigureTCAcknowledgments: {
3180+
ChipLogProgress(Controller, "Setting Terms and Conditions");
3181+
3182+
if (!params.GetRequireTermsAndConditionsAcknowledgement())
3183+
{
3184+
ChipLogProgress(Controller, "Setting Terms and Conditions: Skipped");
3185+
CommissioningStageComplete(CHIP_NO_ERROR);
3186+
return;
3187+
}
3188+
3189+
if (!params.GetTermsAndConditionsAcknowledgement().HasValue())
3190+
{
3191+
ChipLogError(Controller, "No acknowledgements provided");
3192+
CommissioningStageComplete(CHIP_ERROR_INCORRECT_STATE);
3193+
return;
3194+
}
3195+
3196+
GeneralCommissioning::Commands::SetTCAcknowledgements::Type request;
3197+
TermsAndConditionsAcknowledgement termsAndConditionsAcknowledgement = params.GetTermsAndConditionsAcknowledgement().Value();
3198+
request.TCUserResponse = termsAndConditionsAcknowledgement.acceptedTermsAndConditions;
3199+
request.TCVersion = termsAndConditionsAcknowledgement.acceptedTermsAndConditionsVersion;
3200+
3201+
ChipLogProgress(Controller, "Setting Terms and Conditions: %hu, %hu", request.TCUserResponse, request.TCVersion);
3202+
CHIP_ERROR err =
3203+
SendCommissioningCommand(proxy, request, OnSetTCAcknowledgementsResponse, OnBasicFailure, endpoint, timeout);
3204+
if (err != CHIP_NO_ERROR)
3205+
{
3206+
ChipLogError(Controller, "Failed to send SetTCAcknowledgements command: %" CHIP_ERROR_FORMAT, err.Format());
3207+
CommissioningStageComplete(err);
3208+
return;
3209+
}
3210+
break;
3211+
}
31633212
case CommissioningStage::kSendPAICertificateRequest: {
31643213
ChipLogProgress(Controller, "Sending request for PAI certificate");
31653214
CHIP_ERROR err = SendCertificateChainRequestCommand(proxy, CertificateType::kPAI, timeout);

src/controller/CHIPDeviceController.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (c) 2020-2022 Project CHIP Authors
3+
* Copyright (c) 2020-2024 Project CHIP Authors
44
* Copyright (c) 2013-2017 Nest Labs, Inc.
55
* All rights reserved.
66
*
@@ -947,6 +947,9 @@ class DLL_EXPORT DeviceCommissioner : public DeviceController,
947947
static void OnSetRegulatoryConfigResponse(
948948
void * context,
949949
const chip::app::Clusters::GeneralCommissioning::Commands::SetRegulatoryConfigResponse::DecodableType & data);
950+
static void OnSetTCAcknowledgementsResponse(
951+
void * context,
952+
const chip::app::Clusters::GeneralCommissioning::Commands::SetTCAcknowledgementsResponse::DecodableType & data);
950953
static void OnSetUTCError(void * context, CHIP_ERROR error);
951954
static void
952955
OnSetTimeZoneResponse(void * context,

src/controller/CommissioningDelegate.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ const char * StageToString(CommissioningStage stage)
4646
case kConfigRegulatory:
4747
return "ConfigRegulatory";
4848

49+
case kConfigureTCAcknowledgments:
50+
return "ConfigureTCAcknowledgments";
51+
4952
case kConfigureUTCTime:
5053
return "ConfigureUTCTime";
5154

src/controller/CommissioningDelegate.h

+32-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (c) 2021 Project CHIP Authors
3+
* Copyright (c) 2021-2024 Project CHIP Authors
44
* All rights reserved.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -70,10 +70,8 @@ enum CommissioningStage : uint8_t
7070
///< Commissioning Complete command
7171
kSendComplete, ///< Send CommissioningComplete (0x30:4) command to the device
7272
kICDSendStayActive, ///< Send Keep Alive to ICD
73-
kCleanup, ///< Call delegates with status, free memory, clear timers and state
7473
/// Send ScanNetworks (0x31:0) command to the device.
7574
/// ScanNetworks can happen anytime after kArmFailsafe.
76-
/// However, the cirque tests fail if it is earlier in the list
7775
kScanNetworks,
7876
/// Waiting for the higher layer to provide network credentials before continuing the workflow.
7977
/// Call CHIPDeviceController::NetworkCredentialsReady() when CommissioningParameters is populated with
@@ -82,7 +80,9 @@ enum CommissioningStage : uint8_t
8280
kPrimaryOperationalNetworkFailed, ///< Indicate that the primary operational network (on root endpoint) failed, should remove
8381
///< the primary network config later.
8482
kRemoveWiFiNetworkConfig, ///< Remove Wi-Fi network config.
85-
kRemoveThreadNetworkConfig ///< Remove Thread network config.
83+
kRemoveThreadNetworkConfig, ///< Remove Thread network config.
84+
kConfigureTCAcknowledgments, ///< Send SetTCAcknowledgements (0x30:6) command to the device
85+
kCleanup, ///< Call delegates with status, free memory, clear timers and state
8686
};
8787

8888
enum class ICDRegistrationStrategy : uint8_t
@@ -105,6 +105,12 @@ struct WiFiCredentials
105105
WiFiCredentials(ByteSpan newSsid, ByteSpan newCreds) : ssid(newSsid), credentials(newCreds) {}
106106
};
107107

108+
struct TermsAndConditionsAcknowledgement
109+
{
110+
uint16_t acceptedTermsAndConditions;
111+
uint16_t acceptedTermsAndConditionsVersion;
112+
};
113+
108114
struct NOCChainGenerationParameters
109115
{
110116
ByteSpan nocsrElements;
@@ -169,6 +175,13 @@ class CommissioningParameters
169175
// The country code to be used for the node, if set.
170176
Optional<CharSpan> GetCountryCode() const { return mCountryCode; }
171177

178+
bool GetRequireTermsAndConditionsAcknowledgement() const { return mRequireTermsAndConditionsAcknowledgement; }
179+
180+
Optional<TermsAndConditionsAcknowledgement> GetTermsAndConditionsAcknowledgement() const
181+
{
182+
return mTermsAndConditionsAcknowledgement;
183+
}
184+
172185
// Time zone to set for the node
173186
// If required, this will be truncated to fit the max size allowable on the node
174187
Optional<app::DataModel::List<app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type>> GetTimeZone() const
@@ -341,6 +354,19 @@ class CommissioningParameters
341354
return *this;
342355
}
343356

357+
CommissioningParameters & SetRequireTermsAndConditionsAcknowledgement(bool requireTermsAndConditionsAcknowledgement)
358+
{
359+
mRequireTermsAndConditionsAcknowledgement = requireTermsAndConditionsAcknowledgement;
360+
return *this;
361+
}
362+
363+
CommissioningParameters &
364+
SetTermsAndConditionsAcknowledgement(TermsAndConditionsAcknowledgement termsAndConditionsAcknowledgement)
365+
{
366+
mTermsAndConditionsAcknowledgement.SetValue(termsAndConditionsAcknowledgement);
367+
return *this;
368+
}
369+
344370
// The lifetime of the list buffer needs to exceed the lifetime of the CommissioningParameters object.
345371
CommissioningParameters &
346372
SetTimeZone(app::DataModel::List<app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type> timeZone)
@@ -612,6 +638,7 @@ class CommissioningParameters
612638
Optional<ByteSpan> mAttestationNonce;
613639
Optional<WiFiCredentials> mWiFiCreds;
614640
Optional<CharSpan> mCountryCode;
641+
Optional<TermsAndConditionsAcknowledgement> mTermsAndConditionsAcknowledgement;
615642
Optional<ByteSpan> mThreadOperationalDataset;
616643
Optional<NOCChainGenerationParameters> mNOCChainGenerationParameters;
617644
Optional<ByteSpan> mRootCert;
@@ -644,6 +671,7 @@ class CommissioningParameters
644671
Optional<uint32_t> mICDStayActiveDurationMsec;
645672
ICDRegistrationStrategy mICDRegistrationStrategy = ICDRegistrationStrategy::kIgnore;
646673
bool mCheckForMatchingFabric = false;
674+
bool mRequireTermsAndConditionsAcknowledgement = false;
647675
};
648676

649677
struct RequestedCertificate

src/controller/python/ChipDeviceController-ScriptBinding.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@ PyChipError pychip_DeviceController_OpenCommissioningWindow(chip::Controller::De
182182
bool pychip_DeviceController_GetIPForDiscoveredDevice(chip::Controller::DeviceCommissioner * devCtrl, int idx, char * addrStr,
183183
uint32_t len);
184184

185+
PyChipError pychip_DeviceController_SetRequireTermsAndConditionsAcknowledgement(bool tcRequired);
186+
187+
PyChipError pychip_DeviceController_SetTermsAcknowledgements(uint16_t tcVersion, uint16_t tcUserResponse);
188+
189+
PyChipError pychip_DeviceController_SetSkipCommissioningComplete(bool skipCommissioningComplete);
190+
185191
// Pairing Delegate
186192
PyChipError
187193
pychip_ScriptDevicePairingDelegate_SetKeyExchangeCallback(chip::Controller::ScriptDevicePairingDelegate * pairingDelegate,
@@ -570,6 +576,25 @@ PyChipError pychip_DeviceController_SetDefaultNtp(const char * defaultNTP)
570576
return ToPyChipError(CHIP_NO_ERROR);
571577
}
572578

579+
PyChipError pychip_DeviceController_SetRequireTermsAndConditionsAcknowledgement(bool tcRequired)
580+
{
581+
sCommissioningParameters.SetRequireTermsAndConditionsAcknowledgement(tcRequired);
582+
return ToPyChipError(CHIP_NO_ERROR);
583+
}
584+
585+
PyChipError pychip_DeviceController_SetTermsAcknowledgements(uint16_t tcVersion, uint16_t tcUserResponse)
586+
{
587+
sCommissioningParameters.SetTermsAndConditionsAcknowledgement(
588+
{ .acceptedTermsAndConditions = tcUserResponse, .acceptedTermsAndConditionsVersion = tcVersion });
589+
return ToPyChipError(CHIP_NO_ERROR);
590+
}
591+
592+
PyChipError pychip_DeviceController_SetSkipCommissioningComplete(bool skipCommissioningComplete)
593+
{
594+
sCommissioningParameters.SetSkipCommissioningComplete(skipCommissioningComplete);
595+
return ToPyChipError(CHIP_NO_ERROR);
596+
}
597+
573598
PyChipError pychip_DeviceController_SetTrustedTimeSource(chip::NodeId nodeId, chip::EndpointId endpoint)
574599
{
575600
chip::app::Clusters::TimeSynchronization::Structs::FabricScopedTrustedTimeSourceStruct::Type timeSource = { .nodeID = nodeId,

src/controller/python/chip/ChipDeviceCtrl.py

+30
Original file line numberDiff line numberDiff line change
@@ -1974,6 +1974,15 @@ def _InitLib(self):
19741974
self._dmLib.pychip_CreateManualCode.restype = PyChipError
19751975
self._dmLib.pychip_CreateManualCode.argtypes = [c_uint16, c_uint32, c_char_p, c_size_t, POINTER(c_size_t)]
19761976

1977+
self._dmLib.pychip_DeviceController_SetSkipCommissioningComplete.restype = PyChipError
1978+
self._dmLib.pychip_DeviceController_SetSkipCommissioningComplete.argtypes = [c_bool]
1979+
1980+
self._dmLib.pychip_DeviceController_SetRequireTermsAndConditionsAcknowledgement.restype = PyChipError
1981+
self._dmLib.pychip_DeviceController_SetRequireTermsAndConditionsAcknowledgement.argtypes = [c_bool]
1982+
1983+
self._dmLib.pychip_DeviceController_SetTermsAcknowledgements.restype = PyChipError
1984+
self._dmLib.pychip_DeviceController_SetTermsAcknowledgements.argtypes = [c_uint16, c_uint16]
1985+
19771986

19781987
class ChipDeviceController(ChipDeviceControllerBase):
19791988
''' The ChipDeviceCommissioner binding, named as ChipDeviceController
@@ -2102,6 +2111,27 @@ def SetDSTOffset(self, offset: int, validStarting: int, validUntil: int):
21022111
lambda: self._dmLib.pychip_DeviceController_SetDSTOffset(offset, validStarting, validUntil)
21032112
).raise_on_error()
21042113

2114+
def SetTCRequired(self, tcRequired: bool):
2115+
''' Set whether TC Acknowledgements should be set during commissioning'''
2116+
self.CheckIsActive()
2117+
self._ChipStack.Call(
2118+
lambda: self._dmLib.pychip_DeviceController_SetRequireTermsAndConditionsAcknowledgement(tcRequired)
2119+
).raise_on_error()
2120+
2121+
def SetTCAcknowledgements(self, tcAcceptedVersion: int, tcUserResponse: int):
2122+
''' Set the TC acknowledgements to set during commissioning'''
2123+
self.CheckIsActive()
2124+
self._ChipStack.Call(
2125+
lambda: self._dmLib.pychip_DeviceController_SetTermsAcknowledgements(tcAcceptedVersion, tcUserResponse)
2126+
).raise_on_error()
2127+
2128+
def SetSkipCommissioningComplete(self, skipCommissioningComplete: bool):
2129+
''' Set whether to skip the commissioning complete callback'''
2130+
self.CheckIsActive()
2131+
self._ChipStack.Call(
2132+
lambda: self._dmLib.pychip_DeviceController_SetSkipCommissioningComplete(skipCommissioningComplete)
2133+
).raise_on_error()
2134+
21052135
def SetDefaultNTP(self, defaultNTP: str):
21062136
''' Set the DefaultNTP to set during commissioning'''
21072137
self.CheckIsActive()

src/controller/python/chip/commissioning/__init__.py

+7
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ class WiFiCredentials:
7272
passphrase: bytes
7373

7474

75+
@dataclasses.dataclass
76+
class TermsAndConditionsParameters:
77+
version: int
78+
user_response: int
79+
80+
7581
@dataclasses.dataclass
7682
class Parameters:
7783
pase_param: Union[PaseOverBLEParameters, PaseOverIPParameters]
@@ -80,6 +86,7 @@ class Parameters:
8086
commissionee_info: CommissioneeInfo
8187
wifi_credentials: WiFiCredentials
8288
thread_credentials: bytes
89+
tc_acknowledgements: Optional[TermsAndConditionsParameters] = None
8390
failsafe_expiry_length_seconds: int = 600
8491

8592

src/controller/python/chip/commissioning/commissioning_flow_blocks.py

+9
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,15 @@ async def send_regulatory_config(self, parameter: commissioning.Parameters, node
240240
if response.errorCode != 0:
241241
raise commissioning.CommissionFailure(repr(response))
242242

243+
async def send_terms_and_conditions_acknowledgements(self, parameter: commissioning.Parameters, node_id: int):
244+
self._logger.info("Settings Terms and Conditions")
245+
if parameter.tc_acknowledgements:
246+
response = await self._devCtrl.SendCommand(node_id, commissioning.ROOT_ENDPOINT_ID, Clusters.GeneralCommissioning.Commands.SetTCAcknowledgements(
247+
TCVersion=parameter.tc_acknowledgements.version, TCUserResponse=parameter.tc_acknowledgements.user_response
248+
))
249+
if response.errorCode != 0:
250+
raise commissioning.CommissionFailure(repr(response))
251+
243252
async def complete_commission(self, node_id: int):
244253
response = await self._devCtrl.SendCommand(node_id, commissioning.ROOT_ENDPOINT_ID, Clusters.GeneralCommissioning.Commands.CommissioningComplete())
245254
if response.errorCode != 0:

0 commit comments

Comments
 (0)