-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update bonding v2 merged with main and tested. #768
base: main
Are you sure you want to change the base?
Conversation
…State Changes Update: Register broadcast receiver in the main thread and add support for Bluetooth bond state changes Update: Register broadcast receiver in the main thread and add support for Bluetooth bond state changes
Thanks for this! It is great to have a branch that is tested and known working. I've also updated #494 with the changes that will be going into the upcoming Kable release. Although I have not been able to test my branch (I'm very excited for being able to test against custom Arduino or Raspberry Pi code though, when that becomes available). |
Hi @twyatt , I’ve just finished developing a Python script for Raspberry and an example app in Jetpack Compose, both aimed at testing the pairing process using the library you created. You can find the script at this link: kable-ble-test. In particular, in "Just Works" mode on devices running Android 13 and later, pairing is always requested due to a change in the Bluetooth stack. However, in Android 12 and earlier, the device connects without requiring authentication, and when a feature that requires bonding is executed, it initiates the authentication process. I’ve also observed that if bonding has already been performed on Android 12 and the keys are then deleted from the Android device, bonding is requested again during the next connection attempt. This raises doubts for me about the waitBonding part in the connect method, as it seems there is no predictable behavior across different Android versions. Perhaps it would be better to remove this part and revert to the original implementation, which waits on the read or write methods. I’ve been observing these behaviors for a while, as I have extensive experience working with Android and the BLE stack, which seems to have quite a few bugs in the latest versions due to the stack refactoring. I’d love to hear if you’ve received similar reports from other users or if you have any recommendations on how to handle these variations. I truly appreciate your work and hope to contribute to the community with my findings. Thank you! Image of example application: |
Wow, thanks so much! This is great! This is exactly what I needed to unblock progress on bonding support. I'll be in touch if I run into any issues or have any questions. Thanks again, this is so incredibly helpful! |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
I made some changes in requirements.txt, could you try again? |
Thanks for the update, @CristianMG! I was able to get everything setup per your instructions (and some additional dependency installations): $ pip install virtualenv
$ virtualenv kable-env
$ source kable-env/bin/activate
# https://stackoverflow.com/a/62510708
$ sudo apt install build-essential libdbus-glib-1-dev libgirepository1.0-dev
$ pip install dbus-python
# https://stackoverflow.com/a/23649012
$ sudo apt-get install libcairo2-dev libjpeg-dev libgif-dev
$ pip install -r requirements.txt Unfortunately, now it is failing with:
Perhaps I'm using the wrong Python version? $ python --version
Python 3.11.2 |
I hate that error I can't fix properly it's seems related with this libraries
|
Thanks for the tips! Got it working. I ended up getting it running by deleting the I'm assuming it worked because I have a system version of the |
Maybe, but in my experience if you delete all gi references threw error I mean delete from pi, that´s the reason I think this error is weird. Whatever if this script become a standard to test the library would improve with more test cases and eventually I´ll fix this bug the reason that I have to involved in the improvement or fixing library errors is that the company I work use this library in some projects related with hardware. |
@CristianMG I'm going to continue the conversation in #111. |
This PR includes the following key changes:
Merged with main branch
Replaced the value of NOT_EXPORTED with EXPORTED.
Motivation: Although the Android developer documentation doesn't mention this explicitly, through my testing and by finding examples in other codebases, I realized that this is necessary for proper functionality.
For example, the Nordic Semiconductor BLE library includes this in their implementation: Example from Nordic Semiconductor BLE Library
Executing on the main thread: Broadcasting should be registered and executed on the main thread, as this is a requirement for correct operation.
Another thing, added waitForBonding to connect constructor function I think that's can be usefull because you can control bonding at the connect which in some cases is a must for all operations. Maybe including in the main call can be little aggresive to the api be free to indicate another place to put this functionality.
I will work on make a little piece of software to execute in raspberry or similar to be able to test by your part. I'll keep on touch with you through this pull request.