How to bond phone to Karoo via BLE
Hey everyone,
I'm currently developing an android app that requires data-transfer between my phone and Karoo in real-time.
I am, however, faced with a major problem:
Karoo is using a resolvable private address, which means I cannot simply remember the Karoo device address. From what I've found on the little documentation and mostly forums, we need to have the Identity Resolving Key (IRK) in order to get the current device address. However android does not expose any way to obtain this using it's API, and it's probably not the best method anyways.
But Android API provides the createBond() function, which should handle all that by itself, the thing is, it seems that Karoo requires pin-authentication (just like the one shown when you pair companion app with karoo), but when calling createBond() it does not display this pin anywhere, nor does my phone (I can get a pair request if I send from karoo to phone, but doesn't work either), below will be some of the logs from the Karoo (3) device when bonding is called (we can see Found no reason to show the dialog - do not show dialog. I don't know why)
EDIT: My application flow goes like this:
- On Android: Scan for BLE devices with my service uuid, connect to the device, create bond to device
- On Karoo: Advertise BLE with my service uuid
I receive BOND_BONDING on both sides, but as previously said nothing more happens, so after a certain time it just goes back to BOND_NONE.
So here I am, after days of going through all the forums, I cannot find a way to connect and remember the Karoo device using BLE. I have thought of pairing it using the Phone Pairing option from Karoo, but I do not want my users to be forced to use the Companion app.
If anyone could help me figure out how to achieve my goals, that would be greatly appreciated
Cheers,
Here are the logs from Karoo device when requesting bonding.
get_cod remote_cod = 0x00001f00
2025-04-01 21:18:53.009 4524-4550 BluetoothB...ateMachine com.android.bluetooth I bondStateChangeCallback: Status: 0 Address: 63:49:4F:B6:61:C5 newState: 1
2025-04-01 21:18:53.010 4524-4550 BluetoothB...ateMachine com.android.bluetooth I sspRequestCallback: [B@d83c24 name: [B@63cc38d cod: 7936 pairingVariant 2 passkey: ******
2025-04-01 21:18:53.020 4524-4554 BluetoothAdapterService com.android.bluetooth D isAdvAudioDevice false
2025-04-01 21:18:53.020 4524-4554 BluetoothAdapterService com.android.bluetooth D isAdvAudioDevice false
2025-04-01 21:18:53.030 4524-4554 BluetoothB...ateMachine com.android.bluetooth I Bond State Change Intent:63:49:4F:B6:61:C5 BOND_NONE => BOND_BONDING
2025-04-01 21:18:53.031 4524-4554 BluetoothB...ateMachine com.android.bluetooth I Entering PendingCommandState State
2025-04-01 21:18:53.040 1816-1953 BluetoothEventManager com.android.systemui W Got bonding state changed for 63:49:4F:B6:61:C5, but we have no record of that device.
2025-04-01 21:18:53.043 635-4573 vendor.qti...bs_handler and...are.bluetooth@1.0-service-qti I ProcessIbsCmd: Received IBS_SLEEP_IND: 0xFE
2025-04-01 21:18:53.043 635-4573 vendor.qti...bs_handler and...are.bluetooth@1.0-service-qti D SerialClockVote: vote for UART CLK OFF
2025-04-01 21:18:53.044 4524-4524 BluetoothDatabase com.android.bluetooth D updateDatabase 63:49:4F:B6:61:C5
2025-04-01 21:18:53.051 4524-4524 A2dpService com.android.bluetooth D Bond state changed for device: 63:49:4F:B6:61:C5 state: 11
2025-04-01 21:18:53.054 2224-2224 BluetoothEventManager com.android.settings W Got bonding state changed for 63:49:4F:B6:61:C5, but we have no record of that device.
2025-04-01 21:18:53.061 1221-1323 CompatibilityInfo system_server D mCompatibilityFlags - 4
2025-04-01 21:18:53.061 1221-1323 CompatibilityInfo system_server D applicationDensity - 300
2025-04-01 21:18:53.061 1221-1323 CompatibilityInfo system_server D applicationScale - 1.0
2025-04-01 21:18:53.066 4524-4594 BluetoothDatabase com.android.bluetooth W Invalid metadata key 17
2025-04-01 21:18:53.067 4524-4594 BluetoothDatabase com.android.bluetooth E getCustomMeta: meta key invalid 17
2025-04-01 21:18:53.067 4524-4536 BluetoothDatabase com.android.bluetooth W Invalid metadata key 17
2025-04-01 21:18:53.067 4524-4536 BluetoothDatabase com.android.bluetooth E getCustomMeta: meta key invalid 17
2025-04-01 21:18:53.077 2224-2224 LocalBluet...references com.android.settings V Found no reason to show the dialog - do not show dialog.
2025-04-01 21:18:53.082 2224-2224 BluetoothPairingService com.android.settings D onStartCommand() action : android.bluetooth.device.action.PAIRING_REQUEST
2025-04-01 21:18:53.092 2224-2224 BluetoothPairingService com.android.settings D Show pairing notification for (63:49:4F:B6:61:C5)
2025-04-01 21:18:53.194 635-4568 vendor.qti...-wake_lock and...are.bluetooth@1.0-service-qti D Release wakelock is released
2025-04-01 21:18:53.308 1221-1221 NotificationHistory system_server W Attempted to add notif for locked/gone/disabled user 0
Please sign in to leave a comment.
Comments
1 comment