From d878b72d45fac8e4349d988bafe3017659deb70b Mon Sep 17 00:00:00 2001 From: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com> Date: Mon, 22 Jan 2024 15:14:37 -0500 Subject: [PATCH] [ICD] Add activeModeThreshold check for LIT ICDs (#31608) * add activeModeThreshold check for LIT ICDs * Change default ActiveModeTreshold to 5s * Update LIT ICD checks --- .../linux/include/CHIPProjectAppConfig.h | 2 +- examples/lit-icd-app/silabs/openthread.gni | 2 +- src/app/icd/ICDConfigurationData.h | 4 ++++ src/app/icd/ICDManager.cpp | 23 +++++++++++-------- .../suites/TestIcdManagementCluster.yaml | 2 +- src/lib/core/CHIPConfig.h | 2 +- 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/examples/lit-icd-app/linux/include/CHIPProjectAppConfig.h b/examples/lit-icd-app/linux/include/CHIPProjectAppConfig.h index 60cf9dfd7324b5..dd77b121fb4e3a 100644 --- a/examples/lit-icd-app/linux/include/CHIPProjectAppConfig.h +++ b/examples/lit-icd-app/linux/include/CHIPProjectAppConfig.h @@ -39,4 +39,4 @@ // ICD configurations #define CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC 3600 #define CHIP_CONFIG_ICD_ACTIVE_MODE_DURATION_MS 10000 -#define CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS 1000 +#define CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS 5000 diff --git a/examples/lit-icd-app/silabs/openthread.gni b/examples/lit-icd-app/silabs/openthread.gni index 49ffdf306c9e2f..69bd7b88e6bdc6 100644 --- a/examples/lit-icd-app/silabs/openthread.gni +++ b/examples/lit-icd-app/silabs/openthread.gni @@ -40,4 +40,4 @@ sl_ot_active_interval_ms = 1000 # 1000ms Active Polling Interval # ICD Matter Configuration flags sl_idle_mode_interval_s = 3600 # 60min Idle Mode Interval sl_active_mode_interval_ms = 0 # 0 Active Mode Interval -sl_active_mode_threshold_ms = 30000 # 30s Active Mode Threshold +sl_active_mode_threshold_ms = 5000 # 5s Active Mode Threshold diff --git a/src/app/icd/ICDConfigurationData.h b/src/app/icd/ICDConfigurationData.h index 2bdd832c52f0c5..48f3966a5e5948 100644 --- a/src/app/icd/ICDConfigurationData.h +++ b/src/app/icd/ICDConfigurationData.h @@ -61,6 +61,8 @@ class ICDConfigurationData System::Clock::Milliseconds32 GetFastPollingInterval() { return mFastPollingInterval; } + uint32_t GetMinLitActiveModeThresholdMs() { return kMinLitActiveModeThreshold_ms; } + /** * If ICD_ENFORCE_SIT_SLOW_POLL_LIMIT is set to 0, function will always return the configured Slow Polling interval * (CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL). @@ -93,6 +95,8 @@ class ICDConfigurationData void SetSlowPollingInterval(System::Clock::Milliseconds32 slowPollInterval) { mSlowPollingInterval = slowPollInterval; }; void SetFastPollingInterval(System::Clock::Milliseconds32 fastPollInterval) { mFastPollingInterval = fastPollInterval; }; + static constexpr uint32_t kMinLitActiveModeThreshold_ms = 5000; + static_assert((CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC) <= 64800, "Spec requires the IdleModeDuration to be equal or inferior to 64800s."); static_assert((CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC) >= 1, diff --git a/src/app/icd/ICDManager.cpp b/src/app/icd/ICDManager.cpp index 1d4c69c688f090..99e8e950dd853f 100644 --- a/src/app/icd/ICDManager.cpp +++ b/src/app/icd/ICDManager.cpp @@ -48,15 +48,20 @@ void ICDManager::Init(PersistentStorageDelegate * storage, FabricTable * fabricT VerifyOrDie(symmetricKeystore != nullptr); VerifyOrDie(exchangeManager != nullptr); - bool supportLIT = SupportsFeature(Feature::kLongIdleTimeSupport); - VerifyOrDieWithMsg((supportLIT == false) || SupportsFeature(Feature::kCheckInProtocolSupport), AppServer, - "The CheckIn protocol feature is required for LIT support"); - VerifyOrDieWithMsg((supportLIT == false) || SupportsFeature(Feature::kUserActiveModeTrigger), AppServer, - "The user ActiveMode trigger feature is required for LIT support"); - - // Disabling check until LIT support is compelte - // VerifyOrDieWithMsg((supportLIT == false) && (GetSlowPollingInterval() <= GetSITPollingThreshold()) , AppServer, - // "LIT support is required for slow polling intervals superior to 15 seconds"); + // LIT ICD Verification Checks + if (SupportsFeature(Feature::kLongIdleTimeSupport)) + { + VerifyOrDieWithMsg(SupportsFeature(Feature::kCheckInProtocolSupport), AppServer, + "The CheckIn protocol feature is required for LIT support."); + VerifyOrDieWithMsg(SupportsFeature(Feature::kUserActiveModeTrigger), AppServer, + "The user ActiveMode trigger feature is required for LIT support."); + VerifyOrDieWithMsg(ICDConfigurationData::GetInstance().GetMinLitActiveModeThresholdMs() <= + ICDConfigurationData::GetInstance().GetActiveModeThresholdMs(), + AppServer, "The minimum ActiveModeThreshold value for a LIT ICD is 5 seconds."); + // Disabling check until LIT support is compelte + // VerifyOrDieWithMsg((GetSlowPollingInterval() <= GetSITPollingThreshold()) , AppServer, + // "LIT support is required for slow polling intervals superior to 15 seconds"); + } mStorage = storage; mFabricTable = fabricTable; diff --git a/src/app/tests/suites/TestIcdManagementCluster.yaml b/src/app/tests/suites/TestIcdManagementCluster.yaml index eb611f27db24b9..3d69afd7744af8 100644 --- a/src/app/tests/suites/TestIcdManagementCluster.yaml +++ b/src/app/tests/suites/TestIcdManagementCluster.yaml @@ -58,7 +58,7 @@ tests: command: "readAttribute" attribute: "ActiveModeThreshold" response: - value: 1000 + value: 5000 - label: "Read ICDCounter" command: "readAttribute" diff --git a/src/lib/core/CHIPConfig.h b/src/lib/core/CHIPConfig.h index 0fa3e6e257988f..0dd1bb85de3fd7 100644 --- a/src/lib/core/CHIPConfig.h +++ b/src/lib/core/CHIPConfig.h @@ -1599,7 +1599,7 @@ extern const char CHIP_NON_PRODUCTION_MARKER[]; * @brief Default value for the ICD Management cluster ActiveModeThreshold attribute, in milliseconds */ #ifndef CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS -#define CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS 300 +#define CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS 5000 #endif /**