Skip to content

Commit

Permalink
Rename ICDSubscriber class to ICDListener, Update comment with Boris'…
Browse files Browse the repository at this point in the history
…s suggestion
  • Loading branch information
jmartinez-silabs committed Oct 10, 2023
1 parent 33ce657 commit aa1dffb
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion examples/platform/silabs/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/app/FailSafeContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/icd/ICDManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/app/icd/ICDManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/app/icd/ICDNotifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
{
Expand All @@ -67,7 +67,7 @@ void ICDNotifier::BroadcastNetworkActivityNotification()
}
}

void ICDNotifier::BroadcastActiveRequestNotification(ICDSubscriber::KeepActiveFlags request)
void ICDNotifier::BroadcastActiveRequestNotification(ICDListener::KeepActiveFlags request)
{
for (auto subscriber : mSubscribers)
{
Expand All @@ -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)
{
Expand Down
20 changes: 10 additions & 10 deletions src/app/icd/ICDNotifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@
#include <app/AppConfig.h>
#include <lib/core/CHIPError.h>

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
Expand All @@ -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
Expand Down Expand Up @@ -74,23 +74,23 @@ 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
* For thread-safety reason (mostly of the ICDManager, which is a full time subscriber),
* 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
Expand Down
2 changes: 1 addition & 1 deletion src/app/server/CommissioningWindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/TestICDManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class TestICDManager
static void TestKeepActivemodeRequests(nlTestSuite * aSuite, void * aContext)
{
TestContext * ctx = static_cast<TestContext *>(aContext);
typedef ICDSubscriber::KeepActiveFlags ActiveFlag;
typedef ICDListener::KeepActiveFlags ActiveFlag;
ICDNotifier notifier = ICDNotifier::GetInstance();

// Setting a requirement will transition the ICD to active mode.
Expand Down
4 changes: 2 additions & 2 deletions src/messaging/ExchangeContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit aa1dffb

Please sign in to comment.