Skip to content

Commit

Permalink
[mcxw71_k32w1][lit icd] add platform support for dsls (Dynamic SIT LI…
Browse files Browse the repository at this point in the history
…T support)

Signed-off-by: Doru Gucea <[email protected]>
  • Loading branch information
doru91 committed Sep 10, 2024
1 parent c688b81 commit 68424b7
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ dpkg
dropdown
dryrun
DS
DSLS
duplicative
DUT
DUTS
Expand Down
1 change: 1 addition & 0 deletions examples/contact-sensor-app/nxp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
15 changes: 8 additions & 7 deletions examples/contact-sensor-app/nxp/k32w1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions examples/contact-sensor-app/nxp/k32w1/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3818,7 +3818,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x0007",
"defaultValue": "0x000F",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down Expand Up @@ -4317,4 +4317,4 @@
"parentEndpointIdentifier": null
}
]
}
}
36 changes: 36 additions & 0 deletions examples/platform/nxp/mcxw71_k32w1/button/ButtonManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}

Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions examples/platform/nxp/mcxw71_k32w1/button/ButtonManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit 68424b7

Please sign in to comment.