Anda di halaman 1dari 8

BLUETOOTH APPLICATION IN JAVA (J2SE) FOR TRANSFERRING DATA FROM PC TO MOBILE

Introduction to Bluetooth –

Bluetooth is an open wireless protocol for exchanging data over short


distances from fixed and mobile devices, creating personal area networks (PANs). It
was originally conceived as a wireless alternative to RS232 data cables. It can
connect several devices, overcoming problems of synchronization.

Uses -

Bluetooth is a standard and communications protocol primarily designed for


low power consumption, with a short range (power-class-dependent: 1 meter, 10
meters, 100 meters) based on low-cost transceiver microchips in each device.
Bluetooth makes it possible for these devices to communicate with each other when
they are in range. Because the devices use a radio (broadcast) communications
system, they do not have to be in line of sight of each other.

Maximum Permitted Range


Clas
Power (approxim
s
mW (dBm) ate)

Clas ~100
100 mW (20 dBm)
s1 meters

Clas
2.5 mW (4 dBm) ~10 meters
s2

Clas
1 mW (0 dBm) ~1 meter
s3
In most cases the effective range of class 2 devices is extended if they
connect to a class 1 transceiver, compared to a pure class 2 network. This is
accomplished by the higher sensitivity and transmission power of Class 1 devices.

Data
Version
Rate

Version 1.2 1 Mbit/s

Version 2.0 +
3 Mbit/s
EDR

System Requirements -

A personal computer must have a Bluetooth adapter in order to communicate


with other Bluetooth devices (such as mobile phones, mice and keyboards). While
some desktop computers and most recent laptops come with a built-in Bluetooth
adapter, others will require an external one in the form of a dongle. Unlike its
predecessor, IrDA, which requires a separate adapter for each device, Bluetooth
allows multiple devices to communicate with a computer over a single adapter.

A mobile phone that is Bluetooth enabled is able to pair with many devices. To
ensure the broadest support of feature functionality together with legacy device
support, the Open Mobile Terminal Platform (OMTP) forum has recently published a
recommendations paper, entitled "Bluetooth Local Connectivity"; see external links
below to download this paper.

Technical Information -

Bluetooth protocol stack

“Bluetooth is defined as a layer protocol architecture consisting of core


protocols, cable replacement protocols, telephony control protocols, and adopted
protocols”

Mandatory protocols for all Bluetooth stacks are: LMP, L2CAP and SDP

Additionally, these protocols are almost universally supported: HCI and


RFCOMM

LMP (Link Management Protocol)

Used for control of the radio link between two devices. Implemented on the
controller.
L2CAP (Logical Link Control & Adaptation Protocol)

Used to multiplex multiple logical connections between two devices using


different higher level protocols. Provides segmentation and reassembly of on-air
packets.

In Basic mode, L2CAP provides packets with a payload configurable up to


64kB, with 672 bytes as the default MTU, and 48 bytes as the minimum mandatory
supported MTU.

In Retransmission & Flow Control modes, L2CAP can be configured for reliable
or isochronous data per channel by performing retransmissions and CRC checks.

Bluetooth Core Specification Addendum 1 adds two additional L2CAP modes


to the core specification. These modes effectively deprecate original Retransmission
and Flow Control modes:

Enhanced Retransmission Mode (ERTM): This mode is an improved version of


the original retransmission mode. This mode provides a reliable L2CAP channel.

Streaming Mode (SM): This is a very simple mode, with no retransmission or


flow control. This mode provides an unreliable L2CAP channel.

Reliability in any of these modes is optionally and/or additionally guaranteed


by the lower layer Bluetooth BDR/EDR air interface by configuring the number of
retransmissions and flush timeout (time after which the radio will flush packets). In-
order sequencing is guaranteed by the lower layer.

Only L2CAP channels configured in ERTM or SM may be operated over AMP logical
links.

SDP (Service Discovery Protocol)

Used to allow devices to discover what services each other support, and what
parameters to use to connect to them. For example, when connecting a mobile
phone to a Bluetooth headset, SDP will be used to determine which Bluetooth
profiles are supported by the headset (Headset Profile, Hands Free Profile, Advanced
Audio Distribution Profile etc) and the protocol multiplexer settings needed to
connect to each of them. Each service is identified by a Universally Unique Identifier
(UUID), with official services (Bluetooth profiles) assigned a short form UUID (16 bits
rather than the full 128)

HCI (Host/Controller Interface)

Standardized communication between the host stack (e.g. a PC or mobile


phone OS) and the controller (the Bluetooth I.C.) This standard allows the host stack
or controller I.C. to be swapped with minimal adaptation.
There are several HCI transport layer standards, each using a different
hardware interface to transfer the same command, event and data packets. The
most commonly used are USB (in PCs) and UART (in mobile phones and PDAs).

In Bluetooth devices with simple functionality, e.g. headsets, the host stack
and controller can be implemented on the same microprocessor. In this case the HCI
is optional, although often implemented as an internal software interface.

RFCOMM (Cable replacement protocol)

Radio frequency communications (RFCOMM) is the cable replacement


protocol used to create a virtual serial data stream. RFCOMM provides for binary
data transport and emulates EIA-232 (formerly RS-232) control signals over the
Bluetooth baseband layer.

RFCOMM provides a simple reliable data stream to the user, similar to TCP. It
is used directly by many telephony related profiles as a carrier for AT commands, as
well as being a transport layer for OBEX over Bluetooth.

Many Bluetooth applications use RFCOMM because of its widespread support


and publicly available API on most operating systems. Additionally, applications that
used a serial port to communicate can be quickly ported to use RFCOMM.

Reference –

http://en.wikipedia.org/wiki/Bluetooth

Bluetooth Related with JAVA –

The Java APIs for Bluetooth is a Java ME specification for APIs that allow Java midlets
to use Bluetooth on supporting devices. The specification was developed under the
Java Community Process as JSR 82. The Specification, Reference Implementation,
and TCK are maintained at Motorola Open Source.

Java APIs described in the JSR-82 interface for following Bluetooth Protocols/Profiles:

SDAP - Service Discovery Application Profile

RFCOMM - Serial Cable Emulation Protocol

L2CAP - Logical Link Control and Adaptation Protocol

GOEP - Generic Object Exchange (OBEX) Profile


JSR 82 implementations for Java 2 Platform Standard Edition (J2SE) are also
available.

BlueCove provides an implementation of the JSR 82. Applications


should use API defined in JSR-82. See javax.bluetooth package for JSR-82
Bluetooth API and javax.obex package for JSR-82 OBEX API. Javadocs for this
packages are licensed under the Apache License, Version 2.0 and copied
from The Java Community Process - JSR 82 website.

Refer to the following link

http://bluecove.org/bluecove/apidocs/overview-summary.html

Related books and jar file are attached here for the reference

Bluetooth.pdf bluecove-2.1.0.jar J 2ME Bluetooth


Programming.pdf

The Application made -

The application that is made at our end is the application for sending the any
type of file be it image, be it text, be it video (mobile compatible) from PC to mobile.
The file which is sent can also be received in a PC with Bluetooth enabled. The
application is capable of sending files to multiple devices at a time; hence it is not
necessary to select a device.

Basically, the client requirement was to develop an application which is


capable of sending text file of about 500 words to multiple devices at the same
instance of time. The requirement was also to send the message to a 100 meter of
range, which was totally dependent upon the Bluetooth device range. Hence, the
application was made filling the above client requirements.

The application basically is a standard J2SE application which is using the


bluecove-2.1.0. jar java API’s for running. The application consists of four class files.

1. SendObexClient.java

This class file contains the main method that starts the
application with the init method defined in it. The init method comprise
of ServiceSearch object which is basically searching for the OBEX
service which is required for the device to be capable of sending the
message. It also contains the call for the sendFile method which is in
turn is called for sending the file from PC to mobile or any Bluetooth
device capable of receiving the message.
SendObexClient.java

2. ServiceSearch.java

This class file contains the methods for searching the services of
the Bluetooth device found nearby. This will simply return the services
found on the particular device, which in turn is found by the
RemoteDeviceDiscovery object which is the class searching the
remote devices around.

ServiceSearch.java

3. RemoteDeviceDiscovery.java

This is the class file for searching the devices in vicinity. This
class file contains the various methods discovering the devices.

RemoteDeviceDiscov
ery.java

4. SendFileTask.java

This is the class file which basically takes the method to send
the file from pc to mobile. It uses the ClientSession, HeaderSet objects
to transfer the message.

ServiceSearch.java

The Testing Phase –

During the testing phase we faced various types of issues. The first
successful test was done on a internal Bluetooth enabled Laptop, then application
was successfully tested with the computer with externally installed Bluetooth
(Bluetooth dongle). The application was not working with the bluesoleil driver;
instead it was working with the Widcomm driver which was Microsoft enabled. The
widcomm driver had to be installed in our PC from some external source to make it
compatible with our Bluetooth device. Other issues faced during testing were of
range and load that our application can sustain. By load we mean the number of
devices to which the file can be transferred at the single instance of time. The range
was dependent on the Bluetooth device and the application was successfully
sending the files to multiple devices at a same time.

Running the Application -

Attached are the application executable and the related jar file for running the
application.

bluecove-2.1.0.jar BluetoothED.jar

To run this application:

1. Your desktop (with Bluetooth dongle attached and enable after driver installed) or Laptop
with Bluetooth on
2. Copy the given jar file into any folder location.
3. The PC/laptop should have JDK 1.5 version or above and classpath set to run the java command from
command prompt
5. Open a command prompt console and navigate to the folder you have copied the jar file
6. Then execute the command

java -jar BluetoothED.jar

Both the jar files should be kept at the same folder location.

Future Enhancements -

Future Enhancement to the project is likely to make it compatible with the all
types of Bluetooth drivers, and all types of Bluetooth devices, which can be done
further using the improved Bluetooth API’s. Some more API’s are existing but we
were unable to search for the jar file, hence couldn’t be used. Like BCC API’s.

Anda mungkin juga menyukai