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 Sep 2, 2024
1 parent 952873e commit ff89cd9
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 0 deletions.
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
27 changes: 27 additions & 0 deletions src/app/icd/server/ICDManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,12 @@ void ICDManager::UpdateICDMode()
// Device can only switch to the LIT operating mode if LIT support is present
if (SupportsFeature(Feature::kLongIdleTimeSupport))
{
#if CHIP_CONFIG_ENABLE_ICD_DSLS
// Ensure SIT mode is not requested
if (SupportsFeature(Feature::kLongIdleTimeSupport) && !mSITModeRequested)
{
#endif // CHIP_CONFIG_ENABLE_ICD_DSLS

VerifyOrDie(mStorage != nullptr);
VerifyOrDie(mFabricTable != nullptr);
// We can only get to LIT Mode, if at least one client is registered with the ICD device
Expand All @@ -380,6 +386,9 @@ void ICDManager::UpdateICDMode()
break;
}
}
#if CHIP_CONFIG_ENABLE_ICD_DSLS
}
#endif // CHIP_CONFIG_ENABLE_ICD_DSLS
}
#endif // CHIP_CONFIG_ENABLE_ICD_LIT

Expand Down Expand Up @@ -622,6 +631,24 @@ void ICDManager::OnActiveRequestWithdrawal(KeepActiveFlags request)
}
}

#if CHIP_CONFIG_ENABLE_ICD_DSLS
void ICDManager::OnSITModeRequest()
{
mSITModeRequested = true;
this->UpdateICDMode();
// Update the poll interval also to comply with SIT requirements
UpdateOperationState(OperationalState::ActiveMode);
}

void ICDManager::OnSITModeRequestWithdrawal()
{
mSITModeRequested = false;
this->UpdateICDMode();
// Update the poll interval also to comply with LIT requirements
UpdateOperationState(OperationalState::ActiveMode);
}
#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 ff89cd9

Please sign in to comment.