Skip to content

Commit

Permalink
Add / update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mkardous-silabs committed Apr 3, 2024
1 parent c45315b commit 59a9862
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/app/InteractionModelEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,11 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,
bool SubjectHasPersistedSubscription(FabricIndex aFabricIndex, NodeId subjectID) override;

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

Expand Down Expand Up @@ -681,6 +686,12 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,
#endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST

#if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
/**
* mNumOfSubscriptionsToResume tracks the number of subscriptions that the device will try to resume at its next resumption
* attempt. At boot up, the attempt will be at the highest min interval of all the subscriptions to resume.
* When the subscription timeout resumption feature is present, after the boot up attempt, the next attempt will be determined
* by ComputeTimeSecondsTillNextSubscriptionResumption.
*/
int8_t mNumOfSubscriptionsToResume = 0;
#if CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION
bool HasSubscriptionsToResume();
Expand Down
8 changes: 6 additions & 2 deletions src/app/SubscriptionResumptionSessionEstablisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ void SubscriptionResumptionSessionEstablisher::HandleDeviceConnected(void * cont
SubscriptionResumptionStorage::SubscriptionInfo & subscriptionInfo = establisher->mSubscriptionInfo;
InteractionModelEngine * imEngine = InteractionModelEngine::GetInstance();

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

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

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

auto * subscriptionResumptionStorage = imEngine->GetSubscriptionResumptionStorage();
Expand Down
9 changes: 9 additions & 0 deletions src/app/icd/server/ICDManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,12 @@ bool ICDManager::CheckInMessagesWouldBeSent(const std::function<ShouldCheckInMsg
* @brief Implementation for when the persistent subscription and subscription timeout resumption feature are present.
* Function checks that there are no active or persisted subscriptions for a given fabricIndex or subjectID.
*
* @note When the persistent subscription and subscription timeout resumption feature are present, we need to check for
* persisted subscription at each transition to ActiveMode since there will be persisted subscriptions during normal
* operation for the subscription timeout resumption feature. Once we have finished all our subscription resumption attempts
* for a given subscription, the entry is deleted from persisted storage which will enable us to send Check-In messages for
* the client registration. This logic avoids the device sending a Check-In message while trying to resume subscriptions.
*
* @param aFabricIndex
* @param subjectID subjectID to check. Can be an operational node id or a CAT
*
Expand Down Expand Up @@ -307,6 +313,9 @@ bool ICDManager::ShouldCheckInMsgsBeSentAtActiveModeFunction(FabricIndex aFabric
* @brief Implementation for when neither the persistent subscription nor the subscription timeout resumption features are present.
* Function checks that there no active sbuscriptions for a given fabricIndex and subjectId combination.
*
* @note When neither the persistent subscription nor the subscription timeout resumption features are present, we only need to
* check for active subscription since we will never have any persisted subscription.
*
* @param aFabricIndex
* @param subjectID subjectID to check. Can be an opperationnal node id or a CAT
*
Expand Down

0 comments on commit 59a9862

Please sign in to comment.