From 2a708b79b90c948c388b574db17b6c9310d4660c Mon Sep 17 00:00:00 2001 From: James Swan <122404367+swan-amazon@users.noreply.github.com> Date: Sun, 4 Aug 2024 19:52:22 +0000 Subject: [PATCH] --- .../commands/pairing/PairingCommand.cpp | 13 +-- .../commands/pairing/PairingCommand.h | 12 +-- .../general-commissioning-server.cpp | 13 ++- .../DefaultEnhancedSetupFlowProvider.cpp | 2 - .../server/DefaultEnhancedSetupFlowProvider.h | 33 +------ .../DefaultTermsAndConditionsProvider.cpp | 9 +- .../DefaultTermsAndConditionsProvider.h | 19 +--- src/app/server/EnhancedSetupFlowProvider.h | 30 +----- src/app/server/Server.cpp | 1 + src/app/server/TermsAndConditionsProvider.h | 10 +- .../TestDefaultEnhancedSetupFlowProvider.cpp | 91 ++++++++++--------- .../TestDefaultTermsAndConditionsProvider.cpp | 91 ++++++++++--------- src/controller/CommissioningDelegate.h | 9 ++ src/lib/core/CHIPConfig.h | 56 ++++++++++++ src/system/SystemConfig.h | 54 ----------- 15 files changed, 190 insertions(+), 253 deletions(-) diff --git a/examples/chip-tool/commands/pairing/PairingCommand.cpp b/examples/chip-tool/commands/pairing/PairingCommand.cpp index b583aa5f202bd4..245c9ed57ff82c 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.cpp +++ b/examples/chip-tool/commands/pairing/PairingCommand.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024 Project CHIP Authors + * Copyright (c) 2020 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -129,17 +129,6 @@ CommissioningParameters PairingCommand::GetCommissioningParameters() params.SetCountryCode(CharSpan::fromCharString(mCountryCode.Value())); } - // 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 1161c3b0950374..9965b663ec111c 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.h +++ b/examples/chip-tool/commands/pairing/PairingCommand.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2024 Project CHIP Authors + * Copyright (c) 2020 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -202,14 +202,6 @@ class PairingCommand : public CHIPCommand, AddArgument("dst-offset", &mComplex_DSTOffsets, "DSTOffset list to use when setting Time Synchronization cluster's DSTOffset attribute", Argument::kOptional); - - 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); @@ -267,8 +259,6 @@ class PairingCommand : public CHIPCommand, chip::Optional mICDMonitoredSubject; chip::Optional mICDClientType; chip::Optional mICDStayActiveDurationMsec; - chip::Optional mTCAcknowledgements; - chip::Optional mTCAcknowledgementVersion; chip::app::DataModel::List mTimeZoneList; TypedComplexArgument> mComplex_TimeZones; diff --git a/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp b/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp index 82bd9113708d06..17755a551a280b 100644 --- a/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp +++ b/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp @@ -88,10 +88,10 @@ static CHIP_ERROR ReadIfSupported(Provider * const provider, CHIP_ERROR (Provide return ReadIfSupported(provider, nonConstGetter, aEncoder); } -class _ : public AttributeAccessInterface +class GeneralCommissioningAttrAccess : public AttributeAccessInterface { public: - _() : AttributeAccessInterface(Optional::Missing(), GeneralCommissioning::Id) {} + GeneralCommissioningAttrAccess() : AttributeAccessInterface(Optional::Missing(), GeneralCommissioning::Id) {} CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) { @@ -157,7 +157,9 @@ class _ : public AttributeAccessInterface } return CHIP_NO_ERROR; } -} gAttributeAccessInstance; +}; + +GeneralCommissioningAttrAccess gAttributeAccessInstance; } // anonymous namespace @@ -279,7 +281,6 @@ bool emberAfGeneralCommissioningClusterCommissioningCompleteCallback( if (!hasRequiredTermAccepted) { ChipLogProgress(AppServer, "Required terms and conditions have not been accepted"); - Breadcrumb::Set(commandPath.mEndpointId, 0); response.errorCode = (0 == termsAndConditionsAcceptedAcknowledgements) ? CommissioningErrorEnum::kTCAcknowledgementsNotReceived : CommissioningErrorEnum::kRequiredTCNotAccepted; @@ -288,7 +289,6 @@ bool emberAfGeneralCommissioningClusterCommissioningCompleteCallback( else if (!hasRequiredTermVersionAccepted) { ChipLogProgress(AppServer, "Minimum terms and conditions version has not been accepted"); - Breadcrumb::Set(commandPath.mEndpointId, 0); response.errorCode = CommissioningErrorEnum::kTCMinVersionNotMet; } @@ -400,6 +400,9 @@ void OnPlatformEventHandler(const DeviceLayer::ChipDeviceEvent * event, intptr_t { // Spec says to reset Breadcrumb attribute to 0. Breadcrumb::Set(0, 0); + + // Clear terms and conditions acceptance on failsafe timer expiration + Server::GetInstance().GetEnhancedSetupFlowProvider()->ClearTermsAndConditionsAcceptance(); } } diff --git a/src/app/server/DefaultEnhancedSetupFlowProvider.cpp b/src/app/server/DefaultEnhancedSetupFlowProvider.cpp index 821d247308b1c0..e82af06ad5b014 100644 --- a/src/app/server/DefaultEnhancedSetupFlowProvider.cpp +++ b/src/app/server/DefaultEnhancedSetupFlowProvider.cpp @@ -16,8 +16,6 @@ * limitations under the License. */ -#include - #include "DefaultEnhancedSetupFlowProvider.h" #include diff --git a/src/app/server/DefaultEnhancedSetupFlowProvider.h b/src/app/server/DefaultEnhancedSetupFlowProvider.h index d5bd31f6ecb35f..52bbd7ab68ac4d 100644 --- a/src/app/server/DefaultEnhancedSetupFlowProvider.h +++ b/src/app/server/DefaultEnhancedSetupFlowProvider.h @@ -18,12 +18,11 @@ #pragma once -#include - #include "EnhancedSetupFlowProvider.h" #include +#include #include #include "TermsAndConditionsProvider.h" @@ -40,49 +39,25 @@ class DefaultEnhancedSetupFlowProvider : public EnhancedSetupFlowProvider */ CHIP_ERROR Init(TermsAndConditionsProvider * const inTermsAndConditionsProvider); - /** - * @copydoc EnhancedSetupFlowProvider::HasTermsAndConditionsRequiredAcknowledgementsBeenAccepted - */ CHIP_ERROR HasTermsAndConditionsRequiredAcknowledgementsBeenAccepted(bool & outAccepted) const override; - /** - * @copydoc EnhancedSetupFlowProvider::HasTermsAndConditionsRequiredAcknowledgementsVersionBeenAccepted - */ CHIP_ERROR HasTermsAndConditionsRequiredAcknowledgementsVersionBeenAccepted(bool & outAccepted) const override; - /** - * @copydoc EnhancedSetupFlowProvider::GetTermsAndConditionsRequiredAcknowledgements - */ CHIP_ERROR GetTermsAndConditionsRequiredAcknowledgements(uint16_t & outValue) const override; - /** - * @copydoc EnhancedSetupFlowProvider::GetTermsAndConditionsRequiredAcknowledgementsVersion - */ CHIP_ERROR GetTermsAndConditionsRequiredAcknowledgementsVersion(uint16_t & outValue) const override; - /** - * @copydoc EnhancedSetupFlowProvider::GetTermsAndConditionsAcceptedAcknowledgements - */ CHIP_ERROR GetTermsAndConditionsAcceptedAcknowledgements(uint16_t & outValue) const override; - /** - * @copydoc EnhancedSetupFlowProvider::GetTermsAndConditionsAcceptedAcknowledgementsVersion - */ CHIP_ERROR GetTermsAndConditionsAcceptedAcknowledgementsVersion(uint16_t & outValue) const override; - /** - * @copydoc EnhancedSetupFlowProvider::SetTermsAndConditionsAcceptance - */ CHIP_ERROR SetTermsAndConditionsAcceptance(uint16_t aTCAcknowledgements, uint16_t inTCAcknowledgementsVersionValue) override; - /** - * @copydoc EnhancedSetupFlowProvider::ClearTermsAndConditionsAcceptance - */ CHIP_ERROR ClearTermsAndConditionsAcceptance() override; private: - TermsAndConditionsProvider * mTermsAndConditionsProvider; /**< TermsAndConditionsProvider instance. */ + TermsAndConditionsProvider * mTermsAndConditionsProvider; }; -}; // namespace app -}; // namespace chip +} // namespace app +} // namespace chip diff --git a/src/app/server/DefaultTermsAndConditionsProvider.cpp b/src/app/server/DefaultTermsAndConditionsProvider.cpp index e57734346cd1e7..c38390823f04a2 100644 --- a/src/app/server/DefaultTermsAndConditionsProvider.cpp +++ b/src/app/server/DefaultTermsAndConditionsProvider.cpp @@ -30,8 +30,13 @@ constexpr chip::TLV::Tag kSerializationVersionTag = chip::TLV::Contex constexpr chip::TLV::Tag kAcceptedAcknowledgementsTag = chip::TLV::ContextTag(2); constexpr chip::TLV::Tag kAcceptedAcknowledgementsVersionTag = chip::TLV::ContextTag(3); constexpr uint8_t kSerializationVersion = 1; -constexpr size_t kEstimatedTlvBufferSize = chip::TLV::EstimateStructOverhead(sizeof(uint8_t), sizeof(uint16_t), sizeof(uint16_t)); -}; // namespace + +constexpr size_t kEstimatedTlvBufferSize = chip::TLV::EstimateStructOverhead(sizeof(uint8_t), // SerializationVersion + sizeof(uint16_t), // AcceptedAcknowledgements + sizeof(uint16_t) // AcceptedAcknowledgementsVersion + ) * + 2; // Extra space for rollback compatibility +} // namespace CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::Init(chip::PersistentStorageDelegate * const inPersistentStorageDelegate, uint16_t inRequiredAcknowledgementsValue, diff --git a/src/app/server/DefaultTermsAndConditionsProvider.h b/src/app/server/DefaultTermsAndConditionsProvider.h index 49f59bdc661cf8..a65efa76310443 100644 --- a/src/app/server/DefaultTermsAndConditionsProvider.h +++ b/src/app/server/DefaultTermsAndConditionsProvider.h @@ -18,12 +18,11 @@ #pragma once -#include - #include "TermsAndConditionsProvider.h" #include +#include #include #include @@ -42,24 +41,12 @@ class DefaultTermsAndConditionsProvider : public TermsAndConditionsProvider CHIP_ERROR Init(PersistentStorageDelegate * const inPersistentStorageDelegate, uint16_t inRequiredAcknowledgementsValue, uint16_t inRequiredAcknowledgementsVersionValue); - /** - * @copydoc TermsAndConditionsProvider::ClearAcceptance - */ CHIP_ERROR ClearAcceptance() override; - /** - * @copydoc TermsAndConditionsProvider::GetAcceptance - */ CHIP_ERROR GetAcceptance(uint16_t & outAcknowledgementsValue, uint16_t & outAcknowledgementsVersionValue) const override; - /** - * @copydoc TermsAndConditionsProvider::GetRequirements - */ CHIP_ERROR GetRequirements(uint16_t & outAcknowledgementsValue, uint16_t & outAcknowledgementsVersionValue) const override; - /** - * @copydoc TermsAndConditionsProvider::SetAcceptance - */ CHIP_ERROR SetAcceptance(uint16_t inAcknowledgementsValue, uint16_t inAcknowledgementsVersionValue) override; private: @@ -68,5 +55,5 @@ class DefaultTermsAndConditionsProvider : public TermsAndConditionsProvider uint16_t mRequiredAcknowledgementsVersionValue; }; -}; // namespace app -}; // namespace chip +} // namespace app +} // namespace chip diff --git a/src/app/server/EnhancedSetupFlowProvider.h b/src/app/server/EnhancedSetupFlowProvider.h index 9a52075f8bdd75..c5d860c90f2888 100644 --- a/src/app/server/EnhancedSetupFlowProvider.h +++ b/src/app/server/EnhancedSetupFlowProvider.h @@ -18,73 +18,53 @@ #pragma once -#include - #include +#include #include namespace chip { namespace app { /** - * @brief Feature state access layer for the EnhancedSetupFlowProvider. - * * This class provides access to the state of the Enhanced Setup Flow feature. */ class EnhancedSetupFlowProvider { public: - /** - * @brief Destructor. - */ virtual ~EnhancedSetupFlowProvider() = default; /** - * @brief Checks if the required terms and conditions acknowledgements have been accepted. - * * @param[out] outAccepted true if the required acknowledgements have been accepted, false otherwise. */ virtual CHIP_ERROR HasTermsAndConditionsRequiredAcknowledgementsBeenAccepted(bool & outAccepted) const = 0; /** - * @brief Checks if the required terms and conditions acknowledgements version has been accepted. - * * @param[out] outAccepted true if the required acknowledgements version has been accepted, false otherwise. */ virtual CHIP_ERROR HasTermsAndConditionsRequiredAcknowledgementsVersionBeenAccepted(bool & outAccepted) const = 0; /** - * @brief Retrieves the required terms and conditions acknowledgements. - * * @param[out] outValue The version of the required acknowledgements. */ virtual CHIP_ERROR GetTermsAndConditionsRequiredAcknowledgements(uint16_t & outValue) const = 0; /** - * @brief Retrieves the required terms and conditions acknowledgements version. - * * @param[out] outValue The outValue of the required acknowledgements version. */ virtual CHIP_ERROR GetTermsAndConditionsRequiredAcknowledgementsVersion(uint16_t & outValue) const = 0; /** - * @brief Retrieves the accepted terms and conditions acknowledgements. - * * @param[out] outValue The outValue of the accepted acknowledgements. */ virtual CHIP_ERROR GetTermsAndConditionsAcceptedAcknowledgements(uint16_t & outValue) const = 0; /** - * @brief Retrieves the accepted terms and conditions acknowledgements version. - * * @param[out] outValue The outValue of the accepted acknowledgements version. */ virtual CHIP_ERROR GetTermsAndConditionsAcceptedAcknowledgementsVersion(uint16_t & outValue) const = 0; /** - * @brief Sets the acceptance status of the terms and conditions. - * * @param[in] inTCAcknowledgements The acknowledgements to accept. * @param[in] inTCAcknowledgementsVersionValue The version of the acknowledgements to accept. */ @@ -92,11 +72,11 @@ class EnhancedSetupFlowProvider uint16_t inTCAcknowledgementsVersionValue) = 0; /** - * @brief Clears the acceptance status of the terms and conditions. - * + * Reset the terms and conditions acceptance. The terms and conditions should be cleared on factory reset or if failure occurs + * during a failsafe context. */ virtual CHIP_ERROR ClearTermsAndConditionsAcceptance() = 0; }; -}; // namespace app -}; // namespace chip +} // namespace app +} // namespace chip diff --git a/src/app/server/Server.cpp b/src/app/server/Server.cpp index 58ff786ad40c2a..a62ce6545a422a 100644 --- a/src/app/server/Server.cpp +++ b/src/app/server/Server.cpp @@ -701,6 +701,7 @@ void Server::ScheduleFactoryReset() GetInstance().GetFabricTable().DeleteAllFabrics(); PlatformMgr().HandleServerShuttingDown(); ConfigurationMgr().InitiateFactoryReset(); + // Clear accepted terms and conditions }); } diff --git a/src/app/server/TermsAndConditionsProvider.h b/src/app/server/TermsAndConditionsProvider.h index 99dfbebc3caa2d..201b3b983d466d 100644 --- a/src/app/server/TermsAndConditionsProvider.h +++ b/src/app/server/TermsAndConditionsProvider.h @@ -18,10 +18,9 @@ #pragma once -#include - #include +#include #include namespace chip { @@ -33,9 +32,6 @@ namespace app { class TermsAndConditionsProvider { public: - /** - * @brief Destructor. - */ virtual ~TermsAndConditionsProvider() = default; /** @@ -68,5 +64,5 @@ class TermsAndConditionsProvider virtual CHIP_ERROR SetAcceptance(uint16_t inAcknowledgementsValue, uint16_t inAcknowledgementsVersionValue) = 0; }; -}; // namespace app -}; // namespace chip +} // namespace app +} // namespace chip diff --git a/src/app/tests/TestDefaultEnhancedSetupFlowProvider.cpp b/src/app/tests/TestDefaultEnhancedSetupFlowProvider.cpp index 4a368d52a4d22a..d73c811472fceb 100644 --- a/src/app/tests/TestDefaultEnhancedSetupFlowProvider.cpp +++ b/src/app/tests/TestDefaultEnhancedSetupFlowProvider.cpp @@ -22,6 +22,7 @@ #include "app/server/DefaultEnhancedSetupFlowProvider.h" #include +#include #include class FakeTermsAndConditionsProvider : public chip::app::TermsAndConditionsProvider @@ -78,10 +79,10 @@ TEST(DefaultEnhancedSetupFlowProvider, TestNoAcceptanceRequiredCheckAcknowledgem chip::app::DefaultEnhancedSetupFlowProvider esfProvider; err = esfProvider.Init(&tncProvider); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); err = esfProvider.HasTermsAndConditionsRequiredAcknowledgementsBeenAccepted(hasTermsBeenAccepted); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); EXPECT_TRUE(hasTermsBeenAccepted); } @@ -94,10 +95,10 @@ TEST(DefaultEnhancedSetupFlowProvider, TestNoAcceptanceRequiredCheckAcknowledgem chip::app::DefaultEnhancedSetupFlowProvider esfProvider; err = esfProvider.Init(&tncProvider); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); err = esfProvider.HasTermsAndConditionsRequiredAcknowledgementsVersionBeenAccepted(hasTermsVersionBeenAccepted); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); EXPECT_TRUE(hasTermsVersionBeenAccepted); } @@ -110,11 +111,11 @@ TEST(DefaultEnhancedSetupFlowProvider, TestAcceptanceRequiredNoTermsAcceptedChec chip::app::DefaultEnhancedSetupFlowProvider esfProvider; err = esfProvider.Init(&tncProvider); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); err = esfProvider.HasTermsAndConditionsRequiredAcknowledgementsBeenAccepted(hasTermsBeenAccepted); - EXPECT_TRUE(CHIP_NO_ERROR == err); - EXPECT_TRUE(!hasTermsBeenAccepted); + EXPECT_EQ(CHIP_NO_ERROR, err); + EXPECT_FALSE(hasTermsBeenAccepted); } TEST(DefaultEnhancedSetupFlowProvider, @@ -128,18 +129,18 @@ TEST(DefaultEnhancedSetupFlowProvider, chip::app::DefaultEnhancedSetupFlowProvider esfProvider; err = esfProvider.Init(&tncProvider); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); err = esfProvider.SetTermsAndConditionsAcceptance(1, 0); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); err = esfProvider.HasTermsAndConditionsRequiredAcknowledgementsBeenAccepted(hasTermsBeenAccepted); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); EXPECT_TRUE(hasTermsBeenAccepted); err = esfProvider.HasTermsAndConditionsRequiredAcknowledgementsVersionBeenAccepted(hasTermsVersionBeenAccepted); - EXPECT_TRUE(CHIP_NO_ERROR == err); - EXPECT_TRUE(!hasTermsVersionBeenAccepted); + EXPECT_EQ(CHIP_NO_ERROR, err); + EXPECT_FALSE(hasTermsVersionBeenAccepted); } TEST(DefaultEnhancedSetupFlowProvider, TestAcceptanceRequiredTermsAcceptedFutureVersionCheckAcknowledgementsAcceptedSuccess) @@ -157,14 +158,14 @@ TEST(DefaultEnhancedSetupFlowProvider, TestAcceptanceRequiredTermsAcceptedFuture chip::app::DefaultEnhancedSetupFlowProvider esfProvider; err = esfProvider.Init(&tncProvider); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); err = esfProvider.HasTermsAndConditionsRequiredAcknowledgementsBeenAccepted(hasTermsBeenAccepted); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); EXPECT_TRUE(hasTermsBeenAccepted); err = esfProvider.HasTermsAndConditionsRequiredAcknowledgementsVersionBeenAccepted(hasTermsVersionBeenAccepted); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); EXPECT_TRUE(hasTermsVersionBeenAccepted); } @@ -178,17 +179,17 @@ TEST(DefaultEnhancedSetupFlowProvider, TestAcceptanceRequiredTermsAcceptedSucces chip::app::DefaultEnhancedSetupFlowProvider esfProvider; err = esfProvider.Init(&tncProvider); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); err = esfProvider.SetTermsAndConditionsAcceptance(1, 1); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); err = esfProvider.HasTermsAndConditionsRequiredAcknowledgementsBeenAccepted(hasTermsBeenAccepted); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); EXPECT_TRUE(hasTermsBeenAccepted); err = esfProvider.HasTermsAndConditionsRequiredAcknowledgementsVersionBeenAccepted(hasTermsVersionBeenAccepted); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); EXPECT_TRUE(hasTermsVersionBeenAccepted); } @@ -207,14 +208,14 @@ TEST(DefaultEnhancedSetupFlowProvider, TestAcceptanceRequiredTermsMissingFailure chip::app::DefaultEnhancedSetupFlowProvider esfProvider; err = esfProvider.Init(&tncProvider); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); err = esfProvider.HasTermsAndConditionsRequiredAcknowledgementsBeenAccepted(hasTermsBeenAccepted); - EXPECT_TRUE(CHIP_NO_ERROR == err); - EXPECT_TRUE(!hasTermsBeenAccepted); + EXPECT_EQ(CHIP_NO_ERROR, err); + EXPECT_FALSE(hasTermsBeenAccepted); err = esfProvider.HasTermsAndConditionsRequiredAcknowledgementsVersionBeenAccepted(hasTermsVersionBeenAccepted); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); EXPECT_TRUE(hasTermsVersionBeenAccepted); } @@ -233,14 +234,14 @@ TEST(DefaultEnhancedSetupFlowProvider, TestAcceptanceRequiredAllTermsAcceptedChe chip::app::DefaultEnhancedSetupFlowProvider esfProvider; err = esfProvider.Init(&tncProvider); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); err = esfProvider.HasTermsAndConditionsRequiredAcknowledgementsBeenAccepted(hasTermsBeenAccepted); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); EXPECT_TRUE(hasTermsBeenAccepted); err = esfProvider.HasTermsAndConditionsRequiredAcknowledgementsVersionBeenAccepted(hasTermsVersionBeenAccepted); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); EXPECT_TRUE(hasTermsVersionBeenAccepted); } @@ -267,43 +268,43 @@ TEST(DefaultEnhancedSetupFlowProvider, TestClearAcceptanceRetainsRequirements) chip::app::DefaultEnhancedSetupFlowProvider esfProvider; err = esfProvider.Init(&tncProvider); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); err = esfProvider.SetTermsAndConditionsAcceptance(updatedAcceptedTermsAndConditions, updatedAcceptedTermsAndConditionsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); err = esfProvider.GetTermsAndConditionsRequiredAcknowledgements(outRequiredTermsAndConditions); - EXPECT_TRUE(CHIP_NO_ERROR == err); - EXPECT_TRUE(outRequiredTermsAndConditions == initialRequiredTermsAndConditions); + EXPECT_EQ(CHIP_NO_ERROR, err); + EXPECT_EQ(outRequiredTermsAndConditions, initialRequiredTermsAndConditions); err = esfProvider.GetTermsAndConditionsRequiredAcknowledgementsVersion(outRequiredTermsAndConditionsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); - EXPECT_TRUE(outRequiredTermsAndConditionsVersion == initialRequiredTermsAndConditionsVersion); + EXPECT_EQ(CHIP_NO_ERROR, err); + EXPECT_EQ(outRequiredTermsAndConditionsVersion, initialRequiredTermsAndConditionsVersion); err = esfProvider.GetTermsAndConditionsAcceptedAcknowledgements(outAcceptedTermsAndConditions); - EXPECT_TRUE(CHIP_NO_ERROR == err); - EXPECT_TRUE(outAcceptedTermsAndConditions == updatedAcceptedTermsAndConditions); + EXPECT_EQ(CHIP_NO_ERROR, err); + EXPECT_EQ(outAcceptedTermsAndConditions, updatedAcceptedTermsAndConditions); err = esfProvider.GetTermsAndConditionsAcceptedAcknowledgementsVersion(outAcceptedTermsAndConditionsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); - EXPECT_TRUE(outAcceptedTermsAndConditionsVersion == updatedAcceptedTermsAndConditionsVersion); + EXPECT_EQ(CHIP_NO_ERROR, err); + EXPECT_EQ(outAcceptedTermsAndConditionsVersion, updatedAcceptedTermsAndConditionsVersion); err = esfProvider.ClearTermsAndConditionsAcceptance(); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); err = esfProvider.GetTermsAndConditionsRequiredAcknowledgements(outRequiredTermsAndConditions); - EXPECT_TRUE(CHIP_NO_ERROR == err); - EXPECT_TRUE(outRequiredTermsAndConditions == initialRequiredTermsAndConditions); + EXPECT_EQ(CHIP_NO_ERROR, err); + EXPECT_EQ(outRequiredTermsAndConditions, initialRequiredTermsAndConditions); err = esfProvider.GetTermsAndConditionsRequiredAcknowledgementsVersion(outRequiredTermsAndConditionsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); - EXPECT_TRUE(outRequiredTermsAndConditionsVersion == initialRequiredTermsAndConditionsVersion); + EXPECT_EQ(CHIP_NO_ERROR, err); + EXPECT_EQ(outRequiredTermsAndConditionsVersion, initialRequiredTermsAndConditionsVersion); err = esfProvider.GetTermsAndConditionsAcceptedAcknowledgements(outAcceptedTermsAndConditions); - EXPECT_TRUE(CHIP_NO_ERROR == err); - EXPECT_TRUE(outAcceptedTermsAndConditions == 0); + EXPECT_EQ(CHIP_NO_ERROR, err); + EXPECT_EQ(outAcceptedTermsAndConditions, 0); err = esfProvider.GetTermsAndConditionsAcceptedAcknowledgementsVersion(outAcceptedTermsAndConditionsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); - EXPECT_TRUE(outAcceptedTermsAndConditionsVersion == 0); + EXPECT_EQ(CHIP_NO_ERROR, err); + EXPECT_EQ(outAcceptedTermsAndConditionsVersion, 0); } diff --git a/src/app/tests/TestDefaultTermsAndConditionsProvider.cpp b/src/app/tests/TestDefaultTermsAndConditionsProvider.cpp index 536c1319a4ccbc..bffd47efb7b5be 100644 --- a/src/app/tests/TestDefaultTermsAndConditionsProvider.cpp +++ b/src/app/tests/TestDefaultTermsAndConditionsProvider.cpp @@ -23,6 +23,7 @@ #include "app/server/DefaultTermsAndConditionsProvider.h" #include +#include #include #include @@ -36,7 +37,7 @@ TEST(DefaultTermsAndConditionsProvider, TestInitSuccess) uint16_t requiredAcknowledgements = 1; uint16_t requiredAcknowledgementsVersion = 1; err = tncProvider.Init(&storageDelegate, requiredAcknowledgements, requiredAcknowledgementsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); } TEST(DefaultTermsAndConditionsProvider, TestNoRequirementsGetRequirementsSuccess) @@ -49,14 +50,14 @@ TEST(DefaultTermsAndConditionsProvider, TestNoRequirementsGetRequirementsSuccess uint16_t requiredAcknowledgements = 0; uint16_t requiredAcknowledgementsVersion = 0; err = tncProvider.Init(&storageDelegate, requiredAcknowledgements, requiredAcknowledgementsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); uint16_t outAcceptance; uint16_t outAcknowledgementsVersion; err = tncProvider.GetAcceptance(outAcceptance, outAcknowledgementsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); - EXPECT_TRUE(0 == outAcceptance); - EXPECT_TRUE(0 == outAcknowledgementsVersion); + EXPECT_EQ(CHIP_NO_ERROR, err); + EXPECT_EQ(0, outAcceptance); + EXPECT_EQ(0, outAcknowledgementsVersion); } TEST(DefaultTermsAndConditionsProvider, TestNeverAcceptanceGetAcceptanceSuccess) @@ -69,14 +70,14 @@ TEST(DefaultTermsAndConditionsProvider, TestNeverAcceptanceGetAcceptanceSuccess) uint16_t requiredAcknowledgements = 0b1111'1111'1111'1111; uint16_t requiredAcknowledgementsVersion = 1; err = tncProvider.Init(&storageDelegate, requiredAcknowledgements, requiredAcknowledgementsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); uint16_t outAcceptance; uint16_t outAcknowledgementsVersion; err = tncProvider.GetAcceptance(outAcceptance, outAcknowledgementsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); - EXPECT_TRUE(0 == outAcceptance); - EXPECT_TRUE(0 == outAcknowledgementsVersion); + EXPECT_EQ(CHIP_NO_ERROR, err); + EXPECT_EQ(0, outAcceptance); + EXPECT_EQ(0, outAcknowledgementsVersion); } TEST(DefaultTermsAndConditionsProvider, TestTermsAcceptedPersistsSuccess) @@ -90,27 +91,27 @@ TEST(DefaultTermsAndConditionsProvider, TestTermsAcceptedPersistsSuccess) uint16_t requiredAcknowledgements = 1; uint16_t requiredAcknowledgementsVersion = 1; err = tncProvider.Init(&storageDelegate, requiredAcknowledgements, requiredAcknowledgementsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); uint16_t acceptedTermsAndConditions = 1; uint16_t acceptedTermsAndConditionsVersion = 1; err = tncProvider.SetAcceptance(acceptedTermsAndConditions, acceptedTermsAndConditionsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); uint16_t outAcceptance; uint16_t outAcknowledgementsVersion; err = tncProvider.GetAcceptance(outAcceptance, outAcknowledgementsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); - EXPECT_TRUE(1 == outAcceptance); - EXPECT_TRUE(1 == outAcknowledgementsVersion); + EXPECT_EQ(CHIP_NO_ERROR, err); + EXPECT_EQ(1, outAcceptance); + EXPECT_EQ(1, outAcknowledgementsVersion); err = anotherTncProvider.Init(&storageDelegate, requiredAcknowledgements, requiredAcknowledgementsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); err = anotherTncProvider.GetAcceptance(outAcceptance, outAcknowledgementsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); - EXPECT_TRUE(1 == outAcceptance); - EXPECT_TRUE(1 == outAcknowledgementsVersion); + EXPECT_EQ(CHIP_NO_ERROR, err); + EXPECT_EQ(1, outAcceptance); + EXPECT_EQ(1, outAcknowledgementsVersion); } TEST(DefaultTermsAndConditionsProvider, TestTermsRequiredGetRequirementsSuccess) @@ -123,14 +124,14 @@ TEST(DefaultTermsAndConditionsProvider, TestTermsRequiredGetRequirementsSuccess) uint16_t initialRequiredAcknowledgements = 1; uint16_t initialRequiredAcknowledgementsVersion = 1; err = tncProvider.Init(&storageDelegate, initialRequiredAcknowledgements, initialRequiredAcknowledgementsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); uint16_t outRequiredAcknowledgements; uint16_t outRequiredAcknowledgementsVersion; err = tncProvider.GetRequirements(outRequiredAcknowledgements, outRequiredAcknowledgementsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); - EXPECT_TRUE(1 == outRequiredAcknowledgements); - EXPECT_TRUE(1 == outRequiredAcknowledgementsVersion); + EXPECT_EQ(CHIP_NO_ERROR, err); + EXPECT_EQ(1, outRequiredAcknowledgements); + EXPECT_EQ(1, outRequiredAcknowledgementsVersion); } TEST(DefaultTermsAndConditionsProvider, TestSetAcceptanceGetAcceptanceSuccess) @@ -143,19 +144,19 @@ TEST(DefaultTermsAndConditionsProvider, TestSetAcceptanceGetAcceptanceSuccess) uint16_t requiredAcknowledgements = 1; uint16_t requiredAcknowledgementsVersion = 1; err = tncProvider.Init(&storageDelegate, requiredAcknowledgements, requiredAcknowledgementsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); uint16_t acceptedTermsAndConditions = 1; uint16_t acceptedTermsAndConditionsVersion = 1; err = tncProvider.SetAcceptance(acceptedTermsAndConditions, acceptedTermsAndConditionsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); uint16_t outAcceptance; uint16_t outAcknowledgementsVersion; err = tncProvider.GetAcceptance(outAcceptance, outAcknowledgementsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); - EXPECT_TRUE(1 == outAcceptance); - EXPECT_TRUE(1 == outAcknowledgementsVersion); + EXPECT_EQ(CHIP_NO_ERROR, err); + EXPECT_EQ(1, outAcceptance); + EXPECT_EQ(1, outAcknowledgementsVersion); } TEST(DefaultTermsAndConditionsProvider, TestClearAcceptanceGetAcceptanceSuccess) @@ -168,29 +169,29 @@ TEST(DefaultTermsAndConditionsProvider, TestClearAcceptanceGetAcceptanceSuccess) uint16_t requiredAcknowledgements = 1; uint16_t requiredAcknowledgementsVersion = 1; err = tncProvider.Init(&storageDelegate, requiredAcknowledgements, requiredAcknowledgementsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); uint16_t acceptedTermsAndConditions = 1; uint16_t acceptedTermsAndConditionsVersion = 1; err = tncProvider.SetAcceptance(acceptedTermsAndConditions, acceptedTermsAndConditionsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); uint16_t outAcceptance; uint16_t outAcknowledgementsVersion; err = tncProvider.GetAcceptance(outAcceptance, outAcknowledgementsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); - EXPECT_TRUE(1 == outAcceptance); - EXPECT_TRUE(1 == outAcknowledgementsVersion); + EXPECT_EQ(CHIP_NO_ERROR, err); + EXPECT_EQ(1, outAcceptance); + EXPECT_EQ(1, outAcknowledgementsVersion); err = tncProvider.ClearAcceptance(); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); uint16_t outAcceptance2; uint16_t outAcknowledgementsVersion2; err = tncProvider.GetAcceptance(outAcceptance2, outAcknowledgementsVersion2); - EXPECT_TRUE(CHIP_NO_ERROR == err); - EXPECT_TRUE(0 == outAcceptance2); - EXPECT_TRUE(0 == outAcknowledgementsVersion2); + EXPECT_EQ(CHIP_NO_ERROR, err); + EXPECT_EQ(0, outAcceptance2); + EXPECT_EQ(0, outAcknowledgementsVersion2); } TEST(DefaultTermsAndConditionsProvider, TestAcceptanceRequiredTermsMissingFailure) @@ -203,27 +204,27 @@ TEST(DefaultTermsAndConditionsProvider, TestAcceptanceRequiredTermsMissingFailur uint16_t requiredAcknowledgements = 1; uint16_t requiredAcknowledgementsVersion = 1; err = tncProvider.Init(&storageDelegate, requiredAcknowledgements, requiredAcknowledgementsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); uint16_t acceptedTermsAndConditions = 1; uint16_t acceptedTermsAndConditionsVersion = 1; err = tncProvider.SetAcceptance(acceptedTermsAndConditions, acceptedTermsAndConditionsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); uint16_t outAcceptance; uint16_t outAcknowledgementsVersion; err = tncProvider.GetAcceptance(outAcceptance, outAcknowledgementsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); - EXPECT_TRUE(1 == outAcceptance); - EXPECT_TRUE(1 == outAcknowledgementsVersion); + EXPECT_EQ(CHIP_NO_ERROR, err); + EXPECT_EQ(1, outAcceptance); + EXPECT_EQ(1, outAcknowledgementsVersion); err = tncProvider.ClearAcceptance(); - EXPECT_TRUE(CHIP_NO_ERROR == err); + EXPECT_EQ(CHIP_NO_ERROR, err); uint16_t outRequiredAcknowledgements; uint16_t outRequiredAcknowledgementsVersion; err = tncProvider.GetRequirements(outRequiredAcknowledgements, outRequiredAcknowledgementsVersion); - EXPECT_TRUE(CHIP_NO_ERROR == err); - EXPECT_TRUE(1 == outRequiredAcknowledgements); - EXPECT_TRUE(1 == outRequiredAcknowledgementsVersion); + EXPECT_EQ(CHIP_NO_ERROR, err); + EXPECT_EQ(1, outRequiredAcknowledgements); + EXPECT_EQ(1, outRequiredAcknowledgementsVersion); } diff --git a/src/controller/CommissioningDelegate.h b/src/controller/CommissioningDelegate.h index 73716e0d9ad0de..c3a839beb96681 100644 --- a/src/controller/CommissioningDelegate.h +++ b/src/controller/CommissioningDelegate.h @@ -174,6 +174,8 @@ class CommissioningParameters // The country code to be used for the node, if set. Optional GetCountryCode() const { return mCountryCode; } + Optional GetRequireTermsAndConditionsAcknowledgement() const { return mRequireTermsAndConditionsAcknowledgement; } + Optional GetTermsAndConditionsAcknowledgement() const { return mTermsAndConditionsAcknowledgement; @@ -351,6 +353,12 @@ class CommissioningParameters return *this; } + CommissioningParameters & SetRequireTermsAndConditionsAcknowledgement(bool requireTermsAndConditionsAcknowledgement) + { + mRequireTermsAndConditionsAcknowledgement.SetValue(requireTermsAndConditionsAcknowledgement); + return *this; + } + CommissioningParameters & SetTermsAndConditionsAcknowledgement(TermsAndConditionsAcknowledgement termsAndConditionsAcknowledgement) { @@ -629,6 +637,7 @@ class CommissioningParameters Optional mAttestationNonce; Optional mWiFiCreds; Optional mCountryCode; + Optional mRequireTermsAndConditionsAcknowledgement; Optional mTermsAndConditionsAcknowledgement; Optional mThreadOperationalDataset; Optional mNOCChainGenerationParameters; diff --git a/src/lib/core/CHIPConfig.h b/src/lib/core/CHIPConfig.h index e9c317dfc79d5c..d3cd8041e1a14e 100644 --- a/src/lib/core/CHIPConfig.h +++ b/src/lib/core/CHIPConfig.h @@ -1785,6 +1785,62 @@ extern const char CHIP_NON_PRODUCTION_MARKER[]; #define CHIP_CONFIG_MAX_BDX_LOG_TRANSFERS 5 #endif // CHIP_CONFIG_MAX_BDX_LOG_TRANSFERS +/** + * @file + * Configuration settings for Terms and Conditions (TC) acknowledgements during device commissioning. + */ + +/** + * @def CHIP_CONFIG_TC_REQUIRED + * + * @brief Indicates whether terms and conditions are required during commissioning. + * + * This macro defines whether the device commissioning process requires the user to acknowledge terms and conditions. + * - 1: Terms and conditions are required. + * - 0: Terms and conditions are not required. + * + * If this is set to 1, both CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS and + * CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION must be defined. + */ +#ifndef CHIP_CONFIG_TC_REQUIRED +#define CHIP_CONFIG_TC_REQUIRED (1) +#define CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS 1 +#define CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION 1 +#endif + +#if CHIP_CONFIG_TC_REQUIRED + +/** + * @def CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS + * + * @brief Configures the required terms and conditions acknowledgements bitmask. + * + * This macro defines the required terms and conditions acknowledgements bitmask. The bit-field is 16 bits long, so the possible + * value range is [0, 65535). This setting can be used to require that terms and conditions are presented to the user during + * commissioning. + */ +#ifndef CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS +#error "CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS must be defined when CHIP_CONFIG_TC_REQUIRED is enabled." +#endif + +/** + * @def CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION + * + * @brief Configures the latest known version of the terms and conditions. + * + * This macro defines the version number of the latest terms and conditions. It allows the application to iterate on revisions of + * the terms and conditions. A value of 0 indicates that no specific version is required. This setting can be used to enforce + * version-specific terms and conditions acknowledgements in the application. When the set of terms and conditions needs to be + * changed, the version number should be monotonically increased. If the latest terms and conditions version is updated (most + * likely during an OTA), then this may signal to the Administrator that updated terms and conditions should be presented to the + * user. + */ +#ifndef CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION +#error "CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION must be defined when CHIP_CONFIG_TC_REQUIRED is enabled." +#endif + +#endif // CHIP_CONFIG_TC_REQUIRED + /** * @} */ diff --git a/src/system/SystemConfig.h b/src/system/SystemConfig.h index b1b421d2aa98fd..b37cfe555278dd 100644 --- a/src/system/SystemConfig.h +++ b/src/system/SystemConfig.h @@ -806,57 +806,3 @@ struct LwIPEvent; #ifndef CHIP_SYSTEM_CONFIG_MAX_LARGE_BUFFER_SIZE_BYTES #define CHIP_SYSTEM_CONFIG_MAX_LARGE_BUFFER_SIZE_BYTES (64000) #endif - -/** - * @file - * Configuration settings for Terms and Conditions (TC) acknowledgements during device commissioning. - */ - -/** - * @def CHIP_CONFIG_TC_REQUIRED - * - * @brief Indicates whether terms and conditions are required during commissioning. - * - * This macro defines whether the device commissioning process requires the user to acknowledge terms and conditions. - * - 1: Terms and conditions are required. - * - 0: Terms and conditions are not required. - * - * If this is set to 1, both CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS and - * CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION must be defined. - */ -#ifndef CHIP_CONFIG_TC_REQUIRED -#define CHIP_CONFIG_TC_REQUIRED (0) -#endif - -#if CHIP_CONFIG_TC_REQUIRED - -/** - * @def CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS - * - * @brief Configures the required terms and conditions acknowledgements bitmask. - * - * This macro defines the required terms and conditions acknowledgements bitmask. The bit-field is 16 bits long, so the possible - * value range is [0, 65535). This setting can be used to require that terms and conditions are presented to the user during - * commissioning. - */ -#ifndef CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS -#error "CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS must be defined when CHIP_CONFIG_TC_REQUIRED is enabled." -#endif - -/** - * @def CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION - * - * @brief Configures the latest known version of the terms and conditions. - * - * This macro defines the version number of the latest terms and conditions. It allows the application to iterate on revisions of - * the terms and conditions. A value of 0 indicates that no specific version is required. This setting can be used to enforce - * version-specific terms and conditions acknowledgements in the application. When the set of terms and conditions needs to be - * changed, the version number should be monotonically increased. If the latest terms and conditions version is updated (most - * likely during an OTA), then this may signal to the Administrator that updated terms and conditions should be presented to the - * user. - */ -#ifndef CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION -#error "CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION must be defined when CHIP_CONFIG_TC_REQUIRED is enabled." -#endif - -#endif // CHIP_CONFIG_TC_REQUIRED