Creating a Data Connection That Uses Bluetooth DUN

Windows CE 5.0 Not SupportedWindows Embedded NavReady 2009 Supported

10/16/2008

Some connected applications on a Windows Embedded NavReady powered device, such as a Live Search application, must access the Internet to send or receive data.

To enable an application to connect to the Internet, a Windows Embedded NavReady powered device without a built-in wireless network adapter or cellular capabilities can use a paired Bluetooth-enabled device as a wireless modem to access the Internet. The paired device and the Windows Embedded NavReady powered device must both support the Bluetooth Dial-up Networking (DUN) profile.

When you create a data connection to the Internet by using Connection Manager, Windows Embedded CE automatically activates and uses the Bluetooth Dial-up Networking (DUN) profile to connect to a paired device and access the Internet.

If you do not want to use Connection Manager, you can create the data connection manually by using the Bluetooth Pairing Service. A paired device is required for a connected application that uses DUN. For more information, see How to Create and Manage Bluetooth Pairing Relationships.

To manually create a data connection that uses Bluetooth DUN

  1. In Platform Builder for Windows CE 5.0, open your connected application.

    • On the File menu, choose Open, and set Files of type to "Projects (.pbpxml)".
    • Browse to the project file, select it, and choose Open.
  2. In the source code for your connected application, add an #include statement for btpairapi.h, ras.h, and raserror.h.

  3. Set up the RAS entries, such as the RAS entry name, RAS entry parameters, device name, device type, local phone number, and RAS dial parameters. For more information about setting up RAS entries, see Dial-up Samples.

  4. Obtain the Bluetooth device address of the device that is paired to the Windows Embedded NavReady powered device by using the Bluetooth Pairing Service.

  5. Call ActivateBTDevice to obtain the number of the virtual Bluetooth COM port that is used for Bluetooth DUN connections. In this function call, Pass DialupNetworkingServiceClassID_UUID16 into the nProfileID parameter, and pass the btAddr member of the PAIREDDEVICEINFO structure into the btdevice parameter.

  6. Call RAS Dial functions in order to establish a dial-up connection to a remote server through the opened Bluetooth DUN connection. For example, you can use the functions in the RAS API. For more information about how to call RAS Dial functions, see Dial-up Samples and Starting a RAS Connection.

    Note

    Bluetooth DUN communicates over a Bluetooth link by using GSM TS 07.10 and AT commands.

  7. When you are finished with the Internet connection, call DeActivateBTDevice, passing in the btAddr member of the PAIREDDEVICEINFO structure as btdevice.

  8. Rebuild the connected application.

    • On the Build Project menu, choose Build Current Project.

Example

The following code example is a simple illustration of how to use the ActivateBTDevice function to open a Bluetooth DUN connection, so that you can start establishing a dial-up connection by using the paired device.

Note

To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.

#include "stdafx.h"
#include "ras.h"
#include "raserror.h"
#include btpairapi.h"

PAIREDDEVICEINFO    pi;
DWORD               dwBufSize = sizeof(pi);

DWORD  dwErr = GetBTDeviceList(  HandsfreeAudioGatewayServiceClassID_UUID16, TRUE, &pi, &dwBufSize );
 
UINT    nPortNo = BTPAIRAPI_INACTIVE_PORT_NUM;

ActivateBTDevice( pi.m_btAddr, DialupNetworkingServiceClassID_UUID16, &nPortNo );
// Insert code to update the RAS book and update the RASENTRY device name with nPortNo

See Also

Concepts

Overview of Dial-up Networking (DUN) Profile (Data Terminal Role)
How to Make a Data Connection by Using Connection Manager

Other Resources

Bluetooth Profiles Application Development
Bluetooth Pairing Service Reference