Author Topic: Finding windows assigned com port with WCL  (Read 16501 times)

OneEng

  • Guest
Finding windows assigned com port with WCL
« on: July 17, 2014, 12:19:06 AM »
Hi,

I have a legacy application that uses a 3rd party serial com port connection.  Currently, if we manually pair a bluetooth device, we can go into windows bluetooth manager and visually see which com port it is using and manually connect to this com port.  This method does work, but we want it to be automatic.

I am using the WCL to automatically determine which com port is being used by the bluetooth device of my choosing and to pair a new device.

I have read several posts where you strongly recommend that we not use 3rd party devices to communicate with bluetooth devices; however, we have found that the latency we are able to achieve using our 3rd party device code is able to achieve ~15-20mSec latencies reliably while using the WCL Client can only give us ~25-25mSec latency.  Therefore at this time, we must continue to use the legacy method.

I wish to make it so we can eliminate the manual process for figuring out the virtual com port that windows is using.  As it is now, I can create a virtual com port in WCL, and get the com port in the wclVirtualCOMPortAfterOpen(TObject *Sender, DWORD Port, int Error) event using the C++ builder XE version.

Unfortunately, once I create a virtual com port, it appears that the port is held by the WCL.  If I close the port, it doesn't just close the com port, it un-pairs the device.  If I don't close the port, the port is closed for me when I unload the WCLApi... and the device is unpaired.

I am testing on Windows 7 and my computer uses the microsoft blue tooth stack.

Any help would be greatly appreciated.  I love your library.  It makes it possible to deal with the chaos of windows bluetooth.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Finding windows assigned com port with WCL
« Reply #1 on: July 17, 2014, 08:03:12 AM »
Hi,

Unfortunately there is no way to know which port assigned to paired device (at least there is no common way which can work for all supported BT stacks). So the only way to use vCOM is wclVirtualCOMPort and pass a vCOM port number to your legacy app somehow, wait when your app finished (WaitForSingleObject on a process handle helps) and then destroys vCOM.

OneEng

  • Guest
Re: Finding windows assigned com port with WCL
« Reply #2 on: July 17, 2014, 03:37:45 PM »
Hi Mike,

Thanks very much for the advice.

I am using wclVirtualCOMPort.  I am unclear on a few things.

  • If the device is not paired, do I need to pair it before I create the virtual com port
  • Why does the pairing disappear when I close the virtual com port?
[li]It appears that if I don't close the virtual com port, that it is not available for use by other programs (I have only checked through windows bluetooth manager)
[/li][/list]

I will be doing more work on this to actually hook up a serial port using a 3rd party component to see if I can communicate once the virtual com port is created.

Is it necessary for the pairing to be eliminated when the wclVirtualCOMPort is closed?

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Finding windows assigned com port with WCL
« Reply #3 on: July 17, 2014, 04:39:28 PM »
Hi,

1. Pairing depends on your device requirement. Usually SPP requires pairing. However, you can use wclAuthenticator and do not think about pairing (when it is needed wclAuthenticator generates an event and you can provide PIN or accept pairing).
2. It also depends on Bluetooth driver. With MS BT driver it is unpaired when device removed.
3. It is also depends on Bt driver, But usualy vCOM is available only during it is created by the component.

OneEng

  • Guest
Re: Finding windows assigned com port with WCL
« Reply #4 on: July 17, 2014, 09:18:39 PM »
Thank you Mike!

 

Sitemap 1 2 3 4 5 6 7