-
-
Notifications
You must be signed in to change notification settings - Fork 316
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
Bonding extensions #691
Bonding extensions #691
Conversation
Fixed issue in BondStatusBroadcastReceiver to add the adapter to new devices provided to the event.
This PR is linked to issue #690. |
I solved my issue that after CreateBond() or ForgetBond() connecting to the device failed because the device no longer had a reference to the adapter which crashed in OnDeviceStateChanged. |
Not sure I understand the question, but in any case you say the problem is solved, right? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Looking through the code, I don't see any issues. I assume you have tested this to a certain extent?
Just one minor comment ...
Source/Plugin.BLE/Android/BroadcastReceivers/BondStatusBroadcastReceiver.cs
Outdated
Show resolved
Hide resolved
Yes, but I do not really understand why. |
And yes, tested the whole functionality with two devices. |
It seems that |
…e bond state to DeviceBondState
In this context, what I'm actually not completely sure about is whether it is such a good idea for Since one can also get another One step towards solving this might be to keep a permanent list of bonded devices in AdapterBase (analogous to the discovered and connected devices), instead of just providing a getter method that returns a new @midoragh What do you think about this topic? Do you agree with my ideas? |
GetBondedDevice is similar to GetSystemConnectedOrPairedDevices (at the end it's just the paired part of this method). Only the OS knows about the bonded devices. So if you startup you would have to call GetBondedDevices once and than update this list on BondStateChanged. This could be done. |
it never crashed on disconnect but in |
In
Yeah, that is understandable. For every
Well, if you re-use the But I assume further problems arise, if you don't reuse the Note: The I think some action is required to address this issue. We need to avoid creating new |
I agree. For the connected devices there is already But good that you mention
Yes, probably it would make sense to add a @midoragh Would you be willing/interested to include this in this PR? (If not, I could try to handle it in a follow-up PR.) |
|
Yeah, might be an option. I was also thinking about a single device registry, but I couldn't make up my mind yet whether it would be preferable over three distinct ones. We can still think this through some more ...
That would be awesome. I was actually planning to tag another beta release soon, in order to make the recent API additions available to a larger audience. I guess I'll just do that tonight. This PR can be merged afterwards, then we can work on the device cleanup in a follow-up PR and publish another beta soon after that (in the time frame of about a month or so).
Haven't tried that recently, but it certainly used to work at some point. I think it would be a great idea to create a proper MAUI sample app as well, in addition to the old Xamarin samples we have, but I'm not sure if I'll have any time to deal with that soon ... |
That's fine for me. As long as the bonding extension will be added later ;-). In the moment I'm still doing extensions and fix in 2.1.2 and port them later to 3.0. After bonding has been included I would like to add Pair |
I did more test regarding CreateBond and there is an issue in the case that the device is not connected and CreateBond is called. |
Any updates to this? |
Unfortunately I don't. Is this a blocker, or should we just merge this PR after all, @midoragh? |
Sorry, I'm really busy with an other project which needs approval (ETA in August). The binding state works fine in my tests but CreateBond has issues. In the moment I guess there is an issue with the device lists in the plugin.ble. There is something not consistent. I wouldn't use it for a production release of an app. |
Thanks for the feedback! The point is: We should really publish a final version 3.0 soon, and we need to decide if this PR should still be part of it. I would like to publish the release no later than end of August, and this PR is one of the last open items. So, yes, it's a question of priority and timing. Since there are some open issues, I don't think this PR should be included in 3.0 as is. That basically leaves us with to options:
Any opinions about which way we should go? Which one sounds more reasonable to you, @midoragh ? |
I would propose to remove the methods CreateBond and ForgetBond in the moment and merge it to 3.0. Just the bonding state and event helps in some tools. We can later check if we can solve it later. |
Sounds like a reasonable suggestion. Could you maybe open a new PR that does this? (Or modify this one?) I will then merge it. |
I compared a bit this with the other bonding solution. The main difference seams to be that it provides BondAsync as a method which calls CreateBond and waits for the result. I expect similar issues. At the end I like to support more, like the pairing request which would allow to bond without ui if the pass key is available. |
This pull request provides bonding extensions for Android (and dummies for Apple and Windows).
IDevice provides property BondState and methods CreateBond() and ForgetBond().
IAdapter provides event DeviceBondStateChanged and property BondedDevices.