From 514e810a7cfd3a8c99f612cbfe51a4e403f2ffd5 Mon Sep 17 00:00:00 2001 From: doru91 Date: Tue, 17 Sep 2024 11:39:33 +0300 Subject: [PATCH] [lit icd] add sdk support for dsls (Dynamic SIT LIT support) (#35325) * [lit icd] add sdk support for dsls (Dynamic SIT LIT support) Signed-off-by: Doru Gucea * [mcxw71_k32w1][lit icd] add platform support for dsls (Dynamic SIT LIT support) Signed-off-by: Doru Gucea * [lit icd] add DSLS Test Event trigger Signed-off-by: Doru Gucea * [linux app][lit icd] enable DSLS Signed-off-by: Doru Gucea --------- Signed-off-by: Doru Gucea --- .github/.wordlist.txt | 1 + examples/contact-sensor-app/nxp/README.md | 1 + .../contact-sensor-app/nxp/k32w1/README.md | 15 ++--- .../contact-sensor-app/nxp/k32w1/args.gni | 1 + .../nxp/zap-lit/contact-sensor-app.matter | 2 +- .../nxp/zap-lit/contact-sensor-app.zap | 4 +- examples/lit-icd-app/linux/args.gni | 1 + .../lit-icd-common/lit-icd-server-app.matter | 2 +- .../lit-icd-common/lit-icd-server-app.zap | 20 +------ .../nxp/mcxw71_k32w1/button/ButtonManager.cpp | 36 ++++++++++++ .../nxp/mcxw71_k32w1/button/ButtonManager.h | 7 +++ src/app/icd/icd.gni | 3 + src/app/icd/server/BUILD.gn | 1 + src/app/icd/server/ICDManager.cpp | 55 +++++++++++++++--- src/app/icd/server/ICDManager.h | 10 ++++ src/app/icd/server/ICDNotifier.cpp | 24 ++++++++ src/app/icd/server/ICDNotifier.h | 18 ++++++ src/app/icd/server/tests/TestICDManager.cpp | 58 +++++++++++++++++++ .../suites/TestIcdManagementCluster.yaml | 2 +- 19 files changed, 221 insertions(+), 40 deletions(-) diff --git a/.github/.wordlist.txt b/.github/.wordlist.txt index f317901e450aa6..31955b6c9ad617 100644 --- a/.github/.wordlist.txt +++ b/.github/.wordlist.txt @@ -453,6 +453,7 @@ dpkg dropdown dryrun DS +DSLS duplicative DUT DUTS diff --git a/examples/contact-sensor-app/nxp/README.md b/examples/contact-sensor-app/nxp/README.md index 133539e44ce3ec..20474bea76057c 100644 --- a/examples/contact-sensor-app/nxp/README.md +++ b/examples/contact-sensor-app/nxp/README.md @@ -154,6 +154,7 @@ This is a list of ICD configuration gn args. | nxp_active_mode_threshold_ms | 1000 (ms) | Active Mode Threshold value | | nxp_icd_supported_clients_per_fabric | 2 | Registration slots per fabric | | chip_enable_icd_lit | false | Enable LIT ICD support | +| chip_enable_icd_dsls | false | Enable LIT ICD DSLS support | | chip_persist_subscriptions | true | Try once to re-establish subscriptions from the server side after reboot. May be disabled for LIT use case | | chip_subscription_timeout_resumption | true | Same as above, but try to re-establish timeout out subscriptions | | using `Fibonacci Backoff` for retries pacing. May be disabled for LIT use case | diff --git a/examples/contact-sensor-app/nxp/k32w1/README.md b/examples/contact-sensor-app/nxp/k32w1/README.md index 217f06e11906b6..5f47979e2d25bb 100644 --- a/examples/contact-sensor-app/nxp/k32w1/README.md +++ b/examples/contact-sensor-app/nxp/k32w1/README.md @@ -41,13 +41,14 @@ operation by corrupting packages and OTA will not work. The user actions are summarized below: -| button | action | state | output | -| ------ | ----------- | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -| SW2 | short press | not commissioned | Enable BLE advertising | -| SW2 | short press | commissioned + device is LIT | Enable Active Mode | -| SW2 | long press | NA | Initiate a factory reset (can be cancelled by pressing the button again within the factory reset timeout limit - 6 seconds by default) | -| SW3 | short press | NA | Toggle attribute `StateValue` value | -| SW3 | long press | NA | Clean soft reset of the device (takes into account proper Matter shutdown procedure) | +| button | action | state | output | +| ------ | ------------ | -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | +| SW2 | short press | not commissioned | Enable BLE advertising | +| SW2 | short press | commissioned + device is LIT | Enable Active Mode | +| SW2 | double press | commissioned + device is LIT + supports DSLS | Enable / Disable SIT Mode | +| SW2 | long press | NA | Initiate a factory reset (can be cancelled by pressing the button again within the factory reset timeout limit - 6 seconds by default) | +| SW3 | short press | NA | Toggle attribute `StateValue` value | +| SW3 | long press | NA | Clean soft reset of the device (takes into account proper Matter shutdown procedure) | ## Building diff --git a/examples/contact-sensor-app/nxp/k32w1/args.gni b/examples/contact-sensor-app/nxp/k32w1/args.gni index b1c31aa7eb642a..98372f4b8261e4 100644 --- a/examples/contact-sensor-app/nxp/k32w1/args.gni +++ b/examples/contact-sensor-app/nxp/k32w1/args.gni @@ -31,6 +31,7 @@ chip_with_lwip = false chip_enable_icd_server = true chip_enable_icd_lit = false +chip_enable_icd_dsls = false icd_enforce_sit_slow_poll_limit = true chip_persist_subscriptions = true chip_subscription_timeout_resumption = true diff --git a/examples/contact-sensor-app/nxp/zap-lit/contact-sensor-app.matter b/examples/contact-sensor-app/nxp/zap-lit/contact-sensor-app.matter index 5e877d10e662a1..25deeedf5ee495 100644 --- a/examples/contact-sensor-app/nxp/zap-lit/contact-sensor-app.matter +++ b/examples/contact-sensor-app/nxp/zap-lit/contact-sensor-app.matter @@ -2012,7 +2012,7 @@ endpoint 0 { callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 0x0007; + ram attribute featureMap default = 0x000F; ram attribute clusterRevision default = 3; handle command RegisterClient; diff --git a/examples/contact-sensor-app/nxp/zap-lit/contact-sensor-app.zap b/examples/contact-sensor-app/nxp/zap-lit/contact-sensor-app.zap index 83c1526403104e..25d003c55eb798 100644 --- a/examples/contact-sensor-app/nxp/zap-lit/contact-sensor-app.zap +++ b/examples/contact-sensor-app/nxp/zap-lit/contact-sensor-app.zap @@ -3818,7 +3818,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0007", + "defaultValue": "0x000F", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -4317,4 +4317,4 @@ "parentEndpointIdentifier": null } ] -} \ No newline at end of file +} diff --git a/examples/lit-icd-app/linux/args.gni b/examples/lit-icd-app/linux/args.gni index b1567dd6284893..1692f982753031 100644 --- a/examples/lit-icd-app/linux/args.gni +++ b/examples/lit-icd-app/linux/args.gni @@ -31,3 +31,4 @@ chip_enable_icd_server = true chip_subscription_timeout_resumption = true chip_icd_report_on_active_mode = true chip_enable_icd_lit = true +chip_enable_icd_dsls = true diff --git a/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter b/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter index a1beda368f8f29..a5d5f2ba4fb274 100644 --- a/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter +++ b/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter @@ -2097,7 +2097,7 @@ endpoint 0 { callback attribute acceptedCommandList; callback attribute eventList; callback attribute attributeList; - ram attribute featureMap default = 0x0007; + ram attribute featureMap default = 0x000F; ram attribute clusterRevision default = 3; handle command RegisterClient; diff --git a/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.zap b/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.zap index 09567dcb43c99f..18c561cfbf3314 100644 --- a/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.zap +++ b/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.zap @@ -829,24 +829,6 @@ "isIncoming": 0, "isEnabled": 1 } - ], - "attributes": [ - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "client", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } ] }, { @@ -3558,7 +3540,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0007", + "defaultValue": "0x000F", "reportable": 1, "minInterval": 1, "maxInterval": 65534, diff --git a/examples/platform/nxp/mcxw71_k32w1/button/ButtonManager.cpp b/examples/platform/nxp/mcxw71_k32w1/button/ButtonManager.cpp index 09b0546c30968c..6e5390d997a9b8 100644 --- a/examples/platform/nxp/mcxw71_k32w1/button/ButtonManager.cpp +++ b/examples/platform/nxp/mcxw71_k32w1/button/ButtonManager.cpp @@ -51,6 +51,10 @@ ButtonManager ButtonManager::sInstance; TimerHandle_t resetTimer; +#if (CHIP_CONFIG_ENABLE_ICD_LIT && CHIP_CONFIG_ENABLE_ICD_DSLS) +static bool sitModeRequested; +#endif // CHIP_CONFIG_ENABLE_ICD_LIT && CHIP_CONFIG_ENABLE_ICD_DSLS + CHIP_ERROR ButtonManager::Init() { resetTimer = xTimerCreate("FnTmr", 1, false, (void *) this, [](TimerHandle_t xTimer) { @@ -60,6 +64,10 @@ CHIP_ERROR ButtonManager::Init() }); VerifyOrReturnError(resetTimer != NULL, APP_ERROR_CREATE_TIMER_FAILED); +#if (CHIP_CONFIG_ENABLE_ICD_LIT && CHIP_CONFIG_ENABLE_ICD_DSLS) + static bool sitModeRequested; +#endif // CHIP_CONFIG_ENABLE_ICD_LIT && CHIP_CONFIG_ENABLE_ICD_DSLS + return CHIP_NO_ERROR; } @@ -76,6 +84,13 @@ button_status_t ButtonManager::BleCallback(void * handle, button_callback_messag case kBUTTON_EventLongPress: event.Handler = ButtonManager::ResetActionEventHandler; break; + +#if (CHIP_CONFIG_ENABLE_ICD_LIT && CHIP_CONFIG_ENABLE_ICD_DSLS) + case kBUTTON_EventDoubleClick: + event.Handler = ButtonManager::DSLSActionEventHandler; + break; +#endif + default: /* No action required */ break; @@ -187,6 +202,27 @@ void ButtonManager::BleHandler(const AppEvent & event) chip::NXP::App::GetAppTask().SwitchCommissioningStateHandler(); } +#if (CHIP_CONFIG_ENABLE_ICD_LIT && CHIP_CONFIG_ENABLE_ICD_DSLS) +void ButtonManager::DSLSActionEventHandler(const AppEvent & event) +{ + if (chip::DeviceLayer::ConfigurationMgr().IsFullyProvisioned()) + { + if (!sitModeRequested) + { + chip::DeviceLayer::PlatformMgr().ScheduleWork( + [](intptr_t arg) { chip::app::ICDNotifier::GetInstance().NotifySITModeRequestNotification(); }, 0); + sitModeRequested = true; + } + else + { + chip::DeviceLayer::PlatformMgr().ScheduleWork( + [](intptr_t arg) { chip::app::ICDNotifier::GetInstance().NotifySITModeRequestWithdrawal(); }, 0); + sitModeRequested = false; + } + } +} +#endif // CHIP_CONFIG_ENABLE_ICD_LIT && CHIP_CONFIG_ENABLE_ICD_DSLS + void ButtonManager::CancelTimer() { if (xTimerStop(resetTimer, 0) == pdFAIL) diff --git a/examples/platform/nxp/mcxw71_k32w1/button/ButtonManager.h b/examples/platform/nxp/mcxw71_k32w1/button/ButtonManager.h index aec2411e1095af..7f4f6cf81d94d3 100644 --- a/examples/platform/nxp/mcxw71_k32w1/button/ButtonManager.h +++ b/examples/platform/nxp/mcxw71_k32w1/button/ButtonManager.h @@ -87,6 +87,13 @@ class ButtonManager */ static void ResetActionEventHandler(const AppEvent & event); + /** + * @brief This callback schedules a DSLS LIT action (Dynamic SIT LIT Support). + * + * It is used when the app requests SIT mode (check spec, "Runtime Operating Mode Switching") + */ + static void DSLSActionEventHandler(const AppEvent & event); + /** * @brief This callback performs a factory reset. * diff --git a/src/app/icd/icd.gni b/src/app/icd/icd.gni index 8994cf486106aa..ed3fd0518f5858 100644 --- a/src/app/icd/icd.gni +++ b/src/app/icd/icd.gni @@ -30,6 +30,9 @@ declare_args() { # Set to true to enforce SIT Slow Polling Max value to 15seconds (spec 9.16.1.5) icd_enforce_sit_slow_poll_limit = false + + # Set to true if device supports dynamic switching from SIT to LIT operating modes (DSLS) + chip_enable_icd_dsls = false } # Set the defaults for CIP and UAT features to be consistent with the LIT value. diff --git a/src/app/icd/server/BUILD.gn b/src/app/icd/server/BUILD.gn index b30b79d3d4a1d0..e1967c23f52f90 100644 --- a/src/app/icd/server/BUILD.gn +++ b/src/app/icd/server/BUILD.gn @@ -36,6 +36,7 @@ buildconfig_header("icd-server-buildconfig") { "CHIP_CONFIG_ENABLE_ICD_LIT=${chip_enable_icd_lit}", "CHIP_CONFIG_ENABLE_ICD_CIP=${chip_enable_icd_checkin}", "CHIP_CONFIG_ENABLE_ICD_UAT=${chip_enable_icd_user_active_mode_trigger}", + "CHIP_CONFIG_ENABLE_ICD_DSLS=${chip_enable_icd_dsls}", "ICD_REPORT_ON_ENTER_ACTIVE_MODE=${chip_icd_report_on_active_mode}", "ICD_MAX_NOTIFICATION_SUBSCRIBERS=${icd_max_notification_subscribers}", "ICD_ENFORCE_SIT_SLOW_POLL_LIMIT=${icd_enforce_sit_slow_poll_limit}", diff --git a/src/app/icd/server/ICDManager.cpp b/src/app/icd/server/ICDManager.cpp index 2ba08990aef4b6..3e89af1e1613a5 100644 --- a/src/app/icd/server/ICDManager.cpp +++ b/src/app/icd/server/ICDManager.cpp @@ -36,6 +36,8 @@ enum class ICDTestEventTriggerEvent : uint64_t kInvalidateHalfCounterValues = 0x0046'0000'00000003, kInvalidateAllCounterValues = 0x0046'0000'00000004, kForceMaximumCheckInBackOffState = 0x0046'0000'00000005, + kDSLSForceSitMode = 0x0046'0000'00000006, + kDSLSWithdrawSitMode = 0x0046'0000'00000007, }; } // namespace @@ -367,19 +369,28 @@ void ICDManager::UpdateICDMode() // Device can only switch to the LIT operating mode if LIT support is present if (SupportsFeature(Feature::kLongIdleTimeSupport)) { - VerifyOrDie(mStorage != nullptr); - VerifyOrDie(mFabricTable != nullptr); - // We can only get to LIT Mode, if at least one client is registered with the ICD device - for (const auto & fabricInfo : *mFabricTable) +#if CHIP_CONFIG_ENABLE_ICD_DSLS + // Ensure SIT mode is not requested + if (SupportsFeature(Feature::kDynamicSitLitSupport) && !mSITModeRequested) { - // We only need 1 valid entry to ensure LIT compliance - ICDMonitoringTable table(*mStorage, fabricInfo.GetFabricIndex(), 1 /*Table entry limit*/, mSymmetricKeystore); - if (!table.IsEmpty()) +#endif // CHIP_CONFIG_ENABLE_ICD_DSLS + + VerifyOrDie(mStorage != nullptr); + VerifyOrDie(mFabricTable != nullptr); + // We can only get to LIT Mode, if at least one client is registered with the ICD device + for (const auto & fabricInfo : *mFabricTable) { - tempMode = ICDConfigurationData::ICDMode::LIT; - break; + // We only need 1 valid entry to ensure LIT compliance + ICDMonitoringTable table(*mStorage, fabricInfo.GetFabricIndex(), 1 /*Table entry limit*/, mSymmetricKeystore); + if (!table.IsEmpty()) + { + tempMode = ICDConfigurationData::ICDMode::LIT; + break; + } } +#if CHIP_CONFIG_ENABLE_ICD_DSLS } +#endif // CHIP_CONFIG_ENABLE_ICD_DSLS } #endif // CHIP_CONFIG_ENABLE_ICD_LIT @@ -622,6 +633,24 @@ void ICDManager::OnActiveRequestWithdrawal(KeepActiveFlags request) } } +#if CHIP_CONFIG_ENABLE_ICD_DSLS +void ICDManager::OnSITModeRequest() +{ + mSITModeRequested = true; + this->UpdateICDMode(); + // Update the poll interval also to comply with SIT requirements + UpdateOperationState(OperationalState::ActiveMode); +} + +void ICDManager::OnSITModeRequestWithdrawal() +{ + mSITModeRequested = false; + this->UpdateICDMode(); + // Update the poll interval also to comply with LIT requirements + UpdateOperationState(OperationalState::ActiveMode); +} +#endif // CHIP_CONFIG_ENABLE_ICD_DSLS + void ICDManager::OnNetworkActivity() { this->UpdateOperationState(OperationalState::ActiveMode); @@ -685,6 +714,14 @@ CHIP_ERROR ICDManager::HandleEventTrigger(uint64_t eventTrigger) err = mICDCheckInBackOffStrategy->ForceMaximumCheckInBackoff(); break; #endif // CHIP_CONFIG_ENABLE_ICD_CIP +#if CHIP_CONFIG_ENABLE_ICD_DSLS + case ICDTestEventTriggerEvent::kDSLSForceSitMode: + OnSITModeRequest(); + break; + case ICDTestEventTriggerEvent::kDSLSWithdrawSitMode: + OnSITModeRequestWithdrawal(); + break; +#endif // CHIP_CONFIG_ENABLE_ICD_DSLS default: err = CHIP_ERROR_INVALID_ARGUMENT; break; diff --git a/src/app/icd/server/ICDManager.h b/src/app/icd/server/ICDManager.h index 19f5f0abeda955..dc516673df8d40 100644 --- a/src/app/icd/server/ICDManager.h +++ b/src/app/icd/server/ICDManager.h @@ -241,6 +241,12 @@ class ICDManager : public ICDListener, public TestEventTriggerHandler void OnNetworkActivity() override; void OnKeepActiveRequest(KeepActiveFlags request) override; void OnActiveRequestWithdrawal(KeepActiveFlags request) override; + +#if CHIP_CONFIG_ENABLE_ICD_DSLS + void OnSITModeRequest() override; + void OnSITModeRequestWithdrawal() override; +#endif + void OnICDManagementServerEvent(ICDManagementEvents event) override; void OnSubscriptionReport() override; @@ -356,6 +362,10 @@ class ICDManager : public ICDListener, public TestEventTriggerHandler ObjectPool mStateObserverPool; uint8_t mOpenExchangeContextCount = 0; +#if CHIP_CONFIG_ENABLE_ICD_DSLS + bool mSITModeRequested = false; +#endif + #if CHIP_CONFIG_ENABLE_ICD_CIP uint8_t mCheckInRequestCount = 0; diff --git a/src/app/icd/server/ICDNotifier.cpp b/src/app/icd/server/ICDNotifier.cpp index 4df2379d065131..4b4bf2a7009a46 100644 --- a/src/app/icd/server/ICDNotifier.cpp +++ b/src/app/icd/server/ICDNotifier.cpp @@ -89,6 +89,30 @@ void ICDNotifier::NotifyActiveRequestWithdrawal(ICDListener::KeepActiveFlags req } } +#if CHIP_CONFIG_ENABLE_ICD_DSLS +void ICDNotifier::NotifySITModeRequestNotification() +{ + for (auto subscriber : mSubscribers) + { + if (subscriber != nullptr) + { + subscriber->OnSITModeRequest(); + } + } +} + +void ICDNotifier::NotifySITModeRequestWithdrawal() +{ + for (auto subscriber : mSubscribers) + { + if (subscriber != nullptr) + { + subscriber->OnSITModeRequestWithdrawal(); + } + } +} +#endif // CHIP_CONFIG_ENABLE_ICD_DSLS + void ICDNotifier::NotifyICDManagementEvent(ICDListener::ICDManagementEvents event) { for (auto subscriber : mSubscribers) diff --git a/src/app/icd/server/ICDNotifier.h b/src/app/icd/server/ICDNotifier.h index 785fd1e08c9879..6f4b458bdd7e49 100644 --- a/src/app/icd/server/ICDNotifier.h +++ b/src/app/icd/server/ICDNotifier.h @@ -71,6 +71,20 @@ class ICDListener */ virtual void OnKeepActiveRequest(KeepActiveFlags request) = 0; +#if CHIP_CONFIG_ENABLE_ICD_DSLS + /** + * @brief This function is called for all subscribers of the ICDNotifier when it calls NotifySITModeRequestNotification. + * It informs the subscriber that the ICD must be kept in SIT mode. + */ + virtual void OnSITModeRequest() = 0; + + /** + * @brief This function is called for all subscribers of the ICDNotifier when it calls NotifySITModeRequestWithdrawal. + * It informs the subscriber that a previous request no longer needs ICD to be kept in SIT mode. + */ + virtual void OnSITModeRequestWithdrawal() = 0; +#endif // CHIP_CONFIG_ENABLE_ICD_DSLS + /** * @brief This function is called for all subscribers of the ICDNotifier when it calls NotifyActiveRequestWithdrawal. * It informs the subscriber that a previous request no longer needs ICD to maintain its Active Mode. @@ -109,6 +123,10 @@ class ICDNotifier void NotifyNetworkActivityNotification(); void NotifyActiveRequestNotification(ICDListener::KeepActiveFlags request); void NotifyActiveRequestWithdrawal(ICDListener::KeepActiveFlags request); +#if CHIP_CONFIG_ENABLE_ICD_DSLS + void NotifySITModeRequestNotification(); + void NotifySITModeRequestWithdrawal(); +#endif // CHIP_CONFIG_ENABLE_ICD_DSLS void NotifyICDManagementEvent(ICDListener::ICDManagementEvents event); void NotifySubscriptionReport(); diff --git a/src/app/icd/server/tests/TestICDManager.cpp b/src/app/icd/server/tests/TestICDManager.cpp index df5c2e4970c579..f6f999c1a36bca 100644 --- a/src/app/icd/server/tests/TestICDManager.cpp +++ b/src/app/icd/server/tests/TestICDManager.cpp @@ -695,6 +695,64 @@ TEST_F(TestICDManager, TestICDMStayActive) EXPECT_EQ(stayActivePromisedMs, 20000UL); } +#if CHIP_CONFIG_ENABLE_ICD_DSLS +/** + * @brief Test verifies the logic of the ICDManager related to DSLS (Dynamic SIT LIT Support) + */ +TEST_F(TestICDManager, TestICDMDSLS) +{ + typedef ICDListener::ICDManagementEvents ICDMEvent; + ICDNotifier notifier = ICDNotifier::GetInstance(); + + // Set FeatureMap + // Configures CIP, UAT, LITS and DSLS to 1 + mICDManager.SetTestFeatureMapValue(0x0F); + + // Check ICDManager starts in SIT mode if no entries are present + EXPECT_EQ(ICDConfigurationData::GetInstance().GetICDMode(), ICDConfigurationData::ICDMode::SIT); + + // Create table with one fabric + ICDMonitoringTable table1(testStorage, kTestFabricIndex1, kMaxTestClients, &(mKeystore)); + + // Add an entry to the fabric + ICDMonitoringEntry entry1(&(mKeystore)); + entry1.checkInNodeID = kClientNodeId11; + entry1.monitoredSubject = kClientNodeId12; + EXPECT_EQ(CHIP_NO_ERROR, entry1.SetKey(ByteSpan(kKeyBuffer1a))); + EXPECT_EQ(CHIP_NO_ERROR, table1.Set(0, entry1)); + + // Trigger register event after first entry was added + notifier.NotifyICDManagementEvent(ICDMEvent::kTableUpdated); + + // Check ICDManager is now in the LIT operating mode + EXPECT_EQ(ICDConfigurationData::GetInstance().GetICDMode(), ICDConfigurationData::ICDMode::LIT); + + // Simulate SIT Mode Request - device must switch to SIT mode even if there is a client registered + notifier.NotifySITModeRequestNotification(); + + // Check ICDManager is now in the SIT operating mode + EXPECT_EQ(ICDConfigurationData::GetInstance().GetICDMode(), ICDConfigurationData::ICDMode::SIT); + + // Advance time so active mode interval expires. + AdvanceClockAndRunEventLoop(ICDConfigurationData::GetInstance().GetActiveModeDuration() + 1_ms32); + + // Check ICDManager is still in the SIT operating mode + EXPECT_EQ(ICDConfigurationData::GetInstance().GetICDMode(), ICDConfigurationData::ICDMode::SIT); + + // Withdraw SIT mode + notifier.NotifySITModeRequestWithdrawal(); + + // Check ICDManager is now in the LIT operating mode + EXPECT_EQ(ICDConfigurationData::GetInstance().GetICDMode(), ICDConfigurationData::ICDMode::LIT); + + // Advance time so active mode interval expires. + AdvanceClockAndRunEventLoop(ICDConfigurationData::GetInstance().GetActiveModeDuration() + 1_ms32); + + // Check ICDManager is still in the LIT operating mode + EXPECT_EQ(ICDConfigurationData::GetInstance().GetICDMode(), ICDConfigurationData::ICDMode::LIT); +} +#endif // CHIP_CONFIG_ENABLE_ICD_DSLS + #if CHIP_CONFIG_ENABLE_ICD_CIP #if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS #if CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION diff --git a/src/app/tests/suites/TestIcdManagementCluster.yaml b/src/app/tests/suites/TestIcdManagementCluster.yaml index 68e358385b8e21..b8ccab4bcf6538 100644 --- a/src/app/tests/suites/TestIcdManagementCluster.yaml +++ b/src/app/tests/suites/TestIcdManagementCluster.yaml @@ -115,7 +115,7 @@ tests: command: "readAttribute" attribute: "FeatureMap" response: - value: 0x07 + value: 0x0F - label: "Read IdleModeDuration" command: "readAttribute"