I am attempting to use a DevicePicker
to enable pairing of Bluetooth devices in my VB.NET UWP application. When I run this code, the device picker doesn't even attempt to search for Bluetooth devices and immediately advises me to "Make sure the device is turned on and discoverable." Discovering and pairing Bluetooth devices works in Settings. Do I need to somehow enable/activate Bluetooth for my UWP application? (I am trying to pair and interact with an iPhone from a Windows PC.)
The code I have is below:
Imports Windows.Devices.Bluetooth
Imports Windows.Devices.Enumeration
Public NotInheritable Class MainPage
Inherits Page
Private Async Sub Button_Click(sender As Object, e As RoutedEventArgs)
Debug.WriteLine("Starting enumeration...")
Dim dp = New DevicePicker()
dp.Filter.SupportedDeviceSelectors.Add(BluetoothLEDevice.GetDeviceSelector())
dp.Filter.SupportedDeviceSelectors.Add(BluetoothLEDevice.GetDeviceSelectorFromPairingState(False))
dp.Filter.SupportedDeviceSelectors.Add(BluetoothLEDevice.GetDeviceSelectorFromPairingState(True))
Dim mydev As DeviceInformation = Await dp.PickSingleDeviceAsync(New Rect())
If mydev IsNot Nothing Then
Await mydev.Pairing.PairAsync(DevicePairingProtectionLevel.EncryptionAndAuthentication)
End If
End Sub
End Class
Thanks!