-
Notifications
You must be signed in to change notification settings - Fork 582
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
Document uses of ConnectionSharingAdapter #185
Comments
Hello @RobLewis |
Thanks. I almost understand what you're saying.
I'm thinking to replace this method with:
And this:
Am I on the right track? |
Should work. |
Hi, can we avoid using this class when we need to share the connection between multiple activity ? Let's suppose my app allows to control a ble device and there is multiple parameters (read battery stat, change a setting later, etc...) |
As I noted in my OP, when I first obtain the BLE connection, I store it in a static variable and reference the variable when I need a connection. I use it to send data on 2 different characteristics, receive notifications on two others, and read the RSSI, all at the same time. It works across two different Activities and a bound Service. So I don't understand the need for a separate "connection sharing" component, though I would love to know the rationale for it! I wrote up an analysis of the
Honestly, I still don't understand why it's needed. Can anyone explain? |
For reference — in this stackoverflow answer is a part regarding |
I guess there is no point in leaving this open. |
I'll reopen it anyway, we'll document it more in the future. |
I had some issues using the I had to use the following construct instead to prevent a re-connection to happen over and over again, when a characteristic is re-read. E.g:
I needed the |
Hello @streetsofboston |
Hi Darius, In my example, the subscription happens over and over again, each 5 seconds, through the If I were to replace the
If i'm understanding correctly, the |
Yes, correct. The above example would never complete until the connection would get lost though. The |
Thanks! The example I gave is just showing the creation of the |
Yes but still even if you would subscribe to it-it would never complete and the |
I modified the example somewhat, but the code is basically the same that I have in my project. |
There is a little bit of a difference between Either way- good that you have managed to get your use case to work. To not be completely offtopic: I will try to wrap up the documentation for the Best Regards |
Thank you, Dariusz! This library is great and makes working with BLE sooooooo much easier! |
|
Summary
Please provide some discussion of the use of ConnectionSharingAdapter
Preconditions
I/O on more than one Characteristic using a BLE connection
Apologies for double-posting this: I first tried StackOverflow but need an answer ASAP.
I have been developing an app for a few months that connects to a BLE peripheral. The device has 4 characteristics: 2 write and 2 notify, all working simultaneously. I also monitor connection state changes and BLE signal strength.
It seems to be working OK without the use of
ConnectionSharingAdapter
, which I have only recently discovered. Have I just been lucky? When I first obtain the BLE connection, I store it in a static variable and reference the variable when I need a connection.Could we have more extensive documentation of
ConnectionSharingAdapter
—what it does, when it's appropriate to use, etc.?The text was updated successfully, but these errors were encountered: