Skip to content

Commit af336ec

Browse files
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 4c725be commit af336ec

File tree

12 files changed

+237
-20
lines changed

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");
@@ -310,6 +310,8 @@ CommissioningStage AutoCommissioner::GetNextCommissioningStageInternal(Commissio
310310
case CommissioningStage::kArmFailsafe:
311311
return CommissioningStage::kConfigRegulatory;
312312
case CommissioningStage::kConfigRegulatory:
313+
return CommissioningStage::kConfigureTCAcknowledgments;
314+
case CommissioningStage::kConfigureTCAcknowledgments:
313315
if (mDeviceCommissioningInfo.requiresUTC)
314316
{
315317
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
*
@@ -2795,6 +2795,22 @@ void DeviceCommissioner::OnSetRegulatoryConfigResponse(
27952795
commissioner->CommissioningStageComplete(err, report);
27962796
}
27972797

2798+
void DeviceCommissioner::OnSetTCAcknowledgementsResponse(
2799+
void * context, const GeneralCommissioning::Commands::SetTCAcknowledgementsResponse::DecodableType & data)
2800+
{
2801+
CommissioningDelegate::CommissioningReport report;
2802+
CHIP_ERROR err = CHIP_NO_ERROR;
2803+
2804+
ChipLogProgress(Controller, "Received SetTCAcknowledgements response errorCode=%u", to_underlying(data.errorCode));
2805+
if (data.errorCode != GeneralCommissioning::CommissioningErrorEnum::kOk)
2806+
{
2807+
err = CHIP_ERROR_INTERNAL;
2808+
report.Set<CommissioningErrorInfo>(data.errorCode);
2809+
}
2810+
DeviceCommissioner * commissioner = static_cast<DeviceCommissioner *>(context);
2811+
commissioner->CommissioningStageComplete(err, report);
2812+
}
2813+
27982814
void DeviceCommissioner::OnSetTimeZoneResponse(void * context,
27992815
const TimeSynchronization::Commands::SetTimeZoneResponse::DecodableType & data)
28002816
{
@@ -3207,6 +3223,39 @@ void DeviceCommissioner::PerformCommissioningStep(DeviceProxy * proxy, Commissio
32073223
}
32083224
}
32093225
break;
3226+
case CommissioningStage::kConfigureTCAcknowledgments: {
3227+
ChipLogProgress(Controller, "Setting Terms and Conditions");
3228+
3229+
if (!params.GetRequireTermsAndConditionsAcknowledgement())
3230+
{
3231+
ChipLogProgress(Controller, "Setting Terms and Conditions: Skipped");
3232+
CommissioningStageComplete(CHIP_NO_ERROR);
3233+
return;
3234+
}
3235+
3236+
if (!params.GetTermsAndConditionsAcknowledgement().HasValue())
3237+
{
3238+
ChipLogError(Controller, "No acknowledgements provided");
3239+
CommissioningStageComplete(CHIP_ERROR_INCORRECT_STATE);
3240+
return;
3241+
}
3242+
3243+
GeneralCommissioning::Commands::SetTCAcknowledgements::Type request;
3244+
TermsAndConditionsAcknowledgement termsAndConditionsAcknowledgement = params.GetTermsAndConditionsAcknowledgement().Value();
3245+
request.TCUserResponse = termsAndConditionsAcknowledgement.acceptedTermsAndConditions;
3246+
request.TCVersion = termsAndConditionsAcknowledgement.acceptedTermsAndConditionsVersion;
3247+
3248+
ChipLogProgress(Controller, "Setting Terms and Conditions: %hu, %hu", request.TCUserResponse, request.TCVersion);
3249+
CHIP_ERROR err =
3250+
SendCommissioningCommand(proxy, request, OnSetTCAcknowledgementsResponse, OnBasicFailure, endpoint, timeout);
3251+
if (err != CHIP_NO_ERROR)
3252+
{
3253+
ChipLogError(Controller, "Failed to send SetTCAcknowledgements command: %" CHIP_ERROR_FORMAT, err.Format());
3254+
CommissioningStageComplete(err);
3255+
return;
3256+
}
3257+
break;
3258+
}
32103259
case CommissioningStage::kSendPAICertificateRequest: {
32113260
ChipLogProgress(Controller, "Sending request for PAI certificate");
32123261
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
*
@@ -960,6 +960,9 @@ class DLL_EXPORT DeviceCommissioner : public DeviceController,
960960
static void OnSetRegulatoryConfigResponse(
961961
void * context,
962962
const chip::app::Clusters::GeneralCommissioning::Commands::SetRegulatoryConfigResponse::DecodableType & data);
963+
static void OnSetTCAcknowledgementsResponse(
964+
void * context,
965+
const chip::app::Clusters::GeneralCommissioning::Commands::SetTCAcknowledgementsResponse::DecodableType & data);
963966
static void OnSetUTCError(void * context, CHIP_ERROR error);
964967
static void
965968
OnSetTimeZoneResponse(void * context,

src/controller/CommissioningDelegate.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ const char * StageToString(CommissioningStage stage)
4343
case kConfigRegulatory:
4444
return "ConfigRegulatory";
4545

46+
case kConfigureTCAcknowledgments:
47+
return "ConfigureTCAcknowledgments";
48+
4649
case kConfigureUTCTime:
4750
return "ConfigureUTCTime";
4851

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");
@@ -69,10 +69,8 @@ enum CommissioningStage : uint8_t
6969
///< Commissioning Complete command
7070
kSendComplete, ///< Send CommissioningComplete (0x30:4) command to the device
7171
kICDSendStayActive, ///< Send Keep Alive to ICD
72-
kCleanup, ///< Call delegates with status, free memory, clear timers and state
7372
/// Send ScanNetworks (0x31:0) command to the device.
7473
/// ScanNetworks can happen anytime after kArmFailsafe.
75-
/// However, the cirque tests fail if it is earlier in the list
7674
kScanNetworks,
7775
/// Waiting for the higher layer to provide network credentials before continuing the workflow.
7876
/// Call CHIPDeviceController::NetworkCredentialsReady() when CommissioningParameters is populated with
@@ -81,7 +79,9 @@ enum CommissioningStage : uint8_t
8179
kPrimaryOperationalNetworkFailed, ///< Indicate that the primary operational network (on root endpoint) failed, should remove
8280
///< the primary network config later.
8381
kRemoveWiFiNetworkConfig, ///< Remove Wi-Fi network config.
84-
kRemoveThreadNetworkConfig ///< Remove Thread network config.
82+
kRemoveThreadNetworkConfig, ///< Remove Thread network config.
83+
kConfigureTCAcknowledgments, ///< Send SetTCAcknowledgements (0x30:6) command to the device
84+
kCleanup, ///< Call delegates with status, free memory, clear timers and state
8585
};
8686

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

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

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

356+
CommissioningParameters & SetRequireTermsAndConditionsAcknowledgement(bool requireTermsAndConditionsAcknowledgement)
357+
{
358+
mRequireTermsAndConditionsAcknowledgement = requireTermsAndConditionsAcknowledgement;
359+
return *this;
360+
}
361+
362+
CommissioningParameters &
363+
SetTermsAndConditionsAcknowledgement(TermsAndConditionsAcknowledgement termsAndConditionsAcknowledgement)
364+
{
365+
mTermsAndConditionsAcknowledgement.SetValue(termsAndConditionsAcknowledgement);
366+
return *this;
367+
}
368+
343369
// The lifetime of the list buffer needs to exceed the lifetime of the CommissioningParameters object.
344370
CommissioningParameters &
345371
SetTimeZone(app::DataModel::List<app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type> timeZone)
@@ -611,6 +637,7 @@ class CommissioningParameters
611637
Optional<ByteSpan> mAttestationNonce;
612638
Optional<WiFiCredentials> mWiFiCreds;
613639
Optional<CharSpan> mCountryCode;
640+
Optional<TermsAndConditionsAcknowledgement> mTermsAndConditionsAcknowledgement;
614641
Optional<ByteSpan> mThreadOperationalDataset;
615642
Optional<NOCChainGenerationParameters> mNOCChainGenerationParameters;
616643
Optional<ByteSpan> mRootCert;
@@ -643,6 +670,7 @@ class CommissioningParameters
643670
Optional<uint32_t> mICDStayActiveDurationMsec;
644671
ICDRegistrationStrategy mICDRegistrationStrategy = ICDRegistrationStrategy::kIgnore;
645672
bool mCheckForMatchingFabric = false;
673+
bool mRequireTermsAndConditionsAcknowledgement = false;
646674
};
647675

648676
struct RequestedCertificate

src/controller/python/ChipDeviceController-ScriptBinding.cpp

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

186+
PyChipError pychip_DeviceController_SetRequireTermsAndConditionsAcknowledgement(bool tcRequired);
187+
188+
PyChipError pychip_DeviceController_SetTermsAcknowledgements(uint16_t tcVersion, uint16_t tcUserResponse);
189+
190+
PyChipError pychip_DeviceController_SetSkipCommissioningComplete(bool skipCommissioningComplete);
191+
186192
// Pairing Delegate
187193
PyChipError
188194
pychip_ScriptDevicePairingDelegate_SetKeyExchangeCallback(chip::Controller::ScriptDevicePairingDelegate * pairingDelegate,
@@ -572,6 +578,25 @@ PyChipError pychip_DeviceController_SetDefaultNtp(const char * defaultNTP)
572578
return ToPyChipError(CHIP_NO_ERROR);
573579
}
574580

581+
PyChipError pychip_DeviceController_SetRequireTermsAndConditionsAcknowledgement(bool tcRequired)
582+
{
583+
sCommissioningParameters.SetRequireTermsAndConditionsAcknowledgement(tcRequired);
584+
return ToPyChipError(CHIP_NO_ERROR);
585+
}
586+
587+
PyChipError pychip_DeviceController_SetTermsAcknowledgements(uint16_t tcVersion, uint16_t tcUserResponse)
588+
{
589+
sCommissioningParameters.SetTermsAndConditionsAcknowledgement(
590+
{ .acceptedTermsAndConditions = tcUserResponse, .acceptedTermsAndConditionsVersion = tcVersion });
591+
return ToPyChipError(CHIP_NO_ERROR);
592+
}
593+
594+
PyChipError pychip_DeviceController_SetSkipCommissioningComplete(bool skipCommissioningComplete)
595+
{
596+
sCommissioningParameters.SetSkipCommissioningComplete(skipCommissioningComplete);
597+
return ToPyChipError(CHIP_NO_ERROR);
598+
}
599+
575600
PyChipError pychip_DeviceController_SetTrustedTimeSource(chip::NodeId nodeId, chip::EndpointId endpoint)
576601
{
577602
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
@@ -2005,6 +2005,15 @@ def _InitLib(self):
20052005
self._dmLib.pychip_CreateManualCode.restype = PyChipError
20062006
self._dmLib.pychip_CreateManualCode.argtypes = [c_uint16, c_uint32, c_char_p, c_size_t, POINTER(c_size_t)]
20072007

2008+
self._dmLib.pychip_DeviceController_SetSkipCommissioningComplete.restype = PyChipError
2009+
self._dmLib.pychip_DeviceController_SetSkipCommissioningComplete.argtypes = [c_bool]
2010+
2011+
self._dmLib.pychip_DeviceController_SetRequireTermsAndConditionsAcknowledgement.restype = PyChipError
2012+
self._dmLib.pychip_DeviceController_SetRequireTermsAndConditionsAcknowledgement.argtypes = [c_bool]
2013+
2014+
self._dmLib.pychip_DeviceController_SetTermsAcknowledgements.restype = PyChipError
2015+
self._dmLib.pychip_DeviceController_SetTermsAcknowledgements.argtypes = [c_uint16, c_uint16]
2016+
20082017

20092018
class ChipDeviceController(ChipDeviceControllerBase):
20102019
''' The ChipDeviceCommissioner binding, named as ChipDeviceController
@@ -2133,6 +2142,27 @@ def SetDSTOffset(self, offset: int, validStarting: int, validUntil: int):
21332142
lambda: self._dmLib.pychip_DeviceController_SetDSTOffset(offset, validStarting, validUntil)
21342143
).raise_on_error()
21352144

2145+
def SetTCRequired(self, tcRequired: bool):
2146+
''' Set whether TC Acknowledgements should be set during commissioning'''
2147+
self.CheckIsActive()
2148+
self._ChipStack.Call(
2149+
lambda: self._dmLib.pychip_DeviceController_SetRequireTermsAndConditionsAcknowledgement(tcRequired)
2150+
).raise_on_error()
2151+
2152+
def SetTCAcknowledgements(self, tcAcceptedVersion: int, tcUserResponse: int):
2153+
''' Set the TC acknowledgements to set during commissioning'''
2154+
self.CheckIsActive()
2155+
self._ChipStack.Call(
2156+
lambda: self._dmLib.pychip_DeviceController_SetTermsAcknowledgements(tcAcceptedVersion, tcUserResponse)
2157+
).raise_on_error()
2158+
2159+
def SetSkipCommissioningComplete(self, skipCommissioningComplete: bool):
2160+
''' Set whether to skip the commissioning complete callback'''
2161+
self.CheckIsActive()
2162+
self._ChipStack.Call(
2163+
lambda: self._dmLib.pychip_DeviceController_SetSkipCommissioningComplete(skipCommissioningComplete)
2164+
).raise_on_error()
2165+
21362166
def SetDefaultNTP(self, defaultNTP: str):
21372167
''' Set the DefaultNTP to set during commissioning'''
21382168
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)