From f488b99a5b107aca237658d457b26a5f15ce0c73 Mon Sep 17 00:00:00 2001 From: Jon Smirl Date: Thu, 18 Aug 2022 11:23:37 -0400 Subject: [PATCH] Remove the default constructor for ChipDeviceController(). It is required to set a vendor ID so it must be passed during construction. Also fix typo in onCommissioningStatusUpdate JNI method description. --- .../main/java/com/google/chip/chiptool/ChipClient.kt | 5 ++++- .../java/AndroidDeviceControllerWrapper.cpp | 2 +- .../chip/devicecontroller/ChipDeviceController.java | 11 +++++------ .../src/chip/devicecontroller/ControllerParams.java | 3 ++- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/ChipClient.kt b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/ChipClient.kt index 10d7c32e994a9e..6e3833820716a3 100644 --- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/ChipClient.kt +++ b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/ChipClient.kt @@ -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 @@ -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 } diff --git a/src/controller/java/AndroidDeviceControllerWrapper.cpp b/src/controller/java/AndroidDeviceControllerWrapper.cpp index 8b28896a701d44..ada814133734fc 100644 --- a/src/controller/java/AndroidDeviceControllerWrapper.cpp +++ b/src/controller/java/AndroidDeviceControllerWrapper.cpp @@ -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)); diff --git a/src/controller/java/src/chip/devicecontroller/ChipDeviceController.java b/src/controller/java/src/chip/devicecontroller/ChipDeviceController.java index 97627b56c4ce1f..47c87b364143e3 100644 --- a/src/controller/java/src/chip/devicecontroller/ChipDeviceController.java +++ b/src/controller/java/src/chip/devicecontroller/ChipDeviceController.java @@ -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); } diff --git a/src/controller/java/src/chip/devicecontroller/ControllerParams.java b/src/controller/java/src/chip/devicecontroller/ControllerParams.java index 42fd04f42907de..b0413cf4a8abf0 100644 --- a/src/controller/java/src/chip/devicecontroller/ControllerParams.java +++ b/src/controller/java/src/chip/devicecontroller/ControllerParams.java @@ -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()