Documentation  |   Table of Contents   |  < Previous   |  Next >   |  Index

12    Bluetooth Exchange Library Support

Low-Level Communications

Exploring Palm OS®

Accompanying the Bluetooth Library is the Bluetooth Exchange Library, a shared library that allows applications to support Bluetooth using the standard Exchange Manager APIs. The Bluetooth Exchange Library conforms to the Object Push and Generic Object Exchange profiles.

For more information about the Exchange Manager, see Chapter 4, "Object Exchange," of the book Exploring Palm OS: High-Level Communications.

Detecting the Bluetooth Exchange Library ^TOP^

To check for the presence of the Bluetooth Exchange Library, you use FtrGet:

err = FtrGet(btexgFtrCreator,
     btexgFtrNumVersion, &btExgLibVersion);

If the Bluetooth Exchange Library is present, FtrGet returns errNone. In this case, the value pointed to by btExgLibVersion contains the version number of the Bluetooth Exchange Library. The format of the version number is 0xMMmfsbbb, where MM is the major version, m is the minor version, f is the bug fix level, s is the stage, and bbb is the build number. Stage 3 indicates a release version of the library. Stage 2 indicates a beta release, stage 1 indicates an alpha release, and stage 0 indicates a development release. So, for example, a value of 0x01013000 would correspond to the released version 1.01 of the Bluetooth Exchange Library.

Using the Exchange Manager With Bluetooth ^TOP^

Using the Exchange Manager with Bluetooth is almost exactly like using it with IrDA and SMS. The differences are as follows:

  • The URL you use when you send an object has some special fields specific to Bluetooth.
  • Your application may want to know the URL of the device or devices with which it is communicating. The Exchange Manager provides a way to get this information.
  • The ExgLibGet() and ExgLibRequest() functions are not supported with Bluetooth.

These differences are discussed further in the following sections.

Bluetooth Exchange URLs ^TOP^

If you send objects using the Bluetooth Exchange Library and use a URL, you can send the objects to single or multiple devices at the same time depending on the way the URL is formed. A Bluetooth Exchange Library URL can have one of the following forms:

_btobex:filename
_btobex://filename
_btobex://?_multi/filename
Performs a device inquiry, presents the available devices to the user, and allows the user to choose one or more devices. Sends the object to all selected devices.
_btobex://?_single/filename
Performs a device inquiry, presents the available devices to the user, and allows the user to choose only one device. Sends the object to that device.
_btobex://address1[,address2, ...]/filename
Sends the object to the device(s) with the specified Bluetooth device address(es). The addresses are in the form "xx:xx:xx:xx:xx:xx".

Do not combine these URL forms. Doing so may give unintended results.

Obtaining the URL of a Remote Device ^TOP^

For some applications you need to know the URL that addresses the remote device from which you receive data. This is especially useful for games. You can get the URL after calling ExgAccept() using the ExgControl() function code exgLibCtlGetUrl as shown in the following code:


ExgCtlGetURLType getUrl; 
UInt16 getUrlLen; 
 
// First get the size of the URL 
getUrl.socketP = exgSocketP; 
getUrl.URLP = NULL; 
getUrl.URLSize = 0; 
getUrlLen =  sizeof(getUrl); 
ExgControl(exgSocketP, exgLibCtlGetURL, &getUrl, &getUrlLen); 
 
// Now get the URL 
getUrl.URLP = MemPtrNew(getUrl.URLSize); 
ExgControl(exgSocketP, exgLibCtlGetURL, &getUrl, &getUrlLen); 
 
// getUrl.URLP points to a null-terminated URL string 
// describing the remote device, for example, 
// "_btobex://01:23:45:67:89:ab/" 
... 
// Free the URL after you're done with it 
MemPtrFree(getUrl.URLP); 

ExgLibGet() and ExgLibRequest() ^TOP^

The Bluetooth Exchange Library does not support the pull functions provided by ExgLibGet() and ExgLibRequest(). If you want to perform these functions, you must use the general Bluetooth Library APIs. See "Developing Bluetooth-enabled Applications".