Reputation: 5360
I have already paired peripheral ble device (iPhone) with my Android phone. Now I want from my Android code connect to this iPhone.
I received list of paired devices by mBluetoothAdapter.getBondedDevices()
and try to connect to the proper one but connection fails (GATT_ERROR
).
I know the mac address is randomizing but on the other hand this iPhone is paired and I am authorized to connect it. Can I do this?
Upvotes: 0
Views: 1879
Reputation: 13285
In Bluetooth Low Energy, Pairing and Bonding are two different things as follows:-
In your case, if the devices are "paired" then this means that they are already in an active connection (This is different to classic Bluetooth where a connection and pairing are mutually exclusive). If this is the case, then try to list active connections to make sure that the iPhone is not one of them.
If you are "bonded" and not paired, then this means that there is no active connection and another one needs to be created. You will need to make sure that your peripheral device is advertising and that the Android device can scan and detect it. Once it is detected through the scan, connect to the iPhone and this should work without an issue.
This might be a useful reference:-
Should one create a bond with a Bluetooth LE device
I hope this helps.
Upvotes: 1