1

I need to get connected Bluetooth device's property in Windows via C#. And I find this post:

Getting a list of already connected bluetooth devices on Windows 10

The code it mentioned is:

//Connected bluetooth devices
DeviceInformationCollection ConnectedBluetoothDevices =
       await DeviceInformation.FindAllAsync(BluetoothDevice.GetDeviceSelectorFromConnectionStatus(BluetoothConnectionStatus.Connected));

But when running the code, I get below exception. It seems that this method cannot be used any more.

Any advise?

enter image description here

Tom Xue
  • 3,169
  • 7
  • 40
  • 77

2 Answers2

3

Good luck!

ax.
  • 58,560
  • 8
  • 81
  • 72
  • Yep this should do it. In the case OP doesn't want to read that article here is the github to the Nuget referenced in the article: https://github.com/inthehand/32feet – Michael Coxon May 03 '23 at 11:34
0

Might still be usefull.

I got information about connected bluetooth devices using this package and following code

public class Bluetooth
    {
        public async Task<BluetoothDeviceInfo[]> GetBluetoothDevices()
        {
            var bluetoothClient = new BluetoothClient();
            var devices = await Task.Run(() => bluetoothClient.DiscoverDevices());
            bluetoothClient.Close();
            return devices;
        }
    }

    public static async void SomeAction()
    {
        var bluetooth = new Bluetooth();
        var ConnectedDevices = await bluetooth.GetBluetoothDevices();
        if (ConnectedDevices != null)
        {
            Console.WriteLine(ConnectedDevices[0].DeviceName);
            Console.WriteLine(ConnectedDevices[0].DeviceAddress);
        }
    }