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

bonding

Open don opened this issue 6 years ago • 4 comments

Adding support for bonding has been a feature request. This can be implement on Android. There are no APIs on iOS. Adding some implementation notes so they don't get lost.

ble.createBond(deviceId, success, failure) BluetoothDevice.createBond returns immediately. Need to add an intent filter for BluetoothDevice.ACTION_BOND_STATE_CHANGED and register a broadcast receiver.

Bond state change notifications could be sent to the success callback or we could make the user register another listener ble.startBondStateChangeNotifications which could send the MAC address and the bonding state. It's a cleaner Javascript API if the plugin handles the bond state change notifications and sends them to the success callback of create bond.

Assume the OS will handle the pin negotiation. Revisit when that's not good enough.

ble.getBondedState(deviceId, success, failure) Returns BOND_NONE, BOND_BONDING, BOND_BONDED to the success callback

The peripheral JSON should be modified to include the bonded state.

BluetoothDevice does not have a public unbond method.

don avatar Jun 13 '18 04:06 don

Hi @don, did you finally work on createBond? There are problems coming when boards are pin protected... We are trying to override plugin with a setPin method, but we have not success so far on using this method to avoid errors on write. On android v7 and 8, password popup coming from android os not working properly... Regards

imaginae avatar Jul 05 '19 16:07 imaginae

@imaginae I have not worked on this. Perhaps you can bond the device outside of the app then use ble.bondedDevices()?

don avatar Oct 18 '19 02:10 don

Hi Don,

we don't use bond, finally we avoided to use pinage as per errors on setting/getting them from board... We finally work with attributes inside boards. In any case, there some other issues at this point that some people in our team have solved, do you want me to share it or better if we create a push in a branch to update?

imaginae avatar Oct 21 '19 14:10 imaginae

That'd be great if you could submit a pull request with your updates.

don avatar Oct 21 '19 15:10 don

Feature has been implemented in 1.6.3

peitschie avatar Feb 18 '23 10:02 peitschie