Skip to content

Commit

Permalink
Remove the default constructor for ChipDeviceController(). It is requ…
Browse files Browse the repository at this point in the history
…ired to set a vendor ID (#21980)

so it must be passed during construction. Also fix typo in onCommissioningStatusUpdate
JNI method description.
  • Loading branch information
jonsmirl authored Aug 22, 2022
1 parent 9713e10 commit 7c53493
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package com.google.chip.chiptool
import android.content.Context
import android.util.Log
import chip.devicecontroller.ChipDeviceController
import chip.devicecontroller.ControllerParams
import chip.devicecontroller.GetConnectedDeviceCallbackJni.GetConnectedDeviceCallback
import chip.platform.AndroidBleManager
import chip.platform.AndroidChipPlatform
Expand All @@ -38,12 +39,14 @@ object ChipClient {
private const val TAG = "ChipClient"
private lateinit var chipDeviceController: ChipDeviceController
private lateinit var androidPlatform: AndroidChipPlatform
/* 0xFFF4 is a test vendor ID, replace with your assigned company ID */
private const val VENDOR_ID = 0xFFF4

fun getDeviceController(context: Context): ChipDeviceController {
getAndroidChipPlatform(context)

if (!this::chipDeviceController.isInitialized) {
chipDeviceController = ChipDeviceController()
chipDeviceController = ChipDeviceController(ControllerParams.newBuilder().setControllerVendorId(VENDOR_ID).build())
}
return chipDeviceController
}
Expand Down
2 changes: 1 addition & 1 deletion src/controller/java/AndroidDeviceControllerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ void AndroidDeviceControllerWrapper::OnCommissioningStatusUpdate(PeerId peerId,
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
jmethodID onCommissioningStatusUpdateMethod;
CHIP_ERROR err = JniReferences::GetInstance().FindMethod(env, mJavaObjectRef, "onCommissioningStatusUpdate",
"(JLjava/lang/string;I)V", &onCommissioningStatusUpdateMethod);
"(JLjava/lang/String;I)V", &onCommissioningStatusUpdateMethod);
VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Controller, "Error finding Java method: %" CHIP_ERROR_FORMAT, err.Format()));

UtfString jStageCompleted(env, StageToString(stageCompleted));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,11 @@ public static void loadJni() {
return;
}

/** Returns a new {@link ChipDeviceController} with default parameters. */
public ChipDeviceController() {
this(ControllerParams.newBuilder().build());
}

/** Returns a new {@link ChipDeviceController} with the specified parameters. */
/**
* Returns a new {@link ChipDeviceController} with the specified parameters. you must set a vendor
* ID, ControllerParams.newBuilder().setControllerVendorId(0xFFF4).build() 0xFFF4 is a test vendor
* ID
*/
public ChipDeviceController(ControllerParams params) {
deviceControllerPtr = newDeviceController(params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public static Builder newBuilder() {

/**
* Returns parameters which uses the provided {@code operationalKeyConfig} as its operating
* credentials.
* credentials. You must set a vendor ID, 0xFFF4 is a test vendor ID
* ControllerParams.newBuilder().setControllerVendorId(0xFFF4).build()
*/
public static Builder newBuilder(OperationalKeyConfig operationalKeyConfig) {
return newBuilder()
Expand Down

0 comments on commit 7c53493

Please sign in to comment.