Java Reference
In-Depth Information
Note A UUID is a Universally Unique identifier. This is usually a very large number, typically 128 bits. UUIDs
are generated using a combination of unique items (such as the MAC address on an ethernet interface) and
random elements (the clock ticks on the computer at time of number generation). The idea is that the proba-
bility of two numbers generated, anywhere in the world, at any time, is infinitesimally small. In Bluetooth,
some UUIDs are “short” and are only 16 or 32 bits long. However, these short UUIDs are always converted
to 128 bits before comparison. 128-bit UUIDs are frequently expressed in programs as hexidecimal strings
(“BAE0D0C0B0A000955570605040302010”, for example).
The Bluetooth specification describes a number of interoperability profiles, much like the
role of the profiles in J2ME, for implementers of Bluetooth devices. These profiles specify
interoperability standards between different implementations. The Service Application Discovery
Profile (SADP) enables applications running on Bluetooth devices to discover services. The
Java API for Bluetooth works over this profile to give you the high-level ability to discover
services (with or without having to explicitly discover the devices).
At the lower level, the actual protocol used for service discovery between devices is called
the Service Discovery Protocol (SDP).
Other than the SADP, JSR 82-compliant devices must also support the Generic Access
Profile, or GAP (for access to device remotely), and the Serial Port Profile, or SPP (serial port
emulation for sending and receiving streamed data between devices).
The Bluetooth API
The Java API for Bluetooth is delivered as the javax.bluetooth package. The following sections
describe the most important classes and interfaces in this package.
Accessing Local Bluetooth Stack
You can talk to the software stack local to your device using the LocalDevice class. For example,
you can get information on your stack by calling one of the following:
String getBluetoothAddress() ;
DeviceClass getDeviceClass();
DiscoveryAgent getDiscoveryAgent();
String getFriendlyName() ;
The first method returns the address, specific to Bluetooth, for the device. You don't really
need to know how the address is formatted, since you will either store it or send it to somebody
else “as is.”
getDeviceClass() will return the major class of the device. getDiscoverable() will indicate
whether the device can be discovered by other devices. The getDiscoveryAgent() method
is a static factory method that can be used to obtain the singleton instance of the device's
 
Search WWH ::




Custom Search