02-22-2012 08:48 AM
Hello!
Problem: Unknown virtual com port number after pairing bluetooth device
Description I have bluetooth devices that use the serialport service. I've figured out how to discover, pair, and start the service, but I can't figure out a good automated way to determine which com port is connected to which bluetooth device.
Request: Any dotnet, or other platform commands that I can use to accomplish this I will gladly explore. Any ideas other ideas how to do this?
I've already thought of querying each device, but it's very time consuming.
-Eximo
02-22-2012 10:50 AM
What i do for Com ports is query the devices and Identify them by Model Number, Serial Number or in some cases a responce to a particular command. Then I assign the discovered instruments to a com port. You can use an array of clusters for this {[Instrument] [ Com Port]}.
It can get tricky trying to Identify a particular instrument to a com port especially with primitive porly written device drivers.
02-22-2012 01:58 PM - edited 02-22-2012 02:00 PM
right, but someplace windows knows the relationship between devices and com ports, especially bluetooth devices. When you pair with a bluetooth device and check the serial port box. It will pop up a box that says something to the effect "cell-johnson assigned comport 14". I just need to know where that information is stored in the dotnet variable structure for the stack or operating system.
In order to query a comport that is attached to a bluetooth device you have to connect to the device. If i have 15 bluetooth devices in a room with me (bluetooth device manufacturer here, so i could have hundreds, and the list would be continously changing), I can't wait for it to check each one each time I want to connect.
06-03-2013 09:29 AM
Hi eximo,
As far as I know it depends on the Bluetooth stack you are using. You will need to consult the API to find out more.
However, you can use WMI to get the plug and play ID, which contains the BT Address:
using System; using System.IO.Ports; namespace SerialPortExample { class SerialPortExample { public static void Main() { System.Management.ManagementObjectSearcher Searcher = new System.Management.ManagementObjectSearcher("Select * from WIN32_SerialPort"); foreach (System.Management.ManagementObject Port in Searcher.Get()) { if (System.Text.RegularExpressions.Regex.IsMatch(Port.Properties["PNPDeviceID"].Value.ToString(),"BT")) { foreach (System.Management.PropertyData Property in Port.Properties) { Console.WriteLine(Property.Name + " " + (Property.Value == null ? null : Property.Value.ToString())); } } } Console.ReadLine(); } } }
Please see this link for more details:
http://botbench.com/blog/2011/09/23/finding-bluetooth-paired-nxts-with-wmi/
Kind Regards,
06-30-2017 08:38 AM
I think you are right to use system.io.ports.
How do you get access to system.io.ports in labview. If I attempt to open that assembly class with a property I just get the "This assembly contains no public classes or interfaces"
07-01-2017 06:01 AM
Before connecting, use the Find VISA Resource to get a list of available COM ports. Then after you connect, use it again to figure out which was added. You now know what COM port was added due to that Bluetooth connection.
07-01-2017 06:25 AM
That works as long as you have physical access to the machine. But if it's a remote machine which might reboot and enumerate the connected devices in another order then you'll need a lower level solution like above.
07-01-2017 02:22 PM - edited 07-01-2017 02:23 PM
That is correct LathoS,
The entire reason this function is needed is because there are multiple devices connected to different machines. Different technicians are expected to use different machines, the user-needs specify that the technicians won't have to open device manager to determine which com port is connected to which device. (understandably this will increase productivity as it will decrease wasted time opening and looking at device configuration multiple times a day each day)
I have determined that there is a method to do this through registry queries but it's a significant pain. There is a function in the Windows development pack that is called USBview, but it's not compiled into a DLL or .net assembly so is not useful unless somebody can explain how to transform the .net c# code into labVIEWease
07-01-2017 08:08 PM
So you have a central machine controlling all Bluetooth connections in a test lab? Or is each machine managing itself?
07-03-2017 07:32 PM
Essentially one machine with multiple permanently enumerated comports. Some of the connected devices are the same as others.