Skip to content

Commit 3559bdc

Browse files
Plumb ActiveModeDuration, ActiveModeThreshold, IdleModeDuration to android (project-chip#32768)
1 parent 3a39c29 commit 3559bdc

File tree

4 files changed

+44
-3
lines changed

4 files changed

+44
-3
lines changed

examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/provisioning/DeviceProvisioningFragment.kt

+5-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,11 @@ class DeviceProvisioningFragment : Fragment() {
303303
requireActivity(),
304304
getString(
305305
R.string.icd_registration_completed,
306-
icdDeviceInfo.userActiveModeTriggerHint.toString()
306+
icdDeviceInfo.userActiveModeTriggerHint.toString(),
307+
icdDeviceInfo.userActiveModeTriggerInstruction,
308+
icdDeviceInfo.idleModeDuration.toString(),
309+
icdDeviceInfo.activeModeDuration.toString(),
310+
icdDeviceInfo.activeModeThreshold.toString()
307311
),
308312
Toast.LENGTH_LONG
309313
)

src/controller/java/AndroidDeviceControllerWrapper.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,9 @@ void AndroidDeviceControllerWrapper::OnReadCommissioningInfo(const chip::Control
791791
memset(mUserActiveModeTriggerInstructionBuffer, 0x00, kUserActiveModeTriggerInstructionBufferLen);
792792
CopyCharSpanToMutableCharSpan(info.icd.userActiveModeTriggerInstruction, mUserActiveModeTriggerInstruction);
793793

794+
ChipLogProgress(AppServer, "OnReadCommissioningInfo ICD - IdleModeDuration=%u activeModeDuration=%u activeModeThreshold=%u",
795+
info.icd.idleModeDuration, info.icd.activeModeDuration, info.icd.activeModeThreshold);
796+
794797
env->CallVoidMethod(mJavaObjectRef.ObjectRef(), onReadCommissioningInfoMethod, static_cast<jint>(info.basic.vendorId),
795798
static_cast<jint>(info.basic.productId), static_cast<jint>(info.network.wifi.endpoint),
796799
static_cast<jint>(info.network.thread.endpoint));
@@ -1035,7 +1038,7 @@ void AndroidDeviceControllerWrapper::OnICDRegistrationComplete(chip::NodeId icdN
10351038
methodErr = chip::JniReferences::GetInstance().GetLocalClassRef(env, "chip/devicecontroller/ICDDeviceInfo", icdDeviceInfoClass);
10361039
VerifyOrReturn(methodErr == CHIP_NO_ERROR, ChipLogError(Controller, "Could not find class ICDDeviceInfo"));
10371040

1038-
icdDeviceInfoStructCtor = env->GetMethodID(icdDeviceInfoClass, "<init>", "([BILjava/lang/String;JJJJI)V");
1041+
icdDeviceInfoStructCtor = env->GetMethodID(icdDeviceInfoClass, "<init>", "([BILjava/lang/String;JJIJJJJI)V");
10391042
VerifyOrReturn(icdDeviceInfoStructCtor != nullptr, ChipLogError(Controller, "Could not find ICDDeviceInfo constructor"));
10401043

10411044
methodErr =
@@ -1047,7 +1050,8 @@ void AndroidDeviceControllerWrapper::OnICDRegistrationComplete(chip::NodeId icdN
10471050

10481051
icdDeviceInfoObj = env->NewObject(
10491052
icdDeviceInfoClass, icdDeviceInfoStructCtor, jSymmetricKey, static_cast<jint>(mUserActiveModeTriggerHint.Raw()),
1050-
jUserActiveModeTriggerInstruction, static_cast<jlong>(icdNodeId), static_cast<jlong>(icdCounter),
1053+
jUserActiveModeTriggerInstruction, static_cast<jlong>(mIdleModeDuration), static_cast<jlong>(mActiveModeDuration),
1054+
static_cast<jint>(mActiveModeThreshold), static_cast<jlong>(icdNodeId), static_cast<jlong>(icdCounter),
10511055
static_cast<jlong>(mAutoCommissioner.GetCommissioningParameters().GetICDMonitoredSubject().Value()),
10521056
static_cast<jlong>(Controller()->GetFabricId()), static_cast<jint>(Controller()->GetFabricIndex()));
10531057

src/controller/java/AndroidDeviceControllerWrapper.h

+3
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ class AndroidDeviceControllerWrapper : public chip::Controller::DevicePairingDel
271271
chip::MutableCharSpan mUserActiveModeTriggerInstruction = chip::MutableCharSpan(mUserActiveModeTriggerInstructionBuffer);
272272
chip::BitMask<chip::app::Clusters::IcdManagement::UserActiveModeTriggerBitmap> mUserActiveModeTriggerHint;
273273

274+
uint32_t mIdleModeDuration = 0;
275+
uint32_t mActiveModeDuration = 0;
276+
uint16_t mActiveModeThreshold = 0;
274277
chip::Controller::CommissioningParameters mCommissioningParameter;
275278

276279
AndroidDeviceControllerWrapper(ChipDeviceControllerPtr controller,

src/controller/java/src/chip/devicecontroller/ICDDeviceInfo.java

+30
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ public int getBitIndex() {
5656
private final byte[] symmetricKey;
5757
private final Set<UserActiveModeTriggerBitmap> userActiveModeTriggerHint;
5858
private final String userActiveModeTriggerInstruction;
59+
private final long idleModeDuration;
60+
private final long activeModeDuration;
61+
private final int activeModeThreshold;
5962
private final long icdNodeId;
6063
private final long icdCounter;
6164
private final long monitoredSubject;
@@ -66,6 +69,9 @@ public int getBitIndex() {
6669
byte[] symmetricKey,
6770
Set<UserActiveModeTriggerBitmap> userActiveModeTriggerHint,
6871
String userActiveModeTriggerInstruction,
72+
long idleModeDuration,
73+
long activeModeDuration,
74+
int activeModeThreshold,
6975
long icdNodeId,
7076
long icdCounter,
7177
long monitoredSubject,
@@ -74,6 +80,9 @@ public int getBitIndex() {
7480
this.symmetricKey = symmetricKey;
7581
this.userActiveModeTriggerHint = userActiveModeTriggerHint;
7682
this.userActiveModeTriggerInstruction = userActiveModeTriggerInstruction;
83+
this.idleModeDuration = idleModeDuration;
84+
this.activeModeDuration = activeModeDuration;
85+
this.activeModeThreshold = activeModeThreshold;
7786
this.icdNodeId = icdNodeId;
7887
this.icdCounter = icdCounter;
7988
this.monitoredSubject = monitoredSubject;
@@ -85,13 +94,19 @@ public int getBitIndex() {
8594
byte[] symmetricKey,
8695
int userActiveModeTriggerHintRaw,
8796
String userActiveModeTriggerInstruction,
97+
long idleModeDuration,
98+
long activeModeDuration,
99+
int activeModeThreshold,
88100
long icdNodeId,
89101
long icdCounter,
90102
long monitoredSubject,
91103
long fabricId,
92104
int fabricIndex) {
93105
this.symmetricKey = symmetricKey;
94106
this.userActiveModeTriggerInstruction = userActiveModeTriggerInstruction;
107+
this.idleModeDuration = idleModeDuration;
108+
this.activeModeDuration = activeModeDuration;
109+
this.activeModeThreshold = activeModeThreshold;
95110
this.icdNodeId = icdNodeId;
96111
this.icdCounter = icdCounter;
97112
this.monitoredSubject = monitoredSubject;
@@ -122,6 +137,21 @@ public String getUserActiveModeTriggerInstruction() {
122137
return userActiveModeTriggerInstruction;
123138
}
124139

140+
/** Returns the GetIdleModeDuration. */
141+
public long getIdleModeDuration() {
142+
return idleModeDuration;
143+
}
144+
145+
/** Returns the GetActiveModeDuration. */
146+
public long getActiveModeDuration() {
147+
return activeModeDuration;
148+
}
149+
150+
/** Returns the GetActiveModeThreshold. */
151+
public int getActiveModeThreshold() {
152+
return activeModeThreshold;
153+
}
154+
125155
/** Returns the ICD Node Id. */
126156
public long getIcdNodeId() {
127157
return icdNodeId;

0 commit comments

Comments
 (0)