Firstly, the client establishes the Bluetooth transport layer connection
by using the GCF Connector.open()
with OBEX client URL.
The JSR-82 specification defines three types of URL for using OBEX over RFCOMM
(Bluetooth), TCP/IP, and IrDA. For example, an OBEX client connection URL
over RFCOMM may look like:
btgoep://00A3920B2C22:12
where:
btgoep
- is the protocol (Bluetooth
Generic Object Exchange Profile)
00A3920B2C22
- is the Bluetooth Address
of the target device
12
- is the RFCOMM server channel identifier
(each OBEX service has its own identifier)
This information is obtained during device discovery and service discovery. The OBEX client URL is similar to other JSR-82 Bluetooth URL formats and allows using various optional parameters, as defined in the JSR-82 specification.
In case an application wants to connect to a standard OBEX service (for
example, send the message to the Inbox or browse the file system of the remote
device), it must use the UUID defined in Bluetooth
Assigned Numbers. For example, the short Universally Unique Identifier
(UUID) 0x1105
is used for searching the standard Inbox
service and the short UUID 0x1106
- for Bluetooth OBEX
File Transfer Profile services.
Note: Nokia Prototype SDK 3.0 / 4.0 for JavaTM Platform,
Micro Edition used for developing the example application supports only OBEX
over RFCOMM (btgoep
).
The Connector.open()
method returns a ClientSession
object.
The ClientSession
interface provides methods for accessing
the client part of the OBEX protocol, which is responsible for sending requests
to a server; for example, in order to issue the OBEX CONNECT, call method connect()
of
the ClientSession
interface. GET and PUT requests are
issued by invoking get()
and put()
methods
respectively.
In order to create headers, the method createHeaderSet()
of
the interface ClientSession
is used. Using the returned HeaderSet
object
you can define a set of headers, which can be transmitted during such operations
as CONNECT, PUT, GET, etc.
Methods get()
or put()
return
an Operation
object representing the current PUT or GET
operation. In practice, by using an Operation
object
you can access transmitted data via input and output streams. In case of lengthy
operations, the Operation.abort()
method is used to stop
the current operation. However, the Operation.abort()
does
not affect the connection session and new operations can be executed after
the abortion.
Other OBEX commands are accessible via the ClientSession
object
in a similar manner and are thoroughly described in the JSR-82 specification.