Professional Documents
Culture Documents
DEVELOPMENT PROJECT
Name of the project: Wireless controlling pc
by using Bluetooth supported mobile.
Project supervisor
Mr. Sheikh Md. Masudul Ahsan
Assistant Professor
Khulna-9203
Project submitted by
Samiul hoque Prosenjit Shaha
Roll: 0507035
Roll:0507012
ACKNOWLEDGEMENTS
1. Objectives
2. What is Bluetooth
4. RFCOMM
5. Profiles
14. Limitations
15. Conclusion
16. Resources
2.We can see Text file and image file in mobile and play and control song in pc.
3. This software enables user to control various windows applications (ex: Restart ,
Log off , Turn off) from a remote place and no need to use keyboard or mouse.
What is Bluetooth?
Bluetooth is a wireless communication protocol mainly used for short distance and in
devices with low power consumption. Because Bluetooth is capable of communicating in an
omni-directional manner of up to 30 feet at 1 Mb/s it is far superior to infrared. Where
infrared requires a distance of a few feet or less and requires a direct line of site for
transmissions. The Bluetooth core system consists of a radio frequency (RF) transceiver,
baseband, and protocol stack. The system offers services that enable the connection of
devices and the exchange of a variety of classes of data between these devices. Actually it's
a wireless communication protocol that, like HTTP or FTP, operates in a client/server
architecture. It uses the 2.4 GHz band. If there are multiple
peripherals to be connected to a computer using RS-232 or USB, then Bluetooth is the ideal
solution to use those devices wirelessly.
For example the Bluetooth protocol stack similar with the HTTP protocol stack . A Web
browser uses an HTTP protocol stack so that it can receive Web content like HTML pages,
images, files, and best of all, Java applets. A Web server also uses an HTTP protocol stack
to send out Web content to Web browsers over the network. So, like the HTTP protocol
stack, a Bluetooth protocol stack will allow Bluetooth clients and servers to send and receive
data over a wireless network.
RFCOMM
RFCOMM is commonly known as the wireless serial port, or the cable replacement
protocol. The name is derived from the fact that the serial ports are called COMM1, COMM2,
etc. RFCOMM simulates the functionality of a standard serial port. For instance, a Bluetooth-
enabled mobile would use the RFCOMM
some Bluetooth kits come with a driver that will allow the operating system to communicate
over the virtual serial port as if it were an actual serial port. By using the serial port profile we
were able to send stream data to PC. The Bluetooth device in PC receives the stream data
through virtual com port. There are many profiles such as:
1. javax.bluetooth (the 13 classes and interfaces that are needed to perform wireless
communication with the Bluetooth protocol)
2. javax.obex (the 8 classes that are needed to send objects between devices,
independent of the transport mechanism between them)
Device Management
LocalDevice, RemoteDevice, and DeviceClass are the classes in the Java Bluetooth
specification that form the Generic Access Profile and allow you to perform device
management. These classes allow you to query some statistical information about your own
Bluetooth device (LocalDevice) and also some information on the devices in the area
(RemoteDevice). The DeviceClass object gives you information about the official class of
device (CoD) as defined in the Bluetooth specification.
The two classes needed in order for your Bluetooth device to discover remote Bluetooth
devices in the area: DiscoveryAgent and DiscoveryListener.
The method DiscoveryAgent is used to make the Bluetooth device search for other devices
in the area. The length of the inquiry is totally dependent upon the implementation of the
Java Bluetooth specification. The accessCode can be one of the following DiscoveryAgent
constants:
A reference to a class that implements the DiscoveryListener interface is also passed. When
new devices are discovered, event callbacks are passed back to this object. This method will
return true if the device successfully went into discovery mode. The startInquiry() method is
the only way to perform device discovery without blocking the current thread.
Service Discovery
After locating devices in the area, it would be really nice to see what services those devices
offer. The service discovery-related classes in the Java Bluetooth specification implement
the Service Discovery Application Profile. The Service Discovery Application Profile, in turn,
uses the Service Discovery Protocol (SDP) layer in your Bluetooth stack to find services on
remote Bluetooth devices.
The following classes are provided in the Java Bluetooth specification for service discovery:
Discovery Agent, Discovery Listener, Service Record, Data Element, and UUID.
The Service Discovery Database (SDDB) is the central repository for all service records. If a
particular JSR-82 implementation does not store
Service records in the SDDB as Java objects, then it must convert them into Service Record
objects when a client performs a search for services and a match is found.
Communication
As Bluetooth is a communication protocol the official Java Bluetooth API gives three ways
to send and receive data. Here two of them are: RFCOMM for stream data and L2CAP for
packet data.
RFCOMM is the protocol layer that the serial port profile uses in order to communicate.
The Bluetooth dongle works as a receiver or a server and we developed a program for
the mobile which works as the client. The client first discovers the Bluetooth devices around
it. Then it discovers what services they contain. If the device is a desktop and supports the
serial port profile, out client can interact with it over its RFCOMM protocol layer. The client
program sends some stream data as command to PC’s virtual communication port. There is
a server program in the PC which reads stream data from the communication port and
executes those commands.
This is the basic interface of our client program. From its menu we can choose to discover
any Bluetooth device around the host mobile phone or can view the Bluetooth information
about the mobile phone. It can discover any device around its Bluetooth range and can show
its friendly name.
b. Service Discovery
Device Dicovery
Our client program can discover any Bluetooth devices around it. Whenever the Device
discovery option is pressed it starts the discovery agent to discover any remote device.
DiscoveryAgent agent =
device.getDiscoveryAgent();
agent.startInquiry( DiscoveryAgent.GIAC,
new Listener() );
Our client device starts in GIAC mode, which means other remote device also can discover
our device. Whenever a device is discovered a discovery Listener shows the friendly name
of the Bluetooth device.
Service Dicovery
Our client program is also capable of Discovering Services offered by the remote device.
Our program search services with the UUID 0x0003 which is the UUID for RFCOMM.
remote,
Whenever a service is found our program stores the service records in a service array. Then
our program retrieves the service name from a user defined function uuidToName and
shows the list of services in the MIDLET screen.
ServiceRecord rec =
(ServiceRecord)bluetooth.services.elementAt(i);
DataElement e =
rec.getAttributeValue( 0x0001 ); // ServiceClassIDList
Enumeration en = (Enumeration)e.getValue();
DataElement e2 =
(DataElement)en.nextElement();
Controlling The PC
The PC controlling part of our program can send command to a connected PC to control
some basic component of it. The mobile connects with the PC by obtaining the url String
that is needed to connect to the device from the ServiceRecord object that we get from
service discovery. Our program generates the connecting string automatically by comparing
the UUID of Serial Port profile with the UUID of discovered service record objects in the
current inquiry. If there is a match then our program saves the connecting string to connect
with the remote device.
if ( u.equals( new UUID( 0x1105 ) )){ //0x1105 UUID for serial port
profile
remote=(RemoteDevice)bluetooth.devices.elementAt(device
DiscoveryUI.getSelectedIndex());
URL="btspp://"+remote.getBluetoothAddress()
+":"+i+";master=false;encrypt =false;authenticate=false";
In the connecting string the part “btspp:\\” means Bluetooth serial port profile, the next
number is the Bluetooth address of the remote device which is found by
getBluetoothAddress() method. The next digit will be the channel number which will
be the index number of the matching UUID in the Service Record. Here master is false
which means that the client can only request for data transferring operation. Encrypt and
Authenticate is also false.
If there is no matching UUID found then our program rejects to be connected. Our
program also checks the characteristics of the remote device. If the remote device is a
computer and a desktop then it gives permission to be connected.
if((cls.getMajorDeviceClass())!
=256&&(cls.getMinorDeviceClass())!=4)
con = (OutputConnection)
Connector.open( url2,Connector.WRITE );
out = con.openOutputStream();
out.write( data1 );
out.flush();
The Java communications API:
This Java communications API contains support for RS232 serial ports. Using this
API one can:
The Java communications API does not support unsigned applet access to ports.
The Receiver Program:
The receiver program is used in the computer which receives command
from the client’s mobile through serial port and takes necessary steps to perform
different actions. İt contains all the necessary informations to receive command
from the client and to contrtol computer as well as external electric devices.
When the receiver program is run it always waits for a connection from any
bluetooth remote device within it’s range.
The receiver is
waiting for
connection from
any Bluetooth
enable mobile
Here three buttons are used: “Open Port”, ”Close Port” and “EXIT”
The actions to be performed by these buttons are specified in this part of the
receiver program. Any exception in performing the specified action is handled
here.
Now let us discuss about the actions performed by these three buttons
Open Port:
Once the program is started, the appropriate communication port to receive the data from
client is selected from the list of available communication ports. Then the button “Open Port”
is pressed to open the selected port. After the port is successfully opened, it becomes ready to
receive data sent from mobile by the client.
Close Port:
When the function of the opened port come to an end, that port should be
closed so that another ports can be opened further. Because in case of serial
port only port can be accessed at a time. So after performing action the port
should be closed.
EXIT:
If the receiver wishes to be disconnected from client, then the receiver program
should be closed. This is done by pressing the “EXIT” button. After pressing the
“EXIT” button if any port remains opened at that time, then that port is closed
and after this the program terminates.
In the text area the current status of the receiver remains shown. When the
client send new commands status of the receiver becomes changed. This help
anyone near the receiver to know the command that is currently being
processed by the computer
Limitations
Though we have developed our software using the platform independent programming
language Java but our software is not totally platform independent at all.Our soft ware can
only read data from the serial port. It can generate signal from the PC. So we can perform
two way operation. Our software also can’t initialize the Bluetooth stack for dongle. It needs
a matching driver for the dongle.
Conclusion
This software is very much user-friendly. To use it one needs just to press button to control
pc operation. User don’t have to know the Bluetooth address of the server PC. It can
discover any Bluetooth device and there services around it.
This software is applicable for all versions of WINDOWS operating system. As maximum
computer users feel comfort to use this operating system. We are looking forward to improve
our software to make it truly platform independent and to implement the software in two way
communication.
Future plan
1.Our future plan is to stream music files and video files (.3gp,mp4,avi) from pc.
Resources:
1. Jdk 5.5
2. Net Beans IDE 5.5
3. Java how to program 6th edition
- Deitel & Deitel
4. The Complete Reference J2ME
-Herbert Schildt
8 . javax.comm package
Installation Process:
There are two parts of our software. One is developed for the mobile
phone (client sided) which must be installed in appropriate mobile phone. To do
so,
1. Transfer the .JAR and .JAD file to the mobile phone provided in the
CD.(recommended to Bluetooth Serial port enable mobile)
2. Install it.
The other part is developed for the personal computer (server sided) which
processes the upcoming command and takes actions.This software is bundled
with JRE-1.6 and does not requires pre-installation of JAVA. It is also required
to attach a blue tooth receiver to your computer if it is not capable of receiving
blue tooth signal. It is suggested to use a Bluetooth dongle. Now,