Bluetooth Chat: An Android Private Chatroom

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 5

Bluetooth Chat

An Android Private Chatroom


Husain Shah
Department of Computer Science (Bachelors), UIA
Gombak, Malaysia
Email: [email protected]

2014). Firstly, the working frequency band starts the


This project is based on the development of a chat application application and searches the Bluetooth devices, this occurs
that makes use of Bluetooth rather than the internet in order to during the connection initialization phase. The signals are send
initiate chat conversation. Low-cost wireless connections and to the server class in the second phase after which it can run,
low-power are two of the most attractive features that are stop and pause the application. The alert is shown in the third
provided by Bluetooth and can be used in mobile devices and phase, where the setAlert function appears on every changing.
other accessories as well. This, therefore, provides an open The server goes active and sends the signals to other devices
standard for the implementation of a short range wireless while the Client class works to respond to the other Bluetooth
communication. Bluetooth, when integrated into Android, which device server. This enables a two-way chat over Bluetooth,
is a mainstream smart phone platform becomes a means of
requiring no GSM or Wi-Fi connection. Chat rooms can be
mobile communication. A large number of developers have been
used to gather more than two persons at a time in addition to
attracted to the Android design because it possesses the
characteristics of both, open sourcing and powerful application
the person to person chat.
AP I. The purpose of this project is to explore the concept of a
chat room designed on the basis of Bluetooth. The aim is to
analyse the architecture of the Android platform and introduce
the process of implementing the Bluetooth communication in II. BLUETOOTH ARCHITECTURE
detail. We eventually proceed to design and implement the Bluetooth is a wireless technology standard for exchanging
concept of a chat room based on Bluetooth by making use of data over short distances. This is a low cost transmission
API’s of Android platform. technology for the handheld devices and various electronic
Keywords—Bluetooth; chat; android; smartphone.
products. A Linux kernel, Bluetooth driver, Bluetooth protocol
layers blueZ Bluetooth user library, and a blueZ adaption layer
are all parts of an Android Bluetooth system. Asynchronous
I. INTRODUCTION data and synchronous language both, can be transmitted at the
The development of mobile communication and mobile same by Bluetooth. The underlying protocol layers are L2C
terminal, especially the release of android smartphone in recent AP, SDP, RFCOMM, etc. that include a number of
years, has led to a renewed strength and vivacity within the agreements, which enable the provision of the upper
mobile space (Pan, Luo, & Xu, 2012). Linux is a completely transmission. In order to establish a Bluetooth communication,
open and integrated platform for mobile devices and Android, we need to have a server and a client, similar to TCP traffic. In
which is an open source mobile operating system, is based on this chat system, one Android phone serves as a Bluetooth
Linux. Android platform consists of the operating system, server-side, and the other Android phone completes the
middleware, and user interface and application software. The functions of acting as a Bluetooth client. Once the client is
Android platform provides ample support for the Bluetooth connected to the server, he is able to receive text messages
network stack which enables a device to wirelessly exchange from the server, and, consequently, also able to send similar
data with other Bluetooth devices. The main source of the new text messages to the server. The application is able to function
vitality in the mobile space is due to the Android platform the same way for the server also, where the server is able to
system (Mahajan, Verma, Erale, Bonde, & Arya, 2014). send and receive text messages.
Android is an operating system based on Linux kernel and is There are three steps involved in the Bluetooth
designed for the touch screen mobile devices. The user
communication process are:
interface of Android is based on direct manipulation. The
Android phones can be divided into client and server with the 1. Query Bluetooth: The Bluetooth Adapter is used to get the
help of Bluetooth. The initiation of a Chat is accomplished Bluetooth Activity. The entry-point for all Bluetooth
only after the division of client and server, wherein the server interaction is the Bluetooth Adapter, which is used to get the
helps in initializing the connection. Bluetooth Activity. It also enables the discovery other
Bluetooth devices.
Bluetooth does not require a license around the globe for
the working frequency band (Verma, Gupta, Gupta, & Singh,
Designer and Blocks. Designer interface basically designs the
interface for your app and involves the organization of
components. The main role, however, is played by the second
interface, where the user can provide function and behaviour to
the components that he used in designer interface. This is
referred to as the coding part of the project.
The basic idea of creating this program was to have a cheap
and easy way to handle communication with other nearby
devices. This enables people who don’t have an Internet
connection, such as those in a classroom, in houses, and so on,
to chat for free. The first step involved the creation of an
account in MIT app inventor 2(BETA) server and then click on
new project>type the name for the project and click ok. This
helped in creating a program friendly environment for me in
order to create apps. The layout tab in the workspace was used
in order to design the layout of the app. Four horizontal
Figure1: Bluetooth inquiries, the pairing process arrangement layouts and one vertical arrangement layout was
2. Finding devices: The second step requires the opening of used, where each layout is used to different components. In
the Bluetooth user name and MAC address in order to pair the Figure 4, the image will give you the complete layout structure.
Bluetooth. It also contains some of the hidden components like
3. Connecting Bluetooth: The third step involves making the BluetoothClient1, BluetoothServer1, Clock1, Notifier1 and
request of the BLUETOOTH PERMISSION in order to Accelerometer Sensor1. The main task involved connecting
establish any Bluetooth communication, such as requesting a these components with each other and giving them the function
connection, accepting a connection and transferring the data. to perform. This can be done using the Blocks interface.

Figure3: Interface Layout

Figure2: Bluetooth pairing and Connection process


III. METHODOLOGY
The entire coding of the android chat application is done
using MIT App Inventor 2 (Beta) which is a blocks-based
programming tool. With the use of this app, everyone, even
novices, are able to start programming and build fully
functional apps for Android devices. It was initially developed
by Professor Hal Abelson and a team from Google Education
while Hal was on sabbatical at Google. App Inventor runs as a
Web service administered by staff at MIT’s Center for Mobile
Learning - a collaboration of MIT’s Computer Science and
Artificial Intelligence Laboratory (CSAIL) and the MIT Media Figure4: Components
Lab. the usage of MIT App inventor 2(BETA) makes The following picture depicts a general idea of what the
programming hassle free. It is comprised of two interfaces; application looks like.
Bluetooth on his Android phone and pair it with another device
that contains the same application.

Figure 8: Block used for error display


This block deals with any errors that might take place and
eventually activates the following blocks.

Figure 5: Main interface


It can clearly be seen that the navigation and usage of this
application will be very easy even by a new user.

Figure 9: Block used for checking bluetooth availability

Figure 6: Blocks
The above picture shows the main coding of the application
which was done with the help of afore mentioned MIT App
Inventor2 Beta. Figure 10: Block used for connecting two devices

Figure 7: block used for auto generate username


As soon as the screen is launched, the user is shown a
random integer that falls between 1000 and 9999, as shown in
the block. During this time, the disconnect button is disabled. Figure 11: Block used for initializing startup screen
In order to use this application, a user is required to switch his
This block notifies the user to switch on his Bluetooth on
his Android phone if it is not. Once the pairing is completed,
the user can click Connect. This will lead to a display of all the
paired devices, as shown in Figure 12.. The person with which
the pairing has been initiated has to emulate the same process
to get this application running. The running application will
render the Connect button to be disabled and the Disconnect
and Send button to be enabled after which the users will be
able to send and receive messages to and from the device that
he has paired his Android phone with.

Figure 15: Block used for sending a message


This block is responsible for the sending of the messages. If
the value of the global bool server is true, the send button will
be activated, which shows that he is connected to the server.

Figure 12: Block responsible for connecting

Figure 16: Block used to display message in the chat


history layout
This block shows that once the message is sent, which is
Figure 13: Block responsible for enabling the buttons when shown in the chat history. This block enables you to retype
a connection is successfull messages in the chatbox. The users on both sides continue
their chat. When the users will try to disconnect the
This above orange block shows that the default value for application, the following block will do the work.
global bool server is false, which does not enable the Send
button to function. The second block shows that the Connect
button will be disabled and the Disconnect and Send button
will be enabled, which shows that you are connected to the
Bluetooth application server.

Figure 14: Block used for clearing the chat history


The chat history is cleared when the clear button is clicked,
which is shown in the above block.

Figure 17: Block used for disconnecting


When the user clicks the Disconnect button, it calls the
Disconnect function. The purple block is the Disconnect
function, which displays in the chat history box that the user is
disconnected. If the global bool server value if true, the
Bluetooth server1 is disconnected, or else the Bluetooth client1
is disconnected. In the end, the value of the global bool server
will be rendered false, after which the user gets disconnected.
IV. ACKNOWLEDGMENT Android Bluetooth. International Journal of
I would like to extend my sincere thanks to my supervisor Computer Science and Mobile Computing, 712-717.
Professor Amelia Ritahani Bt. Ismail for helping me Pan, W., Luo, F., & Xu, L. (2012). Research and Design of
throughout the course of my project and guiding me through chatting room system based on Android Bluetooth.
all of the problems that were faced. I thank her for her Consumer Electronics, Communications and
patience and of course, all gratitude to Allah swt for helping Networks (CECNet), 2012 2nd International
me during this time and enabling me to complete my project. Conference on, 3390-3393.
Verma, R., Gupta, R., Gupta, M., & Singh, R. (2014). A
V. REFERENCES complete study of chatting room system based on
Mahajan, N., Verma, G., Erale, G., Bonde, S., & Arya, D. android bluetooth. Moradabad, India: International
(2014). Design of Chatting Application Based on Journal of Emerging Technology and Advanced
Engineering.

You might also like