Skip to content

Commit

Permalink
Co-authored-by: Boris Zbarsky <[email protected]>
Browse files Browse the repository at this point in the history
Applied comments about #if and clarifying maximum guaranteed stay active
  • Loading branch information
lpbeliveau-silabs committed Feb 22, 2024
1 parent 21329bd commit 55f75e2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -425,15 +425,9 @@ bool emberAfIcdManagementClusterUnregisterClientCallback(CommandHandler * comman
bool emberAfIcdManagementClusterStayActiveRequestCallback(CommandHandler * commandObj, const ConcreteCommandPath & commandPath,
const Commands::StayActiveRequest::DecodableType & commandData)
{
#if CHIP_CONFIG_ENABLE_ICD_SERVER
IcdManagement::Commands::StayActiveResponse::Type response;
response.promisedActiveDuration = Server::GetInstance().GetICDManager().StayActiveRequest(commandData.stayActiveDuration);
commandObj->AddResponse(commandPath, response);
#else
// Note: We only keep this line around for platforms examples that enable the ICD management server without building the sample
// as an ICD.
commandObj->AddStatus(commandPath, InteractionModel::Status::UnsupportedCommand);
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
return true;
}

Expand Down
7 changes: 4 additions & 3 deletions src/app/icd/server/ICDConfigurationData.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ICDConfigurationData

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

System::Clock::Milliseconds32 GetMaxStayActiveDuration() { return kMaxStayActiveDuration; }
System::Clock::Milliseconds32 GetMaxStayActiveDuration() { return kMaxGuaranteedStayActiveDuration; }

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

Expand Down Expand Up @@ -125,8 +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 duration for the StayActiveDuration is 30s (spec 7.5.1)
static constexpr System::Clock::Milliseconds32 kMaxStayActiveDuration = System::Clock::Milliseconds32(30000);
// 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 kMaxGuaranteedStayActiveDuration = 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
4 changes: 2 additions & 2 deletions src/app/icd/server/ICDManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ class ICDManager : public ICDListener
OperationalState GetOperationalState() { return mOperationalState; }

/**
* @brief Extends the Active Mode duration for whichever is smallest between 30000 milliseconds and stayActiveDuration, taking
* in account the remaining active time.
* @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
*/
Expand Down

0 comments on commit 55f75e2

Please sign in to comment.