kable
kable copied to clipboard
Support for bonding
Is there a plan for supporting bonding (pairing) with a bluetooth device gracefully? I think that at connect() time or later on, when reading / writing a characteristic (which could respond with INSUFFICIENT_AUTHENTICATION) would have to do it. I saw that Advertisement has a BondState property.
It isn't on the short-term roadmap but I've been trying to prioritize GitHub issues by the number of 👍 they have. So, if there are others who also need this feature (and "up vote" it) then I'd be happy to tackle it sooner rather than later.
Long-term I would like to support it, so it will come eventually. Also happy to accept PRs. 😉
This issue appears to be getting a fair amount of attention (👍 ) so I'll start trying to dedicate time to researching/brainstorming this integration.
Found the following articles that offer awesome insight into the bonding process:
Does anyone have any recommendations on a BLE peripheral (that needs/supports bonding) that I can purchase to start developing against?
There are multiple medical devices that I've come across requiring pairing: Thermometer (requires pairing at reading measurements stage, not when connecting to it), Pulse Oximeter but as mentioned in those articles you posted, the pairing process could be started by the OS at different moments of communication to the bluetooth device, answering with GATT_STATUS - INSUFFICIENT_AUTHENTICATION or GATT_INSUFFICIENT_ENCRYPTION.
Quick update on this, I haven't made any real progress, but I have acquired both the Thermometer and Pulse Oximeter for when I do have time to investigate this further. Thanks @DoruAdryan for the recommendations.
Hey @twyatt any real advance on this? I would suggest acquiring a stater kit like the one silicon labs have: https://www.silabs.com/development-tools/wireless/bluetooth/bgx220p-bluetooth-xpress-starter-kit Do you think you need some support on this?
Unfortunately no real progress on this yet, though I am eager to get started on it once I have a free moment — hopefully sooner rather than later.
Do you think you need some support on this?
Any help would be greatly appreciated.
Most helpful would be determining if JavaScript and Apple platforms support bonding, and then finding any simple sample code for bonding for any of the platforms (Android, JavaScript, Apple).
Also, identifying failure cases, i.e. when calling a function for bonding, when something goes wrong: how does it go wrong (on each platform)? — are exceptions thrown, or: are callbacks called, etc.
PRs are always welcome, or discussions can also be started to brainstorm what the shape of the Kable API should be for bonding.
I would suggest acquiring a stater kit like the one silicon labs have: https://www.silabs.com/development-tools/wireless/bluetooth/bgx220p-bluetooth-xpress-starter-kit
@WildStudio Does the starter kit support BLE bonding out-of-the-box, or does it have to be programmed/configured for bonding?
Has there been any progress on this part one year later ? I don't think this has been implemented, or else I missed it. It's the only thing currently preventing me from using this lib, even though it's really great!
Unfortunately I've been really busy with projects at work, and we don't have an immediate need for bonding so I haven't been able to prioritize this effort.
I know this is the most requested feature, so I would love to make some progress on it.
Some things that would really help out in the effort is:
- Create some basic sample apps for each platform that perform bonding (without Kable)
- Would help demonstrate all the moving parts that will be needed and help drive decisions about how to make a Coroutines based API in Kable
- Alternatively, we could start a discussion on what the shape of the API should be
- I have no experience around performing bonding on any of the platforms, so getting some general understanding (outline) of what is involved w/ the process would be super helpful
- If people have worked w/ bonding before, maybe some
interfaces(written in pseudo-Kotlin code) of what they imagine the API could look like, could help kick off this effort
Whenever I've done pairing it's by using the Nordic library (https://github.com/NordicSemiconductor/Android-BLE-Library), I've never implemented it from scratch. So I may not be in the best position to provide a test sample. But I will continue to follow this library and its development closely.
It has recently come up that we may have a need for bonding internally. Meaning that this may end up on our team's project roadmap (so I'd be able to allocate a lot of time to this effort). 🤞
I'm not certain of timelines, but I'm hopeful the effort kicks off sometime in first half of 2023.
Hello @twyatt, Just wondering, how's that feature coming along :smiley: ?
Just wondering, how's that feature coming along 😃 ?
I just last week researched what typical Android bonding looks like, here are some great articles I came across:
- Making Android BLE work — part 4 by Martijn van Welie
- Bluetooth LE for modern Android Development - part 2 by Erik Hellman
- The Ultimate Guide to Android Bluetooth Low Energy by Chee Yi Ong
...that is to say: sorry it has taken so long, but I have finally started on this. Thanks for your patience. ❤️
I have a completely untested implementation (#494), based on the great articles I linked. Although I don't (yet) have any devices to test it against.
I have a Beurer PO60 Pulse Oximeter but getting the BLE working on it was super wonky (I ultimately gave up). Additionally, according to this, it doesn't require bonding anyways. 🤷
Does anyone have some recommendations of devices that:
- require bonding out-of-the-box
- are simple to setup (BLE just works — no need to flash specific firmware)
- is affordable
Thank you!
Any update on this? Our company would like to use your library but bonding is a key requirement.
@YSDC do you happen to know of a publicly available (and affordable) device that requires/supports bonding? Or, is the product your company is wanting to developer for available for use as something I can develop against?
The only blocker at this point is me getting a device I can test #494 against.
Mentioned a couple of devices that requires bonding with different behaviors here
Mentioned a couple of devices that requires bonding with different behaviors here
Yes, thanks for those recommendations @DoruAdryan!
Unfortunately I could not get the bluetooth on the Beurer PO60 Pulse Oximeter working (the guides in the official app were terrible — could not even get it connected in their app). If you happen to know how to enable bluetooth on that device, then I'll give it another try.
I didn't get very far with the Beurer Thermometer either, as it was difficult to find documentation on how to communicate with it over bluetooth (i.e. what are its characteristic UUIDs, what does the data format look like to communicate with it, etc?).
I was hoping to have a device that was a little more developer friendly (specifically, better documentation) but I'll go back to reverse engineering it if no better device options come up.
Hi @twyatt
I'm checking these modifications on my own. The first problem I'm facing is that 'onCharacteristicRead' inside the callback is not firing. It seems like Android is waiting for pairing because my device requires pairing from the initial connection. Maybe this behavior only occurs with devices that require pairing at the initial connection, and not with devices that only require pairing for some protected characteristics.
Perhaps we should add a function to wait for pairing or consider giving access to the bonding state from an external part and keeping that responsibility outside of this library.
Added to this I'm clear code and merge with the main in my own pull request, the broadcast ACTION_BOND_STATE_CHANGED have a problem because is not called. Can you check this?
https://github.com/CristianMG/kable/tree/feature/bonding_v2
as you can see, I have modified some problematic code.
Greetings
Hi @CristianMG, is the peripheral you're working with publicly available?
If not, are you able to provide me with one so that I can test the bonding support against it?
Feel free to reach out to me directly on the Kotlin Slack, user @travis.