[BluetoothLEHelper] await services subscriptions #3972
Unanswered
GeertvanHorrik
asked this question in
Questions & Help
Replies: 3 comments
-
Hi @GeertvanHorrik I see you already investigated the fix for this issue, would it be possible for you to submit a PR with these modifications? Thanks! |
Beta Was this translation helpful? Give feedback.
0 replies
-
Unfortunately the toolkit no longer targets the version that supports mobile, so the interest is very low. But I might find some time in the near future. |
Beta Was this translation helpful? Give feedback.
0 replies
-
For anyone waiting for a fix to this, here is an ugly work around... int wait = 25;
await bleDevice.ConnectAsync();
while (bleDevice.BluetoothLEDevice == null)
await Task.Delay(wait);
while (bleDevice.ServiceCount != (await bleDevice.BluetoothLEDevice.GetGattServicesAsync()).Services.Count)
await Task.Delay(wait);
foreach (var service in bleDevice.Services)
while (service.Characteristics.Count != (await service.Service.GetCharacteristicsAsync()).Characteristics.Count)
await Task.Delay(wait); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm submitting a...
Current behavior
The services registration happens in
ObservableBluetoothLEDevice.ConnectAsync
. However, the services characteristics are being initialized in an non-async way in the service ctor.Expected behavior
After
await ConnectAsync
, I would expect a fully available object (with services), which is not the case.How to fix
My recommendation is to fix this by adding an
Task InitializeAsync
method toObservableGattDeviceService
. Then this can be called from within theConnectAsync
method and actually be awaited.Beta Was this translation helpful? Give feedback.
All reactions