Skip to content

Commit

Permalink
rename functions and remove comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mkardous-silabs committed Sep 22, 2023
1 parent 6b50a81 commit 0aebaec
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/app/ReadHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ using Status = Protocols::InteractionModel::Status;
uint16_t ReadHandler::GetPublisherSelectedIntervalLimit()
{
#if CHIP_CONFIG_ENABLE_ICD_SERVER
return static_cast<uint16_t>(IcdManagementServer::GetInstance().GetIdleModeInterval());
return static_cast<uint16_t>(IcdManagementServer::GetInstance().GetIdleModeIntervalSec());
#else
return kSubscriptionMaxIntervalPublisherLimit;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ CHIP_ERROR IcdManagementAttributeAccess::ReadIdleModeInterval(EndpointId endpoin

CHIP_ERROR IcdManagementAttributeAccess::ReadActiveModeInterval(EndpointId endpoint, AttributeValueEncoder & encoder)
{
return encoder.Encode(IcdManagementServer::GetInstance().GetActiveModeInterval());
return encoder.Encode(IcdManagementServer::GetInstance().GetActiveModeIntervalMs());
}

CHIP_ERROR IcdManagementAttributeAccess::ReadActiveModeThreshold(EndpointId endpoint, AttributeValueEncoder & encoder)
Expand Down
8 changes: 4 additions & 4 deletions src/app/icd/ICDManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void ICDManager::Init(PersistentStorageDelegate * storage, FabricTable * fabricT
mFabricTable = fabricTable;
mStateObserver = stateObserver;

uint32_t activeModeInterval = IcdManagementServer::GetInstance().GetActiveModeInterval();
uint32_t activeModeInterval = IcdManagementServer::GetInstance().GetActiveModeIntervalMs();
VerifyOrDie(kFastPollingInterval.count() < activeModeInterval);

UpdateIcdMode();
Expand Down Expand Up @@ -128,7 +128,7 @@ void ICDManager::UpdateOperationState(OperationalState state)
if (state == OperationalState::IdleMode)
{
mOperationalState = OperationalState::IdleMode;
uint32_t idleModeInterval = IcdManagementServer::GetInstance().GetIdleModeInterval();
uint32_t idleModeInterval = IcdManagementServer::GetInstance().GetIdleModeIntervalSec();
DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds32(idleModeInterval), OnIdleModeDone, this);

System::Clock::Milliseconds32 slowPollInterval = GetSlowPollingInterval();
Expand Down Expand Up @@ -156,7 +156,7 @@ void ICDManager::UpdateOperationState(OperationalState state)
DeviceLayer::SystemLayer().CancelTimer(OnIdleModeDone, this);

mOperationalState = OperationalState::ActiveMode;
uint32_t activeModeInterval = IcdManagementServer::GetInstance().GetActiveModeInterval();
uint32_t activeModeInterval = IcdManagementServer::GetInstance().GetActiveModeIntervalMs();
DeviceLayer::SystemLayer().StartTimer(System::Clock::Timeout(activeModeInterval), OnActiveModeDone, this);
uint32_t activeModeJitterInterval =
(activeModeInterval >= ICD_ACTIVE_TIME_JITTER_MS) ? activeModeInterval - ICD_ACTIVE_TIME_JITTER_MS : 0;
Expand All @@ -172,7 +172,7 @@ void ICDManager::UpdateOperationState(OperationalState state)
}
else
{
uint16_t activeModeThreshold = IcdManagementServer::GetInstance().GetActiveModeThreshold();
uint16_t activeModeThreshold = IcdManagementServer::GetInstance().GetActiveModeThresholdMs();
DeviceLayer::SystemLayer().ExtendTimerTo(System::Clock::Timeout(activeModeThreshold), OnActiveModeDone, this);
uint16_t activeModeJitterThreshold =
(activeModeThreshold >= ICD_ACTIVE_TIME_JITTER_MS) ? activeModeThreshold - ICD_ACTIVE_TIME_JITTER_MS : 0;
Expand Down
12 changes: 6 additions & 6 deletions src/app/icd/IcdManagementServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ using chip::Protocols::InteractionModel::Status;
class IcdManagementServer
{
public:
uint32_t GetIdleModeInterval() { return mIdleInterval_s; }
uint32_t GetIdleModeIntervalSec() { return mIdleInterval_s; }

uint32_t GetActiveModeInterval() { return mActiveInterval_ms; }
uint32_t GetActiveModeIntervalMs() { return mActiveInterval_ms; }

uint16_t GetActiveModeThreshold() { return mActiveThreshold_ms; }
uint16_t GetActiveModeThresholdMs() { return mActiveThreshold_ms; }

uint32_t GetICDCounter() { return mIcdCounter; }

Expand All @@ -61,17 +61,17 @@ class IcdManagementServer
"Spec requires the IdleModeInterval to be equal or inferior to 64800s.");
static_assert((CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC) >= 1,
"Spec requires the IdleModeInterval to be equal or greater to 1s.");
uint32_t mIdleInterval_s = CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC; // in seconds.
uint32_t mIdleInterval_s = CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC;

static_assert((CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL_MS) <= (CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC * 1000),
"Spec requires the IdleModeInterval be equal or greater to the ActiveModeInterval.");
static_assert((CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL_MS) >= 300,
"Spec requires the ActiveModeThreshold to be equal or greater to 300ms");
uint32_t mActiveInterval_ms = CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL_MS; // in milliseconds
uint32_t mActiveInterval_ms = CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL_MS;

static_assert((CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS) >= 300,
"Spec requires the ActiveModeThreshold to be equal or greater to 300ms.");
uint16_t mActiveThreshold_ms = CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS; // in milliseconds
uint16_t mActiveThreshold_ms = CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS;

uint32_t mIcdCounter = 0;

Expand Down
16 changes: 8 additions & 8 deletions src/app/tests/TestICDManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,20 @@ class TestICDManager

// After the init we should be in active mode
NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode);
AdvanceClockAndRunEventLoop(ctx, IcdManagementServer::GetInstance().GetActiveModeInterval() + 1);
AdvanceClockAndRunEventLoop(ctx, IcdManagementServer::GetInstance().GetActiveModeIntervalMs() + 1);
// Active mode interval expired, ICDManager transitioned to the IdleMode.
NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode);
AdvanceClockAndRunEventLoop(ctx, (IcdManagementServer::GetInstance().GetIdleModeInterval() * 1000) + 1);
AdvanceClockAndRunEventLoop(ctx, (IcdManagementServer::GetInstance().GetIdleModeIntervalMs() * 1000) + 1);
// Idle mode interval expired, ICDManager transitioned to the ActiveMode.
NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode);

// Events updating the Operation to Active mode can extend the current active mode time by 1 Active mode threshold.
// Kick an active Threshold just before the end of the Active interval and validate that the active mode is extended.
AdvanceClockAndRunEventLoop(ctx, IcdManagementServer::GetInstance().GetActiveModeInterval() - 1);
AdvanceClockAndRunEventLoop(ctx, IcdManagementServer::GetInstance().GetActiveModeIntervalMs() - 1);
ctx->mICDManager.UpdateOperationState(ICDManager::OperationalState::ActiveMode);
AdvanceClockAndRunEventLoop(ctx, IcdManagementServer::GetInstance().GetActiveModeThreshold() / 2);
AdvanceClockAndRunEventLoop(ctx, IcdManagementServer::GetInstance().GetActiveModeThresholdMs() / 2);
NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode);
AdvanceClockAndRunEventLoop(ctx, IcdManagementServer::GetInstance().GetActiveModeThreshold());
AdvanceClockAndRunEventLoop(ctx, IcdManagementServer::GetInstance().GetActiveModeThresholdMs());
NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode);
}

Expand All @@ -139,7 +139,7 @@ class TestICDManager
ctx->mICDManager.SetKeepActiveModeRequirements(ICDManager::KeepActiveFlags::kCommissioningWindowOpen, true);
NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode);
// Advance time so active mode interval expires.
AdvanceClockAndRunEventLoop(ctx, IcdManagementServer::GetInstance().GetActiveModeInterval() + 1);
AdvanceClockAndRunEventLoop(ctx, IcdManagementServer::GetInstance().GetActiveModeIntervalMs() + 1);
// Requirement flag still set. We stay in active mode
NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode);

Expand All @@ -153,12 +153,12 @@ class TestICDManager

// Advance time, but by less than the active mode interval and remove the requirement.
// We should stay in active mode.
AdvanceClockAndRunEventLoop(ctx, IcdManagementServer::GetInstance().GetActiveModeInterval() / 2);
AdvanceClockAndRunEventLoop(ctx, IcdManagementServer::GetInstance().GetActiveModeIntervalMs() / 2);
ctx->mICDManager.SetKeepActiveModeRequirements(ICDManager::KeepActiveFlags::kFailSafeArmed, false);
NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode);

// Advance time again, The activemode interval is completed.
AdvanceClockAndRunEventLoop(ctx, IcdManagementServer::GetInstance().GetActiveModeInterval() + 1);
AdvanceClockAndRunEventLoop(ctx, IcdManagementServer::GetInstance().GetActiveModeIntervalMs() + 1);
NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode);

// Set two requirements
Expand Down
2 changes: 1 addition & 1 deletion src/messaging/ReliableMessageProtocolConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Optional<ReliableMessageProtocolConfig> GetLocalMRPConfig()
// which the device can be at sleep and not be able to receive any messages).
config.mIdleRetransTimeout += app::ICDManager::GetSlowPollingInterval();
config.mActiveRetransTimeout += app::ICDManager::GetFastPollingInterval();
config.mActiveThresholdTime = System::Clock::Milliseconds16(IcdManagementServer::GetInstance().GetActiveModeThreshold());
config.mActiveThresholdTime = System::Clock::Milliseconds16(IcdManagementServer::GetInstance().GetActiveModeThresholdMs());
#endif

#if CONFIG_BUILD_FOR_HOST_UNIT_TEST
Expand Down

0 comments on commit 0aebaec

Please sign in to comment.