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 fd7bbc6421525d..9ea66d4779b09d 100644 --- a/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp +++ b/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp @@ -59,133 +59,105 @@ using Transport::Session; namespace { template -static CHIP_ERROR ReadInternal(Provider* const provider, CHIP_ERROR (Provider::*const getter)(T&), AttributeValueEncoder& aEncoder) +static CHIP_ERROR ReadIfSupported(Provider * const provider, CHIP_ERROR (Provider::*const nonConstGetter)(T &), + AttributeValueEncoder & aEncoder) { - T data; - if (nullptr == provider) { return CHIP_ERROR_PERSISTED_STORAGE_FAILED; } - CHIP_ERROR err = (provider->*getter)(data); - if (err == CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE) - { - data = 0; - } - else if (err != CHIP_NO_ERROR) + T value; + CHIP_ERROR err = (provider->*nonConstGetter)(value); + if (err != CHIP_NO_ERROR) { return err; } - return aEncoder.Encode(data); + return aEncoder.Encode(value); } template -static CHIP_ERROR ReadInternal(Provider* const provider, CHIP_ERROR (Provider::*const getter)(T&) const, AttributeValueEncoder& aEncoder) +static CHIP_ERROR ReadIfSupported(Provider * const provider, CHIP_ERROR (Provider::*const getter)(T &) const, + AttributeValueEncoder & aEncoder) { - // Removing the const qualifier from the getter function pointer because there are a handful of getter functions that are not correctly marked as const. - using NonConstGetter = CHIP_ERROR (Provider::*)(T&); + // Removing the const qualifier from the getter function pointer because there are a handful of getter functions that are not + // correctly marked as const. + using NonConstGetter = CHIP_ERROR (Provider::*)(T &); NonConstGetter nonConstGetter = reinterpret_cast(getter); - - return ReadInternal(provider, nonConstGetter, aEncoder); + return ReadIfSupported(provider, nonConstGetter, aEncoder); } -template -static CHIP_ERROR ReadIfSupported(Args &&... args) -{ - return ReadInternal(std::forward(args)...); -} - -class GeneralCommissioningAttrAccess : public AttributeAccessInterface +class _ : public AttributeAccessInterface { public: - // Register for the GeneralCommissioning cluster on all endpoints. - GeneralCommissioningAttrAccess() : AttributeAccessInterface(Optional::Missing(), GeneralCommissioning::Id) {} - - CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override; - -private: - CHIP_ERROR ReadBasicCommissioningInfo(AttributeValueEncoder & aEncoder); - CHIP_ERROR ReadSupportsConcurrentConnection(AttributeValueEncoder & aEncoder); -}; - -GeneralCommissioningAttrAccess gAttrAccess; - -CHIP_ERROR GeneralCommissioningAttrAccess::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) -{ - if (aPath.mClusterId != GeneralCommissioning::Id) - { - // We shouldn't have been called at all. - return CHIP_ERROR_INVALID_ARGUMENT; - } + _() : AttributeAccessInterface(Optional::Missing(), GeneralCommissioning::Id) {} - switch (aPath.mAttributeId) + CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) { - case RegulatoryConfig::Id: { - return ReadIfSupported(&DeviceLayer::ConfigurationMgr(), &ConfigurationManager::GetRegulatoryLocation, aEncoder); - } - case LocationCapability::Id: { - return ReadIfSupported(&DeviceLayer::ConfigurationMgr(), &ConfigurationManager::GetLocationCapability, aEncoder); - } - case BasicCommissioningInfo::Id: { - return ReadBasicCommissioningInfo(aEncoder); - } - case SupportsConcurrentConnection::Id: { - return ReadSupportsConcurrentConnection(aEncoder); - } -#if defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) - case TCAcceptedVersion::Id: { - app::EnhancedSetupFlowProvider * provider = Server::GetInstance().GetEnhancedSetupFlowProvider(); - auto getter = &EnhancedSetupFlowProvider::GetTermsAndConditionsAcceptedAcknowledgementsVersion; - return ReadIfSupported(provider, getter, aEncoder); - } - case TCMinRequiredVersion::Id: { - auto provider = Server::GetInstance().GetEnhancedSetupFlowProvider(); - auto getter = &EnhancedSetupFlowProvider::GetTermsAndConditionsRequiredAcknowledgementsVersion; - return ReadIfSupported(provider, getter, aEncoder); - } - case TCAcknowledgements::Id: { - auto provider = Server::GetInstance().GetEnhancedSetupFlowProvider(); - auto getter = &EnhancedSetupFlowProvider::GetTermsAndConditionsAcceptedAcknowledgements; - return ReadIfSupported(provider, getter, aEncoder); - } - case TCAcknowledgementsRequired::Id: { - auto provider = Server::GetInstance().GetEnhancedSetupFlowProvider(); - auto getter = &EnhancedSetupFlowProvider::GetTermsAndConditionsRequiredAcknowledgements; - return ReadIfSupported(provider, getter, aEncoder); - } -#endif - default: - break; - } - return CHIP_NO_ERROR; -} - -CHIP_ERROR GeneralCommissioningAttrAccess::ReadBasicCommissioningInfo(AttributeValueEncoder & aEncoder) -{ - BasicCommissioningInfo::TypeInfo::Type basicCommissioningInfo; + if (aPath.mClusterId != GeneralCommissioning::Id) + { + // We shouldn't have been called at all. + return CHIP_ERROR_INVALID_ARGUMENT; + } - // TODO: The commissioner might use the critical parameters in BasicCommissioningInfo to initialize - // the CommissioningParameters at the beginning of commissioning flow. - basicCommissioningInfo.failSafeExpiryLengthSeconds = CHIP_DEVICE_CONFIG_FAILSAFE_EXPIRY_LENGTH_SEC; - basicCommissioningInfo.maxCumulativeFailsafeSeconds = CHIP_DEVICE_CONFIG_MAX_CUMULATIVE_FAILSAFE_SEC; - static_assert(CHIP_DEVICE_CONFIG_MAX_CUMULATIVE_FAILSAFE_SEC >= CHIP_DEVICE_CONFIG_FAILSAFE_EXPIRY_LENGTH_SEC, - "Max cumulative failsafe seconds must be larger than failsafe expiry length seconds"); + switch (aPath.mAttributeId) + { + case RegulatoryConfig::Id: { + return ReadIfSupported(&DeviceLayer::ConfigurationMgr(), &ConfigurationManager::GetRegulatoryLocation, aEncoder); + } + case LocationCapability::Id: { + return ReadIfSupported(&DeviceLayer::ConfigurationMgr(), &ConfigurationManager::GetLocationCapability, aEncoder); + } + case BasicCommissioningInfo::Id: { + BasicCommissioningInfo::TypeInfo::Type basicCommissioningInfo; - return aEncoder.Encode(basicCommissioningInfo); -} + // TODO: The commissioner might use the critical parameters in BasicCommissioningInfo to initialize + // the CommissioningParameters at the beginning of commissioning flow. + basicCommissioningInfo.failSafeExpiryLengthSeconds = CHIP_DEVICE_CONFIG_FAILSAFE_EXPIRY_LENGTH_SEC; + basicCommissioningInfo.maxCumulativeFailsafeSeconds = CHIP_DEVICE_CONFIG_MAX_CUMULATIVE_FAILSAFE_SEC; + static_assert(CHIP_DEVICE_CONFIG_MAX_CUMULATIVE_FAILSAFE_SEC >= CHIP_DEVICE_CONFIG_FAILSAFE_EXPIRY_LENGTH_SEC, + "Max cumulative failsafe seconds must be larger than failsafe expiry length seconds"); -CHIP_ERROR GeneralCommissioningAttrAccess::ReadSupportsConcurrentConnection(AttributeValueEncoder & aEncoder) -{ - SupportsConcurrentConnection::TypeInfo::Type supportsConcurrentConnection; + return aEncoder.Encode(basicCommissioningInfo); + } + case SupportsConcurrentConnection::Id: { + SupportsConcurrentConnection::TypeInfo::Type supportsConcurrentConnection; - // TODO: The commissioner might use the critical parameters in BasicCommissioningInfo to initialize - // the CommissioningParameters at the beginning of commissioning flow. - supportsConcurrentConnection = (CHIP_DEVICE_CONFIG_SUPPORTS_CONCURRENT_CONNECTION) != 0; + // TODO: The commissioner might use the critical parameters in BasicCommissioningInfo to initialize + // the CommissioningParameters at the beginning of commissioning flow. + supportsConcurrentConnection = (CHIP_DEVICE_CONFIG_SUPPORTS_CONCURRENT_CONNECTION) != 0; - return aEncoder.Encode(supportsConcurrentConnection); -} + return aEncoder.Encode(supportsConcurrentConnection); + } +#if defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) + case TCAcceptedVersion::Id: { + auto provider = Server::GetInstance().GetEnhancedSetupFlowProvider(); + auto getter = &EnhancedSetupFlowProvider::GetTermsAndConditionsAcceptedAcknowledgementsVersion; + return ReadIfSupported(provider, getter, aEncoder); + } + case TCMinRequiredVersion::Id: { + auto provider = Server::GetInstance().GetEnhancedSetupFlowProvider(); + auto getter = &EnhancedSetupFlowProvider::GetTermsAndConditionsRequiredAcknowledgementsVersion; + return ReadIfSupported(provider, getter, aEncoder); + } + case TCAcknowledgements::Id: { + auto provider = Server::GetInstance().GetEnhancedSetupFlowProvider(); + auto getter = &EnhancedSetupFlowProvider::GetTermsAndConditionsAcceptedAcknowledgements; + return ReadIfSupported(provider, getter, aEncoder); + } + case TCAcknowledgementsRequired::Id: { + auto provider = Server::GetInstance().GetEnhancedSetupFlowProvider(); + auto getter = &EnhancedSetupFlowProvider::GetTermsAndConditionsRequiredAcknowledgements; + return ReadIfSupported(provider, getter, aEncoder); + } +#endif + default: + break; + } + return CHIP_NO_ERROR; + } +} gAttributeAccessInstance; } // anonymous namespace @@ -257,7 +229,7 @@ bool emberAfGeneralCommissioningClusterCommissioningCompleteCallback( { MATTER_TRACE_SCOPE("CommissioningComplete", "GeneralCommissioning"); -#if defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) +#if defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) EnhancedSetupFlowProvider * enhancedSetupFlowProvider = Server::GetInstance().GetEnhancedSetupFlowProvider(); #endif DeviceControlServer * const devCtrl = &DeviceLayer::DeviceControlServer::DeviceControlSvr(); @@ -287,7 +259,7 @@ bool emberAfGeneralCommissioningClusterCommissioningCompleteCallback( { CHIP_ERROR err; -#if defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) +#if defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) uint16_t termsAndConditionsAcceptedAcknowledgements; bool hasRequiredTermAccepted; @@ -297,8 +269,7 @@ bool emberAfGeneralCommissioningClusterCommissioningCompleteCallback( termsAndConditionsAcceptedAcknowledgements); CheckSuccess(err, Failure); - err = enhancedSetupFlowProvider->HasTermsAndConditionsRequiredAcknowledgementsBeenAccepted( - hasRequiredTermAccepted); + err = enhancedSetupFlowProvider->HasTermsAndConditionsRequiredAcknowledgementsBeenAccepted(hasRequiredTermAccepted); CheckSuccess(err, Failure); err = enhancedSetupFlowProvider->HasTermsAndConditionsRequiredAcknowledgementsVersionBeenAccepted( @@ -408,7 +379,7 @@ bool emberAfGeneralCommissioningClusterSetTCAcknowledgementsCallback( chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::GeneralCommissioning::Commands::SetTCAcknowledgements::DecodableType & commandData) { -#if defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) +#if defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) MATTER_TRACE_SCOPE("SetTCAcknowledgements", "GeneralCommissioning"); Commands::SetTCAcknowledgementsResponse::Type response; EnhancedSetupFlowProvider * const enhancedSetupFlowProvider = Server::GetInstance().GetEnhancedSetupFlowProvider(); @@ -437,7 +408,7 @@ void OnPlatformEventHandler(const DeviceLayer::ChipDeviceEvent * event, intptr_t void MatterGeneralCommissioningPluginServerInitCallback() { Breadcrumb::Set(0, 0); - registerAttributeAccessOverride(&gAttrAccess); + registerAttributeAccessOverride(&gAttributeAccessInstance); DeviceLayer::PlatformMgrImpl().AddEventHandler(OnPlatformEventHandler); } diff --git a/src/app/server/DefaultEnhancedSetupFlowProvider.cpp b/src/app/server/DefaultEnhancedSetupFlowProvider.cpp index b57c0381610e3c..821d247308b1c0 100644 --- a/src/app/server/DefaultEnhancedSetupFlowProvider.cpp +++ b/src/app/server/DefaultEnhancedSetupFlowProvider.cpp @@ -22,7 +22,6 @@ #include #include -#include CHIP_ERROR chip::app::DefaultEnhancedSetupFlowProvider::Init(TermsAndConditionsProvider * const inTermsAndConditionsProvider) { diff --git a/src/app/server/DefaultEnhancedSetupFlowProvider.h b/src/app/server/DefaultEnhancedSetupFlowProvider.h index fc209cb410c334..19cfa7f77791c8 100644 --- a/src/app/server/DefaultEnhancedSetupFlowProvider.h +++ b/src/app/server/DefaultEnhancedSetupFlowProvider.h @@ -74,7 +74,7 @@ class DefaultEnhancedSetupFlowProvider : public EnhancedSetupFlowProvider /** * @copydoc EnhancedSetupFlowProvider::SetTermsAndConditionsAcceptance */ - CHIP_ERROR SetTermsAndConditionsAcceptance(uint16_t aTCAcknowledgements, uint16_t aTCAcknowledgementsVersion) override; + CHIP_ERROR SetTermsAndConditionsAcceptance(uint16_t aTCAcknowledgements, uint16_t inTCAcknowledgementsVersionValue) override; /** * @copydoc EnhancedSetupFlowProvider::ClearTermsAndConditionsAcceptance diff --git a/src/app/server/DefaultTermsAndConditionsProvider.cpp b/src/app/server/DefaultTermsAndConditionsProvider.cpp index 564c80b16e783d..0ce37729b058ba 100644 --- a/src/app/server/DefaultTermsAndConditionsProvider.cpp +++ b/src/app/server/DefaultTermsAndConditionsProvider.cpp @@ -23,12 +23,13 @@ #include #include #include -#include namespace { -static constexpr chip::TLV::Tag kAcceptedAcknowledgementsTag = chip::TLV::ContextTag(1); -static constexpr chip::TLV::Tag kAcceptedAcknowledgementsVersionTag = chip::TLV::ContextTag(2); -static constexpr size_t kEstimatedTlvBufferSize = chip::TLV::EstimateStructOverhead(sizeof(uint16_t), sizeof(uint16_t)); +constexpr chip::TLV::Tag kSerializationVersionTag = chip::TLV::ContextTag(1); +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 CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::Init(chip::PersistentStorageDelegate * const inPersistentStorageDelegate, @@ -83,11 +84,9 @@ CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::GetAcceptance(uint16_t tlvReader.Init(buffer); ReturnErrorOnFailure(tlvReader.Next(chip::TLV::kTLVType_Structure, chip::TLV::AnonymousTag())); ReturnErrorOnFailure(tlvReader.EnterContainer(tlvContainer)); - ReturnErrorOnFailure(tlvReader.Next()); - ReturnErrorOnFailure(tlvReader.Expect(kAcceptedAcknowledgementsTag)); + ReturnErrorOnFailure(tlvReader.Next(kAcceptedAcknowledgementsTag)); ReturnErrorOnFailure(tlvReader.Get(acknowledgements)); - ReturnErrorOnFailure(tlvReader.Next()); - ReturnErrorOnFailure(tlvReader.Expect(kAcceptedAcknowledgementsVersionTag)); + ReturnErrorOnFailure(tlvReader.Next(kAcceptedAcknowledgementsVersionTag)); ReturnErrorOnFailure(tlvReader.Get(acknowledgementsVersion)); ReturnErrorOnFailure(tlvReader.ExitContainer(tlvContainer)); @@ -117,6 +116,7 @@ CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::SetAcceptance(uint16_t tlvWriter.Init(buffer, sizeof(buffer)); ReturnErrorOnFailure(tlvWriter.StartContainer(chip::TLV::AnonymousTag(), chip::TLV::kTLVType_Structure, tlvContainer)); + ReturnErrorOnFailure(tlvWriter.Put(kSerializationVersionTag, kSerializationVersion)); ReturnErrorOnFailure(tlvWriter.Put(kAcceptedAcknowledgementsTag, inAcceptedAcknowledgementsValue)); ReturnErrorOnFailure(tlvWriter.Put(kAcceptedAcknowledgementsVersionTag, inAcceptedAcknowledgementsVersionValue)); ReturnErrorOnFailure(tlvWriter.EndContainer(tlvContainer)); diff --git a/src/app/server/DefaultTermsAndConditionsProvider.h b/src/app/server/DefaultTermsAndConditionsProvider.h index 3205f98e57948a..d70d0f124db6df 100644 --- a/src/app/server/DefaultTermsAndConditionsProvider.h +++ b/src/app/server/DefaultTermsAndConditionsProvider.h @@ -40,7 +40,7 @@ class DefaultTermsAndConditionsProvider : public TermsAndConditionsProvider * @param[in] inRequiredAcknowledgementsVersionValue The version of the required acknowledgements. * @return CHIP_ERROR On success returns CHIP_NO_ERROR, otherwise returns an error code. */ - CHIP_ERROR Init(chip::PersistentStorageDelegate * const inPersistentStorageDelegate, uint16_t inRequiredAcknowledgementsValue, + CHIP_ERROR Init(PersistentStorageDelegate * const inPersistentStorageDelegate, uint16_t inRequiredAcknowledgementsValue, uint16_t inRequiredAcknowledgementsVersionValue); /** @@ -64,7 +64,7 @@ class DefaultTermsAndConditionsProvider : public TermsAndConditionsProvider CHIP_ERROR SetAcceptance(uint16_t inAcknowledgementsValue, uint16_t inAcknowledgementsVersionValue) override; private: - chip::PersistentStorageDelegate * mPersistentStorageDelegate; + PersistentStorageDelegate * mPersistentStorageDelegate; uint16_t mRequiredAcknowledgementsValue; uint16_t mRequiredAcknowledgementsVersionValue; }; diff --git a/src/app/server/EnhancedSetupFlowProvider.h b/src/app/server/EnhancedSetupFlowProvider.h index 063b9352d18013..5e8d276a3d3cd7 100644 --- a/src/app/server/EnhancedSetupFlowProvider.h +++ b/src/app/server/EnhancedSetupFlowProvider.h @@ -92,11 +92,11 @@ class EnhancedSetupFlowProvider * @brief Sets the acceptance status of the terms and conditions. * * @param[in] inTCAcknowledgements The acknowledgements to accept. - * @param[in] inTCAcknowledgementsoutValue The version of the acknowledgements to accept. + * @param[in] inTCAcknowledgementsVersionValue The version of the acknowledgements to accept. * @return CHIP_ERROR On success returns CHIP_NO_ERROR, otherwise returns an error code. */ virtual CHIP_ERROR SetTermsAndConditionsAcceptance(uint16_t inTCAcknowledgementsValue, - uint16_t inTCAcknowledgementsoutValue) = 0; + uint16_t inTCAcknowledgementsVersionValue) = 0; /** * @brief Clears the acceptance status of the terms and conditions. diff --git a/src/app/server/Server.cpp b/src/app/server/Server.cpp index 94915381275e23..46d523a6757e0e 100644 --- a/src/app/server/Server.cpp +++ b/src/app/server/Server.cpp @@ -107,7 +107,7 @@ static ::chip::PersistedCounter sGlobalEventIdCounter; static ::chip::app::CircularEventBuffer sLoggingBuffer[CHIP_NUM_EVENT_LOGGING_BUFFERS]; #endif // CHIP_CONFIG_ENABLE_SERVER_IM_EVENT -#if defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) +#if defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) app::DefaultEnhancedSetupFlowProvider sDefaultEnhancedSetupFlowProviderInstance; app::EnhancedSetupFlowProvider * CommonCaseDeviceServerInitParams::sDefaultEnhancedSetupFlowProvider = &sDefaultEnhancedSetupFlowProviderInstance; @@ -155,7 +155,7 @@ CHIP_ERROR CommonCaseDeviceServerInitParams::InitializeStaticResourcesBeforeServ reportScheduler = &sReportScheduler; } -#if defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) +#if defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) if (this->termsAndConditionsProvider == nullptr) { ReturnErrorOnFailure(sDefaultTermsAndConditionsProviderInstance.Init(this->persistentStorageDelegate, @@ -202,10 +202,10 @@ CHIP_ERROR CommonCaseDeviceServerInitParams::InitializeStaticResourcesBeforeServ #endif #if CHIP_CONFIG_ENABLE_ICD_CIP - if (this->icdCheckInBackOffStrategy == nullptr) - { - this->icdCheckInBackOffStrategy = &sDefaultICDCheckInBackOffStrategy; - } + if (this->icdCheckInBackOffStrategy == nullptr) + { + this->icdCheckInBackOffStrategy = &sDefaultICDCheckInBackOffStrategy; + } #endif return CHIP_NO_ERROR; @@ -235,7 +235,7 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams) VerifyOrExit(initParams.operationalKeystore != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT); VerifyOrExit(initParams.opCertStore != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT); VerifyOrExit(initParams.reportScheduler != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT); -#if defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) +#if defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) VerifyOrExit(initParams.enhancedSetupFlowProvider != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT); VerifyOrExit(initParams.termsAndConditionsProvider != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT); #endif @@ -295,7 +295,7 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams) mReportScheduler = initParams.reportScheduler; -#if defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) +#if defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) mTermsAndConditionsProvider = initParams.termsAndConditionsProvider; mEnhancedSetupFlowProvider = initParams.enhancedSetupFlowProvider; #endif diff --git a/src/app/server/Server.h b/src/app/server/Server.h index f9ef037df96c08..739cffcd445476 100644 --- a/src/app/server/Server.h +++ b/src/app/server/Server.h @@ -181,7 +181,7 @@ struct ServerInitParams // Optional. Support for the ICD Check-In BackOff strategy. Must be initialized before being provided. // If the ICD Check-In protocol use-case is supported and no strategy is provided, server will use the default strategy. app::ICDCheckInBackOffStrategy * icdCheckInBackOffStrategy = nullptr; -#if defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) +#if defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) // Optional. Enhanced setup flow provider to support terms and conditions acceptance check. app::EnhancedSetupFlowProvider * enhancedSetupFlowProvider = nullptr; // Optional. Terms and conditions provider to support enhanced setup flow feature. @@ -254,7 +254,7 @@ struct CommonCaseDeviceServerInitParams : public ServerInitParams #if CHIP_CONFIG_ENABLE_ICD_CIP static app::DefaultICDCheckInBackOffStrategy sDefaultICDCheckInBackOffStrategy; #endif -#if defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) +#if defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) static app::EnhancedSetupFlowProvider * sDefaultEnhancedSetupFlowProvider; static app::TermsAndConditionsProvider * sDefaultTermsAndConditionsProvider; #endif @@ -338,7 +338,7 @@ class Server app::reporting::ReportScheduler * GetReportScheduler() { return mReportScheduler; } -#if defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) +#if defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) app::EnhancedSetupFlowProvider * GetEnhancedSetupFlowProvider() { return mEnhancedSetupFlowProvider; } #endif @@ -615,7 +615,7 @@ class Server GroupDataProviderListener mListener; ServerFabricDelegate mFabricDelegate; app::reporting::ReportScheduler * mReportScheduler; -#if defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined (CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) +#if defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS) && defined(CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION) app::EnhancedSetupFlowProvider * mEnhancedSetupFlowProvider; app::TermsAndConditionsProvider * mTermsAndConditionsProvider; #endif