Home > Net >  Android BLE Numeric Comparison Pairing Implementation
Android BLE Numeric Comparison Pairing Implementation

Time:01-18

How do we implement Numeric Comparison for Android?

I've done alot of research and I know I need to set the IOCapability to KeyboardDisplay.

And if the other BLE device's own IOCapability makes it match the matrix result of Numeric Comparison, it will pair with Numeric Comparison.

But I cannot find any example code online.

We are supposed to somehow use BluetoothConfigManager to set the IO Capabilities right?

I.E. Use setIoCapability(int capability) and IO_CAPABILITY_KBDISP

See here: https://developer.android.com/reference/com/google/android/things/bluetooth/BluetoothConfigManager

Thanks.

CodePudding user response:

You are right that usually the IO capabilities of both devices determine if the pairing pop up should appear, however, this is not the case for Android. On Android, this is usually handled by the device hardware so unfortunatey there is no way to guarantee that you can get the pairing dialog to pop up. Howoever, there are hacks that you can use that have worked for other people in the past. Have a look at the links below:-

CodePudding user response:

Pairing in Android is handled by the system. The system sets the IO Capabilities. For normal smart phones you usually have both a display and a keyboard, so these will be used. Any recent Android version also supports LE Secure Connections (LESC), where numeric comparison was introduced.

As you say, as long as the remote device has a display and yes/no input as IO Capability and supports LESC, the numeric comparison will be used.

If this does not seem to be the case, check the hci log or use an air sniffer to inspect the Pairing Request and Pairing Response messages to see which capabilities each device announces.

  • Related