0
votes

I maintain an application that, amongst other things, provides a list to the user of available serial port devices on the host computer. This application makes use of the GetDefaultCommConfig() function in order to verify that devices in its list of serial port names are valid. I have received notice that my application does not work with Bluetooth serial ports. While debugging this issue today, I found that the GetDefaultCommConfig() function does not return a successful value when called with the bluetooth serial port name. The GetLastError() function returns 29 (invalid parameter) in these circumstances. Is there a workaround for this problem?

2
What Bluetooth stack is it? Microsoft's own or Widcomm/Broadcom, BlueSoleil or Toshiba? Or all of them? :-,(alanjmcf
It's the Microsoft stack and I am using the serial comms API.Jon Trauntvein
Yeh I see that behaviour here too. (Widcomm ports are ok with that API for instance). I use WMI or look in the Registry for instance to get the port names see e.g. 32feet.codeplex.com/…alanjmcf
I use the registry to get a list of port names but that method can result in names for ports that aren't currently functional (such as a USB serial port that has been unplugged). I use GetDefaultCommConfig() to ignore any names that don't appear to be valid. This function always appears to fail for Bluetooth mapped serial ports.Jon Trauntvein
I suppose one could look at HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM and if the name is \Device\BtModemNNN then its the MSFT Bluetooth stack and don't use GetDefaultCommConfig() ...alanjmcf

2 Answers

2
votes

I've had a look at the serial ports on my machines with Bluetooth and can confirm that GetDefaultCommConfig() fails for virtual Serial Ports created by the Microsoft Bluetooth stack. It seems to work ok for Widcomm ports however. (I haven't tested BlueSoleil/Toshiba/etc.)

So it seems the best plan is not to use GetDefaultCommConfig() for the MSFT ports. To identify which ports are which stack, check the values under HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM, which lists the COM port name as the value. If the value name is "\Device\BtModemNNN" then it's the MSFT Bluetooth stack. (Widcomm has "\Device\BtPortNNN").

[HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM]
"\\Device\\BtPort3"="COM19"
"\\Device\\BthModem2"="COM25"

Alan

0
votes

This isn't a full answer. I have found that my Windows 7 development machine quite correctly returns from GetDefaultCommConfig() for Bluetooth SPP COM ports even with using MSFT's stack (the ports show \Device\BthModem0 and \Device\BthModem1).

However, I do see GetDefaultCommConfig() failing in Windows 8.1 with a return code of 87 (returned by GetLastError()). This is identical in behaviour to COM ports that definitely don't exist.

The SPP COM ports do still work with a Hyperterminal type application but I do not know how the ports are scanned or opened in that application - I only know my application uses GetDefaultCommConfig() and its ilk from kernel32.dll and that this does not work.

Long shot and a half but I don't suppose anybody else has any input after 4 years?