Skip to content

Commit

Permalink
Terms and Conditions kTCAcknowledgementsNotReceived fix
Browse files Browse the repository at this point in the history
  • Loading branch information
swan-amazon committed Aug 20, 2024
1 parent 2e61537 commit db130ac
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,18 @@ CHIP_ERROR checkTermsAndConditionsAcknowledgementsState(CommissioningErrorEnum &
CHIP_ERROR err;

uint16_t termsAndConditionsAcceptedAcknowledgements;
bool hasAnyAcknowledgements;
bool hasRequiredTermAccepted;
bool hasRequiredTermVersionAccepted;

err = enhancedSetupFlowProvider->HasReceivedTermsAndConditionscknowledgements(hasAnyAcknowledgements);
if (!::chip::ChipError::IsSuccess(err))
{
ChipLogError(AppServer, "Failed to HasReceivedTermsAndConditionscknowledgements");
errorCode = CommissioningErrorEnum::kTCAcknowledgementsNotReceived;
return err;
}

err = enhancedSetupFlowProvider->GetTermsAndConditionsAcceptedAcknowledgements(termsAndConditionsAcceptedAcknowledgements);
if (!::chip::ChipError::IsSuccess(err))
{
Expand Down
7 changes: 7 additions & 0 deletions src/app/server/DefaultEnhancedSetupFlowProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ CHIP_ERROR chip::app::DefaultEnhancedSetupFlowProvider::Init(TermsAndConditionsP
return CHIP_NO_ERROR;
}

CHIP_ERROR chip::app::DefaultEnhancedSetupFlowProvider::HasReceivedTermsAndConditionscknowledgements(bool & outReceived) const
{
VerifyOrReturnError(nullptr != mTermsAndConditionsProvider, CHIP_ERROR_UNINITIALIZED);
ReturnErrorOnFailure(mTermsAndConditionsProvider->HasAcceptance(outReceived));
return CHIP_NO_ERROR;
}

CHIP_ERROR
chip::app::DefaultEnhancedSetupFlowProvider::HasTermsAndConditionsRequiredAcknowledgementsBeenAccepted(bool & outAccepted) const
{
Expand Down
2 changes: 2 additions & 0 deletions src/app/server/DefaultEnhancedSetupFlowProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class DefaultEnhancedSetupFlowProvider : public EnhancedSetupFlowProvider
*/
CHIP_ERROR Init(TermsAndConditionsProvider * const inTermsAndConditionsProvider);

CHIP_ERROR HasReceivedTermsAndConditionscknowledgements(bool & outReceived) const override;

CHIP_ERROR HasTermsAndConditionsRequiredAcknowledgementsBeenAccepted(bool & outAccepted) const override;

CHIP_ERROR HasTermsAndConditionsRequiredAcknowledgementsVersionBeenAccepted(bool & outAccepted) const override;
Expand Down
8 changes: 8 additions & 0 deletions src/app/server/DefaultTermsAndConditionsProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::GetRequirements(uint16_
return CHIP_NO_ERROR;
}

CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::HasAcceptance(bool & outHasAcceptance) const
{
outHasAcceptance =
mTemporaryAcknowledgementsAcceptanceValue.HasValue() && mTemporaryAcknowledgementsAcceptanceVersionValue.HasValue();

return CHIP_NO_ERROR;
}

CHIP_ERROR chip::app::DefaultTermsAndConditionsProvider::ResetAcceptance()
{
VerifyOrReturnError(nullptr != mPersistentStorageDelegate, CHIP_ERROR_UNINITIALIZED);
Expand Down
2 changes: 2 additions & 0 deletions src/app/server/DefaultTermsAndConditionsProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class DefaultTermsAndConditionsProvider : public TermsAndConditionsProvider

CHIP_ERROR GetRequirements(uint16_t & outAcknowledgementsValue, uint16_t & outAcknowledgementsVersionValue) const override;

CHIP_ERROR HasAcceptance(bool & outHasAcceptance) const override;

CHIP_ERROR ResetAcceptance() override;

CHIP_ERROR RevertAcceptance() override;
Expand Down
2 changes: 2 additions & 0 deletions src/app/server/EnhancedSetupFlowProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class EnhancedSetupFlowProvider
public:
virtual ~EnhancedSetupFlowProvider() = default;

virtual CHIP_ERROR HasReceivedTermsAndConditionscknowledgements(bool & outReceived) const = 0;

/**
* @param[out] outAccepted true if the required acknowledgements have been accepted, false otherwise.
*/
Expand Down
7 changes: 7 additions & 0 deletions src/app/server/TermsAndConditionsProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ class TermsAndConditionsProvider
*/
virtual CHIP_ERROR GetRequirements(uint16_t & outAcknowledgementsValue, uint16_t & outAcknowledgementsVersionValue) const = 0;

/**
* @brief Retrieve if any terms and conditions has been set.
*
* @param[out] outHasAcceptance True if any acceptance has been set.
*/
virtual CHIP_ERROR HasAcceptance(bool & outHasAcceptance) const = 0;

/**
* @brief Reset the persisted acceptance status of the required terms and conditions.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/controller/CommissioningDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ enum CommissioningStage : uint8_t
kPrimaryOperationalNetworkFailed, ///< Indicate that the primary operational network (on root endpoint) failed, should disable
///< the primary network interface later.
kDisablePrimaryNetworkInterface, ///< Send InterfaceEnabled write request to the device to disable network interface.
kGetTCAcknowledgments, ///< Waiting for the higher layer to provide terms and conditions acknowledgements.
kConfigureTCAcknowledgments, ///< Send SetTCAcknowledgements (0x30:6) command to the device
kGetTCAcknowledgments, ///< Waiting for the higher layer to provide terms and conditions acknowledgements.
kConfigureTCAcknowledgments, ///< Send SetTCAcknowledgements (0x30:6) command to the device
};

enum class ICDRegistrationStrategy : uint8_t
Expand Down

0 comments on commit db130ac

Please sign in to comment.