From aa1dffb83a20981c1289c97dce1418def2242d37 Mon Sep 17 00:00:00 2001 From: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> Date: Tue, 10 Oct 2023 08:20:57 -0400 Subject: [PATCH] Rename ICDSubscriber class to ICDListener, Update comment with Boris's suggestion --- examples/platform/silabs/BaseApplication.cpp | 2 +- src/app/FailSafeContext.cpp | 2 +- src/app/icd/ICDManager.cpp | 2 +- src/app/icd/ICDManager.h | 4 ++-- src/app/icd/ICDNotifier.cpp | 8 ++++---- src/app/icd/ICDNotifier.h | 20 +++++++++---------- src/app/server/CommissioningWindowManager.cpp | 2 +- src/app/tests/TestICDManager.cpp | 2 +- src/messaging/ExchangeContext.cpp | 4 ++-- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/examples/platform/silabs/BaseApplication.cpp b/examples/platform/silabs/BaseApplication.cpp index 4ff72f0f088a4c..5eb8a6886ea72f 100644 --- a/examples/platform/silabs/BaseApplication.cpp +++ b/examples/platform/silabs/BaseApplication.cpp @@ -507,7 +507,7 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent) { SILABS_LOG("Network is already provisioned, Ble advertissement not enabled"); #if CHIP_CONFIG_ENABLE_ICD_SERVER - // Temporarly used to cause a user trigger and ICD Active Mode Interval/Threshold + // Temporarily claim network activity, until we implement a "user trigger" reason for ICD wakeups. PlatformMgr().LockChipStack(); ICDNotifier::GetInstance().BroadcastNetworkActivityNotification(); PlatformMgr().UnlockChipStack(); diff --git a/src/app/FailSafeContext.cpp b/src/app/FailSafeContext.cpp index aa5c33fbcda922..2d886b17b34bc0 100644 --- a/src/app/FailSafeContext.cpp +++ b/src/app/FailSafeContext.cpp @@ -56,7 +56,7 @@ void FailSafeContext::SetFailSafeArmed(bool armed) #if CHIP_CONFIG_ENABLE_ICD_SERVER if (IsFailSafeArmed() != armed) { - ICDSubscriber::KeepActiveFlags activeRequest = ICDSubscriber::KeepActiveFlags::kFailSafeArmed; + ICDListener::KeepActiveFlags activeRequest = ICDListener::KeepActiveFlags::kFailSafeArmed; armed ? ICDNotifier::GetInstance().BroadcastActiveRequestNotification(activeRequest) : ICDNotifier::GetInstance().BroadcastActiveRequestWithdrawal(activeRequest); } diff --git a/src/app/icd/ICDManager.cpp b/src/app/icd/ICDManager.cpp index db7924ce5bff8e..d46a166e361172 100644 --- a/src/app/icd/ICDManager.cpp +++ b/src/app/icd/ICDManager.cpp @@ -248,7 +248,7 @@ void ICDManager::OnTransitionToIdle(System::Layer * aLayer, void * appState) pIcdManager->mStateObserver->OnTransitionToIdle(); } -/* ICDSubscriber functions. */ +/* ICDListener functions. */ void ICDManager::OnKeepActiveRequest(KeepActiveFlags request) { assertChipStackLockedByCurrentThread(); diff --git a/src/app/icd/ICDManager.h b/src/app/icd/ICDManager.h index 922a9bccc03b9b..852a4b428e9411 100644 --- a/src/app/icd/ICDManager.h +++ b/src/app/icd/ICDManager.h @@ -34,7 +34,7 @@ class TestICDManager; /** * @brief ICD Manager is responsible of processing the events and triggering the correct action for an ICD */ -class ICDManager : public ICDSubscriber +class ICDManager : public ICDListener { public: enum class OperationalState : uint8_t @@ -63,7 +63,7 @@ class ICDManager : public ICDSubscriber static System::Clock::Milliseconds32 GetSlowPollingInterval() { return kSlowPollingInterval; } static System::Clock::Milliseconds32 GetFastPollingInterval() { return kFastPollingInterval; } - // Implementation of ICDSubscriber functions. + // Implementation of ICDListener functions. // Callers must origin from the chip task context or be holding the ChipStack lock. void OnNetworkActivity() override; void OnKeepActiveRequest(KeepActiveFlags request) override; diff --git a/src/app/icd/ICDNotifier.cpp b/src/app/icd/ICDNotifier.cpp index 8c215a3ec00958..a3b4588004809a 100644 --- a/src/app/icd/ICDNotifier.cpp +++ b/src/app/icd/ICDNotifier.cpp @@ -29,7 +29,7 @@ ICDNotifier::~ICDNotifier() memset(mSubscribers, 0, sizeof(mSubscribers)); } -CHIP_ERROR ICDNotifier::Subscribe(ICDSubscriber * subscriber) +CHIP_ERROR ICDNotifier::Subscribe(ICDListener * subscriber) { CHIP_ERROR err = CHIP_ERROR_PROVIDER_LIST_EXHAUSTED; for (auto & sub : mSubscribers) @@ -44,7 +44,7 @@ CHIP_ERROR ICDNotifier::Subscribe(ICDSubscriber * subscriber) return err; } -void ICDNotifier::Unsubscribe(ICDSubscriber * subscriber) +void ICDNotifier::Unsubscribe(ICDListener * subscriber) { for (auto & sub : mSubscribers) { @@ -67,7 +67,7 @@ void ICDNotifier::BroadcastNetworkActivityNotification() } } -void ICDNotifier::BroadcastActiveRequestNotification(ICDSubscriber::KeepActiveFlags request) +void ICDNotifier::BroadcastActiveRequestNotification(ICDListener::KeepActiveFlags request) { for (auto subscriber : mSubscribers) { @@ -78,7 +78,7 @@ void ICDNotifier::BroadcastActiveRequestNotification(ICDSubscriber::KeepActiveFl } } -void ICDNotifier::BroadcastActiveRequestWithdrawal(ICDSubscriber::KeepActiveFlags request) +void ICDNotifier::BroadcastActiveRequestWithdrawal(ICDListener::KeepActiveFlags request) { for (auto subscriber : mSubscribers) { diff --git a/src/app/icd/ICDNotifier.h b/src/app/icd/ICDNotifier.h index 0dcf54dc6e045f..a90f3ddb675089 100644 --- a/src/app/icd/ICDNotifier.h +++ b/src/app/icd/ICDNotifier.h @@ -19,23 +19,23 @@ #include #include -class ICDSubscriber; +class ICDListener; namespace chip { namespace app { /** - * The ICDManager implements the ICDSubscriber functions and is always subscribed to the ICDNotifier + * The ICDManager implements the ICDListener functions and is always subscribed to the ICDNotifier * This allows other Matter modules to inform the ICDManager that it needs to go and may have to stay in Active Mode, * outside of its standard ActiveModeInterval and IdleModeInterval, without being tightly coupled the application data model * - * This implementation also allows other modules to implement an ICDSubscriber and subscribe to ICDNotifier + * This implementation also allows other modules to implement an ICDListener and subscribe to ICDNotifier * to couple behaviours with the ICD cycles. In such cases, ICD_MAX_NOTIFICATION_SUBSCRIBERS need to be adjusted */ static_assert(ICD_MAX_NOTIFICATION_SUBSCRIBERS > 0, "At least 1 Subscriber is required for the ICD Manager"); -class ICDSubscriber +class ICDListener { public: enum class KeepActiveFlags : uint8_t @@ -45,7 +45,7 @@ class ICDSubscriber kExchangeContextOpen = 0x03, }; - virtual ~ICDSubscriber() {} + virtual ~ICDListener() {} /** * @brief This function is called for all subscribers of the ICDNotifier when it calls BroadcastNetworkActivityNotification @@ -74,8 +74,8 @@ class ICDNotifier { public: ~ICDNotifier(); - CHIP_ERROR Subscribe(ICDSubscriber * subscriber); - void Unsubscribe(ICDSubscriber * subscriber); + CHIP_ERROR Subscribe(ICDListener * subscriber); + void Unsubscribe(ICDListener * subscriber); /** * The following Broacast* methods triggers all the registered ICDSubscribers related callback @@ -83,14 +83,14 @@ class ICDNotifier * Those functions require to be called from the Chip Task Context, or by holding the chip stack lock. */ void BroadcastNetworkActivityNotification(); - void BroadcastActiveRequestNotification(ICDSubscriber::KeepActiveFlags request); - void BroadcastActiveRequestWithdrawal(ICDSubscriber::KeepActiveFlags request); + void BroadcastActiveRequestNotification(ICDListener::KeepActiveFlags request); + void BroadcastActiveRequestWithdrawal(ICDListener::KeepActiveFlags request); static ICDNotifier & GetInstance() { return sICDNotifier; } private: static ICDNotifier sICDNotifier; - ICDSubscriber * mSubscribers[ICD_MAX_NOTIFICATION_SUBSCRIBERS] = {}; + ICDListener * mSubscribers[ICD_MAX_NOTIFICATION_SUBSCRIBERS] = {}; }; } // namespace app diff --git a/src/app/server/CommissioningWindowManager.cpp b/src/app/server/CommissioningWindowManager.cpp index 39b63342f1c775..33eaeedb1eb619 100644 --- a/src/app/server/CommissioningWindowManager.cpp +++ b/src/app/server/CommissioningWindowManager.cpp @@ -544,7 +544,7 @@ void CommissioningWindowManager::UpdateWindowStatus(CommissioningWindowStatusEnu { mWindowStatus = aNewStatus; #if CHIP_CONFIG_ENABLE_ICD_SERVER - app::ICDSubscriber::KeepActiveFlags request = app::ICDSubscriber::KeepActiveFlags::kCommissioningWindowOpen; + app::ICDListener::KeepActiveFlags request = app::ICDListener::KeepActiveFlags::kCommissioningWindowOpen; if (mWindowStatus != CommissioningWindowStatusEnum::kWindowNotOpen) { app::ICDNotifier::GetInstance().BroadcastActiveRequestNotification(request); diff --git a/src/app/tests/TestICDManager.cpp b/src/app/tests/TestICDManager.cpp index 4cbb6f3eadd0aa..5d57be4245f116 100644 --- a/src/app/tests/TestICDManager.cpp +++ b/src/app/tests/TestICDManager.cpp @@ -135,7 +135,7 @@ class TestICDManager static void TestKeepActivemodeRequests(nlTestSuite * aSuite, void * aContext) { TestContext * ctx = static_cast(aContext); - typedef ICDSubscriber::KeepActiveFlags ActiveFlag; + typedef ICDListener::KeepActiveFlags ActiveFlag; ICDNotifier notifier = ICDNotifier::GetInstance(); // Setting a requirement will transition the ICD to active mode. diff --git a/src/messaging/ExchangeContext.cpp b/src/messaging/ExchangeContext.cpp index eaba1fdd138b6b..ac4a620a7ee66a 100644 --- a/src/messaging/ExchangeContext.cpp +++ b/src/messaging/ExchangeContext.cpp @@ -326,7 +326,7 @@ ExchangeContext::ExchangeContext(ExchangeManager * em, uint16_t ExchangeId, cons SetAutoRequestAck(!session->IsGroupSession()); #if CHIP_CONFIG_ENABLE_ICD_SERVER - app::ICDNotifier::GetInstance().BroadcastActiveRequestNotification(app::ICDSubscriber::KeepActiveFlags::kExchangeContextOpen); + app::ICDNotifier::GetInstance().BroadcastActiveRequestNotification(app::ICDListener::KeepActiveFlags::kExchangeContextOpen); #endif #if defined(CHIP_EXCHANGE_CONTEXT_DETAIL_LOGGING) @@ -345,7 +345,7 @@ ExchangeContext::~ExchangeContext() VerifyOrDie(mFlags.Has(Flags::kFlagClosed)); #if CHIP_CONFIG_ENABLE_ICD_SERVER - app::ICDNotifier::GetInstance().BroadcastActiveRequestWithdrawal(app::ICDSubscriber::KeepActiveFlags::kExchangeContextOpen); + app::ICDNotifier::GetInstance().BroadcastActiveRequestWithdrawal(app::ICDListener::KeepActiveFlags::kExchangeContextOpen); #endif // CHIP_CONFIG_ENABLE_ICD_SERVER // Ideally, in this scenario, the retransmit table should