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

These two fixes are needed to get Android chip-tool working again #21980

Merged
merged 2 commits into from
Aug 22, 2022
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
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