Creating A Bluetooth Virtual Com Port - Symbol MC9000-G Product Reference Manual

Hide thumbs Also See for MC9000-G:
Table of Contents

Advertisement

6-40
MC9000-G with Windows

Creating a Bluetooth Virtual COM Port

There are two ways to write an RFCOMM application. The first is by creating a virtual legacy COM
port. The second is through Winsock. Microsoft recommends using Winsock.
The sample code that follows demonstrates how to create a Bluetooth virtual COM port.
// Begin
SetCursor(LoadCursor(NULL, IDC_WAIT)); // Set a wait cursor
memset (&pp, 0, sizeof(pp));
pp.uiportflags = RFCOMM_PORT_FLAGS_KEEP_DCD;
pp.channel = 1;
pp.flocal = FALSE;
// pp.imtu should be set to something other than the default, if data payload size is larger than
// 128 /bytes. For further information on this structure, refer to the Microsoft Help.
GetBA(_T("53594D421722"), &pp.device); // ** Set your slave's BDADDR here
nIndex = 8;
// For devices that expose the stream interface, the drivers are DLL files. Each driver is initialized by
// a call to the RegisterDevice function. The Device Manager calls this function on behalf of the
// driver. However, applications can load their own special-purpose stream interface, in which case
// they also call this function to register the driver.
h = RegisterDevice(_T("COM"), nIndex, _T("btd.dll"), (DWORD)&pp);
if (h != NULL)
{
// Success!
hComPort = InitSerial(TEXT("COM8:"), CBR_115200);
if (hComPort == NULL)
{
// Failure!
#ifdef DEBUG
®
Mobile 2003 Software for Pocket PCs PRG
// Clear the PORTEMUPortParams
// structure.
// DCD ON while in piconet
// Set to either an explicit server channel, or, for a server
// application that wants the server channel to be
//autobound, to RFCOMM_CHANNEL_MULTIPLE.
// Set to FALSE for a client port that is used
// to creating outgoing connections.
// This must be the same as the COM port number.
// Init port.

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents