Skip to content

Commit

Permalink
feat: add force resubscribe to ReadClient
Browse files Browse the repository at this point in the history
  • Loading branch information
GasikPasik committed Dec 2, 2024
1 parent 0ac52eb commit a16e2f5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/app/ReadClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,25 @@ CHIP_ERROR ReadClient::ProcessEventReportIBs(TLV::TLVReader & aEventReportIBsRea
return err;
}

CHIP_ERROR ReadClient::ForceResubscribe()
{
if (IsSubscriptionActive())
{
CancelLivenessCheckTimer();
OnLivenessTimeoutCallback(nullptr, this);
return CHIP_NO_ERROR;
}

if (IsIdle())
{
CancelResubscribeTimer();
OnResubscribeTimerCallback(nullptr, this);
return CHIP_NO_ERROR;
}

return CHIP_ERROR_INCORRECT_STATE;
}

void ReadClient::OverrideLivenessTimeout(System::Clock::Timeout aLivenessTimeout)
{
mLivenessTimeoutOverride = aLivenessTimeout;
Expand Down
12 changes: 12 additions & 0 deletions src/app/ReadClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,18 @@ class ReadClient : public Messaging::ExchangeDelegate
*/
Optional<System::Clock::Timeout> GetSubscriptionTimeout();

/**
* Force the ReadClient to resubscribe immediately.
*
* This method can be called even when the subscription is active.
* It will simulate a liveness timeout to trigger the resubscription
* process according to the resubscription policy.
*
* @retval #CHIP_NO_ERROR On success.
* @retval #CHIP_ERROR_INCORRECT_STATE If the ReadClient is not in a state where resubscription is applicable.
*/
CHIP_ERROR ForceResubscribe();

private:
friend class TestReadInteraction;
friend class InteractionModelEngine;
Expand Down

0 comments on commit a16e2f5

Please sign in to comment.