Bluetooth - Virtual Com Port

B

Ben G

Hi all,

I’m using Visual Studio 2005, Compact Framework 2.0 and C# to develop an
application which needs to transmit/receive data strings (small – only a
couple of bytes) to/from a Bluetooth serial module, e.g.
(http://www.ezurio.com/products/bism/). I’m a novice in this area and
this is the first Pocket PC application I’ve worked on so your patience
with my query will be appreciated.

From basic research on the net I’ve found there doesn’t appear to be a
built in API to access Bluetooth functionality that I initially hoped
for and to be honest expected. The target platform I’m developing for is
a HP iPAQ which I believe uses the BroadCom/Widcomm stack, the SDK for
this is C++ based and this would mean using P/Invoke calls, I don’t have
any experience of this but it does look to make thinks complicated.

On another topic on this forum I did see that it is possible to
communicate via Bluetooth by using a virtual com port, i.e.

//Create output Bluetooth port
SerialPort oBluetooth = new SerialPort("COM8");
oBluetooth.BaudRate = 38400;
oBluetooth.DataBits = 8;
oBluetooth.Parity = Parity.None;
oBluetooth.StopBits = StopBits.One;

//Connect
try
{
oBluetooth.Open();
oBluetooth.WriteLine("Test String");
oBluetooth.Close();
}
catch (Exception ex)
{
MessageBox.Show("Exception: " + ex.Message + " " + ex.StackTrace);
}

Is it really as simple as doing something like the above? I’ve tested
this example on the Pocket PC and attempted to connect with a Bluetooth
enabled laptop, no errors are reported and Bluetooth activity is
indicated on the laptop. What I’m unsure of however is what is required
on the laptop side to receive and display the data? Do I need some form
of handshaking or is this done by the serial port object? Is there
something I could run on the laptop like a terminal window or do I need
to write a custom application? I’ve been searching on the web for
similar examples but haven’t managed to find very much. I’d appreciate
it if anyone could post advice or links. I’d also welcome comments on
whether using the virtual com port is the right approach for what I’m
trying to do or should I be looking to use a commercial SDK such as
BTAccess (http://www.high-point.com/).

Thanks for your time,
Ben.
 
D

Dick Grier

Hi,
Is it really as simple as doing something like the above?
<<

Yes, in general. I use a BT for similar virtual serial connections.
What I’m unsure of however is what is required
on the laptop side to receive and display the data?
<<

Exactly the same as on the device. Open the virtual serial port and proceed
as though you had a physical connection.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
B

Ben G

Thanks for your help Dick, I wrote a small application as you suggested
and am now now able to receive data strings sent from the Pocket PC to
the laptop.

I got the right input port on the laptop by trial and error, the Pocket
PC lists them under Bluetooth Settings > Services > Serial Port >
Advanced and the Inbound & Outbound COM Ports can be viewed/modified
there. For future reference is there a similar configuration page
somewhere in Windows XP that shows this information or is it dependant
on the driver used, I'm using Version v4.00.36 of the Bluetooth Stack
for Windows by Toshiba on a Portege M200.

Also, is there a way of knowing if this will be supported by the
Bluetooth serial module device that is being targeted, anything I should
look for in the spec? Although good to get it working with the laptop
I'm still not sure if the virtual COM port approach will work for the
Bluetooth serial module or whether I'll need to do something at a higher
level such as set up a service.

Thanks again,
Ben.
 
B

Ben G

Thanks Peter,

I'm going to persevere with the Virtual COM port for a while yet but I
see there is an evaluation version of the Franson tools I'll try if that
doesn't work out.

Ben.
 
D

Dick Grier

Franson has a 14-day eval of all of their products. If you decide to
purchase a license, contact me. I can get it for you with a 25% discount.

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 
D

Dick Grier

Hi,
Also, is there a way of knowing if this will be supported by the
Bluetooth serial module device that is being targeted, anything I should
look for in the spec? Although good to get it working with the laptop
I'm still not sure if the virtual COM port approach will work for the
Bluetooth serial module or whether I'll need to do something at a higher
level such as set up a service.
<<

Bluetooth serial devices will work (at least, they should!). Naturally,
there at BT devices that won't (keyboards, mouse, sound devices, network
devices, etc.). I don't think a service would help. The device driver has
to furnish a Virtual Comport. If it does, fine. If it doesn't, then you
have to use some non-serial APIs that are appropriate to that device type.

Dick

--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top