Once I am sure I have checked that System.Devices.Aep.Bluetooth.Le.IsConnectable == true
I call
DiscoveredBluetoothLEDevice = await BluetoothLEDevice.FromIdAsync(DiscoveredDeviceInformation.Id);
Often this works fine and my app can subscribe to receive updates from the GATT characteristic I am after. But equally often the call to FromIdAsync
fails with
Exception thrown: 'System.ArgumentException' in System.Private.CoreLib.dll
Value does not fall within the expected range.
The Id
passed in is correct, and I have tried await BluetoothLEDevice.FromBluetoothAddressAsync
instead with the known Bluetooth address of the device but I often get the same exception.
What underlying problem is this cryptic error is really referring to?
N.B. Following Xavier Xie's comment below
Have you tried the official code sample to see if you still face this issue?
I have. To recreate the error I place a breakpoint on line 119 in Scenario2_Client.ConnectButton_Click
, i.e. the second line in
bluetoothLeDevice = await BluetoothLEDevice.FromIdAsync(rootPage.SelectedBleDeviceId);
if (bluetoothLeDevice == null)
The first time I run the sample all is good, but if I restart when I hit the breakpoint then (in the second run through) I do not reach the breakpoint because I get the error thrown on the previous line.