Reputation: 373
On the Windows Bluetooth stack, you can swap between the internal Bluetooth adapter and an external USB BT dongle being the active radio by disabling both in Device Manager then enabling the desired adapter and the stack does the rest. With the device instance ID, that can be automated with e.g. setupapi, PowerShell's Disable-PnpDevice/Enable-PnpDevice, etc.
In the general case, either programmatically or say from a script etc., how can you determine which adapter is the internal Bluetooth and which is the external dongle? Both seem to be USB devices from Windows' perspective. (In this clip 'Intel(R) Wireless Bluetooth(R) is the internal adapter and 'Realtek Bluetooth 5.1 Adapter' is the external USB BT dongle.) Open to using I'll use powershell, .net (framework or 5+), ms bt api, winrt, setupapi, wmi, 32feet, whatever is necessary.
Upvotes: 0
Views: 876
Reputation: 152
IOCTL_USB_GET_PORT_CONNECTOR_PROPERTIES called on the hub delivers the USB_PORT_CONNECTOR_PROPERTIES struct which has the USB_PORT_PROPERTIES struct as member which has the PortIsUserConnectable member.
For the internal device's port PortIsUserConnectable should be 0, for the external 1. This is usually set correctly on root hubs but random on standard hubs.
The hub is the USB device's parent, you have to do an SetupDiGetClassDevs enumeration with GUID_DEVINTERFACE_USB_HUB finding the hub's DevInst. Then you can open it's DevicePath and call IOCTL_USB_GET_PORT_CONNECTOR_PROPERTIES with the right port number. The port number can be extracted from the device's CM_DRP_LOCATION_INFORMATION, e.g. Port_#0002.Hub_#0001.
Upvotes: 3