Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add target endpoint to CommissioningWindowOpener #34425

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ CHIP_ERROR OpenCommissioningWindowCommand::RunCommand()
VerifyOrReturnError(mSalt.HasValue(), CHIP_ERROR_INVALID_ARGUMENT);
return mWindowOpener->OpenCommissioningWindow(Controller::CommissioningWindowVerifierParams()
.SetNodeId(mNodeId)
.SetEndpointId(mEndpointId)
.SetTimeout(mCommissioningWindowTimeout)
.SetIteration(mIteration)
.SetDiscriminator(mDiscriminator)
Expand All @@ -50,6 +51,7 @@ CHIP_ERROR OpenCommissioningWindowCommand::RunCommand()
SetupPayload ignored;
return mWindowOpener->OpenCommissioningWindow(Controller::CommissioningWindowPasscodeParams()
.SetNodeId(mNodeId)
.SetEndpointId(mEndpointId)
.SetTimeout(mCommissioningWindowTimeout)
.SetIteration(mIteration)
.SetDiscriminator(mDiscriminator)
Expand Down
6 changes: 3 additions & 3 deletions src/controller/CommissioningWindowOpener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ CHIP_ERROR CommissioningWindowOpener::OpenCommissioningWindow(const Commissionin
mCommissioningWindowVerifierCallback = nullptr;
mNodeId = params.GetNodeId();
mCommissioningWindowTimeout = params.GetTimeout();
mTargetEndpointId = params.GetEndpointId();

if (params.GetReadVIDPIDAttributes())
{
Expand Down Expand Up @@ -162,6 +163,7 @@ CHIP_ERROR CommissioningWindowOpener::OpenCommissioningWindow(const Commissionin
mPBKDFIterations = params.GetIteration();
mCommissioningWindowOption = CommissioningWindowOption::kTokenWithProvidedPIN;
mDiscriminator.SetLongValue(params.GetDiscriminator());
mTargetEndpointId = params.GetEndpointId();

mNextStep = Step::kOpenCommissioningWindow;

Expand All @@ -173,9 +175,7 @@ CHIP_ERROR CommissioningWindowOpener::OpenCommissioningWindowInternal(Messaging:
{
ChipLogProgress(Controller, "OpenCommissioningWindow for device ID 0x" ChipLogFormatX64, ChipLogValueX64(mNodeId));

constexpr EndpointId kAdministratorCommissioningClusterEndpoint = 0;

ClusterBase cluster(exchangeMgr, sessionHandle, kAdministratorCommissioningClusterEndpoint);
ClusterBase cluster(exchangeMgr, sessionHandle, mTargetEndpointId);

if (mCommissioningWindowOption != CommissioningWindowOption::kOriginalSetupCode)
{
Expand Down
3 changes: 2 additions & 1 deletion src/controller/CommissioningWindowOpener.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ class CommissioningWindowOpener
Callback::Callback<OnOpenBasicCommissioningWindow> * mBasicCommissioningWindowCallback = nullptr;
SetupPayload mSetupPayload;
SetupDiscriminator mDiscriminator{};
NodeId mNodeId = kUndefinedNodeId;
NodeId mNodeId = kUndefinedNodeId;
EndpointId mTargetEndpointId = kRootEndpointId; // Default endpoint for Administrator Commissioning Cluster
System::Clock::Seconds16 mCommissioningWindowTimeout = System::Clock::kZero;
CommissioningWindowOption mCommissioningWindowOption = CommissioningWindowOption::kOriginalSetupCode;
Crypto::Spake2pVerifier mVerifier; // Used for non-basic commissioning.
Expand Down
9 changes: 9 additions & 0 deletions src/controller/CommissioningWindowParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <lib/core/CHIPCallback.h>
#include <lib/core/CHIPError.h>
#include <lib/core/DataModelTypes.h>
#include <lib/core/NodeId.h>
#include <lib/core/Optional.h>
#include <lib/support/Span.h>
Expand Down Expand Up @@ -53,6 +54,13 @@ class CommissioningWindowCommonParams
return static_cast<Derived &>(*this);
}

EndpointId GetEndpointId() const { return mEndpointId; }
Derived & SetEndpointId(EndpointId endpointId)
{
mEndpointId = endpointId;
return static_cast<Derived &>(*this);
}

System::Clock::Seconds16 GetTimeout() const { return mTimeout; }
// The duration for which the commissioning window should remain open.
Derived & SetTimeout(System::Clock::Seconds16 timeout)
Expand Down Expand Up @@ -82,6 +90,7 @@ class CommissioningWindowCommonParams

private:
NodeId mNodeId = kUndefinedNodeId;
EndpointId mEndpointId = kRootEndpointId; // Default endpoint for Administrator Commissioning Cluster
System::Clock::Seconds16 mTimeout = System::Clock::Seconds16(300); // Defaulting
uint32_t mIteration = 1000; // Defaulting
Optional<uint16_t> mDiscriminator = NullOptional; // Using optional type to avoid picking a sentinnel in valid range
Expand Down
Loading