I am writing an Android application that connects to a physical device via BLE. The Android application will act as a peripheral role, while the device is central. I / O capabilities are also set to NoInputNoOutput ( ble_cmd_sm_set_parameters(0, 8, sm_io_capability_noinputnooutput) )
Stream to establish a connection:
- Open the Android app, then open the connection to the Bluetooth Gatt server via
bluetoothManager.openGattServer() - Add a BluetoothGattService to this BluetoothGattServer (here this service contains some characteristics with properties and notifications, read and write permissions)
- After adding all the services, start sending ads
- Press the button on the device to start scanning for peripheral devices.
- When a phone is detected, the device sends a pairing signal to the phone.
- Having received this signal, theoretically, the Android device will display the Pairing dialog with two PAIR and CANCEL buttons to confirm that it is pairing (this is JustWorks mode instead of Passkey, because it does not require us to enter a key).
- However, after testing on several Android devices, some have such a dialogue as Moto Z (Android 6), Moto G (Android 6), while others do not have such as Galaxy S7, Galaxy Tab S2 (Android 7), I I use WireShark to collect and analyze the Bluetooth package of this device and realize that the former has a
Sent Pairing Request: AuthReq with Secure Connection Flag = 1 , while the latter has Secure Connection Flag = 0 (for more information on the Secure Connection flag, see In Bluetooth Pairing Part 4 )
When reading the output from the logcat Android device (in the case of Samsung devices), I get this log: 01-31 15:21:53.322 D/BluetoothAdapter: isSecureModeEnabled 01-31 15:21:53.322 D/BtConfig.SecureMode: isSecureModeOn:false 01-31 15:21:53.325 D/BluetoothAdapter: STATE_ON 01-31 15:21:53.325 D/BluetoothLeAdvertiser: start advertising Not sure if SecureMode is the same as the SecureConnection we are talking about.
As I understand it, this connection is a BLE Secure Connections, with JustWorks mode. But it seems that not all Android devices support it (could you confirm my idea?). Or, how can we get the latest devices to have a pairing dialog?
One important thing: I have an iOS application with the same connection stream and the same physical device, and it shows the Pairing dialog.
android bluetooth bluetooth-lowenergy pairing bluetooth-peripheral
anticafe
source share