Bluetooth SPP

M

Markus Humm

Hello,

I'm new to bluetooth but shall build a bluetooth connection to a BT
device supporting serial port profile.

The application uses currently COM1 on the PDA with 9600 Baud and no
handshaking whatever. If I simply change the setting to use e.g. COM5
which is displayed as BT Serial UART by one utility I get the BT Manager
shown on opening the port but if I tipp on the device shown there it
normally throws some exception with a message that "open port failed:
the device is not connected or network is not ready" (similar message,
can deliver the exact one in a few days).

So the questions are:

1. how to integrate Bluetooth seamlesly into the app. without going too
deep into the details of the BT stack, because I want to stay
independent of the 2 stacks around.

2. How to find the bluetooth serial port on a given device?

3. How to set up a permanent BT link to a given device? I'd like it to
automatically connect if the device in question is in reach so that
there is as few user interaction as necessary.

4. Can one switch on BT if it is off via application, but indipendent of
the Stack (MS vs. other)?

Btw: we're using CF 1.0 with VS2003.

Greetings

Markus
 
P

Peter Foot [MVP]

Hi, answers inline:-

Peter

--
Peter Foot
Windows Embedded MVP
www.peterfoot.net | www.inthehand.com

Markus Humm said:
Hello,

I'm new to bluetooth but shall build a bluetooth connection to a BT
device supporting serial port profile.

The application uses currently COM1 on the PDA with 9600 Baud and no
handshaking whatever. If I simply change the setting to use e.g. COM5
which is displayed as BT Serial UART by one utility I get the BT Manager
shown on opening the port but if I tipp on the device shown there it
normally throws some exception with a message that "open port failed:
the device is not connected or network is not ready" (similar message,
can deliver the exact one in a few days).

So the questions are:

1. how to integrate Bluetooth seamlesly into the app. without going too
deep into the details of the BT stack, because I want to stay
independent of the 2 stacks around.

The way ports are setup on the two main stacks (Microsoft and Broadcom) is
rather different. On Microsoft it's a one-off process when pairing the
device, on Broadcom the default behaviour will allow the user to chose a
device when an attempt is made to open the port. You can remove this dialog
by setting a registry key which will force it to use the last device which
was chosen for the virtual COM port
http://www.peterfoot.net/StopBroadcomStackDisplayingBrowser.aspx
2. How to find the bluetooth serial port on a given device?

There isn't a standard way of doing this since the available ports are
different on different devices and the stacks store this in different
locations. Prior to WM5.0 the virtual serial port mechanism on the Microsoft
stack was partly provided by the OEM so registry settings are located in
different places. With WM5.0 virtual COM port support was built into the
Settings > Connections > Bluetooth control panel applet and the registry
settings were standardised.
3. How to set up a permanent BT link to a given device? I'd like it to
automatically connect if the device in question is in reach so that
there is as few user interaction as necessary.

This is the standard behaviour on Microsoft stack once you've setup the port
once (unless the device is hard-reset). On Broadcom you can achieve this by
setting the registry key as detailed in the link above.
4. Can one switch on BT if it is off via application, but indipendent of
the Stack (MS vs. other)?

Sadly the Broadcom/Widcomm stack doesn't provide a mechanism to set the
radio state (although it was available on some older iPaq devices). There is
a standard API for setting the radio on Microsoft stack - BthSetMode which
you could P/Invoke or use a wrapper - http://32feet.net for example.
 

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

Similar Threads


Top