Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
swan-amazon committed Aug 8, 2024
1 parent 43af86e commit 3b55d21
Show file tree
Hide file tree
Showing 8 changed files with 202 additions and 179 deletions.

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/app/server/DefaultEnhancedSetupFlowProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include <lib/core/CHIPConfig.h>
#include <lib/support/CodeUtils.h>
#include <platform/KeyValueStoreManager.h>

CHIP_ERROR chip::app::DefaultEnhancedSetupFlowProvider::Init(TermsAndConditionsProvider * const inTermsAndConditionsProvider)
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/server/DefaultEnhancedSetupFlowProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions src/app/server/DefaultTermsAndConditionsProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
#include <lib/core/TLVTypes.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/DefaultStorageKeyAllocator.h>
#include <platform/KeyValueStoreManager.h>

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,
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions src/app/server/DefaultTermsAndConditionsProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/**
Expand All @@ -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;
};
Expand Down
4 changes: 2 additions & 2 deletions src/app/server/EnhancedSetupFlowProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 8 additions & 8 deletions src/app/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static ::chip::PersistedCounter<chip::EventNumber> 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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/app/server/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3b55d21

Please sign in to comment.