Skip to content

Commit d455712

Browse files
committed
[lit icd] add DSLS Test Event trigger
Signed-off-by: Doru Gucea <doru-cristian.gucea@nxp.com>
1 parent 98c1a0a commit d455712

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

src/app/icd/server/ICDManager.cpp

+10
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

@@ -712,6 +714,14 @@ CHIP_ERROR ICDManager::HandleEventTrigger(uint64_t eventTrigger)
712714
err = mICDCheckInBackOffStrategy->ForceMaximumCheckInBackoff();
713715
break;
714716
#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
715725
default:
716726
err = CHIP_ERROR_INVALID_ARGUMENT;
717727
break;

src/app/icd/server/tests/TestICDManager.cpp

+58
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,64 @@ TEST_F(TestICDManager, TestICDMStayActive)
695695
EXPECT_EQ(stayActivePromisedMs, 20000UL);
696696
}
697697

698+
#if CHIP_CONFIG_ENABLE_ICD_DSLS
699+
/**
700+
* @brief Test verifies the logic of the ICDManager related to DSLS (Dynamic SIT LIT Support)
701+
*/
702+
TEST_F(TestICDManager, TestICDMDSLS)
703+
{
704+
typedef ICDListener::ICDManagementEvents ICDMEvent;
705+
ICDNotifier notifier = ICDNotifier::GetInstance();
706+
707+
// Set FeatureMap
708+
// Configures CIP, UAT, LITS and DSLS to 1
709+
mICDManager.SetTestFeatureMapValue(0x0F);
710+
711+
// Check ICDManager starts in SIT mode if no entries are present
712+
EXPECT_EQ(ICDConfigurationData::GetInstance().GetICDMode(), ICDConfigurationData::ICDMode::SIT);
713+
714+
// Create table with one fabric
715+
ICDMonitoringTable table1(testStorage, kTestFabricIndex1, kMaxTestClients, &(mKeystore));
716+
717+
// Add an entry to the fabric
718+
ICDMonitoringEntry entry1(&(mKeystore));
719+
entry1.checkInNodeID = kClientNodeId11;
720+
entry1.monitoredSubject = kClientNodeId12;
721+
EXPECT_EQ(CHIP_NO_ERROR, entry1.SetKey(ByteSpan(kKeyBuffer1a)));
722+
EXPECT_EQ(CHIP_NO_ERROR, table1.Set(0, entry1));
723+
724+
// Trigger register event after first entry was added
725+
notifier.NotifyICDManagementEvent(ICDMEvent::kTableUpdated);
726+
727+
// Check ICDManager is now in the LIT operating mode
728+
EXPECT_EQ(ICDConfigurationData::GetInstance().GetICDMode(), ICDConfigurationData::ICDMode::LIT);
729+
730+
// Simulate SIT Mode Request - device must switch to SIT mode even if there is a client registered
731+
notifier.NotifySITModeRequestNotification();
732+
733+
// Check ICDManager is now in the SIT operating mode
734+
EXPECT_EQ(ICDConfigurationData::GetInstance().GetICDMode(), ICDConfigurationData::ICDMode::SIT);
735+
736+
// Advance time so active mode interval expires.
737+
AdvanceClockAndRunEventLoop(ICDConfigurationData::GetInstance().GetActiveModeDuration() + 1_ms32);
738+
739+
// Check ICDManager is still in the SIT operating mode
740+
EXPECT_EQ(ICDConfigurationData::GetInstance().GetICDMode(), ICDConfigurationData::ICDMode::SIT);
741+
742+
// Withdraw SIT mode
743+
notifier.NotifySITModeRequestWithdrawal();
744+
745+
// Check ICDManager is now in the LIT operating mode
746+
EXPECT_EQ(ICDConfigurationData::GetInstance().GetICDMode(), ICDConfigurationData::ICDMode::LIT);
747+
748+
// Advance time so active mode interval expires.
749+
AdvanceClockAndRunEventLoop(ICDConfigurationData::GetInstance().GetActiveModeDuration() + 1_ms32);
750+
751+
// Check ICDManager is still in the LIT operating mode
752+
EXPECT_EQ(ICDConfigurationData::GetInstance().GetICDMode(), ICDConfigurationData::ICDMode::LIT);
753+
}
754+
#endif // CHIP_CONFIG_ENABLE_ICD_DSLS
755+
698756
#if CHIP_CONFIG_ENABLE_ICD_CIP
699757
#if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
700758
#if CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION

0 commit comments

Comments
 (0)