Java Reference
In-Depth Information
however, infrared devices can discover one another when they are in range. Connections
between infrared devices can be formed dynamically.
As with Bluetooth, low-level communications over infrared is packet based. With Blue-
tooth, the “btspp://” protocol provides a high-level stream interface, via the RFCOMM protocol,
over the low-level L2CAP packet-based protocol. With infrared communications, the lower-
level packet-based protocol is called the IrDA protocol, and OBEX serves as a means to provide
a high-level object-based communications protocol on top of IrDA.
OBEX
OBEX, or Object Exchange, is a protocol designed to enable exchange of data such as contact
and scheduling information in vCalendar and vCard formats. It is a request/response protocol,
loosely modeled after the ubiquitous Hypertext Transfer Protocol (HTTP). OBEX is not exclu-
sively tied to IrDA as its transport protocol. For example, OBEX can work over TCP/IP as well as
RFCOMM (Bluetooth).
Tip While OBEX over TCP/IP and OBEX over RFCOMM/Bluetooth represent possible stackings of software
protocols, you are less likely to find many devices supporting them. This is because IrDA and OBEX have a
very strong bond if you are creating firmware and/or new devices. Furthermore, Bluetooth and IP networks
have high-level protocol solutions that are similar to OBEX, rendering it significantly less important outside
of the infrared arena. If you want to experiment, the Wireless Technology Kit 2.x supports these stacks on
the emulator.
OBEX Requests
All of the Java APIs for OBEX are in the javax.obex package. JSR 82 fully specifies the content of
this package.
As a request/response protocol, an OBEX session consists of a series of client requests and
the corresponding server responses. Like HTTP, each request and response can contain a set of
headers and a body. The ClientSession interface in the OBEX API has methods that facilitate
the sending of client requests. The available OBEX requests, and their corresponding methods
in ClientSession , are tabulated in Table 12-5. The GET and PUT operations, spanning multiple
requests, are most frequently used to transfer large binary objects from and to the server.
When you're in a session (when connect() returns successful), you can get the current
connection ID using the following:
public long getConnectionID();
Depending on your application's requirement, there are at least two ways to communicate
using the OBEX APIs:
Via OBEX request headers
•Via the Operation object with a PUT or GET
 
Search WWH ::




Custom Search