Skip to content
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

ConnectAsync() unhandled exception #11

Open
digital-spinner opened this issue Sep 30, 2020 · 0 comments
Open

ConnectAsync() unhandled exception #11

digital-spinner opened this issue Sep 30, 2020 · 0 comments

Comments

@digital-spinner
Copy link

I'm trying to connect to ELM327 bluetooth device (serial communication) but I'm getting an error..

Unhandled exception. Tmds.DBus.DBusException: org.bluez.Error.NotAvailable: Operation currently not available
   at Tmds.DBus.DBusConnection.CallMethodAsync(Message msg, Boolean checkConnected, Boolean checkReplyType)
   at Tmds.DBus.Connection.CallMethodAsync(Message message)
   at Tmds.DBus.CodeGen.DBusObjectProxy.SendMethodReturnReaderAsync(String iface, String member, Nullable`1 inSignature, MessageWriter writer)
   at *****.ConnectAsync() in ********************

I have also tried to use ConnectProfileAsync() method with proper service UUID - same exception.
Elevating privileges with sudo also doesn't help.
Equivalent test code in Python3 with PyBluez works without problems.

I'm using Linux Ubuntu 20.04 on VM with USB BT dongle and dotnet sdk 3.1.402.
My test source code looks like this:

IAdapter1 adapter = BlueZManager.GetAdaptersAsync().Result.FirstOrDefault();
IReadOnlyList<Device> devices = adapter.GetDevicesAsync().Result;
device = devices.Single(x => x.ObjectPath.ToString().EndsWith(macAddress.Replace(':', '_')));

TimeSpan timeout = TimeSpan.FromSeconds(15);
await device.ConnectAsync();
await device.WaitForPropertyValueAsync("Connected", value: true, timeout);
await device.WaitForPropertyValueAsync("ServicesResolved", value: true, timeout);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant