Disconnect Any Bluetooth Device
Windows offers no API to disconnect connected Bluetooth devices. The
Bluetooth Framework provides wclBluetoothRadio.EnumConnectedDevices
to list connected devices and RemoteDisconnect to disconnect any Bluetooth device - Classic, LE, or Audio - without
unpairing.
When you develop an application to communicate with Bluetooth-enabled devices (Classic, LE, Audio), you may need to check if a device is already connected by another application or by the system, and disconnect it so your application can use the device.
The common way to do this is to ask your application's user to use the standard Windows Devices dialog. A user needs to go to Settings, open the
Devices tab, find the required device (not an easy task if the device has a "strange" name), and then click the
Disconnect button if the device is connected. You need to do this because Windows does not provide any
API to disconnect connected Bluetooth-enabled devices. That does not look too user-friendly. Of course, if the
device is paired, you can disconnect it programmatically by unpairing. However, that works only for paired devices,
removes the device from the system, and requires you to re-pair the device when you need to connect again. This is not the best solution.
However, if your application uses the Bluetooth Framework, you can do all of this
programmatically. You can test this feature using the BluetoothManager sample application from the
Bluetooth Framework package.
Enumerating Connected Bluetooth Devices
In the BluetoothManager sample application, click the Enum connected button to
enumerate all currently connected devices. After that, you will see the connected devices list. Please note that even though you can
find connected devices when you click Enum paired, not all connected devices are paired. Also, if any UWP
application that uses a GATT-enabled device is running, the device used by the application may not be shown because of UWP GATT API limitations.
The Bluetooth Framework does not have such limitations, and any BLE device
(unless specifically restricted) will be properly connected.
To enumerate the connected Bluetooth-enabled devices in your application, you use the EnumConnectedDevices
method of the wclBluetoothRadio class. The method returns a list of the currently connected Bluetooth-enabled devices.
Disconnect a Bluetooth Device
When you have the connected devices list, you are ready to disconnect the required one. Simply select the required device in the devices list and
click the Disconnect button. The selected device will be disconnected, and if it was paired, it
will remain paired.
To do the same in your application, use the RemoteDisconnect method of the wclBluetoothRadio
class. Pass the required device's MAC address to the method, and the device will be disconnected. The
Bluetooth Framework can disconnect any Bluetooth-enabled device type: Classic,
LE, and Audio. However, using this method to disconnect a Bluetooth audio device may cause some issues. For more details about
working with Bluetooth audio devices, refer to this article that describes how to use the
Bluetooth Framework to control Bluetooth audio devices.
For more details, please refer to the BluetoothManager sample application source code.
Frequently Asked Questions
- How to disconnect a connected Bluetooth device on Windows?
- Windows does not provide a native API for disconnecting connected Bluetooth devices. The
Bluetooth Framework adds this ability through the
RemoteDisconnectmethod of thewclBluetoothRadioclass. - Can I disconnect a Bluetooth device without unpairing it?
- Yes, the Bluetooth Framework allows you to disconnect any Bluetooth device while keeping it paired, so you can reconnect later without going through the pairing process again.
- How to find out which Bluetooth devices are currently connected?
- Use the
EnumConnectedDevicesmethod ofwclBluetoothRadioto get a list of all connected Bluetooth devices.