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

Allow null NetworkCredentials in commissionDevice() #13655

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
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 @@ -141,7 +141,7 @@ public void establishPaseConnection(long deviceId, String address, int port, lon
* @param deviceId the ID of the node to be commissioned
* @param networkCredentials the credentials (Wi-Fi or Thread) to be provisioned
*/
public void commissionDevice(long deviceId, NetworkCredentials networkCredentials) {
public void commissionDevice(long deviceId, @Nullable NetworkCredentials networkCredentials) {
commissionDevice(deviceControllerPtr, deviceId, /* csrNonce= */ null, networkCredentials);
}

Expand All @@ -155,7 +155,7 @@ public void commissionDevice(long deviceId, NetworkCredentials networkCredential
* @param networkCredentials the credentials (Wi-Fi or Thread) to be provisioned
*/
public void commissionDevice(
long deviceId, @Nullable byte[] csrNonce, NetworkCredentials networkCredentials) {
long deviceId, @Nullable byte[] csrNonce, @Nullable NetworkCredentials networkCredentials) {
commissionDevice(deviceControllerPtr, deviceId, csrNonce, networkCredentials);
}

Expand Down 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