Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/wifi_RS9116_fixes_for_hardfault_issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bhmanda-silabs authored Feb 26, 2024
2 parents 997e5d5 + 10ff1f6 commit 5673e9d
Show file tree
Hide file tree
Showing 45 changed files with 397 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,10 @@ cluster IcdManagement = 70 {
optional octet_string<16> verificationKey = 1;
}

request struct StayActiveRequestRequest {
int32u stayActiveDuration = 0;
}

response struct StayActiveResponse = 4 {
int32u promisedActiveDuration = 0;
}
Expand All @@ -1346,7 +1350,7 @@ cluster IcdManagement = 70 {
/** Unregister a client from an end device */
fabric command access(invoke: manage) UnregisterClient(UnregisterClientRequest): DefaultSuccess = 2;
/** Request the end device to stay in Active Mode for an additional ActiveModeThreshold */
command access(invoke: manage) StayActiveRequest(): StayActiveResponse = 3;
command access(invoke: manage) StayActiveRequest(StayActiveRequestRequest): StayActiveResponse = 3;
}

endpoint 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,10 @@ cluster IcdManagement = 70 {
optional octet_string<16> verificationKey = 1;
}

request struct StayActiveRequestRequest {
int32u stayActiveDuration = 0;
}

response struct StayActiveResponse = 4 {
int32u promisedActiveDuration = 0;
}
Expand All @@ -1346,7 +1350,7 @@ cluster IcdManagement = 70 {
/** Unregister a client from an end device */
fabric command access(invoke: manage) UnregisterClient(UnregisterClientRequest): DefaultSuccess = 2;
/** Request the end device to stay in Active Mode for an additional ActiveModeThreshold */
command access(invoke: manage) StayActiveRequest(): StayActiveResponse = 3;
command access(invoke: manage) StayActiveRequest(StayActiveRequestRequest): StayActiveResponse = 3;
}

endpoint 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2007,6 +2007,10 @@ cluster IcdManagement = 70 {
optional octet_string<16> verificationKey = 1;
}

request struct StayActiveRequestRequest {
int32u stayActiveDuration = 0;
}

response struct StayActiveResponse = 4 {
int32u promisedActiveDuration = 0;
}
Expand All @@ -2016,7 +2020,7 @@ cluster IcdManagement = 70 {
/** Unregister a client from an end device */
fabric command access(invoke: manage) UnregisterClient(UnregisterClientRequest): DefaultSuccess = 2;
/** Request the end device to stay in Active Mode for an additional ActiveModeThreshold */
command access(invoke: manage) StayActiveRequest(): StayActiveResponse = 3;
command access(invoke: manage) StayActiveRequest(StayActiveRequestRequest): StayActiveResponse = 3;
}

/** Attributes and commands for scene configuration and manipulation. */
Expand Down
6 changes: 5 additions & 1 deletion examples/light-switch-app/qpg/zap/switch.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1804,6 +1804,10 @@ cluster IcdManagement = 70 {
optional octet_string<16> verificationKey = 1;
}

request struct StayActiveRequestRequest {
int32u stayActiveDuration = 0;
}

response struct StayActiveResponse = 4 {
int32u promisedActiveDuration = 0;
}
Expand All @@ -1813,7 +1817,7 @@ cluster IcdManagement = 70 {
/** Unregister a client from an end device */
fabric command access(invoke: manage) UnregisterClient(UnregisterClientRequest): DefaultSuccess = 2;
/** Request the end device to stay in Active Mode for an additional ActiveModeThreshold */
command access(invoke: manage) StayActiveRequest(): StayActiveResponse = 3;
command access(invoke: manage) StayActiveRequest(StayActiveRequestRequest): StayActiveResponse = 3;
}

/** Attributes and commands for scene configuration and manipulation. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,10 @@ cluster IcdManagement = 70 {
optional octet_string<16> verificationKey = 1;
}

request struct StayActiveRequestRequest {
int32u stayActiveDuration = 0;
}

response struct StayActiveResponse = 4 {
int32u promisedActiveDuration = 0;
}
Expand All @@ -1474,7 +1478,7 @@ cluster IcdManagement = 70 {
/** Unregister a client from an end device */
fabric command access(invoke: manage) UnregisterClient(UnregisterClientRequest): DefaultSuccess = 2;
/** Request the end device to stay in Active Mode for an additional ActiveModeThreshold */
command access(invoke: manage) StayActiveRequest(): StayActiveResponse = 3;
command access(invoke: manage) StayActiveRequest(StayActiveRequestRequest): StayActiveResponse = 3;
}

endpoint 0 {
Expand Down
6 changes: 5 additions & 1 deletion examples/lock-app/lock-common/lock-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1825,6 +1825,10 @@ cluster IcdManagement = 70 {
optional octet_string<16> verificationKey = 1;
}

request struct StayActiveRequestRequest {
int32u stayActiveDuration = 0;
}

response struct StayActiveResponse = 4 {
int32u promisedActiveDuration = 0;
}
Expand All @@ -1834,7 +1838,7 @@ cluster IcdManagement = 70 {
/** Unregister a client from an end device */
fabric command access(invoke: manage) UnregisterClient(UnregisterClientRequest): DefaultSuccess = 2;
/** Request the end device to stay in Active Mode for an additional ActiveModeThreshold */
command access(invoke: manage) StayActiveRequest(): StayActiveResponse = 3;
command access(invoke: manage) StayActiveRequest(StayActiveRequestRequest): StayActiveResponse = 3;
}

/** An interface to a generic way to secure a door */
Expand Down
9 changes: 5 additions & 4 deletions examples/lock-app/lock-common/lock-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -2412,10 +2412,10 @@
"side": "server",
"type": "bitmap32",
"included": 1,
"storageOption": "RAM",
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand All @@ -2428,10 +2428,10 @@
"side": "server",
"type": "int16u",
"included": 1,
"storageOption": "RAM",
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x0002",
"defaultValue": null,
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
Expand Down Expand Up @@ -4939,6 +4939,7 @@
"define": "ICD_MANAGEMENT_CLUSTER",
"side": "server",
"enabled": 1,
"commands": [],
"attributes": [
{
"name": "IdleModeDuration",
Expand Down
6 changes: 5 additions & 1 deletion examples/lock-app/qpg/zap/lock.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,10 @@ cluster IcdManagement = 70 {
optional octet_string<16> verificationKey = 1;
}

request struct StayActiveRequestRequest {
int32u stayActiveDuration = 0;
}

response struct StayActiveResponse = 4 {
int32u promisedActiveDuration = 0;
}
Expand All @@ -1490,7 +1494,7 @@ cluster IcdManagement = 70 {
/** Unregister a client from an end device */
fabric command access(invoke: manage) UnregisterClient(UnregisterClientRequest): DefaultSuccess = 2;
/** Request the end device to stay in Active Mode for an additional ActiveModeThreshold */
command access(invoke: manage) StayActiveRequest(): StayActiveResponse = 3;
command access(invoke: manage) StayActiveRequest(StayActiveRequestRequest): StayActiveResponse = 3;
}

/** An interface to a generic way to secure a door */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1801,6 +1801,10 @@ cluster IcdManagement = 70 {
optional octet_string<16> verificationKey = 1;
}

request struct StayActiveRequestRequest {
int32u stayActiveDuration = 0;
}

response struct StayActiveResponse = 4 {
int32u promisedActiveDuration = 0;
}
Expand All @@ -1810,7 +1814,7 @@ cluster IcdManagement = 70 {
/** Unregister a client from an end device */
fabric command access(invoke: manage) UnregisterClient(UnregisterClientRequest): DefaultSuccess = 2;
/** Request the end device to stay in Active Mode for an additional ActiveModeThreshold */
command access(invoke: manage) StayActiveRequest(): StayActiveResponse = 3;
command access(invoke: manage) StayActiveRequest(StayActiveRequestRequest): StayActiveResponse = 3;
}

/** This cluster provides an interface for observing and managing the state of smoke and CO alarms. */
Expand Down
6 changes: 5 additions & 1 deletion examples/window-app/common/window-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1899,6 +1899,10 @@ cluster IcdManagement = 70 {
optional octet_string<16> verificationKey = 1;
}

request struct StayActiveRequestRequest {
int32u stayActiveDuration = 0;
}

response struct StayActiveResponse = 4 {
int32u promisedActiveDuration = 0;
}
Expand All @@ -1908,7 +1912,7 @@ cluster IcdManagement = 70 {
/** Unregister a client from an end device */
fabric command access(invoke: manage) UnregisterClient(UnregisterClientRequest): DefaultSuccess = 2;
/** Request the end device to stay in Active Mode for an additional ActiveModeThreshold */
command access(invoke: manage) StayActiveRequest(): StayActiveResponse = 3;
command access(invoke: manage) StayActiveRequest(StayActiveRequestRequest): StayActiveResponse = 3;
}

/** Provides an interface for controlling and adjusting automatic window coverings. */
Expand Down
20 changes: 8 additions & 12 deletions src/app/clusters/icd-management-server/icd-management-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,6 @@ void ICDManagementServer::TriggerICDMTableUpdatedEvent()

#endif // CHIP_CONFIG_ENABLE_ICD_CIP

Status ICDManagementServer::StayActiveRequest(FabricIndex fabricIndex)
{
// TODO: Implementent stay awake logic for end device
// https://github.com/project-chip/connectedhomeip/issues/24259
ICDNotifier::GetInstance().NotifyICDManagementEvent(ICDListener::ICDManagementEvents::kStayActiveRequestReceived);
return InteractionModel::Status::UnsupportedCommand;
}

void ICDManagementServer::Init(PersistentStorageDelegate & storage, Crypto::SymmetricKeystore * symmetricKeystore,
ICDConfigurationData & icdConfigurationData)
{
Expand Down Expand Up @@ -433,10 +425,14 @@ bool emberAfIcdManagementClusterUnregisterClientCallback(CommandHandler * comman
bool emberAfIcdManagementClusterStayActiveRequestCallback(CommandHandler * commandObj, const ConcreteCommandPath & commandPath,
const Commands::StayActiveRequest::DecodableType & commandData)
{
ICDManagementServer server;
InteractionModel::Status status = server.StayActiveRequest(commandObj->GetAccessingFabricIndex());

commandObj->AddStatus(commandPath, status);
// Note: We only need this #if statement for platform examples that enable the ICD management server without building the sample
// as an ICD. Since this is not spec compliant, we should remove this #if statement once we stop compiling the ICD management
// server in those examples.
#if CHIP_CONFIG_ENABLE_ICD_SERVER
IcdManagement::Commands::StayActiveResponse::Type response;
response.promisedActiveDuration = Server::GetInstance().GetICDManager().StayActiveRequest(commandData.stayActiveDuration);
commandObj->AddResponse(commandPath, response);
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ class ICDManagementServer
const chip::app::Clusters::IcdManagement::Commands::UnregisterClient::DecodableType & commandData);
#endif // CHIP_CONFIG_ENABLE_ICD_CIP

chip::Protocols::InteractionModel::Status StayActiveRequest(chip::FabricIndex fabricIndex);

private:
#if CHIP_CONFIG_ENABLE_ICD_CIP
/**
Expand Down
5 changes: 5 additions & 0 deletions src/app/icd/server/ICDConfigurationData.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class ICDConfigurationData

System::Clock::Milliseconds16 GetActiveModeThreshold() { return mActiveThreshold; }

System::Clock::Milliseconds32 GetGuaranteedStayActiveDuration() { return kGuaranteedStayActiveDuration; }

Protocols::SecureChannel::CheckInCounter & GetICDCounter() { return mICDCounter; }

uint16_t GetClientsSupportedPerFabric() { return mFabricClientsSupported; }
Expand Down Expand Up @@ -123,6 +125,9 @@ class ICDConfigurationData

static constexpr System::Clock::Seconds32 kMaxIdleModeDuration = System::Clock::Seconds32(18 * kSecondsPerHour);
static constexpr System::Clock::Seconds32 kMinIdleModeDuration = System::Clock::Seconds32(1);
// As defined in the spec, the maximum guaranteed duration for the StayActiveDuration is 30s "Matter Application
// Clusters: 9.17.7.5.1. PromisedActiveDuration Field"
static constexpr System::Clock::Milliseconds32 kGuaranteedStayActiveDuration = System::Clock::Milliseconds32(30000);

static_assert((CHIP_CONFIG_ICD_IDLE_MODE_DURATION_SEC) <= kMaxIdleModeDuration.count(),
"Spec requires the IdleModeDuration to be equal or inferior to 64800s.");
Expand Down
46 changes: 30 additions & 16 deletions src/app/icd/server/ICDManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,22 @@ bool ICDManager::SupportsFeature(Feature feature)
#endif // !CONFIG_BUILD_FOR_HOST_UNIT_TEST
}

uint32_t ICDManager::StayActiveRequest(uint32_t stayActiveDuration)
{
// This should only be called when the device is in ActiveMode
VerifyOrReturnValue(mOperationalState == OperationalState::ActiveMode, 0);

uint32_t promisedActiveDuration =
std::min(ICDConfigurationData::GetInstance().GetGuaranteedStayActiveDuration().count(), stayActiveDuration);

// If the device is already in ActiveMode, we need to extend the active mode duration
// for whichever is smallest between 30000 milliseconds and stayActiveDuration, taking in account the remaining active time.
ExtendActiveMode(System::Clock::Milliseconds16(promisedActiveDuration));
promisedActiveDuration = DeviceLayer::SystemLayer().GetRemainingTime(OnActiveModeDone, this).count();

return promisedActiveDuration;
}

#if CHIP_CONFIG_ENABLE_ICD_CIP
void ICDManager::SendCheckInMsgs()
{
Expand Down Expand Up @@ -366,17 +382,7 @@ void ICDManager::UpdateOperationState(OperationalState state)
}
else
{
Milliseconds16 activeModeThreshold = ICDConfigurationData::GetInstance().GetActiveModeThreshold();
DeviceLayer::SystemLayer().ExtendTimerTo(activeModeThreshold, OnActiveModeDone, this);

Milliseconds32 activeModeJitterThreshold = Milliseconds32(ICD_ACTIVE_TIME_JITTER_MS);
activeModeJitterThreshold =
(activeModeThreshold >= activeModeJitterThreshold) ? activeModeThreshold - activeModeJitterThreshold : kZero;

if (!mTransitionToIdleCalled)
{
DeviceLayer::SystemLayer().ExtendTimerTo(activeModeJitterThreshold, OnTransitionToIdle, this);
}
ExtendActiveMode(ICDConfigurationData::GetInstance().GetActiveModeThreshold());
}
}
}
Expand Down Expand Up @@ -521,11 +527,6 @@ void ICDManager::OnICDManagementServerEvent(ICDManagementEvents event)
case ICDManagementEvents::kTableUpdated:
this->UpdateICDMode();
break;

case ICDManagementEvents::kStayActiveRequestReceived:
// TODO : Implement the StayActiveRequest
// https://github.com/project-chip/connectedhomeip/issues/24259
break;
default:
break;
}
Expand All @@ -540,6 +541,19 @@ void ICDManager::OnSubscriptionReport()
this->UpdateOperationState(OperationalState::ActiveMode);
}

void ICDManager::ExtendActiveMode(Milliseconds16 extendDuration)
{
DeviceLayer::SystemLayer().ExtendTimerTo(extendDuration, OnActiveModeDone, this);

Milliseconds32 activeModeJitterThreshold = Milliseconds32(ICD_ACTIVE_TIME_JITTER_MS);
activeModeJitterThreshold = (extendDuration >= activeModeJitterThreshold) ? extendDuration - activeModeJitterThreshold : kZero;

if (!mTransitionToIdleCalled)
{
DeviceLayer::SystemLayer().ExtendTimerTo(activeModeJitterThreshold, OnTransitionToIdle, this);
}
}

ICDManager::ObserverPointer * ICDManager::RegisterObserver(ICDStateObserver * observer)
{
return mStateObserverPool.CreateObject(observer);
Expand Down
14 changes: 14 additions & 0 deletions src/app/icd/server/ICDManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ class ICDManager : public ICDListener
void postObserverEvent(ObserverEventType event);
OperationalState GetOperationalState() { return mOperationalState; }

/**
* @brief Ensures that the remaining Active Mode duration is at least the smaller of 30000 milliseconds and stayActiveDuration.
*
* @param stayActiveDuration The duration (in milliseconds) requested by the client to stay in Active Mode
* @return The duration (in milliseconds) the device will stay in Active Mode
*/
uint32_t StayActiveRequest(uint32_t stayActiveDuration);

#if CHIP_CONFIG_ENABLE_ICD_CIP
void SendCheckInMsgs();

Expand All @@ -131,6 +139,12 @@ class ICDManager : public ICDListener
void OnSubscriptionReport() override;

protected:
/**
* @brief Hepler function that extends the Active Mode duration as well as the Active Mode Jitter timer for the transition to
* iddle mode.
*/
void ExtendActiveMode(System::Clock::Milliseconds16 extendDuration);

friend class TestICDManager;

static void OnIdleModeDone(System::Layer * aLayer, void * appState);
Expand Down
3 changes: 1 addition & 2 deletions src/app/icd/server/ICDNotifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ class ICDListener

enum class ICDManagementEvents : uint8_t
{
kTableUpdated = 0x01,
kStayActiveRequestReceived = 0x02,
kTableUpdated = 0x01,
};

using KeepActiveFlags = BitFlags<KeepActiveFlagsValues>;
Expand Down
Loading

0 comments on commit 5673e9d

Please sign in to comment.