From 3fdf3a84e37c004eb7a5b19ef070bd99e0479a07 Mon Sep 17 00:00:00 2001 From: Doru Gucea Date: Tue, 10 Sep 2024 03:29:50 -0700 Subject: [PATCH] [mcxw71_k32w1][lit icd] add platform support for dsls (Dynamic SIT LIT support) 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 +-- .../nxp/mcxw71_k32w1/button/ButtonManager.cpp | 36 +++++++++++++++++++ .../nxp/mcxw71_k32w1/button/ButtonManager.h | 7 ++++ 8 files changed, 57 insertions(+), 10 deletions(-) diff --git a/.github/.wordlist.txt b/.github/.wordlist.txt index c84d4038352101..cf590675ff1a9d 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 473afb793f9700..1a022bf8d43f43 100644 --- a/examples/contact-sensor-app/nxp/README.md +++ b/examples/contact-sensor-app/nxp/README.md @@ -153,6 +153,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/platform/nxp/mcxw71_k32w1/button/ButtonManager.cpp b/examples/platform/nxp/mcxw71_k32w1/button/ButtonManager.cpp index 47e5f9fd4b6c9d..27ba50c13b4828 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; @@ -189,6 +204,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. *