Open EloiStree opened 2 weeks ago
Usable:
For HC05
import subprocess
def list_bluetooth_device_details():
try:
# PowerShell command to retrieve detailed Bluetooth device info
command = [
"powershell",
"-Command",
"""
Get-PnpDevice -Class Bluetooth | ForEach-Object {
[PSCustomObject]@{
Name = $_.Name
InstanceId = $_.InstanceId
VendorID = $_.InstanceId -match 'VID_([0-9A-F]+)' ? $matches[1] : "N/A"
ProductID = $_.InstanceId -match 'PID_([0-9A-F]+)' ? $matches[1] : "N/A"
SerialNumber = $_.InstanceId -match 'BTHENUM\\\\DEV_(\\w+)' ? $matches[1] : "N/A"
}
} | Select-Object Name, VendorID, ProductID, SerialNumber
"""
]
# Execute the PowerShell command
result = subprocess.run(command, capture_output=True, text=True)
# Display the output
if result.stdout:
print("Bluetooth Devices with Vendor ID, Product ID, and Serial Number:")
print(result.stdout)
else:
print("No Bluetooth devices found or unable to retrieve device information.")
except Exception as e:
print(f"An error occurred: {e}")
if __name__ == "__main__":
list_bluetooth_device_details()
Name InstanceId
---- ----------
Generic Access Profile BTHLEDEVICE\{00001800-0000-100...
Intel(R) Wireless Bluetooth(R) USB\VID_8087&PID_0026\5&1CCFCB...
Device Information Service BTHLEDEVICE\{0000180A-0000-100...
Bluetooth LE Generic Attribute Service BTHLEDEVICE\{0000FFE0-0000-100...
Microsoft Bluetooth LE Enumerator BTH\MS_BTHLE\6&1C7D32E4&0&3
Bluetooth LE Generic Attribute Service BTHLEDEVICE\{0000FE59-0000-100...
Device Information Service BTHLEDEVICE\{0000180A-0000-100...
Device Identification Service BTHENUM\{00001200-0000-1000-80...
Generic Attribute Profile BTHLEDEVICE\{00001801-0000-100...
Device Information Service BTHLEDEVICE\{0000180A-0000-100...
HC-05 BTHENUM\DEV_98DA5001A5A3\7&1C7...
Generic Access Profile BTHLEDEVICE\{00001800-0000-100...
Bluetooth LE Generic Attribute Service BTHLEDEVICE\{00000001-5F60-4C4...
Bluetooth LE Generic Attribute Service BTHLEDEVICE\{0000180F-0000-100...
Microsoft Bluetooth Enumerator BTH\MS_BTHBRB\6&1C7D32E4&0&1
Bluetooth Device (RFCOMM Protocol TDI) BTH\MS_RFCOMM\6&1C7D32E4&0&0
Generic Access Profile BTHLEDEVICE\{00001800-0000-100...
HC-05 BTHLE\DEV_98DA5001A5A3\7&5C8DD...
JBL TUNE230NC TWS BTHENUM\DEV_785EA278907D\7&1C7...
Xbox Wireless Controller BTHLE\DEV_EC83509993F6\7&5C8DD...
BBC micro:bit [papav] BTHLE\DEV_D9CB0FB2D098\7&5C8DD...
JBL TUNE230NC TWS Avrcp Transport BTHENUM\{0000110C-0000-1000-80...
Generic Attribute Profile BTHLEDEVICE\{00001801-0000-100...
JBL TUNE230NC TWS Avrcp Transport BTHENUM\{0000110E-0000-1000-80...
Generic Attribute Profile BTHLEDEVICE\{00001801-0000-100...
Port: COM3 - USB Serial Device (COM3)
Exact Device Name: COM3
Port: COM3
Description: USB Serial Device (COM3)
HWID: USB VID:PID=0D28:0204 SER=99063602000528200673221810C288AE000000006E052820 LOCATION=1-1.1.1:x.1
VID: 3368
PID: 516
Serial Number: 99063602000528200673221810C288AE000000006E052820
Location: 1-1.1.1:x.1
Manufacturer: Microsoft
Product: None
Interface: None
USB Description: <bound method ListPortInfo.usb_description of <serial.tools.list_ports_common.ListPortInfo object at 0x0000025A99289BE0>>
USB Info: <bound method ListPortInfo.usb_info of <serial.tools.list_ports_common.ListPortInfo object at 0x0000025A99289BE0>>
Port: COM18 - USB Serial Device (COM18)
Exact Device Name: COM18
Port: COM18
Description: USB Serial Device (COM18)
HWID: USB VID:PID=0D28:0204 SER=99063602000528200D1EFEB3EE975B55000000006E052820 LOCATION=1-1.1.1:x.1
VID: 3368
PID: 516
Serial Number: 99063602000528200D1EFEB3EE975B55000000006E052820
Location: 1-1.1.1:x.1
Manufacturer: Microsoft
Product: None
Interface: None
USB Description: <bound method ListPortInfo.usb_description of <serial.tools.list_ports_common.ListPortInfo object at 0x0000018F33A69C70>>
USB Info: <bound method ListPortInfo.usb_info of <serial.tools.list_ports_common.ListPortInfo object at 0x0000018F33A69C70>>
Port: COM7 - USB Serial Device (COM7)
Exact Device Name: COM7
Port: COM7
Description: USB Serial Device (COM7)
HWID: USB VID:PID=2886:0042 SER=4150323038323719 LOCATION=1-8:x.0
VID: 10374
PID: 66
Serial Number: 4150323038323719
Location: 1-8:x.0
Manufacturer: Microsoft
Product: None
Interface: None
USB Description: <bound method ListPortInfo.usb_description of <serial.tools.list_ports_common.ListPortInfo object at 0x000001D965169C10>>
USB Info: <bound method ListPortInfo.usb_info of <serial.tools.list_ports_common.ListPortInfo object at 0x000001D965169C10>>
Port: COM10 - USB Serial Device (COM10)
Exact Device Name: COM10
Port: COM10
Description: USB Serial Device (COM10)
HWID: USB VID:PID=2886:0042 SER=4150323038323714 LOCATION=1-8:x.0
VID: 10374
PID: 66
Serial Number: 4150323038323714
Location: 1-8:x.0
Manufacturer: Microsoft
Product: None
Interface: None
USB Description: <bound method ListPortInfo.usb_description of <serial.tools.list_ports_common.ListPortInfo object at 0x000002309B1F9C10>>
USB Info: <bound method ListPortInfo.usb_info of <serial.tools.list_ports_common.ListPortInfo object at 0x000002309B1F9C10>>
Port: COM14 - USB Serial Device (COM14) Exact Device Name: COM14 Port: COM14 Description: USB Serial Device (COM14) HWID: USB VID:PID=2E8A:0005 SER=E6614C3093862A2C LOCATION=1-8:x.0 VID: 11914 PID: 5 Serial Number: E6614C3093862A2C Location: 1-8:x.0 Manufacturer: Microsoft Product: None Interface: None USB Description: <bound method ListPortInfo.usb_description of <serial.tools.list_ports_common.ListPortInfo object at 0x000001814FB89C10>> USB Info: <bound method ListPortInfo.usb_info of <serial.tools.list_ports_common.ListPortInfo object at 0x000001814FB89C10>>
Port: COM17 - USB Serial Device (COM17)
Exact Device Name: COM17
Port: COM17
Description: USB Serial Device (COM17)
HWID: USB VID:PID=2E8A:0005 SER=E66258881770B224 LOCATION=1-8:x.0
VID: 11914
PID: 5
Serial Number: E66258881770B224
Location: 1-8:x.0
Manufacturer: Microsoft
Product: None
Interface: None
USB Description: <bound method ListPortInfo.usb_description of <serial.tools.list_ports_common.ListPortInfo object at 0x000002510DC49C70>>
USB Info: <bound method ListPortInfo.usb_info of <serial.tools.list_ports_common.ListPortInfo object at 0x000002510DC49C70>>
No data (HC06 did not stay connected) And device is a XInput not a COM input 😉
Port: COM23 - Arduino Uno (COM23) Exact Device Name: COM23 Port: COM23 Description: Arduino Uno (COM23) HWID: USB VID:PID=2A03:0043 SER=7543535303535161B132 LOCATION=1-1.4 VID: 10755 PID: 67 Serial Number: 7543535303535161B132 Location: 1-1.4 Manufacturer: Arduino Srl (www.arduino.org) Product: None Interface: None USB Description: <bound method ListPortInfo.usb_description of <serial.tools.list_ports_common.ListPortInfo object at 0x000002802F549DF0>> USB Info: <bound method ListPortInfo.usb_info of <serial.tools.list_ports_common.ListPortInfo object at 0x000002802F549DF0>>
Port: COM24 - USB-SERIAL CH340 (COM24) Exact Device Name: COM24 Port: COM24 Description: USB-SERIAL CH340 (COM24) HWID: USB VID:PID=1A86:7523 SER= LOCATION=1-1.1.3 VID: 6790 PID: 29987 Serial Number: Location: 1-1.1.3 Manufacturer: wch.cn Product: None Interface: None USB Description: <bound method ListPortInfo.usb_description of <serial.tools.list_ports_common.ListPortInfo object at 0x00000239EB069DF0>> USB Info: <bound method ListPortInfo.usb_info of <serial.tools.list_ports_common.ListPortInfo object at 0x00000239EB069DF0>>
Port: COM25 - USB-SERIAL CH340 (COM25) Exact Device Name: COM25 Port: COM25 Description: USB-SERIAL CH340 (COM25) HWID: USB VID:PID=1A86:7523 SER= LOCATION=1-1.1.1 VID: 6790 PID: 29987 Serial Number: Location: 1-1.1.1 Manufacturer: wch.cn Product: None Interface: None USB Description: <bound method ListPortInfo.usb_description of <serial.tools.list_ports_common.ListPortInfo object at 0x00000239EB069FA0>> USB Info: <bound method ListPortInfo.usb_info of <serial.tools.list_ports_common.ListPortInfo object at 0x00000239EB069FA0>>
Midi is apparently not a COM
Not COM but un BLE
Consider as mouse on Window
using System;
using System.Management;
// NuGet\Install-Package System.Management -Version 4.6.0
class Program
{
static void Main()
{
try
{
// Query all COM devices in Win32_PnPEntity
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PnPEntity WHERE Name LIKE '%(COM%'");
foreach (ManagementObject queryObj in searcher.Get())
{
Console.WriteLine("Device Information:");
Console.WriteLine("-------------------");
// Iterate over all properties in the ManagementObject
foreach (PropertyData property in queryObj.Properties)
{
if (property.Value is Array arr) // If property is an array, join its elements
{
Console.WriteLine("{0}: {1}", property.Name, string.Join(", ", arr));
}
else
{
Console.WriteLine("{0}: {1}", property.Name, property.Value ?? "N/A");
}
}
Console.WriteLine(); // Blank line for readability
}
}
catch (ManagementException ex)
{
Console.WriteLine("An error occurred while querying for COM ports: " + ex.Message);
}
catch (Exception ex)
{
Console.WriteLine("An unexpected error occurred: " + ex.Message);
}
}
}
Availability: N/A Caption: USB Serial Device (COM3) ClassGuid: {4d36e978-e325-11ce-bfc1-08002be10318} CompatibleID: System.String[] ConfigManagerErrorCode: 0 ConfigManagerUserConfig: False CreationClassName: Win32_PnPEntity Description: USB Serial Device DeviceID: USB\VID_0D28&PID_0204&MI_01\8&1B049072&0&0001 ErrorCleared: N/A ErrorDescription: N/A HardwareID: System.String[] InstallDate: N/A LastErrorCode: N/A Manufacturer: Microsoft Name: USB Serial Device (COM3) PNPClass: Ports PNPDeviceID: USB\VID_0D28&PID_0204&MI_01\8&1B049072&0&0001 PowerManagementCapabilities: N/A PowerManagementSupported: N/A Present: True Service: usbser Status: OK StatusInfo: N/A SystemCreationClassName: Win32_ComputerSystem SystemName: MSI
Availability: N/A Caption: Standard Serial over Bluetooth link (COM12) ClassGuid: {4d36e978-e325-11ce-bfc1-08002be10318} CompatibleID: System.String[] ConfigManagerErrorCode: 0 ConfigManagerUserConfig: False CreationClassName: Win32_PnPEntity Description: Standard Serial over Bluetooth link DeviceID: BTHENUM{00001101-0000-1000-8000-00805F9B34FB}_VID&000102B0_PID&0000\7&1A14B62F&0&785EA278907D_C00000000 ErrorCleared: N/A ErrorDescription: N/A HardwareID: System.String[] InstallDate: N/A LastErrorCode: N/A Manufacturer: Microsoft Name: Standard Serial over Bluetooth link (COM12) PNPClass: Ports PNPDeviceID: BTHENUM{00001101-0000-1000-8000-00805F9B34FB}_VID&000102B0_PID&0000\7&1A14B62F&0&785EA278907D_C00000000 PowerManagementCapabilities: N/A PowerManagementSupported: N/A Present: True Service: BTHMODEM Status: OK StatusInfo: N/A SystemCreationClassName: Win32_ComputerSystem SystemName: MSI
Availability: N/A Caption: Standard Serial over Bluetooth link (COM19) ClassGuid: {4d36e978-e325-11ce-bfc1-08002be10318} CompatibleID: System.String[] ConfigManagerErrorCode: 0 ConfigManagerUserConfig: False CreationClassName: Win32_PnPEntity Description: Standard Serial over Bluetooth link DeviceID: BTHENUM{00001101-0000-1000-8000-00805F9B34FB}_LOCALMFG&0002\7&1A14B62F&0&98DA5001A5A3_C00000000 ErrorCleared: N/A ErrorDescription: N/A HardwareID: System.String[] InstallDate: N/A LastErrorCode: N/A Manufacturer: Microsoft Name: Standard Serial over Bluetooth link (COM19) PNPClass: Ports PNPDeviceID: BTHENUM{00001101-0000-1000-8000-00805F9B34FB}_LOCALMFG&0002\7&1A14B62F&0&98DA5001A5A3_C00000000 PowerManagementCapabilities: N/A PowerManagementSupported: N/A Present: True Service: BTHMODEM Status: OK StatusInfo: N/A SystemCreationClassName: Win32_ComputerSystem SystemName: MSI
Availability: N/A Caption: Standard Serial over Bluetooth link (COM13) ClassGuid: {4d36e978-e325-11ce-bfc1-08002be10318} CompatibleID: System.String[] ConfigManagerErrorCode: 0 ConfigManagerUserConfig: False CreationClassName: Win32_PnPEntity Description: Standard Serial over Bluetooth link DeviceID: BTHENUM{00001101-0000-1000-8000-00805F9B34FB}_LOCALMFG&0000\7&1A14B62F&0&000000000000_00000002 ErrorCleared: N/A ErrorDescription: N/A HardwareID: System.String[] InstallDate: N/A LastErrorCode: N/A Manufacturer: Microsoft Name: Standard Serial over Bluetooth link (COM13) PNPClass: Ports PNPDeviceID: BTHENUM{00001101-0000-1000-8000-00805F9B34FB}_LOCALMFG&0000\7&1A14B62F&0&000000000000_00000002 PowerManagementCapabilities: N/A PowerManagementSupported: N/A Present: True Service: BTHMODEM Status: OK StatusInfo: N/A SystemCreationClassName: Win32_ComputerSystem SystemName: MSI
Availability: N/A Caption: Standard Serial over Bluetooth link (COM20) ClassGuid: {4d36e978-e325-11ce-bfc1-08002be10318} CompatibleID: System.String[] ConfigManagerErrorCode: 0 ConfigManagerUserConfig: False CreationClassName: Win32_PnPEntity Description: Standard Serial over Bluetooth link DeviceID: BTHENUM{00001101-0000-1000-8000-00805F9B34FB}_LOCALMFG&0000\7&1A14B62F&0&000000000000_0000000B ErrorCleared: N/A ErrorDescription: N/A HardwareID: System.String[] InstallDate: N/A LastErrorCode: N/A Manufacturer: Microsoft Name: Standard Serial over Bluetooth link (COM20) PNPClass: Ports PNPDeviceID: BTHENUM{00001101-0000-1000-8000-00805F9B34FB}_LOCALMFG&0000\7&1A14B62F&0&000000000000_0000000B PowerManagementCapabilities: N/A PowerManagementSupported: N/A Present: True Service: BTHMODEM Status: OK StatusInfo: N/A SystemCreationClassName: Win32_ComputerSystem SystemName: MSI
🤖 A PNP Device ID is an identifier used by the Plug and Play (PNP) system in Windows to identify hardware devices. This particular ID, USB\VID_0D28&PID_0204&MI_01\8&1B049072&0&0001
, follows a specific structure that provides information about the type of device, its manufacturer, and other details.
Let's break down the components:
USB: This is the device class, indicating the device is connected through a USB interface.
VID (Vendor ID): VID_0D28
0D28
is the hexadecimal Vendor ID assigned to a particular manufacturer (in this case, ARM for CMSIS-DAP debugging devices, which are commonly used for ARM microcontroller programming and debugging).PID (Product ID): PID_0204
0204
corresponds to a specific product model associated with VID_0D28
.MI (Multiple Interface): MI_01
01
refers to the interface number, so this device has multiple interfaces, and this identifier represents the second interface (count starts from 00
).Unique Identifier: 8&1B049072&0&0001
The general format of a PNP Device ID is:
<Bus Type>\<Vendor ID>_<Product ID>&[Optional Subfields]\[Unique ID]
In this example:
On Unity3D you can access COM3-N, but you can't access the COM name because it is a bit tool native code. At least not easily.
But in C# Console with the good package or Python is possible.
As python can product code in 30 lines of code. I will do it in python.
If I have the time I can check for the Visuals Studio Code version later