Unable to Pair Device Using Bluetooth LE API RRS feed

  • Question

  • I'm trying to develop a simple console application that uses the Windows 10 Bluetooth LE API as found here: github [dot] com/Microsoft/Windows-universal-samples/tree/master/Samples/BluetoothLE.  The intended design is for the console to enumerate the available devices, take input from the user, and then pair and connect to the requested device. However, I am unable to pair with the selected device using the application, though I am able to pair it manually to the computer. I pretty much copied the code from the Microsoft example code, so I'm not sure what's wrong, unless it's a permission issue. The relevant code follows.

                    if (String.Equals(input, "y"))
                        inputAcquired = true;
                        Console.WriteLine("Pairing to device: " + deviceName + " . . .");
                        selectedDevice = KnownDevices[inputIndex];
                        //BT LE Microsoft Sample Code, adapted
                        //Pair to selectedDevice
                        DevicePairingResult result = await selectedDevice.DeviceInformation.Pairing.PairAsync();
                        if (result.Status == DevicePairingResultStatus.Paired 
                            || result.Status == DevicePairingResultStatus.AlreadyPaired)
                            Console.WriteLine("Pairing Successful! Connecting to device . . .");
                        } else
                            Console.WriteLine("Pairing failed! Returned status: " + result.Status);
                            Console.WriteLine("Device.IsPaired = " + selectedDevice.DeviceInformation.Pairing.IsPaired);
                            Console.WriteLine("Device.IsConnected = " + selectedDevice.DeviceInformation.Properties["System.Devices.Aep.IsConnected"]);
                            Console.WriteLine("Device.IsConnectable = " + selectedDevice.DeviceInformation.Properties["System.Devices.Aep.Bluetooth.Le.IsConnectable"]);
                            Console.WriteLine("Press any key to restart.");
                            return -1;

    In particular, the 

    DevicePairingResult result = await selectedDevice.DeviceInformation.Pairing.PairAsync();

    line is what should do the pairing, and in the Windows example they have the exact same single line to attempt the pairing process. Whenever I run it, however, result.Status returns as "Failed" and I am unable to establish a connection. The code above this is just UI code meant to display the local devices and extract the index (inputIndex) of the desired device. I appreciate any help on this.

    Monday, April 22, 2019 6:33 PM

All replies

  • Hi MSDN_Forum_User,

    Thank you for posting here.

    For your question, you could download the source file from the blog below and refer to the details in the link.

    Best Regards,


    Note: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as a convenience to you. 
    Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.
    There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet. 

    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

    Tuesday, April 23, 2019 3:01 AM
  • Seems this API currently does not work in Win32 environment (information from 2016). You'd want to retry it on UWP projects.
    Tuesday, April 23, 2019 3:35 AM