summaryrefslogtreecommitdiffstats
path: root/examples/java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-09-22 10:27:06 +0200
committerSven Gothel <[email protected]>2020-09-22 10:27:06 +0200
commit8eb3ecb3033b28c5b6cc13807d0948f245ce9729 (patch)
treecf1443928166d0a2d36a8590deeac72f89c4b942 /examples/java
parentefd9938140595944dbdf7fa05e653e7cd61a7e7c (diff)
LE Secure Connections: Initial API to support secure pairing with varying PairingModes (C++, Java)
For now, DBTDevice has a NOP implementation, i.e. returning zero length vectors (or arrays in Java) for supported and required PairingMode. The pair(String passkey) simply returns HCIStatusCode::INTERNAL_FAILURE; Intention is to validate the new API entry with our application.
Diffstat (limited to 'examples/java')
-rw-r--r--examples/java/ScannerTinyB10.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/java/ScannerTinyB10.java b/examples/java/ScannerTinyB10.java
index 4ef7c055..1c38a45f 100644
--- a/examples/java/ScannerTinyB10.java
+++ b/examples/java/ScannerTinyB10.java
@@ -50,6 +50,7 @@ import org.tinyb.EIRDataTypeSet;
import org.tinyb.GATTCharacteristicListener;
import org.tinyb.HCIStatusCode;
import org.tinyb.HCIWhitelistConnectType;
+import org.tinyb.PairingMode;
import direct_bt.tinyb.DBTManager;
@@ -262,6 +263,32 @@ public class ScannerTinyB10 {
final long t1 = BluetoothUtils.getCurrentMilliseconds();
boolean success = false;
+ // Secure Pairing
+ {
+ final List<PairingMode> spm = Arrays.asList(device.getSupportedPairingModes());
+ println("Supported Secure Pairing Modes: " + spm.toString());
+ final List<PairingMode> rpm = Arrays.asList(device.getRequiredPairingModes());
+ println("Required Secure Pairing Modes: " + spm.toString());
+
+ if( spm.contains(PairingMode.JUST_WORKS) ) {
+ final HCIStatusCode res = device.pair(null); // empty for JustWorks
+ println("Secure Pairing Just Works result " + res + " of " + device);
+ } else if( spm.contains(PairingMode.PASSKEY_ENTRY) ) {
+ final HCIStatusCode res = device.pair("111111"); // PasskeyEntry
+ println("Secure Pairing Passkey Entry result " + res + " of " + device);
+ } else {
+ println("Secure Pairing JUST_WORKS or PASSKEY_ENTRY not supported, but " + spm.toString() + " on " + device);
+ }
+ {
+ final HCIStatusCode res = device.pair(null); // empty for JustWorks
+ println("T1 Processing Device: Secure Pairing Just Works result " + res + " of " + device);
+ }
+ {
+ final HCIStatusCode res = device.pair("111111"); // PasskeyEntry
+ println("T2 Processing Device: Secure Pairing Passkey Entry result " + res + " of " + device);
+ }
+ }
+
//
// GATT Service Processing
//