diff --git a/src/controller/CommissioningWindowOpener.cpp b/src/controller/CommissioningWindowOpener.cpp index 37364883730293..e8d1b29cb6437d 100644 --- a/src/controller/CommissioningWindowOpener.cpp +++ b/src/controller/CommissioningWindowOpener.cpp @@ -126,10 +126,7 @@ CHIP_ERROR CommissioningWindowOpener::OpenCommissioningWindow(const Commissionin mCommissioningWindowVerifierCallback = nullptr; mNodeId = params.GetNodeId(); mCommissioningWindowTimeout = params.GetTimeout(); - if (params.HasEndpointId()) - { - mTargetEndpointId = params.GetEndpointId(); - } + mTargetEndpointId = params.GetEndpointId(); if (params.GetReadVIDPIDAttributes()) { @@ -166,10 +163,7 @@ CHIP_ERROR CommissioningWindowOpener::OpenCommissioningWindow(const Commissionin mPBKDFIterations = params.GetIteration(); mCommissioningWindowOption = CommissioningWindowOption::kTokenWithProvidedPIN; mDiscriminator.SetLongValue(params.GetDiscriminator()); - if (params.HasEndpointId()) - { - mTargetEndpointId = params.GetEndpointId(); - } + mTargetEndpointId = params.GetEndpointId(); mNextStep = Step::kOpenCommissioningWindow; diff --git a/src/controller/CommissioningWindowParams.h b/src/controller/CommissioningWindowParams.h index 5acfe156b8b91b..c845ecf2c80135 100644 --- a/src/controller/CommissioningWindowParams.h +++ b/src/controller/CommissioningWindowParams.h @@ -54,11 +54,10 @@ class CommissioningWindowCommonParams return static_cast(*this); } - bool HasEndpointId() const { return mEndpointId.HasValue(); } - EndpointId GetEndpointId() const { return mEndpointId.Value(); } + EndpointId GetEndpointId() const { return mEndpointId; } Derived & SetEndpointId(EndpointId endpointId) { - mEndpointId = MakeOptional(endpointId); + mEndpointId = endpointId; return static_cast(*this); } @@ -91,7 +90,7 @@ class CommissioningWindowCommonParams private: NodeId mNodeId = kUndefinedNodeId; - Optional mEndpointId = NullOptional; + EndpointId mEndpointId = kRootEndpointId; // Default endpoint for Administrator Commissioning Cluster System::Clock::Seconds16 mTimeout = System::Clock::Seconds16(300); // Defaulting uint32_t mIteration = 1000; // Defaulting Optional mDiscriminator = NullOptional; // Using optional type to avoid picking a sentinnel in valid range