Before GATT, createRfcommSocketToServiceRecord, createInsecureRfcommSocketToServiceRecord
methods can make paired device,
but GATT has no option about paired device, only use BluetoothDevice.connectGatt(...)
I want to make a paired device if it's connected already.
thx.
As far as I know, to initiate a pairing procedure in BLE there are two ways:
1) From API 19 and up you can start the pairing by calling the
mBluetoothDevice.createBond()
. You don't need to be connected with the remote BLE device to start the pairing process.2) When you try to do a Gatt operation, let's take for example the method
If the remote BLE device needs to be bonded to do any communication then when the callback
onCharacteristicRead( BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status)
gets called its
status
parameter value will be equal to eitherGATT_INSUFFICIENT_AUTHENTICATION
orGATT_INSUFFICIENT_ENCRYPTION
, and not equal toGATT_SUCCESS
. If this happens then the pairing procedure will start automatically.Here is an example to find out when it fails once the
onCharacteristicRead
callback gets calledOther people mentioning that this operation starts the pairing procedure automatically: Android Bluetooth Low Energy Pairing
And this is how the receiver can be implemented