OBject EXchange

This article is about the communications protocol. For the portion of the brain, see Obex.

OBEX (abbreviation of OBject EXchange, also termed IrOBEX) is a communications protocol that facilitates the exchange of binary objects between devices. It is maintained by the Infrared Data Association but has also been adopted by the Bluetooth Special Interest Group and the SyncML wing of the Open Mobile Alliance (OMA). One of OBEX's earliest popular applications was in the Palm III personal digital assistant. This PDA and its many successors use OBEX to exchange business cards, data, even applications.

Although OBEX was initially designed for infrared, it has now been adopted by Bluetooth, and is also used over RS-232, USB, WAP, and in devices such as Livescribe smartpens.

Comparison to HTTP

OBEX is similar in design and function to HTTP in providing the client with a reliable transport for connecting to a server and may then request or provide objects. But OBEX differs in many important respects:

Objects

OBEX works by exchanging objects, which are used for a variety of purposes: establishing the parameters of a connection, sending and requesting data, changing the current path or the attributes of a file.

Objects are composed of fields and headers. As an example, the following may be the object used for requesting the phonebook from a mobile:

Object Fields Command GET, Final 0x83
Length total length of object 0x00 0x29
Headers Connection ID 1 0xCB 0x00 0x00 0x00 0x01
Name "telecom/pb.vcf" 0x01 0x00 0x1e 0x00 0x74 0x00 0x65 0x00 0x6c 0x00 0x65 0x00 0x63 0x00 0x6f 0x00 0x6d 0x00 0x2f 0x00 0x70 0x00 0x62 0x00 0x2e 0x00 0x76 0x00 0x63 0x00 0x66 0x00 0x00

This object contains two fields (command and length) and two headers. The first field (command) specifies that is a request for data (GET). The second field is the total size of the object, including the two fields.

This object also contains two headers, specifically a "Connection ID" and a "Name". The first byte of each header is the header's name and its content type. In this case:

A possible response, containing the requested data, could be:

Response Fields Response code OK, Final 0xA0
Length total length of object 0x00 0x35
Headers End-of-Body "BEGIN:VCARD..." 0x49 0x00 0x2F 0x42 0x45 0x47 0x49 0x4e 0x3a 0x56 0x43 0x41 0x52 0x44

In this example, the phonebook is assumed short enough to be contained in a single response object. The only header has 0x49 as its identifier, meaning that it is an "End of Body", the last chunk of information (also the only one, in this case). The first two bits of 0x49 are 01, meaning that the content of this header is length-prefixed data: the two next bytes 0x00 0x2F tells the length of this data (in decimal, 47), the succeeding ones are the data, in this case a phonebook comprising only an empty vCard of 47 bytes.

This example shows a single GET command and its response, the only headers involved being connection id, name and end-of-body. Before issuing it, a CONNECT command should have been sent for establishing some parameters of the connection, including the connection id. Other commands are: put, setpath, action, abort, disconnect. Some other notable headers include: type, time, description, target.

Session

After the client (e.g., computer) connects to the server (e.g., mobile), a typical session consists in the client sending a number of objects and getting their responses from the server. As an example:

The exchange may differ significantly depending on the service. For example, SyncML does not use SETPATH, while a OBEX push is made of just CONNECT (without a TARGET header), PUT and an optional DISCONNECT.

Protocols

The following protocols runs over OBEX, or have bindings to do so:

Implementations

javax.obex

Optional package javax.obex in Java APIs for Bluetooth provides an implementation of OBEX in Java.[1]

OpenObex

OpenObex is an open-source implementation of OBEX in C. It provides functions for connecting over IrDA, Bluetooth, USB and TCP/IP, building objects and handling received data. An example schema of a client application is:

void callback_function(...) {
  /* process received data */
}
 
int main() {
  OBEX_Init(..., callback_function);
  OBEX_TransportConnect(...);
 
  object=OBEX_ObjectNew(...);
  OBEX_ObjectAddHeader(object, ...);
  OBEX_ObjectAddHeader(object, ...);
  OBEX_Request(..., object);
  while(...)
    OBEX_HandleInput(...)
 
  object=OBEX_ObjectNew(...);
  OBEX_ObjectAddHeader(object, ...);
  OBEX_Request(..., object);
  while(...)
    OBEX_HandleInput(...)
 
  /* ... */
 
  OBEX_TransportDisconnect(handle);
  OBEX_Cleanup(handle);
}

Objects are sent by OBEX_Request. After calling OBEX_HandleInput, received data is processed in the callback function (which was specified when calling OBEX_Init). The callback function can determine whether the response has been completely received, and therefore whether the main program can exit from the while loop it is executing.

PyOBEX

PyOBEX provides partial support for OBEX in Python.[2]

Profiles

OBEX is the foundation for many higher-layer "profiles":

Profiles
Classification Profile
IrDA Point and Shoot profile
Infrared Financial Messaging (IrFM) profile
Bluetooth SIG Generic Object Exchange Profile
Object Push Profile (phone to phone transfers)
File Transfer Profile (phone to PC transfers)
Synchronization Profile
Basic Imaging Profile
Basic Printing Profile
OMA SyncML binding

Supported devices

See also

References

External links