Connecting to a bluetooth device using bluetoothLEDevice.FromIdAsync results in errors

I am creating a holon app using Unity. I want to connect to a Bluetooth device. I started building a plugin in Visual Studio that I could call from my Unity project to find and connect to a device using bluetooth. I used the Microsoft documentation regarding this project: https://docs.microsoft.com/en-us/windows/uwp/devices-sensors/gatt-client

Requesting neighboring devices works like a charm. When this function is called, events are triggered as expected when a device is detected or removed. But when I try to create a function to connect to the device using BluetootLEDevice.FromIdAsync (), I get the following error:

ErrorCS4036 'AsyncOperation' does not contain a definition for GetAwaiter and the GetAwaiter extension method cannot be found that takes a first argument of type "IAsyncOperation" (are you missing a using directive for "System"?)

I'm using the System reference though, so what am I doing wrong here? This is the code I am using:

private static async void ConnectDevice(string deviceInfoID)
    {
        // Note: BluetoothLEDevice.FromIdAsync must be called from a UI thread because it may prompt for consent.
        BluetoothLEDevice bluetoothLeDevice = await BluetoothLEDevice.FromIdAsync(deviceInfoID);
    }

      

+3


source to share


1 answer


My answer is delayed but I was struggling with the same problem and the solution is to include this .dll "C: \ Program Files (x86) \ Reference Assemblies \ Microsoft \ Framework.NETCore \ v4.5 \ System.Runtime. WindowsRuntime.dll "



0


source







All Articles