diff --git a/src/darwin/Framework/CHIP/MTRCommissioningParameters.h b/src/darwin/Framework/CHIP/MTRCommissioningParameters.h index c5bd65b7a0a03d..d61867a81bdf51 100644 --- a/src/darwin/Framework/CHIP/MTRCommissioningParameters.h +++ b/src/darwin/Framework/CHIP/MTRCommissioningParameters.h @@ -102,6 +102,17 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) */ @property (nonatomic, assign) BOOL readEndpointInformation MTR_AVAILABLE(ios(18.4), macos(15.4), watchos(11.4), tvos(18.4)); +/** + * A bitmask of the user’s responses to the presented terms and conditions. + * Each bit corresponds to a term’s acceptance (1) or non-acceptance (0) at the matching index. + */ +@property (nonatomic, copy, nullable) NSNumber * acceptedTermsAndConditions MTR_PROVISIONALLY_AVAILABLE; + +/** + * The version of the terms and conditions that the user has accepted. + */ +@property (nonatomic, copy, nullable) NSNumber * acceptedTermsAndConditionsVersion MTR_PROVISIONALLY_AVAILABLE; + @end @interface MTRCommissioningParameters (Deprecated) diff --git a/src/darwin/Framework/CHIP/MTRDeviceController_Concrete.mm b/src/darwin/Framework/CHIP/MTRDeviceController_Concrete.mm index 47e3f75884354c..04b541fc7783a6 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController_Concrete.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceController_Concrete.mm @@ -973,6 +973,25 @@ - (BOOL)commissionNodeWithID:(NSNumber *)nodeID if (commissioningParams.threadOperationalDataset) { params.SetThreadOperationalDataset(AsByteSpan(commissioningParams.threadOperationalDataset)); } + if (commissioningParams.acceptedTermsAndConditions && commissioningParams.acceptedTermsAndConditionsVersion) { + if (!chip::CanCastTo([commissioningParams.acceptedTermsAndConditions unsignedIntValue])) { + MTR_LOG_ERROR("%@ Error: acceptedTermsAndConditions value should be between 0 and 65535", self); + *error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_INTEGER_VALUE]; + return NO; + } + + if (!chip::CanCastTo([commissioningParams.acceptedTermsAndConditionsVersion unsignedIntValue])) { + MTR_LOG_ERROR("%@ Error: acceptedTermsAndConditionsVersion value should be between 0 and 65535", self); + *error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_INTEGER_VALUE]; + return NO; + } + + chip::Controller::TermsAndConditionsAcknowledgement termsAndConditionsAcknowledgement = { + .acceptedTermsAndConditions = static_cast([commissioningParams.acceptedTermsAndConditions unsignedIntValue]), + .acceptedTermsAndConditionsVersion = static_cast([commissioningParams.acceptedTermsAndConditionsVersion unsignedIntValue]) + }; + params.SetTermsAndConditionsAcknowledgement(termsAndConditionsAcknowledgement); + } params.SetSkipCommissioningComplete(commissioningParams.skipCommissioningComplete); if (commissioningParams.wifiSSID) { chip::ByteSpan ssid = AsByteSpan(commissioningParams.wifiSSID);