Skip to content

Commit

Permalink
Allow null NetworkCredentials in commissionDevice()
Browse files Browse the repository at this point in the history
For IP commissioning, no credentials should be added, but currently the
Java layer requires either a Thread or Wi-Fi network. The underlying
commissioner logic already has safeguards to ensure that a network is
provided unless we are doing IP commissioning.
  • Loading branch information
g-coppock committed Jan 18, 2022
1 parent be806bb commit e167248
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/controller/java/CHIPDeviceController-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,11 @@ JNI_METHOD(void, commissionDevice)
ChipLogProgress(Controller, "commissionDevice() called");

CommissioningParameters commissioningParams = CommissioningParameters();
err = wrapper->ApplyNetworkCredentials(commissioningParams, networkCredentials);
VerifyOrExit(err == CHIP_NO_ERROR, err = CHIP_ERROR_INVALID_ARGUMENT);
if (networkCredentials != nullptr)
{
err = wrapper->ApplyNetworkCredentials(commissioningParams, networkCredentials);
VerifyOrExit(err == CHIP_NO_ERROR, err = CHIP_ERROR_INVALID_ARGUMENT);
}

if (csrNonce != nullptr)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ private native void commissionDevice(
long deviceControllerPtr,
long deviceId,
@Nullable byte[] csrNonce,
NetworkCredentials networkCredentials);
@Nullable NetworkCredentials networkCredentials);

private native void unpairDevice(long deviceControllerPtr, long deviceId);

Expand Down

0 comments on commit e167248

Please sign in to comment.