Skip to content

Commit

Permalink
[lit icd] add sdk support for dsls (Dynamic SIT LIT support)
Browse files Browse the repository at this point in the history
Signed-off-by: Doru Gucea <[email protected]>
  • Loading branch information
doru91 committed Aug 30, 2024
1 parent 952873e commit e203e97
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 1 deletion.
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 @@ -33,6 +33,7 @@ chip_enable_icd_lit = false
icd_enforce_sit_slow_poll_limit = true
chip_persist_subscriptions = true
chip_subscription_timeout_resumption = true
chip_enable_icd_dsls = true

is_debug = false

Expand Down
3 changes: 3 additions & 0 deletions src/app/icd/icd.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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
chip_enable_icd_dsls = false
}

# Set the defaults for CIP and UAT features to be consistent with the LIT value.
Expand Down
1 change: 1 addition & 0 deletions src/app/icd/server/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down
16 changes: 15 additions & 1 deletion src/app/icd/server/ICDManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ void ICDManager::UpdateICDMode()

#if CHIP_CONFIG_ENABLE_ICD_LIT
// Device can only switch to the LIT operating mode if LIT support is present
if (SupportsFeature(Feature::kLongIdleTimeSupport))
if (SupportsFeature(Feature::kLongIdleTimeSupport) && !mSITModeRequested)
{
VerifyOrDie(mStorage != nullptr);
VerifyOrDie(mFabricTable != nullptr);
Expand Down Expand Up @@ -622,6 +622,20 @@ void ICDManager::OnActiveRequestWithdrawal(KeepActiveFlags request)
}
}

#if CHIP_CONFIG_ENABLE_ICD_DSLS
void ICDManager::OnSITModeRequest()
{
mSITModeRequested = true;
this->UpdateICDMode();
}

void ICDManager::OnSITModeRequestWithdrawal()
{
mSITModeRequested = false;
this->UpdateICDMode();
}
#endif // CHIP_CONFIG_ENABLE_ICD_DSLS

void ICDManager::OnNetworkActivity()
{
this->UpdateOperationState(OperationalState::ActiveMode);
Expand Down
10 changes: 10 additions & 0 deletions src/app/icd/server/ICDManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -356,6 +362,10 @@ class ICDManager : public ICDListener, public TestEventTriggerHandler
ObjectPool<ObserverPointer, CHIP_CONFIG_ICD_OBSERVERS_POOL_SIZE> 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;

Expand Down
24 changes: 24 additions & 0 deletions src/app/icd/server/ICDNotifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions src/app/icd/server/ICDNotifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit e203e97

Please sign in to comment.