From 0deec9f836b7d406daeaef55800759da56ab1b78 Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Fri, 22 Sep 2023 11:01:55 -0400 Subject: [PATCH 1/6] Add units to defines and variables --- src/app/icd/ICDStateObserver.h | 2 +- src/app/icd/IcdManagementServer.h | 32 +++++++------------- src/lib/core/CHIPConfig.h | 18 +++++------ src/platform/nrfconnect/CHIPPlatformConfig.h | 18 +++++------ src/platform/silabs/CHIPPlatformConfig.h | 18 +++++------ 5 files changed, 39 insertions(+), 49 deletions(-) diff --git a/src/app/icd/ICDStateObserver.h b/src/app/icd/ICDStateObserver.h index 7c71d4b3c5b463..b9f7dc363f6993 100644 --- a/src/app/icd/ICDStateObserver.h +++ b/src/app/icd/ICDStateObserver.h @@ -17,7 +17,7 @@ #pragma once #ifndef ICD_SLEEP_TIME_JITTER_MS -#define ICD_SLEEP_TIME_JITTER_MS (CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL * 0.75) +#define ICD_SLEEP_TIME_JITTER_MS (CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC * 0.75) #endif #ifndef ICD_ACTIVE_TIME_JITTER_MS diff --git a/src/app/icd/IcdManagementServer.h b/src/app/icd/IcdManagementServer.h index 185731b5257387..0f24cd43ef3995 100644 --- a/src/app/icd/IcdManagementServer.h +++ b/src/app/icd/IcdManagementServer.h @@ -30,21 +30,11 @@ using chip::Protocols::InteractionModel::Status; class IcdManagementServer { public: - void Init(uint32_t idle_interval, uint32_t active_interval, uint16_t active_threshold, uint32_t count, - uint16_t fabric_clients_supported) - { - mIdleInterval = idle_interval; - mActiveInterval = active_interval; - mActiveThreshold = active_threshold; - mIcdCounter = count; - mFabricClientsSupported = fabric_clients_supported; - } + uint32_t GetIdleModeInterval() { return mIdleInterval_s; } - uint32_t GetIdleModeInterval() { return mIdleInterval; } + uint32_t GetActiveModeInterval() { return mActiveInterval_ms; } - uint32_t GetActiveModeInterval() { return mActiveInterval; } - - uint16_t GetActiveModeThreshold() { return mActiveThreshold; } + uint16_t GetActiveModeThreshold() { return mActiveThreshold_ms; } uint32_t GetICDCounter() { return mIcdCounter; } @@ -67,20 +57,20 @@ class IcdManagementServer static IcdManagementServer mInstance; - static_assert((CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL) <= 64800, + static_assert((CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC) <= 64800, "Spec requires the IdleModeInterval to be equal or inferior to 64800s."); - static_assert((CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL) >= 1, "Spec requires the IdleModeInterval to be equal or greater to 1s."); - uint32_t mIdleInterval = CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL; // in seconds. + 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. - static_assert((CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL) <= (CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL * 1000), + 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) >= 300, + static_assert((CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL_MS) >= 300, "Spec requires the ActiveModeThreshold to be equal or greater to 300ms"); - uint32_t mActiveInterval = CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL; // in milliseconds + uint32_t mActiveInterval_ms = CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL_MS; // in milliseconds - static_assert((CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD) >= 300, + static_assert((CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS) >= 300, "Spec requires the ActiveModeThreshold to be equal or greater to 300ms."); - uint16_t mActiveThreshold = CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD; // in milliseconds + uint16_t mActiveThreshold_ms = CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS; // in milliseconds uint32_t mIcdCounter = 0; diff --git a/src/lib/core/CHIPConfig.h b/src/lib/core/CHIPConfig.h index da5e3c9aebca97..30d6d6b8a65b36 100644 --- a/src/lib/core/CHIPConfig.h +++ b/src/lib/core/CHIPConfig.h @@ -1498,30 +1498,30 @@ extern const char CHIP_NON_PRODUCTION_MARKER[]; #endif /** - * @def CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL + * @def CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC * * @brief Default value for the ICD Management cluster IdleModeInterval attribute, in seconds */ -#ifndef CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL -#define CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL 2 +#ifndef CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC +#define CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC 2 #endif /** - * @def CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL + * @def CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL_MS * * @brief Default value for the ICD Management cluster ActiveModeInterval attribute, in milliseconds */ -#ifndef CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL -#define CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL 300 +#ifndef CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL_MS +#define CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL_MS 300 #endif /** - * @def CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD + * @def CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS * * @brief Default value for the ICD Management cluster ActiveModeThreshold attribute, in milliseconds */ -#ifndef CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD -#define CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD 300 +#ifndef CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS +#define CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS 300 #endif /** diff --git a/src/platform/nrfconnect/CHIPPlatformConfig.h b/src/platform/nrfconnect/CHIPPlatformConfig.h index d3c7b965217f04..078ab065c5897c 100644 --- a/src/platform/nrfconnect/CHIPPlatformConfig.h +++ b/src/platform/nrfconnect/CHIPPlatformConfig.h @@ -112,23 +112,23 @@ #endif // CHIP_ENABLE_OPENTHREAD #endif // CHIP_CONFIG_MRP_LOCAL_IDLE_RETRY_INTERVAL -#ifndef CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL +#ifndef CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC #ifdef CONFIG_CHIP_ICD_IDLE_MODE_INTERVAL -#define CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL CONFIG_CHIP_ICD_IDLE_MODE_INTERVAL +#define CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC CONFIG_CHIP_ICD_IDLE_MODE_INTERVAL #endif // CONFIG_CHIP_ICD_IDLE_MODE_INTERVAL -#endif // CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL +#endif // CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC -#ifndef CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL +#ifndef CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL_MS #ifdef CONFIG_CHIP_ICD_ACTIVE_MODE_INTERVAL -#define CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL CONFIG_CHIP_ICD_ACTIVE_MODE_INTERVAL +#define CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL_MS CONFIG_CHIP_ICD_ACTIVE_MODE_INTERVAL #endif // CONFIG_CHIP_ICD_ACTIVE_MODE_INTERVAL -#endif // CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL +#endif // CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL_MS -#ifndef CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD +#ifndef CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS #ifdef CONFIG_CHIP_ICD_ACTIVE_MODE_THRESHOLD -#define CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD CONFIG_CHIP_ICD_ACTIVE_MODE_THRESHOLD +#define CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS CONFIG_CHIP_ICD_ACTIVE_MODE_THRESHOLD #endif // CONFIG_CHIP_ICD_ACTIVE_MODE_THRESHOLD -#endif // CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD +#endif // CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS #ifndef CHIP_CONFIG_ICD_CLIENTS_SUPPORTED_PER_FABRIC #ifdef CONFIG_CHIP_ICD_CLIENTS_PER_FABRIC diff --git a/src/platform/silabs/CHIPPlatformConfig.h b/src/platform/silabs/CHIPPlatformConfig.h index 49e2bb59454658..e31aa9557b2f73 100644 --- a/src/platform/silabs/CHIPPlatformConfig.h +++ b/src/platform/silabs/CHIPPlatformConfig.h @@ -94,17 +94,17 @@ #ifdef SL_ICD_ENABLED -#ifndef CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL -#define CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL SL_IDLE_MODE_INTERVAL -#endif // CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL +#ifndef CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC +#define CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC SL_IDLE_MODE_INTERVAL +#endif // CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC -#ifndef CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL -#define CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL SL_ACTIVE_MODE_INTERVAL -#endif // CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL +#ifndef CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL_MS +#define CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL_MS SL_ACTIVE_MODE_INTERVAL +#endif // CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL_MS -#ifndef CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD -#define CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD SL_ACTIVE_MODE_THRESHOLD -#endif // CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD +#ifndef CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS +#define CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS SL_ACTIVE_MODE_THRESHOLD +#endif // CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS #ifndef CHIP_CONFIG_ICD_CLIENTS_SUPPORTED_PER_FABRIC #define CHIP_CONFIG_ICD_CLIENTS_SUPPORTED_PER_FABRIC SL_ICD_SUPPORTED_CLIENTS_PER_FABRIC From 6b50a81b8777a408c664e6434bc6fb0a72fa5939 Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Fri, 22 Sep 2023 11:05:44 -0400 Subject: [PATCH 2/6] restyle --- src/app/icd/IcdManagementServer.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/icd/IcdManagementServer.h b/src/app/icd/IcdManagementServer.h index 0f24cd43ef3995..7da7a1b23148d3 100644 --- a/src/app/icd/IcdManagementServer.h +++ b/src/app/icd/IcdManagementServer.h @@ -59,7 +59,8 @@ class IcdManagementServer static_assert((CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC) <= 64800, "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."); + 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. static_assert((CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL_MS) <= (CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC * 1000), From 0aebaec4d041e1f0722728bc0a6ccaa8ef3a43d8 Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Fri, 22 Sep 2023 12:36:51 -0400 Subject: [PATCH 3/6] rename functions and remove comments --- src/app/ReadHandler.cpp | 2 +- .../icd-management-server.cpp | 2 +- src/app/icd/ICDManager.cpp | 8 ++++---- src/app/icd/IcdManagementServer.h | 12 ++++++------ src/app/tests/TestICDManager.cpp | 16 ++++++++-------- src/messaging/ReliableMessageProtocolConfig.cpp | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/app/ReadHandler.cpp b/src/app/ReadHandler.cpp index 6261462da289d7..9339a08fae7cab 100644 --- a/src/app/ReadHandler.cpp +++ b/src/app/ReadHandler.cpp @@ -45,7 +45,7 @@ using Status = Protocols::InteractionModel::Status; uint16_t ReadHandler::GetPublisherSelectedIntervalLimit() { #if CHIP_CONFIG_ENABLE_ICD_SERVER - return static_cast(IcdManagementServer::GetInstance().GetIdleModeInterval()); + return static_cast(IcdManagementServer::GetInstance().GetIdleModeIntervalSec()); #else return kSubscriptionMaxIntervalPublisherLimit; #endif diff --git a/src/app/clusters/icd-management-server/icd-management-server.cpp b/src/app/clusters/icd-management-server/icd-management-server.cpp index 5877224f2d2841..d9f9c31d724064 100644 --- a/src/app/clusters/icd-management-server/icd-management-server.cpp +++ b/src/app/clusters/icd-management-server/icd-management-server.cpp @@ -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) diff --git a/src/app/icd/ICDManager.cpp b/src/app/icd/ICDManager.cpp index 91f12c23035361..a36401653e98e8 100644 --- a/src/app/icd/ICDManager.cpp +++ b/src/app/icd/ICDManager.cpp @@ -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(); @@ -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(); @@ -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; @@ -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; diff --git a/src/app/icd/IcdManagementServer.h b/src/app/icd/IcdManagementServer.h index 7da7a1b23148d3..40782347e0b7ff 100644 --- a/src/app/icd/IcdManagementServer.h +++ b/src/app/icd/IcdManagementServer.h @@ -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; } @@ -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; diff --git a/src/app/tests/TestICDManager.cpp b/src/app/tests/TestICDManager.cpp index a6523bb03008c2..bed95c7088ba46 100644 --- a/src/app/tests/TestICDManager.cpp +++ b/src/app/tests/TestICDManager.cpp @@ -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); } @@ -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); @@ -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 diff --git a/src/messaging/ReliableMessageProtocolConfig.cpp b/src/messaging/ReliableMessageProtocolConfig.cpp index 9dfd0719293774..bd1eb2a3fc073c 100644 --- a/src/messaging/ReliableMessageProtocolConfig.cpp +++ b/src/messaging/ReliableMessageProtocolConfig.cpp @@ -75,7 +75,7 @@ Optional 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 From d1df53e4eec78f31a237115f7841cecade6cd4d6 Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Fri, 22 Sep 2023 12:59:38 -0400 Subject: [PATCH 4/6] fix missing function name --- .../clusters/icd-management-server/icd-management-server.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/clusters/icd-management-server/icd-management-server.cpp b/src/app/clusters/icd-management-server/icd-management-server.cpp index d9f9c31d724064..a99cf22a3334bc 100644 --- a/src/app/clusters/icd-management-server/icd-management-server.cpp +++ b/src/app/clusters/icd-management-server/icd-management-server.cpp @@ -89,7 +89,7 @@ CHIP_ERROR IcdManagementAttributeAccess::Read(const ConcreteReadAttributePath & CHIP_ERROR IcdManagementAttributeAccess::ReadIdleModeInterval(EndpointId endpoint, AttributeValueEncoder & encoder) { - return encoder.Encode(IcdManagementServer::GetInstance().GetIdleModeInterval()); + return encoder.Encode(IcdManagementServer::GetInstance().GetIdleModeIntervalSec()); } CHIP_ERROR IcdManagementAttributeAccess::ReadActiveModeInterval(EndpointId endpoint, AttributeValueEncoder & encoder) @@ -99,7 +99,7 @@ CHIP_ERROR IcdManagementAttributeAccess::ReadActiveModeInterval(EndpointId endpo CHIP_ERROR IcdManagementAttributeAccess::ReadActiveModeThreshold(EndpointId endpoint, AttributeValueEncoder & encoder) { - return encoder.Encode(IcdManagementServer::GetInstance().GetActiveModeThreshold()); + return encoder.Encode(IcdManagementServer::GetInstance().GetActiveModeThresholdMs()); } CHIP_ERROR IcdManagementAttributeAccess::ReadRegisteredClients(EndpointId endpoint, AttributeValueEncoder & encoder) From 1a8fb4ca8c9d1267c7daddee98cfa7b8fee0f63c Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Fri, 22 Sep 2023 14:25:31 -0400 Subject: [PATCH 5/6] Fix typos --- src/app/icd/IcdManagementServer.h | 2 +- src/app/tests/TestICDManager.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/icd/IcdManagementServer.h b/src/app/icd/IcdManagementServer.h index 40782347e0b7ff..cab712e3a340a2 100644 --- a/src/app/icd/IcdManagementServer.h +++ b/src/app/icd/IcdManagementServer.h @@ -63,7 +63,7 @@ class IcdManagementServer "Spec requires the IdleModeInterval to be equal or greater to 1s."); 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), + static_assert((CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL_MS) <= (CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC * kMillisecondsPerSecond), "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"); diff --git a/src/app/tests/TestICDManager.cpp b/src/app/tests/TestICDManager.cpp index bed95c7088ba46..e7dcf3a23d2be3 100644 --- a/src/app/tests/TestICDManager.cpp +++ b/src/app/tests/TestICDManager.cpp @@ -20,9 +20,9 @@ #include #include #include +#include #include #include - #include #include #include @@ -117,7 +117,7 @@ class TestICDManager 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().GetIdleModeIntervalMs() * 1000) + 1); + AdvanceClockAndRunEventLoop(ctx, secondsToMilliseconds(IcdManagementServer::GetInstance().GetIdleModeIntervalSec()) + 1); // Idle mode interval expired, ICDManager transitioned to the ActiveMode. NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); @@ -166,7 +166,7 @@ class TestICDManager ctx->mICDManager.SetKeepActiveModeRequirements(ICDManager::KeepActiveFlags::kAwaitingMsgAck, true); NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); // advance time so the active mode interval expires. - AdvanceClockAndRunEventLoop(ctx, IcdManagementServer::GetInstance().GetActiveModeInterval() + 1); + AdvanceClockAndRunEventLoop(ctx, IcdManagementServer::GetInstance().GetActiveModeIntervalMs() + 1); // A requirement flag is still set. We stay in active mode. NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); From e24d2c6f4011f1fd51ee1576f2f2fc4aa4c8e252 Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Fri, 22 Sep 2023 14:41:24 -0400 Subject: [PATCH 6/6] restyle --- src/app/tests/TestICDManager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/tests/TestICDManager.cpp b/src/app/tests/TestICDManager.cpp index e7dcf3a23d2be3..5af3a0efcf4bed 100644 --- a/src/app/tests/TestICDManager.cpp +++ b/src/app/tests/TestICDManager.cpp @@ -16,16 +16,16 @@ * limitations under the License. */ #include +#include +#include +#include #include #include +#include #include #include -#include #include #include -#include -#include -#include using namespace chip; using namespace chip::app;