I am building an app for the hololens using Unity. I want to connect to a bluetooth device. I started building a plugin in Visual Studio which I could call from my Unity project to find and connect to a device using bluetooth. I used the documentation of Microsoft regarding this project: https://learn.microsoft.com/en-us/windows/uwp/devices-sensors/gatt-client
The query for nearby devices works like a charm. Upon calling this function the events are properly launched when a device is found or removed. But when trying to create the function to connect to a device using the BluetootLEDevice.FromIdAsync() I get the following error:
ErrorCS4036'IAsyncOperation' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accepting a first argument of type 'IAsyncOperation' could be found (are you missing a using directive for 'System'?)
I am using the System reference though, so what am I doing wrong here? This is the code I'm 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);
}