Skip to content

Commit 3434e04

Browse files
bzbarsky-appleratgr
authored andcommitted
Reset backoff on successful subscription in MTRDevice. (project-chip#37503)
ReadClient does this, but we are not using its backoff logic.
1 parent 9ac70fe commit 3434e04

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/darwin/Framework/CHIP/MTRBaseSubscriptionCallback.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,6 @@ class MTRBaseSubscriptionCallback : public chip::app::ClusterStateCache::Callbac
139139

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

142-
void OnSubscriptionEstablished(chip::SubscriptionId aSubscriptionId) override;
143-
144142
CHIP_ERROR OnResubscriptionNeeded(chip::app::ReadClient * apReadClient, CHIP_ERROR aTerminationCause) override;
145143

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

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

154+
void OnSubscriptionEstablished(chip::SubscriptionId aSubscriptionId) override;
155+
156156
private:
157157
DataReportCallback _Nullable mAttributeReportCallback = nil;
158158
DataReportCallback _Nullable mEventReportCallback = nil;

src/darwin/Framework/CHIP/MTRDevice_Concrete.mm

+10
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ - (void)_deviceInternalStateChanged:(MTRDevice *)device;
118118
void ResetResubscriptionBackoff() { mResubscriptionNumRetries = 0; }
119119

120120
private:
121+
void OnSubscriptionEstablished(chip::SubscriptionId aSubscriptionId) override;
122+
121123
void OnEventData(const EventHeader & aEventHeader, TLV::TLVReader * apData, const StatusIB * apStatus) override;
122124

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

47714773
#pragma mark - SubscriptionCallback
47724774
namespace {
4775+
void SubscriptionCallback::OnSubscriptionEstablished(SubscriptionId aSubscriptionId)
4776+
{
4777+
// The next time we need to do a resubscribe, we should start a new backoff
4778+
// sequence.
4779+
ResetResubscriptionBackoff();
4780+
MTRBaseSubscriptionCallback::OnSubscriptionEstablished(aSubscriptionId);
4781+
}
4782+
47734783
void SubscriptionCallback::OnEventData(const EventHeader & aEventHeader, TLV::TLVReader * apData, const StatusIB * apStatus)
47744784
{
47754785
if (mEventReports == nil) {

0 commit comments

Comments
 (0)