Skip to content

Commit

Permalink
Use the recommended value to arm failsafe.
Browse files Browse the repository at this point in the history
  • Loading branch information
cecille committed Feb 3, 2022
1 parent 2ed34e7 commit a17e345
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/controller/AutoCommissioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ CHIP_ERROR AutoCommissioner::CommissioningStepFinished(CHIP_ERROR err, Commissio
{
case CommissioningStage::kReadCommissioningInfo:
mDeviceCommissioingInfo = report.Get<ReadCommissioningInfo>();
if (!mParams.GetFailsafeTimerSeconds().HasValue() && mDeviceCommissioingInfo.general.recommendedFailsafe > 0)
{
mParams.SetFailsafeTimerSeconds(mDeviceCommissioingInfo.general.recommendedFailsafe);
}
break;
case CommissioningStage::kSendPAICertificateRequest:
SetPAI(report.Get<RequestedCertificate>().certificate);
Expand Down
5 changes: 2 additions & 3 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1757,12 +1757,11 @@ void DeviceCommissioner::PerformCommissioningStep(DeviceProxy * proxy, Commissio
switch (step)
{
case CommissioningStage::kArmFailsafe: {
ChipLogProgress(Controller, "Arming failsafe");
// TODO: should get the endpoint information from the descriptor cluster.
GeneralCommissioning::Commands::ArmFailSafe::Type request;
request.expiryLengthSeconds = params.GetFailsafeTimerSeconds();
request.expiryLengthSeconds = params.GetFailsafeTimerSeconds().ValueOr(params.kDefaultFailsafeTimeout);
request.breadcrumb = breadcrumb;
request.timeoutMs = kCommandTimeoutMs;
ChipLogProgress(Controller, "Arming failsafe (%u seconds)", request.expiryLengthSeconds);
SendCommand<GeneralCommissioningCluster>(proxy, request, OnArmFailSafe, OnBasicFailure, endpoint, timeout);
}
break;
Expand Down
13 changes: 7 additions & 6 deletions src/controller/CommissioningDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ struct NOCerts
class CommissioningParameters
{
public:
static constexpr size_t kMaxThreadDatasetLen = 254;
static constexpr size_t kMaxSsidLen = 32;
static constexpr size_t kMaxCredentialsLen = 64;
uint16_t GetFailsafeTimerSeconds() const { return mFailsafeTimerSeconds; }
static constexpr size_t kMaxThreadDatasetLen = 254;
static constexpr size_t kMaxSsidLen = 32;
static constexpr size_t kMaxCredentialsLen = 64;
static constexpr uint16_t kDefaultFailsafeTimeout = 60;
const Optional<uint16_t> GetFailsafeTimerSeconds() const { return mFailsafeTimerSeconds; }
const Optional<ByteSpan> GetCSRNonce() const { return mCSRNonce; }
const Optional<ByteSpan> GetAttestationNonce() const { return mAttestationNonce; }
const Optional<WiFiCredentials> GetWiFiCredentials() const { return mWiFiCreds; }
Expand All @@ -98,7 +99,7 @@ class CommissioningParameters

CommissioningParameters & SetFailsafeTimerSeconds(uint16_t seconds)
{
mFailsafeTimerSeconds = seconds;
mFailsafeTimerSeconds.SetValue(seconds);
return *this;
}

Expand Down Expand Up @@ -185,7 +186,7 @@ class CommissioningParameters
void SetCompletionStatus(CHIP_ERROR err) { completionStatus = err; }

private:
uint16_t mFailsafeTimerSeconds = 60;
Optional<uint16_t> mFailsafeTimerSeconds;
Optional<ByteSpan> mCSRNonce; ///< CSR Nonce passed by the commissioner
Optional<ByteSpan> mAttestationNonce; ///< Attestation Nonce passed by the commissioner
Optional<WiFiCredentials> mWiFiCreds;
Expand Down

0 comments on commit a17e345

Please sign in to comment.