11-10-2012, 01:36 PM
J2ME Bluetooth Programming
BluetoothProgramming.pdf (Size: 897.03 KB / Downloads: 76)
Introduction
Wireless technologies are becoming more and more popular around the world.
Consumers appreciate the wireless lifestyle, relieving them of the well known “cable
chaos” that tends to grow under their desk. Nowadays, the world would virtually stop
if wireless communications suddenly became unavailable. Both our way of life and
the global economy are highly dependent on the flow of information through wireless
mediums like television and radio. Cellphones have become highly available during
the last decade. Now virtually everyone owns a cellphone, making people available
almost wherever they are. Many companies are highly dependent on their employees
having cellphones, some companies have even decided not to employ stationary
phone systems but instead use cellphones exclusively throughout the organization.
New wireless technologies are introduced at an increasing rate. During the last few
years the IEEE 802.11 [1] technologies have started to spread rapidly, enabling
consumers to set up their own wireless networks. This constitutes an important
change in how wireless communications are made available to consumers. Wireless
networks are no longer provided by big corporations alone, they can just as well be
implemented by individuals. Our society is becoming more and more dependent on
wireless communications as new areas of use are introduced.
The Bluetooth wireless technology is also spreading rapidly. The number of
Bluetooth chipsets shipped per year has doubled from 2002 to a total of 69 million
chipsets in 2003 [2]. The majority of these Bluetooth chipsets are used in mobile
phones. An interesting aspect is that consumers are highly dependent on having a
cellphone, and the Bluetooth technology is included in the majority of new
cellphones. The Bluetooth technology will therefore spread because of the general
need for cellphones. As an increasing number of useful Bluetooth applications
become available, many consumers will already have Bluetooth devices and be ready
to start using Bluetooth PANs (Personal Area Networks) where all their Bluetooth
devices communicate with one another [3].
Bluetooth
This chapter gives a brief introduction to the Bluetooth technology. The Bluetooth
architecture will be explained, in addition to basic Bluetooth actions like device
discovery and service discovery. Bluetooth services and some important details about
service records will be explained as well. After reading this chapter, developers
should have sufficient knowledge about the Bluetooth technology to start application
development with JABWT. For the interested reader, references to in-depth
information about the Bluetooth technology are included throughout the chapter. This
chapter is based on my supervisor's Bluetooth lectures available on his website [11],
the Bluetooth book by Bray and Sturman [12], and the Bluetooth Specification
version 1.1 [13] available for download on the Bluetooth Special Interest Group (SIG)
website [14].
Bluetooth is a low cost, low power, short-range radio technology intended to replace
cable connections between cellphones, PDAs and other portable devices. It can clean
up your desk considerably, making wires between your workstation, mouse, laptop
computer etc. obsolete. Ericsson Mobile Communications started developing the
Bluetooth system in 1994, looking for a replacement to the cables connecting
cellphones and their accessories. The Bluetooth system is named after a tenth-century
Danish Viking king, Harald Blåtand, who united and controlled Norway and
Denmark. The first Bluetooth devices hit the market around 1999.
Piconet and scatternet
A piconet is the usual form of a Bluetooth network and is made up of one master and
one or more slaves. The device initiating a Bluetooth connection automatically
becomes the master. A piconet can consist of one master and up to seven active
slaves. The master device is literally the master of the piconet. Slaves may only
transmit data when transmission-time is granted by the master device, also slaves
may not communicate directly with each other, all communication must be directed
through the master. Slaves synchronize their frequency hopping with the master using
the master's clock and Bluetooth address.
Bluetooth links
Two types of physical links are defined in version 1.1 of the Bluetooth specification,
Synchronous Connection Oriented (SCO) links and Asynchronous ConnectionLess
(ACL) links. The SCO and ACL links are part of the baseband specification.
SCO links are intended for audio transmission. When setting up a SCO link time slots
are reserved for transmission of data, thus providing a Quality of Service (QoS)
guarantee. Lost or erroneous packages are not re-transmitted which makes sense for
voice transmissions. All SCO links operate at 64 kbps. A master device can have up
to three simultaneous SCO links at a time, all to the same slave or to different slaves.
Slave devices can have up to three SCO links to the Master device.
ACL links are intended for data communication. An ACL link provides error-free
transmission of data which means that lost or erronous packets are re-transmitted. No
QoS guarantee is provided. The maximum data rate at the application level is around
650 kbps for an ACL link. A master device can have a number of ACL links to a
number of different devices, but only one ACL link can exist between two devices.
User data is usually transferred to and from the Logical Link Control and Adaption
Protocol (L2CAP) layer of the Bluetooth stack. Application developers usually refer
to L2CAP and RFCOMM links when talking about Bluetooth links. To be precise,
L2CAP and RFCOMM are separate layers in the Bluetooth stack which rely on an
ACL physical link for data transmission.
Device discovery (inquiry) and service discovery
Due to the ad-hoc nature of Bluetooth networks, remote Bluetooth devices will move
in and out of range frequently. Bluetooth devices must therefore have the ability to
discover nearby Bluetooth devices. When a new Bluetooth device is discovered, a
service discovery may be initiated in order to determine which services the device is
offering.
The Bluetooth Specification refers to the device discovery operation as inquiry.
During the inquiry process the inquiring Bluetooth device will receive the Bluetooth
address and clock from nearby discoverable devices. The inquiring device then has
identified the other devices by their Bluetooth address and is also able to synchronize
the frequency hopping with discovered devices, using their Bluetooth address and
clock.
Devices make themselves discoverable by entering the inquiry scan mode. In this
mode frequency hopping will be slower than usual, meaning the device will spend a
longer period of time on each channel. This increases the possibility of detecting
inquiring devices. Also, discoverable devices make use of an Inquiry Access Code
(IAC). Two IACs exist, the General Inquiry Access Code (GIAC) and the Limited
Inquiry Access Code (LIAC). The GIAC is used when a device is general
discoverable, meaning it will be discoverable for a undefined period of time. The
LIAC is used when a device will be discoverable for only a limited period of time.