UWP Windows 10 1909 BLE Connecting Without Pairing RRS feed

  • Question

  • My Goal: Connect to a BLE device without manually selecting the pair device popup ie use "Just Works" ble connectivity option.

    To verify that the problem is not on the BLE device side I confirmed that I can connect to the BLE device with the 'Just Works' option through the NRF connect app on Android, and on iOS.

    Some info about my setup and things I have done so far:

    I have Bluetooth capabilities enabled in the Manifest. I have tested that bluetooth works when pairing directly with a separate device that uses BLE such as some headphones. I have made sure that Bluetooth is turned on. I can connect to my BLE device when I used the pairing option however it displays a popup each time and I don't want that popup, I want it to just work without any interaction. When PairAsync is not used the result of FromBluetoothAddressAsync or FromIdAsync is 'Disconnected'. I am using Windows 10 1909 18363.900. I should note that this used to work on 1803. All of my bluetooth drivers are up to date. I tried this on another laptop and it did not work without the pairing popup also.

    Here is my code:

    private string DEVICE_ADDRESS_TEST = "C7:9C:0C:EE:EA:D1";
            // Create BLE watcher
            var bleWatcher = new BluetoothLEAdvertisementWatcher() { ScanningMode = BluetoothLEScanningMode.Active };
            // add received callback
            bleWatcher.Received += async (BluetoothLEAdvertisementWatcher w, BluetoothLEAdvertisementReceivedEventArgs btAdv) => {
                    /// SCAN FIND DEVICE
                    ulong longAgain = ulong.Parse(this.DEVICE_ADDRESS_TEST.Replace(":", ""), System.Globalization.NumberStyles.HexNumber);
                    if (btAdv.BluetoothAddress != longAgain)
                        Logging.info($"Found device: {btAdv.BluetoothAddress}");
                        Logging.info($"Found BLE device [{DEVICE_ADDRESS_TEST}]");
                    // This causes a popup to appear! I don't want this.
                    //DevicePairingResult result = await di.Pairing.PairAsync(DevicePairingProtectionLevel.Encryption); 
                    // This causes a popup to appear! I don't want this.
                    //DevicePairingResult result = await di.Pairing.PairAsync(DevicePairingProtectionLevel.None); 
                    /// CONNECT TO DEVICE
                    var device = await BluetoothLEDevice.FromBluetoothAddressAsync(longAgain);
                    var log1 = $"Connection state: [{device.ConnectionStatus}]";
                    if (device.ConnectionStatus != BluetoothConnectionStatus.Connected)
                        throw new Exception("FromBluetoothAddressAsync did not connect successfully.");
                    /// GET ALL SERVICES
                    Logging.info("Getting services..");
                    // 2) SERVICES!!
                    var result = await device.GetGattServicesAsync();
                    if (result.Status != GattCommunicationStatus.Success)
                        throw new Exception($"GetGattServicesAsync failed with result: status[{result.Status}], error[{result.ProtocolError}]");
                    Logging.info($"[{result.Services.Count}] services found");
                catch (Exception e)

    What am I doing wrong? There has to be a way to connect to devices without needing to interact with a popup. Is there a new API I am missing? Please help!


    I found that performing a GetGattServicesForUuidAsync or GetGattServicesAsync results in the device connecting however they both return the status 'Unreachable'. This is odd because I can see a light that denotes if a device is connected or not. Again I have to reiterate that this behavior is only on the window platform as I can easily connect and get services using the 'just workings' on android and ios.

    Monday, June 22, 2020 2:42 PM

All replies

  • Hi Derek Dev,

    Thank you for posting here.

    According to your description, your issue is more related to uwp. Therefore, it will be more appropriate to ask your question in uwp forum.

    The CLR Forum discuss and ask questions about .NET Framework Base Classes (BCL) such as Collections, I/O, Regigistry, Globalization, Reflection. Also discuss all the other Microsoft libraries that are built on or extend the .NET Framework.

    Thank you for your understanding.

    Best Regards,

    Xingyu Zhao

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, June 23, 2020 1:22 AM