cordova-plugin-ble-central icon indicating copy to clipboard operation
cordova-plugin-ble-central copied to clipboard

Implement createBond/getBondState on Android (#605)

Open peitschie opened this issue 4 years ago • 5 comments

Tested with Android 10 & Android 11... so far so good 😃

peitschie avatar Apr 14 '21 08:04 peitschie

Dear @peitschie , I'm working on Android with your implementation of createBond, anyway, when I try to bond my BLE device with the phone, while in the NRF Connect app it asks me for Bonding requesting the PIN, using the plugin it only tries to Bond but DOES NOT request for a PIN and therefore, the bonding fails. Am I missing something? Thanks for the response.

Doomkyn avatar May 03 '21 09:05 Doomkyn

@Doomkyn I believe you might want to look at the setPin workflow here. I'm not sure if that fits your requirements exactly though, apologies: https://github.com/don/cordova-plugin-ble-central#setpin

peitschie avatar May 03 '21 09:05 peitschie

Thanks for the quick response, don't wanna bother just trying to understand how I should work with these functions. At the moment my BLE device has encrypted characteristics that need authentication. The first thing I do is connecting to the device then setting the pin with setPin. After that I tried different flows: reading the encrypted characteristic fails with status 137 (it doesn't ask me for pairing), createBond fails with message "none" (still not asking for PIN)... When I try the NRF connect app, I can connect and I see the encrypted characteristics, when I try to read them, Android prompts me for Pairing with a PIN. Typing the correct pin bond the device and let me read the encrypted characteristic. If I bond with NRF connect app, then I'm able to read my characteristics through the plugin.

Doomkyn avatar May 03 '21 09:05 Doomkyn

Looking at the PR that added the setPin method (https://github.com/don/cordova-plugin-ble-central/pull/718/files) looks like it might be meant to be called before connection?

The best I could suggest is checking whether that broadcast intent there is fired in your case. I haven't had to do anything with PIN-based pairing like this, sorry... I can't really point to anything specific that might help you.

peitschie avatar May 05 '21 05:05 peitschie

Thanks for the reply, I will do a bunch of tests :)

Doomkyn avatar May 05 '21 08:05 Doomkyn