Skip to content

Commit 514e810

Browse files
authored
[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 <doru-cristian.gucea@nxp.com> * [mcxw71_k32w1][lit icd] add platform support for dsls (Dynamic SIT LIT support) Signed-off-by: Doru Gucea <doru-cristian.gucea@nxp.com> * [lit icd] add DSLS Test Event trigger Signed-off-by: Doru Gucea <doru-cristian.gucea@nxp.com> * [linux app][lit icd] enable DSLS Signed-off-by: Doru Gucea <doru-cristian.gucea@nxp.com> --------- Signed-off-by: Doru Gucea <doru-cristian.gucea@nxp.com>
1 parent add0bf1 commit 514e810

19 files changed

+221
-40
lines changed

.github/.wordlist.txt

+1
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ dpkg
453453
dropdown
454454
dryrun
455455
DS
456+
DSLS
456457
duplicative
457458
DUT
458459
DUTS

examples/contact-sensor-app/nxp/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ This is a list of ICD configuration gn args.
154154
| nxp_active_mode_threshold_ms | 1000 (ms) | Active Mode Threshold value |
155155
| nxp_icd_supported_clients_per_fabric | 2 | Registration slots per fabric |
156156
| chip_enable_icd_lit | false | Enable LIT ICD support |
157+
| chip_enable_icd_dsls | false | Enable LIT ICD DSLS support |
157158
| chip_persist_subscriptions | true | Try once to re-establish subscriptions from the server side after reboot. May be disabled for LIT use case |
158159
| chip_subscription_timeout_resumption | true | Same as above, but try to re-establish timeout out subscriptions |
159160
| using `Fibonacci Backoff` for retries pacing. May be disabled for LIT use case |

examples/contact-sensor-app/nxp/k32w1/README.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ operation by corrupting packages and OTA will not work.
4141

4242
The user actions are summarized below:
4343

44-
| button | action | state | output |
45-
| ------ | ----------- | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
46-
| SW2 | short press | not commissioned | Enable BLE advertising |
47-
| SW2 | short press | commissioned + device is LIT | Enable Active Mode |
48-
| 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) |
49-
| SW3 | short press | NA | Toggle attribute `StateValue` value |
50-
| SW3 | long press | NA | Clean soft reset of the device (takes into account proper Matter shutdown procedure) |
44+
| button | action | state | output |
45+
| ------ | ------------ | -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
46+
| SW2 | short press | not commissioned | Enable BLE advertising |
47+
| SW2 | short press | commissioned + device is LIT | Enable Active Mode |
48+
| SW2 | double press | commissioned + device is LIT + supports DSLS | Enable / Disable SIT Mode |
49+
| 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) |
50+
| SW3 | short press | NA | Toggle attribute `StateValue` value |
51+
| SW3 | long press | NA | Clean soft reset of the device (takes into account proper Matter shutdown procedure) |
5152

5253
## Building
5354

examples/contact-sensor-app/nxp/k32w1/args.gni

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ chip_with_lwip = false
3131

3232
chip_enable_icd_server = true
3333
chip_enable_icd_lit = false
34+
chip_enable_icd_dsls = false
3435
icd_enforce_sit_slow_poll_limit = true
3536
chip_persist_subscriptions = true
3637
chip_subscription_timeout_resumption = true

examples/contact-sensor-app/nxp/zap-lit/contact-sensor-app.matter

+1-1
Original file line numberDiff line numberDiff line change
@@ -2012,7 +2012,7 @@ endpoint 0 {
20122012
callback attribute acceptedCommandList;
20132013
callback attribute eventList;
20142014
callback attribute attributeList;
2015-
ram attribute featureMap default = 0x0007;
2015+
ram attribute featureMap default = 0x000F;
20162016
ram attribute clusterRevision default = 3;
20172017

20182018
handle command RegisterClient;

examples/contact-sensor-app/nxp/zap-lit/contact-sensor-app.zap

+2-2
Original file line numberDiff line numberDiff line change
@@ -3818,7 +3818,7 @@
38183818
"storageOption": "RAM",
38193819
"singleton": 0,
38203820
"bounded": 0,
3821-
"defaultValue": "0x0007",
3821+
"defaultValue": "0x000F",
38223822
"reportable": 1,
38233823
"minInterval": 1,
38243824
"maxInterval": 65534,
@@ -4317,4 +4317,4 @@
43174317
"parentEndpointIdentifier": null
43184318
}
43194319
]
4320-
}
4320+
}

examples/lit-icd-app/linux/args.gni

+1
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ chip_enable_icd_server = true
3131
chip_subscription_timeout_resumption = true
3232
chip_icd_report_on_active_mode = true
3333
chip_enable_icd_lit = true
34+
chip_enable_icd_dsls = true

examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter

+1-1
Original file line numberDiff line numberDiff line change
@@ -2097,7 +2097,7 @@ endpoint 0 {
20972097
callback attribute acceptedCommandList;
20982098
callback attribute eventList;
20992099
callback attribute attributeList;
2100-
ram attribute featureMap default = 0x0007;
2100+
ram attribute featureMap default = 0x000F;
21012101
ram attribute clusterRevision default = 3;
21022102

21032103
handle command RegisterClient;

examples/lit-icd-app/lit-icd-common/lit-icd-server-app.zap

+1-19
Original file line numberDiff line numberDiff line change
@@ -829,24 +829,6 @@
829829
"isIncoming": 0,
830830
"isEnabled": 1
831831
}
832-
],
833-
"attributes": [
834-
{
835-
"name": "ClusterRevision",
836-
"code": 65533,
837-
"mfgCode": null,
838-
"side": "client",
839-
"type": "int16u",
840-
"included": 1,
841-
"storageOption": "RAM",
842-
"singleton": 0,
843-
"bounded": 0,
844-
"defaultValue": "1",
845-
"reportable": 1,
846-
"minInterval": 0,
847-
"maxInterval": 65344,
848-
"reportableChange": 0
849-
}
850832
]
851833
},
852834
{
@@ -3558,7 +3540,7 @@
35583540
"storageOption": "RAM",
35593541
"singleton": 0,
35603542
"bounded": 0,
3561-
"defaultValue": "0x0007",
3543+
"defaultValue": "0x000F",
35623544
"reportable": 1,
35633545
"minInterval": 1,
35643546
"maxInterval": 65534,

examples/platform/nxp/mcxw71_k32w1/button/ButtonManager.cpp

+36
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ ButtonManager ButtonManager::sInstance;
5151

5252
TimerHandle_t resetTimer;
5353

54+
#if (CHIP_CONFIG_ENABLE_ICD_LIT && CHIP_CONFIG_ENABLE_ICD_DSLS)
55+
static bool sitModeRequested;
56+
#endif // CHIP_CONFIG_ENABLE_ICD_LIT && CHIP_CONFIG_ENABLE_ICD_DSLS
57+
5458
CHIP_ERROR ButtonManager::Init()
5559
{
5660
resetTimer = xTimerCreate("FnTmr", 1, false, (void *) this, [](TimerHandle_t xTimer) {
@@ -60,6 +64,10 @@ CHIP_ERROR ButtonManager::Init()
6064
});
6165
VerifyOrReturnError(resetTimer != NULL, APP_ERROR_CREATE_TIMER_FAILED);
6266

67+
#if (CHIP_CONFIG_ENABLE_ICD_LIT && CHIP_CONFIG_ENABLE_ICD_DSLS)
68+
static bool sitModeRequested;
69+
#endif // CHIP_CONFIG_ENABLE_ICD_LIT && CHIP_CONFIG_ENABLE_ICD_DSLS
70+
6371
return CHIP_NO_ERROR;
6472
}
6573

@@ -76,6 +84,13 @@ button_status_t ButtonManager::BleCallback(void * handle, button_callback_messag
7684
case kBUTTON_EventLongPress:
7785
event.Handler = ButtonManager::ResetActionEventHandler;
7886
break;
87+
88+
#if (CHIP_CONFIG_ENABLE_ICD_LIT && CHIP_CONFIG_ENABLE_ICD_DSLS)
89+
case kBUTTON_EventDoubleClick:
90+
event.Handler = ButtonManager::DSLSActionEventHandler;
91+
break;
92+
#endif
93+
7994
default:
8095
/* No action required */
8196
break;
@@ -187,6 +202,27 @@ void ButtonManager::BleHandler(const AppEvent & event)
187202
chip::NXP::App::GetAppTask().SwitchCommissioningStateHandler();
188203
}
189204

205+
#if (CHIP_CONFIG_ENABLE_ICD_LIT && CHIP_CONFIG_ENABLE_ICD_DSLS)
206+
void ButtonManager::DSLSActionEventHandler(const AppEvent & event)
207+
{
208+
if (chip::DeviceLayer::ConfigurationMgr().IsFullyProvisioned())
209+
{
210+
if (!sitModeRequested)
211+
{
212+
chip::DeviceLayer::PlatformMgr().ScheduleWork(
213+
[](intptr_t arg) { chip::app::ICDNotifier::GetInstance().NotifySITModeRequestNotification(); }, 0);
214+
sitModeRequested = true;
215+
}
216+
else
217+
{
218+
chip::DeviceLayer::PlatformMgr().ScheduleWork(
219+
[](intptr_t arg) { chip::app::ICDNotifier::GetInstance().NotifySITModeRequestWithdrawal(); }, 0);
220+
sitModeRequested = false;
221+
}
222+
}
223+
}
224+
#endif // CHIP_CONFIG_ENABLE_ICD_LIT && CHIP_CONFIG_ENABLE_ICD_DSLS
225+
190226
void ButtonManager::CancelTimer()
191227
{
192228
if (xTimerStop(resetTimer, 0) == pdFAIL)

examples/platform/nxp/mcxw71_k32w1/button/ButtonManager.h

+7
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ class ButtonManager
8787
*/
8888
static void ResetActionEventHandler(const AppEvent & event);
8989

90+
/**
91+
* @brief This callback schedules a DSLS LIT action (Dynamic SIT LIT Support).
92+
*
93+
* It is used when the app requests SIT mode (check spec, "Runtime Operating Mode Switching")
94+
*/
95+
static void DSLSActionEventHandler(const AppEvent & event);
96+
9097
/**
9198
* @brief This callback performs a factory reset.
9299
*

src/app/icd/icd.gni

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ declare_args() {
3030

3131
# Set to true to enforce SIT Slow Polling Max value to 15seconds (spec 9.16.1.5)
3232
icd_enforce_sit_slow_poll_limit = false
33+
34+
# Set to true if device supports dynamic switching from SIT to LIT operating modes (DSLS)
35+
chip_enable_icd_dsls = false
3336
}
3437

3538
# Set the defaults for CIP and UAT features to be consistent with the LIT value.

src/app/icd/server/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ buildconfig_header("icd-server-buildconfig") {
3636
"CHIP_CONFIG_ENABLE_ICD_LIT=${chip_enable_icd_lit}",
3737
"CHIP_CONFIG_ENABLE_ICD_CIP=${chip_enable_icd_checkin}",
3838
"CHIP_CONFIG_ENABLE_ICD_UAT=${chip_enable_icd_user_active_mode_trigger}",
39+
"CHIP_CONFIG_ENABLE_ICD_DSLS=${chip_enable_icd_dsls}",
3940
"ICD_REPORT_ON_ENTER_ACTIVE_MODE=${chip_icd_report_on_active_mode}",
4041
"ICD_MAX_NOTIFICATION_SUBSCRIBERS=${icd_max_notification_subscribers}",
4142
"ICD_ENFORCE_SIT_SLOW_POLL_LIMIT=${icd_enforce_sit_slow_poll_limit}",

src/app/icd/server/ICDManager.cpp

+46-9
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ enum class ICDTestEventTriggerEvent : uint64_t
3636
kInvalidateHalfCounterValues = 0x0046'0000'00000003,
3737
kInvalidateAllCounterValues = 0x0046'0000'00000004,
3838
kForceMaximumCheckInBackOffState = 0x0046'0000'00000005,
39+
kDSLSForceSitMode = 0x0046'0000'00000006,
40+
kDSLSWithdrawSitMode = 0x0046'0000'00000007,
3941
};
4042
} // namespace
4143

@@ -367,19 +369,28 @@ void ICDManager::UpdateICDMode()
367369
// Device can only switch to the LIT operating mode if LIT support is present
368370
if (SupportsFeature(Feature::kLongIdleTimeSupport))
369371
{
370-
VerifyOrDie(mStorage != nullptr);
371-
VerifyOrDie(mFabricTable != nullptr);
372-
// We can only get to LIT Mode, if at least one client is registered with the ICD device
373-
for (const auto & fabricInfo : *mFabricTable)
372+
#if CHIP_CONFIG_ENABLE_ICD_DSLS
373+
// Ensure SIT mode is not requested
374+
if (SupportsFeature(Feature::kDynamicSitLitSupport) && !mSITModeRequested)
374375
{
375-
// We only need 1 valid entry to ensure LIT compliance
376-
ICDMonitoringTable table(*mStorage, fabricInfo.GetFabricIndex(), 1 /*Table entry limit*/, mSymmetricKeystore);
377-
if (!table.IsEmpty())
376+
#endif // CHIP_CONFIG_ENABLE_ICD_DSLS
377+
378+
VerifyOrDie(mStorage != nullptr);
379+
VerifyOrDie(mFabricTable != nullptr);
380+
// We can only get to LIT Mode, if at least one client is registered with the ICD device
381+
for (const auto & fabricInfo : *mFabricTable)
378382
{
379-
tempMode = ICDConfigurationData::ICDMode::LIT;
380-
break;
383+
// We only need 1 valid entry to ensure LIT compliance
384+
ICDMonitoringTable table(*mStorage, fabricInfo.GetFabricIndex(), 1 /*Table entry limit*/, mSymmetricKeystore);
385+
if (!table.IsEmpty())
386+
{
387+
tempMode = ICDConfigurationData::ICDMode::LIT;
388+
break;
389+
}
381390
}
391+
#if CHIP_CONFIG_ENABLE_ICD_DSLS
382392
}
393+
#endif // CHIP_CONFIG_ENABLE_ICD_DSLS
383394
}
384395
#endif // CHIP_CONFIG_ENABLE_ICD_LIT
385396

@@ -622,6 +633,24 @@ void ICDManager::OnActiveRequestWithdrawal(KeepActiveFlags request)
622633
}
623634
}
624635

636+
#if CHIP_CONFIG_ENABLE_ICD_DSLS
637+
void ICDManager::OnSITModeRequest()
638+
{
639+
mSITModeRequested = true;
640+
this->UpdateICDMode();
641+
// Update the poll interval also to comply with SIT requirements
642+
UpdateOperationState(OperationalState::ActiveMode);
643+
}
644+
645+
void ICDManager::OnSITModeRequestWithdrawal()
646+
{
647+
mSITModeRequested = false;
648+
this->UpdateICDMode();
649+
// Update the poll interval also to comply with LIT requirements
650+
UpdateOperationState(OperationalState::ActiveMode);
651+
}
652+
#endif // CHIP_CONFIG_ENABLE_ICD_DSLS
653+
625654
void ICDManager::OnNetworkActivity()
626655
{
627656
this->UpdateOperationState(OperationalState::ActiveMode);
@@ -685,6 +714,14 @@ CHIP_ERROR ICDManager::HandleEventTrigger(uint64_t eventTrigger)
685714
err = mICDCheckInBackOffStrategy->ForceMaximumCheckInBackoff();
686715
break;
687716
#endif // CHIP_CONFIG_ENABLE_ICD_CIP
717+
#if CHIP_CONFIG_ENABLE_ICD_DSLS
718+
case ICDTestEventTriggerEvent::kDSLSForceSitMode:
719+
OnSITModeRequest();
720+
break;
721+
case ICDTestEventTriggerEvent::kDSLSWithdrawSitMode:
722+
OnSITModeRequestWithdrawal();
723+
break;
724+
#endif // CHIP_CONFIG_ENABLE_ICD_DSLS
688725
default:
689726
err = CHIP_ERROR_INVALID_ARGUMENT;
690727
break;

src/app/icd/server/ICDManager.h

+10
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ class ICDManager : public ICDListener, public TestEventTriggerHandler
241241
void OnNetworkActivity() override;
242242
void OnKeepActiveRequest(KeepActiveFlags request) override;
243243
void OnActiveRequestWithdrawal(KeepActiveFlags request) override;
244+
245+
#if CHIP_CONFIG_ENABLE_ICD_DSLS
246+
void OnSITModeRequest() override;
247+
void OnSITModeRequestWithdrawal() override;
248+
#endif
249+
244250
void OnICDManagementServerEvent(ICDManagementEvents event) override;
245251
void OnSubscriptionReport() override;
246252

@@ -356,6 +362,10 @@ class ICDManager : public ICDListener, public TestEventTriggerHandler
356362
ObjectPool<ObserverPointer, CHIP_CONFIG_ICD_OBSERVERS_POOL_SIZE> mStateObserverPool;
357363
uint8_t mOpenExchangeContextCount = 0;
358364

365+
#if CHIP_CONFIG_ENABLE_ICD_DSLS
366+
bool mSITModeRequested = false;
367+
#endif
368+
359369
#if CHIP_CONFIG_ENABLE_ICD_CIP
360370
uint8_t mCheckInRequestCount = 0;
361371

src/app/icd/server/ICDNotifier.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,30 @@ void ICDNotifier::NotifyActiveRequestWithdrawal(ICDListener::KeepActiveFlags req
8989
}
9090
}
9191

92+
#if CHIP_CONFIG_ENABLE_ICD_DSLS
93+
void ICDNotifier::NotifySITModeRequestNotification()
94+
{
95+
for (auto subscriber : mSubscribers)
96+
{
97+
if (subscriber != nullptr)
98+
{
99+
subscriber->OnSITModeRequest();
100+
}
101+
}
102+
}
103+
104+
void ICDNotifier::NotifySITModeRequestWithdrawal()
105+
{
106+
for (auto subscriber : mSubscribers)
107+
{
108+
if (subscriber != nullptr)
109+
{
110+
subscriber->OnSITModeRequestWithdrawal();
111+
}
112+
}
113+
}
114+
#endif // CHIP_CONFIG_ENABLE_ICD_DSLS
115+
92116
void ICDNotifier::NotifyICDManagementEvent(ICDListener::ICDManagementEvents event)
93117
{
94118
for (auto subscriber : mSubscribers)

src/app/icd/server/ICDNotifier.h

+18
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@ class ICDListener
7171
*/
7272
virtual void OnKeepActiveRequest(KeepActiveFlags request) = 0;
7373

74+
#if CHIP_CONFIG_ENABLE_ICD_DSLS
75+
/**
76+
* @brief This function is called for all subscribers of the ICDNotifier when it calls NotifySITModeRequestNotification.
77+
* It informs the subscriber that the ICD must be kept in SIT mode.
78+
*/
79+
virtual void OnSITModeRequest() = 0;
80+
81+
/**
82+
* @brief This function is called for all subscribers of the ICDNotifier when it calls NotifySITModeRequestWithdrawal.
83+
* It informs the subscriber that a previous request no longer needs ICD to be kept in SIT mode.
84+
*/
85+
virtual void OnSITModeRequestWithdrawal() = 0;
86+
#endif // CHIP_CONFIG_ENABLE_ICD_DSLS
87+
7488
/**
7589
* @brief This function is called for all subscribers of the ICDNotifier when it calls NotifyActiveRequestWithdrawal.
7690
* It informs the subscriber that a previous request no longer needs ICD to maintain its Active Mode.
@@ -109,6 +123,10 @@ class ICDNotifier
109123
void NotifyNetworkActivityNotification();
110124
void NotifyActiveRequestNotification(ICDListener::KeepActiveFlags request);
111125
void NotifyActiveRequestWithdrawal(ICDListener::KeepActiveFlags request);
126+
#if CHIP_CONFIG_ENABLE_ICD_DSLS
127+
void NotifySITModeRequestNotification();
128+
void NotifySITModeRequestWithdrawal();
129+
#endif // CHIP_CONFIG_ENABLE_ICD_DSLS
112130
void NotifyICDManagementEvent(ICDListener::ICDManagementEvents event);
113131
void NotifySubscriptionReport();
114132

0 commit comments

Comments
 (0)