Skip to content

Commit a32eb38

Browse files
Add / update comments
1 parent 4f37fb3 commit a32eb38

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

src/app/InteractionModelEngine.h

+11
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,11 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,
328328
bool SubjectHasPersistedSubscription(FabricIndex aFabricIndex, NodeId subjectID) override;
329329

330330
#if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
331+
/**
332+
* @brief Function decrements the number of subscriptions to resume counter - mNumOfSubscriptionsToResume.
333+
* This should be called after we have completed a re-subscribe attempt on a persisted subscription wether the attempt
334+
* was succesful or not.
335+
*/
331336
void DecrementNumSubscriptionsToResume();
332337
#endif // CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
333338

@@ -678,6 +683,12 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,
678683
#endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST
679684

680685
#if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
686+
/**
687+
* mNumOfSubscriptionsToResume tracks the number of subscriptions that the device will try to resume at its next resumption
688+
* attempt. At boot up, the attempt will be at the highest min interval of all the subscriptions to resume.
689+
* When the subscription timeout resumption feature is present, after the boot up attempt, the next attempt will be determined
690+
* by ComputeTimeSecondsTillNextSubscriptionResumption.
691+
*/
681692
int8_t mNumOfSubscriptionsToResume = 0;
682693
#if CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION
683694
bool HasSubscriptionsToResume();

src/app/SubscriptionResumptionSessionEstablisher.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ void SubscriptionResumptionSessionEstablisher::HandleDeviceConnected(void * cont
9191
SubscriptionResumptionStorage::SubscriptionInfo & subscriptionInfo = establisher->mSubscriptionInfo;
9292
InteractionModelEngine * imEngine = InteractionModelEngine::GetInstance();
9393

94-
// Decrement the number of subscriptions to resume
94+
// Decrement the number of subscriptions to resume since we have completed our retry attempt for a given subscription.
95+
// We do this before the readHandler creation since we do not care if the subscription has successfully been resumed or
96+
// not. Counter only tracks the number of individual subscriptions we will try to resume.
9597
imEngine->DecrementNumSubscriptionsToResume();
9698

9799
if (!imEngine->EnsureResourceForSubscription(subscriptionInfo.mFabricIndex, subscriptionInfo.mAttributePaths.AllocatedSize(),
@@ -129,7 +131,9 @@ void SubscriptionResumptionSessionEstablisher::HandleDeviceConnectionFailure(voi
129131
ChipLogError(DataManagement, "Failed to establish CASE for subscription-resumption with error '%" CHIP_ERROR_FORMAT "'",
130132
error.Format());
131133

132-
// Decrement the number of subscriptions to resume
134+
// Decrement the number of subscriptions to resume since we have completed our retry attempt for a given subscription.
135+
// We do this here since we were not able to connect to the subscriber thus we have completed our resumption attempt.
136+
// Counter only tracks the number of individual subscriptions we will try to resume.
133137
imEngine->DecrementNumSubscriptionsToResume();
134138

135139
auto * subscriptionResumptionStorage = imEngine->GetSubscriptionResumptionStorage();

src/app/icd/server/ICDManager.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,12 @@ bool ICDManager::CheckInMessagesWouldBeSent(const std::function<ShouldCheckInMsg
260260
* @brief Implementation for when the persistent subscription and subscription timeout resumption feature are present.
261261
* Function checks that there are no active or persisted subscriptions for a given fabricIndex or subjectID.
262262
*
263+
* @note When the persistent subscription and subscription timeout resumption feature are present, we need to check for
264+
* persisted subscription at each transition to ActiveMode since there will be persisted subscriptions during normal
265+
* operation for the subscription timeout resumption feature. Once we have finished all our subscription resumption attempts
266+
* for a given subscription, the entry is deleted from persisted storage which will enable us to send Check-In messages for
267+
* the client registration. This logic avoids the device sending a Check-In message while trying to resume subscriptions.
268+
*
263269
* @param aFabricIndex
264270
* @param subjectID subjectID to check. Can be an operational node id or a CAT
265271
*
@@ -307,6 +313,9 @@ bool ICDManager::ShouldCheckInMsgsBeSentAtActiveModeFunction(FabricIndex aFabric
307313
* @brief Implementation for when neither the persistent subscription nor the subscription timeout resumption features are present.
308314
* Function checks that there no active sbuscriptions for a given fabricIndex and subjectId combination.
309315
*
316+
* @note When neither the persistent subscription nor the subscription timeout resumption features are present, we only need to
317+
* check for active subscription since we will never have any persisted subscription.
318+
*
310319
* @param aFabricIndex
311320
* @param subjectID subjectID to check. Can be an opperationnal node id or a CAT
312321
*

0 commit comments

Comments
 (0)