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

Fixes related to PASE-only commissioning on Android #22140

Merged
merged 7 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
18 changes: 18 additions & 0 deletions src/controller/AutoCommissioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ CHIP_ERROR AutoCommissioner::SetCommissioningParameters(const CommissioningParam
}
mParams.SetCSRNonce(ByteSpan(mCSRNonce, sizeof(mCSRNonce)));

if (params.GetPASEOnlyCommissioning().HasValue())
{
ChipLogProgress(Controller, "Setting PASE-only commissioning from parameters");
mParams.SetPASEOnlyCommissioning(params.GetPASEOnlyCommissioning().Value());
}

return CHIP_NO_ERROR;
}

Expand Down Expand Up @@ -252,6 +258,10 @@ CommissioningStage AutoCommissioner::GetNextCommissioningStageInternal(Commissio
}
else
{
if (mParams.GetPASEOnlyCommissioning().ValueOr(false))
{
return CommissioningStage::kCleanup;
}
return CommissioningStage::kFindOperational;
}
case CommissioningStage::kWiFiNetworkSetup:
Expand Down Expand Up @@ -280,11 +290,19 @@ CommissioningStage AutoCommissioner::GetNextCommissioningStageInternal(Commissio
{
return CommissioningStage::kThreadNetworkEnable;
}
else if (mParams.GetPASEOnlyCommissioning().ValueOr(false))
{
return CommissioningStage::kCleanup;
}
else
{
return CommissioningStage::kFindOperational;
}
case CommissioningStage::kThreadNetworkEnable:
if (mParams.GetPASEOnlyCommissioning().ValueOr(false))
{
return CommissioningStage::kCleanup;
}
return CommissioningStage::kFindOperational;
case CommissioningStage::kFindOperational:
return CommissioningStage::kSendComplete;
chrisdecenzo marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
5 changes: 5 additions & 0 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1551,6 +1551,11 @@ void DeviceCommissioner::CommissioningStageComplete(CHIP_ERROR err, Commissionin
{
// Once this stage is complete, reset mDeviceBeingCommissioned - this will be reset when the delegate calls the next step.
MATTER_TRACE_EVENT_SCOPE("CommissioningStageComplete", "DeviceCommissioner");
if (mDeviceBeingCommissioned == nullptr)
{
ChipLogProgress(Controller, "CommissioningStageComplete with null mDeviceBeingCommissioned");
chrisdecenzo marked this conversation as resolved.
Show resolved Hide resolved
return;
}
NodeId nodeId = mDeviceBeingCommissioned->GetDeviceId();
DeviceProxy * proxy = mDeviceBeingCommissioned;
mDeviceBeingCommissioned = nullptr;
Expand Down
4 changes: 4 additions & 0 deletions src/controller/CommissioningDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ const char * StageToString(CommissioningStage stage)
return "Cleanup";
break;

case kNeedsNetworkCreds:
return "NeedsNetworkCreds";
break;

default:
return "???";
break;
Expand Down
10 changes: 10 additions & 0 deletions src/controller/CommissioningDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,15 @@ class CommissioningParameters
return *this;
}

// Only perform the PASE steps of commissioning.
// Commissioning will be completed by another admin on the network.
Optional<bool> GetPASEOnlyCommissioning() const { return mPASEOnlyCommissioning; }
CommissioningParameters & SetPASEOnlyCommissioning(bool paseOnlyCommissioning)
{
mPASEOnlyCommissioning = MakeOptional(paseOnlyCommissioning);
return *this;
}

private:
// Items that can be set by the commissioner
Optional<uint16_t> mFailsafeTimerSeconds;
Expand Down Expand Up @@ -407,6 +416,7 @@ class CommissioningParameters
nullptr; // Delegate to handle device attestation failures during commissioning
Optional<bool> mAttemptWiFiNetworkScan;
Optional<bool> mAttemptThreadNetworkScan; // This automatically gets set to false when a ThreadOperationalDataset is set
Optional<bool> mPASEOnlyCommissioning;
chrisdecenzo marked this conversation as resolved.
Show resolved Hide resolved
};

struct RequestedCertificate
Expand Down
7 changes: 4 additions & 3 deletions src/controller/java/CHIPDeviceController-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ JNI_METHOD(void, commissionDevice)

ChipLogProgress(Controller, "commissionDevice() called");

CommissioningParameters commissioningParams = CommissioningParameters();
CommissioningParameters commissioningParams = wrapper->GetCommissioningParameters();
if (networkCredentials != nullptr)
{
err = wrapper->ApplyNetworkCredentials(commissioningParams, networkCredentials);
Expand Down Expand Up @@ -417,7 +417,7 @@ JNI_METHOD(void, pairDevice)
#endif
.SetPeerAddress(Transport::PeerAddress::BLE());

CommissioningParameters commissioningParams = CommissioningParameters();
CommissioningParameters commissioningParams = wrapper->GetCommissioningParameters();
wrapper->ApplyNetworkCredentials(commissioningParams, networkCredentials);

if (csrNonce != nullptr)
Expand Down Expand Up @@ -451,7 +451,8 @@ JNI_METHOD(void, pairDeviceWithAddress)
.SetDiscriminator(discriminator)
.SetSetupPINCode(pinCode)
.SetPeerAddress(Transport::PeerAddress::UDP(const_cast<char *>(addrJniString.c_str()), port));
CommissioningParameters commissioningParams = CommissioningParameters();

CommissioningParameters commissioningParams = wrapper->GetCommissioningParameters();
if (csrNonce != nullptr)
{
JniByteArray jniCsrNonce(env, csrNonce);
Expand Down