MC9000-K/S with Windows
®
Mobile 2003 Software for Pocket PCs PRG
8-40
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));
// Clear the PORTEMUPortParams
// structure.
pp.uiportflags = RFCOMM_PORT_FLAGS_KEEP_DCD;
// DCD ON while in piconet
pp.channel = 1;
// Set to either an explicit server channel, or, for a server
// application that wants the server channel to be
// autobound, to RFCOMM_CHANNEL_MULTIPLE.
pp.flocal = FALSE;
// Set to FALSE for a client port that is used
// to creating outgoing connections.
// 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;
// This must be the same as the COM port number.
// 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);
// Init port.
if (hComPort == NULL)
{
// Failure!
#ifdef DEBUG
Summary of Contents for MC9000-K/S
Page 1: ...MC9000 K S Product Reference Guide with Windows Mobile 2003 Software for Pocket PCs ...
Page 2: ......
Page 26: ...MC9000 K S with Windows Mobile 2003 Software for Pocket PCs PRG xx ...
Page 60: ...MC9000 K S with Windows Mobile 2003 Software for Pocket PCs PRG 1 26 ...
Page 154: ...MC9000 K S with Windows Mobile 2003 Software for Pocket PCs PRG 2 94 ...
Page 158: ...MC9000 K S with Windows Mobile 2003 Software for Pocket PCs PRG 3 4 ...
Page 216: ...MC9000 K S with Windows Mobile 2003 Software for Pocket PCs PRG 3 62 ...
Page 218: ...MC9000 K S with Windows Mobile 2003 Software for Pocket PCs PRG 4 2 ...
Page 314: ...MC9000 K S with Windows Mobile 2003 Software for Pocket PCs PRG 6 28 ...
Page 342: ...MC9000 K S with Windows Mobile 2003 Software for Pocket PCs PRG 7 28 ...
Page 386: ...MC9000 K S with Windows Mobile 2003 Software for Pocket PCs PRG 8 44 ...
Page 388: ...MC9000 K S with Windows Mobile 2003 Software for Pocket PCs PRG 9 2 ...
Page 398: ...MC9000 G with Windows Mobile 2003 Software for Pocket PCs PRG 10 2 ...
Page 444: ...MC9000 K S with Windows Mobile 2003 Software for Pocket PCs PRG 11 42 ...
Page 448: ...MC9000 K S with Windows Mobile 2003 Software for Pocket PCs PRG 12 4 ...
Page 512: ...MC9000 K S with Windows Mobile 2003 Software for Pocket PCs PRG 12 68 ...
Page 514: ...MC9000 K S with Windows Mobile 2003 Software for Pocket PCs PRG 13 2 ...
Page 552: ...MC9000 K S with Windows Mobile 2003 Software for Pocket PCs PRGe 14 34 ...
Page 554: ...MC9000 K S with Windows Mobile 2003 Software for Pocket PCs PRG 15 2 ...
Page 571: ...Block Recognizer Contents Introduction A 3 ...
Page 572: ...MC9000 K S with Windows Mobile 2003 Software for Pocket PCs PRG A 2 ...
Page 612: ...MC9000 K S with Windows Mobile 2003 Software for Pocket PCs PRG B 38 ...
Page 614: ...MC9000 K S with Windows Mobile 2003 Software for Pocket PCs PRG C 2 ...
Page 626: ...MC9000 K S with Windows Mobile 2003 Software for Pocket PCs PRG D 2 ...
Page 714: ...MC9000 K S with Windows Mobile 2003 Software for Pocket PCs PRG D 90 ...
Page 748: ......
Page 749: ......