Skip to content

Commit

Permalink
Reset backoff on successful subscription in MTRDevice. (#37503)
Browse files Browse the repository at this point in the history
ReadClient does this, but we are not using its backoff logic.
  • Loading branch information
bzbarsky-apple authored Feb 11, 2025
1 parent 8b73e8a commit 9b62718
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/darwin/Framework/CHIP/MTRBaseSubscriptionCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ class MTRBaseSubscriptionCallback : public chip::app::ClusterStateCache::Callbac

void OnDeallocatePaths(chip::app::ReadPrepareParams && aReadPrepareParams) override;

void OnSubscriptionEstablished(chip::SubscriptionId aSubscriptionId) override;

CHIP_ERROR OnResubscriptionNeeded(chip::app::ReadClient * apReadClient, CHIP_ERROR aTerminationCause) override;

void OnUnsolicitedMessageFromPublisher(chip::app::ReadClient * apReadClient) override;
Expand All @@ -153,6 +151,8 @@ class MTRBaseSubscriptionCallback : public chip::app::ClusterStateCache::Callbac

void CallResubscriptionScheduledHandler(NSError * error, NSNumber * resubscriptionDelay);

void OnSubscriptionEstablished(chip::SubscriptionId aSubscriptionId) override;

private:
DataReportCallback _Nullable mAttributeReportCallback = nil;
DataReportCallback _Nullable mEventReportCallback = nil;
Expand Down
10 changes: 10 additions & 0 deletions src/darwin/Framework/CHIP/MTRDevice_Concrete.mm
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ - (void)_deviceInternalStateChanged:(MTRDevice *)device;
void ResetResubscriptionBackoff() { mResubscriptionNumRetries = 0; }

private:
void OnSubscriptionEstablished(chip::SubscriptionId aSubscriptionId) override;

void OnEventData(const EventHeader & aEventHeader, TLV::TLVReader * apData, const StatusIB * apStatus) override;

void OnAttributeData(const ConcreteDataAttributePath & aPath, TLV::TLVReader * apData, const StatusIB & aStatus) override;
Expand Down Expand Up @@ -4770,6 +4772,14 @@ + (MTRDevice *)deviceWithNodeID:(uint64_t)nodeID deviceController:(MTRDeviceCont

#pragma mark - SubscriptionCallback
namespace {
void SubscriptionCallback::OnSubscriptionEstablished(SubscriptionId aSubscriptionId)
{
// The next time we need to do a resubscribe, we should start a new backoff
// sequence.
ResetResubscriptionBackoff();
MTRBaseSubscriptionCallback::OnSubscriptionEstablished(aSubscriptionId);
}

void SubscriptionCallback::OnEventData(const EventHeader & aEventHeader, TLV::TLVReader * apData, const StatusIB * apStatus)
{
if (mEventReports == nil) {
Expand Down

0 comments on commit 9b62718

Please sign in to comment.