Skip to content

Commit

Permalink
[nxp k32w1][lit icd] add platform support for dsls (Dynamic SIT LIT s…
Browse files Browse the repository at this point in the history
…upport)

Signed-off-by: Doru Gucea <[email protected]>
  • Loading branch information
doru91 committed Sep 3, 2024
1 parent f439600 commit 14b718b
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 8 deletions.
15 changes: 10 additions & 5 deletions examples/contact-sensor-app/nxp/k32w1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,14 @@ lit, the sensor is contacted, when not lit, the sensor is non-contacted.
and commissioning state. If the device is not commissioned, a SHORT press of the
button will enable Bluetooth LE advertising for a predefined period of time. If
the device is commissioned and is acting as a LIT ICD then a SHORT press of the
button will enable Active Mode. A LONG Press of Button SW2 initiates a factory
reset. After an initial period of 3 seconds, LED 2 and RGB LED will flash in
unison to signal the pending reset. After 6 seconds will cause the device to
reset its persistent configuration and initiate a reboot. The reset action can
be cancelled by press SW2 button at any point before the 6 second limit.
button will enable Active Mode. If the device is commissioned and is acting as a
LIT ICD then a double press of the button will request SIT Mode. Double pressing
the button again will cancel the request for SIT mode. A LONG Press of Button
SW2 initiates a factory reset. After an initial period of 3 seconds, LED 2 and
RGB LED will flash in unison to signal the pending reset. After 6 seconds will
cause the device to reset its persistent configuration and initiate a reboot.
The reset action can be cancelled by press SW2 button at any point before the 6
second limit.

**Button SW3** can be used to change the state of the simulated contact sensor.
The button behaves as a toggle, swapping the state every time it is short
Expand Down Expand Up @@ -207,6 +210,8 @@ chip_subscription_timeout_resumption: same as above + try to re-establish timeou
using Fibonacci backoff for retries pacing.
```

`chip_enable_icd_dsls` may be used for enabling DSLS (Dynamic SIT LIT Support).

## Manufacturing data

Use `chip_with_factory_data=1` in the gn build command to enable factory data.
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 @@ -30,6 +30,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 @@ -2016,7 +2016,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
}
]
}
}
33 changes: 33 additions & 0 deletions examples/platform/nxp/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,9 @@ CHIP_ERROR ButtonManager::Init()
});
VerifyOrReturnError(resetTimer != NULL, APP_ERROR_CREATE_TIMER_FAILED);

#if (CHIP_CONFIG_ENABLE_ICD_LIT && CHIP_CONFIG_ENABLE_ICD_DSLS)
sitModeRequested = false;
#endif // CHIP_CONFIG_ENABLE_ICD_LIT && CHIP_CONFIG_ENABLE_ICD_DSLS
return CHIP_NO_ERROR;
}

Expand All @@ -73,6 +80,11 @@ button_status_t ButtonManager::BleCallback(void * handle, button_callback_messag
case kBUTTON_EventShortPress:
event.Handler = ButtonManager::BleHandler;
break;
#if (CHIP_CONFIG_ENABLE_ICD_LIT && CHIP_CONFIG_ENABLE_ICD_DSLS)
case kBUTTON_EventDoubleClick:
event.Handler = ButtonManager::DSLSActionEventHandler;
break;
#endif // CHIP_CONFIG_ENABLE_ICD_LIT && CHIP_CONFIG_ENABLE_ICD_DSLS
case kBUTTON_EventLongPress:
event.Handler = ButtonManager::ResetActionEventHandler;
break;
Expand Down Expand Up @@ -189,6 +201,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/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 14b718b

Please sign in to comment.