32
32
import java .util .List ;
33
33
import java .util .Optional ;
34
34
import java .util .TimeZone ;
35
+ import javax .annotation .Nonnull ;
35
36
import javax .annotation .Nullable ;
36
37
37
38
/** Controller to interact with the CHIP device. */
@@ -156,6 +157,8 @@ public void setICDCheckInDelegate(ICDCheckInDelegate delegate) {
156
157
setICDCheckInDelegate (deviceControllerPtr , new ICDCheckInDelegateWrapper (delegate ));
157
158
}
158
159
160
+ /* This method was deprecated. Please use {@link ChipDeviceController.pairDevice(BluetoothGatt, int, long, long, CommissionParameters)}. */
161
+ @ Deprecated
159
162
public void pairDevice (
160
163
BluetoothGatt bleServer ,
161
164
int connId ,
@@ -165,6 +168,8 @@ public void pairDevice(
165
168
pairDevice (bleServer , connId , deviceId , setupPincode , null , networkCredentials , null );
166
169
}
167
170
171
+ /* This method was deprecated. Please use {@link ChipDeviceController.pairDevice(BluetoothGatt, int, long, long, CommissionParameters)}. */
172
+ @ Deprecated
168
173
public void pairDevice (
169
174
BluetoothGatt bleServer ,
170
175
int connId ,
@@ -176,6 +181,8 @@ public void pairDevice(
176
181
bleServer , connId , deviceId , setupPincode , null , networkCredentials , registrationInfo );
177
182
}
178
183
184
+ /* This method was deprecated. Please use {@link ChipDeviceController.pairDevice(BluetoothGatt, int, long, long, CommissionParameters)}. */
185
+ @ Deprecated
179
186
public void pairDevice (
180
187
BluetoothGatt bleServer ,
181
188
int connId ,
@@ -199,8 +206,10 @@ public void pairDevice(
199
206
* @param icdRegistrationInfo the informations for ICD registration. For detailed information
200
207
* {@link ICDRegistrationInfo}. If this value is null when commissioning an ICD device, {@link
201
208
* CompletionListener.onICDRegistrationInfoRequired} is called to request the
202
- * ICDRegistrationInfo value.
209
+ * ICDRegistrationInfo value. This method was deprecated. Please use {@link
210
+ * ChipDeviceController.pairDevice(BluetoothGatt, int, long, long, CommissionParameters)}.
203
211
*/
212
+ @ Deprecated
204
213
public void pairDevice (
205
214
BluetoothGatt bleServer ,
206
215
int connId ,
@@ -209,6 +218,31 @@ public void pairDevice(
209
218
@ Nullable byte [] csrNonce ,
210
219
NetworkCredentials networkCredentials ,
211
220
@ Nullable ICDRegistrationInfo icdRegistrationInfo ) {
221
+ CommissionParameters params =
222
+ new CommissionParameters .Builder ()
223
+ .setCsrNonce (csrNonce )
224
+ .setNetworkCredentials (networkCredentials )
225
+ .setICDRegistrationInfo (icdRegistrationInfo )
226
+ .build ();
227
+ pairDevice (bleServer , connId , deviceId , setupPincode , params );
228
+ }
229
+
230
+ /**
231
+ * Pair a device connected through BLE.
232
+ *
233
+ * @param bleServer the BluetoothGatt representing the BLE connection to the device
234
+ * @param connId the BluetoothGatt Id representing the BLE connection to the device
235
+ * @param deviceId the node ID to assign to the device
236
+ * @param setupPincode the pincode for the device
237
+ * @param params Parameters representing commissioning arguments. see detailed in {@link
238
+ * CommissionParameters}
239
+ */
240
+ public void pairDevice (
241
+ BluetoothGatt bleServer ,
242
+ int connId ,
243
+ long deviceId ,
244
+ long setupPincode ,
245
+ @ Nonnull CommissionParameters params ) {
212
246
if (connectionId == 0 ) {
213
247
connectionId = connId ;
214
248
@@ -225,15 +259,16 @@ public void pairDevice(
225
259
deviceId ,
226
260
connectionId ,
227
261
setupPincode ,
228
- csrNonce ,
229
- networkCredentials ,
230
- icdRegistrationInfo );
262
+ params . getCsrNonce () ,
263
+ params . getNetworkCredentials () ,
264
+ params . getICDRegistrationInfo () );
231
265
} else {
232
266
Log .e (TAG , "Bluetooth connection already in use." );
233
267
completionListener .onError (new Exception ("Bluetooth connection already in use." ));
234
268
}
235
269
}
236
270
271
+ /* This method was deprecated. Please use {@link ChipDeviceController.pairDeviceWithAddress(long, String, int, int, long, CommissionParameters)}. */
237
272
public void pairDeviceWithAddress (
238
273
long deviceId ,
239
274
String address ,
@@ -258,8 +293,11 @@ public void pairDeviceWithAddress(
258
293
* @param icdRegistrationInfo the informations for ICD registration. For detailed information
259
294
* {@link ICDRegistrationInfo}. If this value is null when commissioning an ICD device, {@link
260
295
* CompletionListener.onICDRegistrationInfoRequired} is called to request the
261
- * ICDRegistrationInfo value.
296
+ * ICDRegistrationInfo value. This method was deprecated. Please use {@link
297
+ * ChipDeviceController.pairDeviceWithAddress(long, String, int, int, long,
298
+ * CommissionParameters)}.
262
299
*/
300
+ @ Deprecated
263
301
public void pairDeviceWithAddress (
264
302
long deviceId ,
265
303
String address ,
@@ -279,6 +317,42 @@ public void pairDeviceWithAddress(
279
317
icdRegistrationInfo );
280
318
}
281
319
320
+ /**
321
+ * Pair a device connected using IP Address.
322
+ *
323
+ * @param deviceId the node ID to assign to the device
324
+ * @param address IP Address of the connecting device
325
+ * @param port the port of the connecting device
326
+ * @param discriminator the discriminator for connecting device
327
+ * @param pinCode the pincode for connecting device
328
+ * @param params Parameters representing commissioning arguments. see detailed in {@link
329
+ * CommissionParameters}
330
+ */
331
+ public void pairDeviceWithAddress (
332
+ long deviceId ,
333
+ String address ,
334
+ int port ,
335
+ int discriminator ,
336
+ long pinCode ,
337
+ @ Nonnull CommissionParameters params ) {
338
+ if (params .getNetworkCredentials () != null ) {
339
+ Log .e (TAG , "Invalid parameter : NetworkCredentials" );
340
+ completionListener .onError (new Exception ("Invalid parameter : NetworkCredentials" ));
341
+ return ;
342
+ }
343
+ pairDeviceWithAddress (
344
+ deviceControllerPtr ,
345
+ deviceId ,
346
+ address ,
347
+ port ,
348
+ discriminator ,
349
+ pinCode ,
350
+ params .getCsrNonce (),
351
+ params .getICDRegistrationInfo ());
352
+ }
353
+
354
+ /* This method was deprecated. Please use {@link ChipDeviceController.pairDeviceWithCode(long, String, boolean, boolean, CommissionParameters)}. */
355
+ @ Deprecated
282
356
public void pairDeviceWithCode (
283
357
long deviceId ,
284
358
String setupCode ,
@@ -312,7 +386,11 @@ public void pairDeviceWithCode(
312
386
* {@link ICDRegistrationInfo}. If this value is null when commissioning an ICD device, {@link
313
387
* CompletionListener.onICDRegistrationInfoRequired} is called to request the
314
388
* ICDRegistrationInfo value.
389
+ * <p>This method was deprecated. Please use {@link
390
+ * ChipDeviceController.pairDeviceWithCode(long, String, boolean, boolean,
391
+ * CommissionParameters)}.
315
392
*/
393
+ @ Deprecated
316
394
public void pairDeviceWithCode (
317
395
long deviceId ,
318
396
String setupCode ,
@@ -332,6 +410,34 @@ public void pairDeviceWithCode(
332
410
icdRegistrationInfo );
333
411
}
334
412
413
+ /**
414
+ * Pair a device connected using the scanned QR code or manual entry code.
415
+ *
416
+ * @param deviceId the node ID to assign to the device
417
+ * @param setupCode the scanned QR code or manual entry code
418
+ * @param discoverOnce the flag to enable/disable PASE auto retry mechanism
419
+ * @param useOnlyOnNetworkDiscovery the flag to indicate the commissionable device is available on
420
+ * the network
421
+ * @param params Parameters representing commissioning arguments. see detailed in {@link
422
+ * CommissionParameters}
423
+ */
424
+ public void pairDeviceWithCode (
425
+ long deviceId ,
426
+ String setupCode ,
427
+ boolean discoverOnce ,
428
+ boolean useOnlyOnNetworkDiscovery ,
429
+ @ Nonnull CommissionParameters params ) {
430
+ pairDeviceWithCode (
431
+ deviceControllerPtr ,
432
+ deviceId ,
433
+ setupCode ,
434
+ discoverOnce ,
435
+ useOnlyOnNetworkDiscovery ,
436
+ params .getCsrNonce (),
437
+ params .getNetworkCredentials (),
438
+ params .getICDRegistrationInfo ());
439
+ }
440
+
335
441
public void establishPaseConnection (long deviceId , int connId , long setupPincode ) {
336
442
if (connectionId == 0 ) {
337
443
connectionId = connId ;
@@ -371,9 +477,12 @@ public void establishPaseConnection(long deviceId, String address, int port, lon
371
477
*
372
478
* @param deviceId the ID of the node to be commissioned
373
479
* @param networkCredentials the credentials (Wi-Fi or Thread) to be provisioned
480
+ * <p>This method was deprecated. Please use {@link
481
+ * ChipDeviceController.commissionDevice(long, CommissionParameters)}.
374
482
*/
483
+ @ Deprecated
375
484
public void commissionDevice (long deviceId , @ Nullable NetworkCredentials networkCredentials ) {
376
- commissionDevice (deviceControllerPtr , deviceId , /* csrNonce= */ null , networkCredentials );
485
+ commissionDevice (deviceControllerPtr , deviceId , /* csrNonce= */ null , networkCredentials , null );
377
486
}
378
487
379
488
/**
@@ -384,10 +493,31 @@ public void commissionDevice(long deviceId, @Nullable NetworkCredentials network
384
493
* @param deviceId the ID of the node to be commissioned
385
494
* @param csrNonce a nonce to be used for the CSR request
386
495
* @param networkCredentials the credentials (Wi-Fi or Thread) to be provisioned
496
+ * <p>This method was deprecated. Please use {@link
497
+ * ChipDeviceController.commissionDevice(long, CommissionParameters)}.
387
498
*/
499
+ @ Deprecated
388
500
public void commissionDevice (
389
501
long deviceId , @ Nullable byte [] csrNonce , @ Nullable NetworkCredentials networkCredentials ) {
390
- commissionDevice (deviceControllerPtr , deviceId , csrNonce , networkCredentials );
502
+ commissionDevice (deviceControllerPtr , deviceId , csrNonce , networkCredentials , null );
503
+ }
504
+
505
+ /**
506
+ * Initiates the automatic commissioning flow using the specified network credentials. It is
507
+ * expected that a secure session has already been established via {@link
508
+ * #establishPaseConnection(long, int, long)}.
509
+ *
510
+ * @param deviceId the ID of the node to be commissioned
511
+ * @param params Parameters representing commissioning arguments. see detailed in {@link
512
+ * CommissionParameters}
513
+ */
514
+ public void commissionDevice (long deviceId , @ Nonnull CommissionParameters params ) {
515
+ commissionDevice (
516
+ deviceControllerPtr ,
517
+ deviceId ,
518
+ params .getCsrNonce (),
519
+ params .getNetworkCredentials (),
520
+ params .getICDRegistrationInfo ());
391
521
}
392
522
393
523
/**
@@ -1498,7 +1628,8 @@ private native void commissionDevice(
1498
1628
long deviceControllerPtr ,
1499
1629
long deviceId ,
1500
1630
@ Nullable byte [] csrNonce ,
1501
- @ Nullable NetworkCredentials networkCredentials );
1631
+ @ Nullable NetworkCredentials networkCredentials ,
1632
+ @ Nullable ICDRegistrationInfo icdRegistrationInfo );
1502
1633
1503
1634
private native void continueCommissioning (
1504
1635
long deviceControllerPtr , long devicePtr , boolean ignoreAttestationFailure );
0 commit comments