Skip to content

Commit

Permalink
rename attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
mkardous-silabs committed Oct 24, 2023
1 parent caa2d2d commit 531f9a3
Show file tree
Hide file tree
Showing 24 changed files with 9,362 additions and 8,576 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5862,7 +5862,7 @@
],
"attributes": [
{
"name": "IdleModeInterval",
"name": "IdleModeDuration",
"code": 0,
"mfgCode": null,
"side": "server",
Expand All @@ -5878,7 +5878,7 @@
"reportableChange": 0
},
{
"name": "ActiveModeInterval",
"name": "ActiveModeDuration",
"code": 1,
"mfgCode": null,
"side": "server",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4448,7 +4448,7 @@
"enabled": 1,
"attributes": [
{
"name": "IdleModeInterval",
"name": "IdleModeDuration",
"code": 0,
"mfgCode": null,
"side": "server",
Expand All @@ -4464,7 +4464,7 @@
"reportableChange": 0
},
{
"name": "ActiveModeInterval",
"name": "ActiveModeDuration",
"code": 1,
"mfgCode": null,
"side": "server",
Expand Down
4 changes: 2 additions & 2 deletions examples/lock-app/lock-common/lock-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -5039,7 +5039,7 @@
"enabled": 1,
"attributes": [
{
"name": "IdleModeInterval",
"name": "IdleModeDuration",
"code": 0,
"mfgCode": null,
"side": "server",
Expand All @@ -5055,7 +5055,7 @@
"reportableChange": 0
},
{
"name": "ActiveModeInterval",
"name": "ActiveModeDuration",
"code": 1,
"mfgCode": null,
"side": "server",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3505,7 +3505,7 @@
],
"attributes": [
{
"name": "IdleModeInterval",
"name": "IdleModeDuration",
"code": 0,
"mfgCode": null,
"side": "server",
Expand All @@ -3521,7 +3521,7 @@
"reportableChange": 0
},
{
"name": "ActiveModeInterval",
"name": "ActiveModeDuration",
"code": 1,
"mfgCode": null,
"side": "server",
Expand Down
10 changes: 5 additions & 5 deletions src/app/ReadHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ using Status = Protocols::InteractionModel::Status;
uint16_t ReadHandler::GetPublisherSelectedIntervalLimit()
{
#if CHIP_CONFIG_ENABLE_ICD_SERVER
return static_cast<uint16_t>(ICDManagementServer::GetInstance().GetIdleModeIntervalSec());
return static_cast<uint16_t>(ICDManagementServer::GetInstance().GetIdleModeDurationSec());
#else
return kSubscriptionMaxIntervalPublisherLimit;
#endif
Expand Down Expand Up @@ -719,17 +719,17 @@ CHIP_ERROR ReadHandler::ProcessSubscribeRequest(System::PacketBufferHandle && aP

#if CHIP_CONFIG_ENABLE_ICD_SERVER

// Default behavior for ICDs where the wanted MaxInterval for a subscription is the IdleModeInterval
// Default behavior for ICDs where the wanted MaxInterval for a subscription is the IdleModeDuration
// defined in the ICD Management Cluster.
// Behavior can be changed with the OnSubscriptionRequested function defined in the application callbacks

// Default Behavior Steps :
// If MinInterval > IdleModeInterval, try to set the MaxInterval to the first interval of IdleModeIntervals above the
// If MinInterval > IdleModeDuration, try to set the MaxInterval to the first interval of IdleModeDurations above the
// MinInterval.
// If the next interval is greater than the MaxIntervalCeiling, use the MaxIntervalCeiling.
// Otherwise, use IdleModeInterval as MaxInterval
// Otherwise, use IdleModeDuration as MaxInterval

// GetPublisherSelectedIntervalLimit() returns the IdleModeInterval if the device is an ICD
// GetPublisherSelectedIntervalLimit() returns the IdleModeDuration if the device is an ICD
uint32_t decidedMaxInterval = GetPublisherSelectedIntervalLimit();

// Check if the PublisherSelectedIntervalLimit is 0. If so, set decidedMaxInterval to MaxIntervalCeiling
Expand Down
20 changes: 10 additions & 10 deletions src/app/clusters/icd-management-server/icd-management-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class IcdManagementAttributeAccess : public app::AttributeAccessInterface
CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override;

private:
CHIP_ERROR ReadIdleModeInterval(EndpointId endpoint, AttributeValueEncoder & encoder);
CHIP_ERROR ReadActiveModeInterval(EndpointId endpoint, AttributeValueEncoder & encoder);
CHIP_ERROR ReadIdleModeDuration(EndpointId endpoint, AttributeValueEncoder & encoder);
CHIP_ERROR ReadActiveModeDuration(EndpointId endpoint, AttributeValueEncoder & encoder);
CHIP_ERROR ReadActiveModeThreshold(EndpointId endpoint, AttributeValueEncoder & encoder);
CHIP_ERROR ReadRegisteredClients(EndpointId endpoint, AttributeValueEncoder & encoder);
CHIP_ERROR ReadICDCounter(EndpointId endpoint, AttributeValueEncoder & encoder);
Expand All @@ -65,11 +65,11 @@ CHIP_ERROR IcdManagementAttributeAccess::Read(const ConcreteReadAttributePath &

switch (aPath.mAttributeId)
{
case IcdManagement::Attributes::IdleModeInterval::Id:
return ReadIdleModeInterval(aPath.mEndpointId, aEncoder);
case IcdManagement::Attributes::IdleModeDuration::Id:
return ReadIdleModeDuration(aPath.mEndpointId, aEncoder);

case IcdManagement::Attributes::ActiveModeInterval::Id:
return ReadActiveModeInterval(aPath.mEndpointId, aEncoder);
case IcdManagement::Attributes::ActiveModeDuration::Id:
return ReadActiveModeDuration(aPath.mEndpointId, aEncoder);

case IcdManagement::Attributes::ActiveModeThreshold::Id:
return ReadActiveModeThreshold(aPath.mEndpointId, aEncoder);
Expand All @@ -87,14 +87,14 @@ CHIP_ERROR IcdManagementAttributeAccess::Read(const ConcreteReadAttributePath &
return CHIP_NO_ERROR;
}

CHIP_ERROR IcdManagementAttributeAccess::ReadIdleModeInterval(EndpointId endpoint, AttributeValueEncoder & encoder)
CHIP_ERROR IcdManagementAttributeAccess::ReadIdleModeDuration(EndpointId endpoint, AttributeValueEncoder & encoder)
{
return encoder.Encode(ICDManagementServer::GetInstance().GetIdleModeIntervalSec());
return encoder.Encode(ICDManagementServer::GetInstance().GetIdleModeDurationSec());
}

CHIP_ERROR IcdManagementAttributeAccess::ReadActiveModeInterval(EndpointId endpoint, AttributeValueEncoder & encoder)
CHIP_ERROR IcdManagementAttributeAccess::ReadActiveModeDuration(EndpointId endpoint, AttributeValueEncoder & encoder)
{
return encoder.Encode(ICDManagementServer::GetInstance().GetActiveModeIntervalMs());
return encoder.Encode(ICDManagementServer::GetInstance().GetActiveModeDurationMs());
}

CHIP_ERROR IcdManagementAttributeAccess::ReadActiveModeThreshold(EndpointId endpoint, AttributeValueEncoder & encoder)
Expand Down
20 changes: 10 additions & 10 deletions src/app/icd/ICDManagementServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ using chip::Protocols::InteractionModel::Status;
class ICDManagementServer
{
public:
uint32_t GetIdleModeIntervalSec() { return mIdleInterval_s; }
uint32_t GetIdleModeDurationSec() { return mIdleInterval_s; }

uint32_t GetActiveModeIntervalMs() { return mActiveInterval_ms; }
uint32_t GetActiveModeDurationMs() { return mActiveInterval_ms; }

void SetSymmetricKeystore(Crypto::SymmetricKeystore * keyStore) { mSymmetricKeystore = keyStore; }

Expand Down Expand Up @@ -63,15 +63,15 @@ class ICDManagementServer
static ICDManagementServer mInstance;
Crypto::SymmetricKeystore * mSymmetricKeystore = nullptr;

static_assert((CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC) <= 64800,
"Spec requires the IdleModeInterval to be equal or inferior to 64800s.");
static_assert((CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC) >= 1,
"Spec requires the IdleModeInterval to be equal or greater to 1s.");
uint32_t mIdleInterval_s = CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC;
static_assert((CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC) <= 64800,
"Spec requires the IdleModeDuration to be equal or inferior to 64800s.");
static_assert((CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC) >= 1,
"Spec requires the IdleModeDuration to be equal or greater to 1s.");
uint32_t mIdleInterval_s = CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC;

static_assert((CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL_MS) <= (CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC * kMillisecondsPerSecond),
"Spec requires the IdleModeInterval be equal or greater to the ActiveModeInterval.");
uint32_t mActiveInterval_ms = CHIP_CONFIG_ICD_ACTIVE_MODE_INTERVAL_MS;
static_assert((CHIP_CONFIG_ICD_ACTIVE_MODE_DURATION_MS) <= (CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC * kMillisecondsPerSecond),
"Spec requires the IdleModeDuration be equal or greater to the ActiveModeDuration.");
uint32_t mActiveInterval_ms = CHIP_CONFIG_ICD_ACTIVE_MODE_DURATION_MS;

uint16_t mActiveThreshold_ms = CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS;

Expand Down
24 changes: 12 additions & 12 deletions src/app/icd/ICDManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ void ICDManager::Init(PersistentStorageDelegate * storage, FabricTable * fabricT
ICDManagementServer::GetInstance().SetSymmetricKeystore(mSymmetricKeystore);

// Removing the check for now since it is possible for the Fast polling
// to be larger than the ActiveModeInterval for now
// uint32_t activeModeInterval = ICDManagementServer::GetInstance().GetActiveModeIntervalMs();
// VerifyOrDie(kFastPollingInterval.count() < activeModeInterval);
// to be larger than the ActiveModeDuration for now
// uint32_t activeModeDuration = ICDManagementServer::GetInstance().GetActiveModeDurationMs();
// VerifyOrDie(kFastPollingInterval.count() < activeModeDuration);

UpdateICDMode();
UpdateOperationState(OperationalState::ActiveMode);
Expand Down Expand Up @@ -138,10 +138,10 @@ void ICDManager::UpdateOperationState(OperationalState state)
mOperationalState = OperationalState::IdleMode;

// When the active mode interval is 0, we stay in idleMode until a notification brings the icd into active mode
if (ICDManagementServer::GetInstance().GetActiveModeIntervalMs() > 0)
if (ICDManagementServer::GetInstance().GetActiveModeDurationMs() > 0)
{
uint32_t idleModeInterval = ICDManagementServer::GetInstance().GetIdleModeIntervalSec();
DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds32(idleModeInterval), OnIdleModeDone, this);
uint32_t idleModeDuration = ICDManagementServer::GetInstance().GetIdleModeDurationSec();
DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds32(idleModeDuration), OnIdleModeDone, this);
}

System::Clock::Milliseconds32 slowPollInterval = GetSlowPollingInterval();
Expand Down Expand Up @@ -169,19 +169,19 @@ void ICDManager::UpdateOperationState(OperationalState state)
DeviceLayer::SystemLayer().CancelTimer(OnIdleModeDone, this);

mOperationalState = OperationalState::ActiveMode;
uint32_t activeModeInterval = ICDManagementServer::GetInstance().GetActiveModeIntervalMs();
uint32_t activeModeDuration = ICDManagementServer::GetInstance().GetActiveModeDurationMs();

if (activeModeInterval == 0 && !mKeepActiveFlags.HasAny())
if (activeModeDuration == 0 && !mKeepActiveFlags.HasAny())
{
// A Network Activity triggered the active mode and activeModeInterval is 0.
// A Network Activity triggered the active mode and activeModeDuration is 0.
// Stay active for at least Active Mode Threshold.
activeModeInterval = ICDManagementServer::GetInstance().GetActiveModeThresholdMs();
activeModeDuration = ICDManagementServer::GetInstance().GetActiveModeThresholdMs();
}

DeviceLayer::SystemLayer().StartTimer(System::Clock::Timeout(activeModeInterval), OnActiveModeDone, this);
DeviceLayer::SystemLayer().StartTimer(System::Clock::Timeout(activeModeDuration), OnActiveModeDone, this);

uint32_t activeModeJitterInterval =
(activeModeInterval >= ICD_ACTIVE_TIME_JITTER_MS) ? activeModeInterval - ICD_ACTIVE_TIME_JITTER_MS : 0;
(activeModeDuration >= ICD_ACTIVE_TIME_JITTER_MS) ? activeModeDuration - ICD_ACTIVE_TIME_JITTER_MS : 0;
DeviceLayer::SystemLayer().StartTimer(System::Clock::Timeout(activeModeJitterInterval), OnTransitionToIdle, this);

CHIP_ERROR err = DeviceLayer::ConnectivityMgr().SetPollingInterval(GetFastPollingInterval());
Expand Down
4 changes: 2 additions & 2 deletions src/app/icd/ICDManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ class ICDManager : public ICDListener
static constexpr System::Clock::Milliseconds32 kFastPollingInterval = CHIP_DEVICE_CONFIG_ICD_FAST_POLL_INTERVAL;

// Minimal constraint value of the the ICD attributes.
static constexpr uint32_t kMinIdleModeInterval = 500;
static constexpr uint32_t kMinActiveModeInterval = 300;
static constexpr uint32_t kMinIdleModeDuration = 500;
static constexpr uint32_t kMinActiveModeDuration = 300;
static constexpr uint16_t kMinActiveModeThreshold = 300;

bool SupportsCheckInProtocol();
Expand Down
2 changes: 1 addition & 1 deletion src/app/icd/ICDNotifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace app {
/**
* The ICDManager implements the ICDListener functions and is always subscribed to the ICDNotifier
* This allows other Matter modules to inform the ICDManager that it needs to go and may have to stay in Active Mode,
* outside of its standard ActiveModeInterval and IdleModeInterval, without being tightly coupled the application data model
* outside of its standard ActiveModeDuration and IdleModeDuration, without being tightly coupled the application data model
*
* This implementation also allows other modules to implement an ICDListener and subscribe to ICDNotifier
* to couple behaviours with the ICD cycles. In such cases, ICD_MAX_NOTIFICATION_SUBSCRIBERS need to be adjusted
Expand Down
2 changes: 1 addition & 1 deletion src/app/icd/ICDStateObserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#pragma once

#ifndef ICD_SLEEP_TIME_JITTER_MS
#define ICD_SLEEP_TIME_JITTER_MS (CHIP_CONFIG_ICD_IDLE_MODE_INTERVAL_SEC * 0.75)
#define ICD_SLEEP_TIME_JITTER_MS (CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC * 0.75)
#endif

#ifndef ICD_ACTIVE_TIME_JITTER_MS
Expand Down
18 changes: 9 additions & 9 deletions src/app/tests/TestICDManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,22 @@ class TestICDManager
ctx->GetIOContext().DriveIO();
}

static void TestICDModeIntervals(nlTestSuite * aSuite, void * aContext)
static void TestICDModeDurations(nlTestSuite * aSuite, void * aContext)
{
TestContext * ctx = static_cast<TestContext *>(aContext);

// After the init we should be in active mode
NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode);
AdvanceClockAndRunEventLoop(ctx, ICDManagementServer::GetInstance().GetActiveModeIntervalMs() + 1);
AdvanceClockAndRunEventLoop(ctx, ICDManagementServer::GetInstance().GetActiveModeDurationMs() + 1);
// Active mode interval expired, ICDManager transitioned to the IdleMode.
NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode);
AdvanceClockAndRunEventLoop(ctx, secondsToMilliseconds(ICDManagementServer::GetInstance().GetIdleModeIntervalSec()) + 1);
AdvanceClockAndRunEventLoop(ctx, secondsToMilliseconds(ICDManagementServer::GetInstance().GetIdleModeDurationSec()) + 1);
// Idle mode interval expired, ICDManager transitioned to the ActiveMode.
NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode);

// Events updating the Operation to Active mode can extend the current active mode time by 1 Active mode threshold.
// Kick an active Threshold just before the end of the Active interval and validate that the active mode is extended.
AdvanceClockAndRunEventLoop(ctx, ICDManagementServer::GetInstance().GetActiveModeIntervalMs() - 1);
AdvanceClockAndRunEventLoop(ctx, ICDManagementServer::GetInstance().GetActiveModeDurationMs() - 1);
ICDNotifier::GetInstance().BroadcastNetworkActivityNotification();
AdvanceClockAndRunEventLoop(ctx, ICDManagementServer::GetInstance().GetActiveModeThresholdMs() / 2);
NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode);
Expand All @@ -146,7 +146,7 @@ class TestICDManager
notifier.BroadcastActiveRequestNotification(ActiveFlag::kCommissioningWindowOpen);
NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode);
// Advance time so active mode interval expires.
AdvanceClockAndRunEventLoop(ctx, ICDManagementServer::GetInstance().GetActiveModeIntervalMs() + 1);
AdvanceClockAndRunEventLoop(ctx, ICDManagementServer::GetInstance().GetActiveModeDurationMs() + 1);
// Requirement flag still set. We stay in active mode
NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode);

Expand All @@ -160,20 +160,20 @@ class TestICDManager

// Advance time, but by less than the active mode interval and remove the requirement.
// We should stay in active mode.
AdvanceClockAndRunEventLoop(ctx, ICDManagementServer::GetInstance().GetActiveModeIntervalMs() / 2);
AdvanceClockAndRunEventLoop(ctx, ICDManagementServer::GetInstance().GetActiveModeDurationMs() / 2);
notifier.BroadcastActiveRequestWithdrawal(ActiveFlag::kFailSafeArmed);
NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode);

// Advance time again, The activemode interval is completed.
AdvanceClockAndRunEventLoop(ctx, ICDManagementServer::GetInstance().GetActiveModeIntervalMs() + 1);
AdvanceClockAndRunEventLoop(ctx, ICDManagementServer::GetInstance().GetActiveModeDurationMs() + 1);
NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode);

// Set two requirements
notifier.BroadcastActiveRequestNotification(ActiveFlag::kFailSafeArmed);
notifier.BroadcastActiveRequestNotification(ActiveFlag::kExchangeContextOpen);
NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode);
// advance time so the active mode interval expires.
AdvanceClockAndRunEventLoop(ctx, ICDManagementServer::GetInstance().GetActiveModeIntervalMs() + 1);
AdvanceClockAndRunEventLoop(ctx, ICDManagementServer::GetInstance().GetActiveModeDurationMs() + 1);
// A requirement flag is still set. We stay in active mode.
NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode);

Expand All @@ -196,7 +196,7 @@ namespace {
// clang-format off
static const nlTest sTests[] =
{
NL_TEST_DEF("TestICDModeIntervals", TestICDManager::TestICDModeIntervals),
NL_TEST_DEF("TestICDModeDurations", TestICDManager::TestICDModeDurations),
NL_TEST_DEF("TestKeepActivemodeRequests", TestICDManager::TestKeepActivemodeRequests),
NL_TEST_SENTINEL()
};
Expand Down
Loading

0 comments on commit 531f9a3

Please sign in to comment.