Xan-Kun Clark-Davis
Xan-Kun Clark-Davis

Reputation: 2843

Getting a list of already connected bluetooth devices on Windows 10

This question might be stupid, and maybe the first accepted answer will be one that explains why this is not an intended use-case.

Is it possible to get a list of BT devices, that are already connect to the machine?

The machine is a Win10 box and using "pure" C#/.Net would be nice, although there is also 32feet. The BT device is not BTLE (low energy).

The device is already connected via the normal Windows routines and the goal would be to get some kind of status information about the device and the connection status.

Addendum: I searched a lot and most results talk about how to pair and/or connect and the different capabilities of Win7, 8 and 10 confused me quite a lot. That's why I don't want to include any code, this time :-)

I saw Getting a list of bluetooth devices in a C# .NET framework and read through the answer and the comments. It is explicitly not about UWP but a CLI and furthermore, it doesn't seem to work. Even with 32feet, as the suggested API call to DiscoverDevicesInRange looks for devices that are in range and are in ‘discoverable mode’. Not connected yet. In the question itself it states that it should clearly work with Windows.Devices.Bluetooth, but I couldn't find anything that actually works.

Upvotes: 12

Views: 16607

Answers (1)

Breeze Liu - MSFT
Breeze Liu - MSFT

Reputation: 3808

You can find the Paired or Connected Bluetooth device by using the DeviceInformation.FindAllAsync(String) method, you can specify the string to be BluetoothDevice.GetDeviceSelectorFromPairingState(true) or BluetoothDevice.GetDeviceSelectorFromConnectionStatus(BluetoothConnectionStatus.Connected) as the following code.

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

For more information, you can see the topic Enumerate devices and the official DeviceEnumerationAndPairing sample.

Upvotes: 13

Related Questions