Cosc 5/4730 Android Bluetooth. Bluetooth Basics First off Bluetooth is NOT – Infrared, which requires line-of-sight – 802.11a/b/g/n. It was designed as.

Slides:



Advertisements
Similar presentations
Bluetooth. Wireless networking technology Limited broadcast range (< 10 meters) Example uses include Connecting headsets to phones, keyboard/mouse to.
Advertisements

1 Working with the Bluetooth radio Nilanjan Banerjee Mobile Systems Programming University of Arkansas Fayetteville, AR
1 Introduction to Bluetooth v1.1 (Part I) Overview Radio Specification Baseband Specification LMP L2CAP.
Design Description Java Bluetooth stack (JBS). What is a Bluetooth stack? In short, to get any functionality out of a Bluetooth device, one needs to implement.
Mohamed Mokdad Ecole d’Ingénieurs de Bienne
A CHAT CLIENT-SERVER MODULE IN JAVA BY MAHTAB M HUSSAIN MAYANK MOHAN ISE 582 FALL 2003 PROJECT.
1 Java Networking – Part I CS , Spring 2008/9.
WECPP1 Java networking Jim Briggs based on notes by Amanda Peart based on Bell & Parr's bonus chapter
CPET 260 Bluetooth. What is Bluetooth? Not IEEE (Wi-Fi) or HomeRF Originally designed to replace wires Short-range, lower-power wireless technology.
Bluetooth: Blackberry (JSR 82) And Android
Computer Networks IGCSE ICT Section 4.
The OSI Model A layered framework for the design of network systems that allows communication across all types of computer systems regardless of their.
 The Open Systems Interconnection model (OSI model) is a product of the Open Systems Interconnection effort at the International Organization for Standardization.
Bluetooth. Bluetooth is an open, wireless protocol for exchanging data between devices over a short distance. –managed by the Bluetooth Special Interest.
TCP Sockets Reliable Communication. TCP As mentioned before, TCP sits on top of other layers (IP, hardware) and implements Reliability In-order delivery.
2011 Embedded Systems Software Training Center BluRapport SDK.
Hacking the Bluetooth Pairing Authentication Process Graduate Operating System Mini Project Siyuan Jiang and Haipeng Cai.
BLUETOOTH. Introduction Bluetooth technology discussed here aims at so-called ad- hoc piconets, which are local area networks with a very limited coverage.
Data Communications and Networks
Distributed systems – Part 2  Bluetooth – 2 nd set of slides Anila Mjeda.
1 Chapter Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer.
Kaj J. Grahn1 A Virtual Airport Flight Information System Implemented with Bluetooth Nicolas Le Duigou, ENSEIRB Kaj J. Grahn, Arcada Polytechnic.
INTRODUCTION Bluetooth technology is code name for Personal Area Network (PAN) technology that makes it extremely easy to connect a mobile, computing device.
By Santosh Sam Koshy. Agenda Need for Bluetooth Brief History of Bluetooth Introduction to Bluetooth Bluetooth System Specifications Commercial Bluetooth.
Bluetooth Kirthika Parmeswaran Telcordia Technologies OOPSLA’2000.
1 Chapter Overview Using the New Connection Wizard to configure network and Internet connections Using the New Connection Wizard to configure outbound.
© 2007 Cisco Systems, Inc. All rights reserved.Cisco Public 1 Version 4.0 Network Services Networking for Home and Small Businesses – Chapter 6.
Distributed systems – Part 2  Bluetooth 4 Anila Mjeda.
Distributed Topology Construction of Bluetooth Personal Area Networks Theodoros Salonidis, Pravin Bhagwat, Leandros Tassiulas and Richard LaMaire.
Bluetooth Techniques ECE 591. Overview  Universal short-range wireless capability  Uses 2.4-GHz band  Available globally for unlicensed users  Devices.
© 2009 Research In Motion Limited Advanced Java Application Development for the BlackBerry Smartphone Trainer name Date.
REVIEW On Friday we explored Client-Server Applications with Sockets. Servers must create a ServerSocket object on a specific Port #. They then can wait.
10/15/ Short-Range Radio Frequency Networking B. Ramamuthy.
King Fahd University of Petroleum & Minerals Electrical Engineering Department EE400 PROJECT Personal Area Networks Instructed by Dr.AlGhadbanPresenters.
Doc.: IEEE /033r2 Submission July 1999 Simon Baatz, University of BonnSlide 1 Integration of Bluetooth into LAN Environments Simon Baatz, Matthias.
HandsFree Profile (HFP) 통신연구소 S/W Team 이상제.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 23 - Bluetooth™ Wireless Technology Outline 23.1 Introduction 23.2 History of Bluetooth Wireless.
Li Tak Sing COMPS311F. Case study: consumers and producers A fixed size buffer which can hold at most certain integers. A number of producers which generate.
BLUETOOTH Created By: Ajay Bahoriya. Agenda Introduction to Bluetooth Bluetooth Basics Mode of operation Technology Security Advantages Integrating BT.
Bluetooth Techniques Chapter 15. Overview of Bluetooth Initially developed by Swedish mobile phone maker in 1994 to let laptop computers make calls over.
Bluetooth on CE. Mid - Presentation Roman Zoltsman & Oren Haggai Group /2001 Instructor: Nir Borenshtein HSDSL Lab. Technion.
발표자 : 현근수 Bluetooth. Overview wireless protocol short-range communications technology single digital wireless protocol connecting multiple devices mobile.
Team Topic Presentation Team 6 BLUETOOTH What is Bluetooth? Cable Replacement Automatic Connectivity Hidden Computing Few Examples: 1.Automatic Door.
SEMINAR ON BLUETOOTH TECHNOLOGY
Networking in Linux. ♦ Introduction A computer network is defined as a number of systems that are connected to each other and exchange information across.
GPRS functionality overview in Horner OCS. GPRS functionality – Peer to Peer communication over GPRS – CSCAPE connectivity over GPRS – Data exchange using.
Lectured By: Vivek Dimri Asst Professor CSE Deptt. SET.
Bluetooth In 1994, the L. M. Ericsson company became interested in connecting its mobile phones to other devices without cables. A SIG (Special Interest.
Mapping Salutation to Bluetooth 4 Overview 4 Bluetooth Summary 4 Salutation Architecture Summary 4 Mapping Bluetooth SDP to Salutation APIs 4 Mapping Bluetooth.
JPMA PROJECT PRESENTATION (ITU) 1 INTRODUCTION BLUETOOTH CHAT DESIGN JAVA ON MOBILE DEVICE Presenters Benjamin Boateng Abass Omer Venkateshwar Rao Namilakonda.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
UNIT-6. Basics of Networking TCP/IP Sockets Simple Client Server program Multiple clients Sending file from Server to Client Parallel search server.
Agenda Socket Programming The OSI reference Model The OSI protocol stack Sockets Ports Java classes for sockets Input stream and.
Technology By :-. What Is Bluetooth? Designed to be used to connect both mobile devices and peripherals that currently require a wire Short range wireless.
Development of a Bluetooth based web camera module.
Network Programming. These days almost all devices.
Bluetooth Technology -Prepared By Jasmin Patel -Guided By Jagruti Goswami.
Bluetooth Technology -Prepared By Jasmin Patel -Guided By Jagruti Goswami.
Created by :- prashant more prashant more. INTRODUCTION Bluetooth is wireless high speed data transfer technology over a short range ( meters).
Bluetooth.
MCA – 405 Elective –I (A) Java Programming & Technology
A Wireless LAN technologies IEEE
Wireless Communication between Android Application and Sensors
“I don’t have to be careful, I’ve got a gun.”
Bluetooth Profiles.
BLUETOOTH Personal Area Networking [ PAN ] over Bluetooth
Short-Range Radio Frequency Networking
Short-Range Radio Frequency Networking
Emilia Nisha D’souza [ ]
Presentation transcript:

Cosc 5/4730 Android Bluetooth

Bluetooth Basics First off Bluetooth is NOT – Infrared, which requires line-of-sight – a/b/g/n. It was designed as a network (LAN) technology. About 300 feet or 100 meters Bluetooth is – a cable replacement technology. PAN (Personal Area Network) of about 30 feet (10 meters) Transfer speed about 1 Mbit/sec and burst speed of about 20 Mbit/sec – Signals are omni-directional and can pass through walls and briefcases.

Bluetooth Network Topology Bluetooth-enabled devices are organized in groups called piconets. – A piconet consists of a master and up to seven active slaves. – A master and a single slave use point-to-point communication; if there are multiple slaves, point-to-multipoint communication is used. – A master unit is the device that initiates the communication. – A device in one piconet can communicate to another device in another piconet, forming a scatternet, as depicted in next slide.

Bluetooth Network Topology Notice that a master in one piconet may be a slave in another piconet.

Establishing a Connection the following procedures are carried out automatically when a application uses a bluetooth connection 1.Inquire: In a new environment, the device automatically initiates an inquiry to find an access point. All nearby access points respond with their addresses, and the device picks one. 2.Page: The paging procedure synchronizes the device with the access point. 3.Establish a link: The Link Manager Protocol establishes a link with the access point. 4.Discover services: The LMP uses the Service Discovery Protocol (SDP) to find out what services are available from the access point. Here we assume that the service is available. 5.Create an L2CAP Channel: The LMP uses information obtained from the Service Discovery Protocol (SDP) to create an L2CAP channel to the access point. The application may use this channel directly or use a protocol like RFCOMM (Radio Frequency Communications Protocol) that might be running over L2CAP. RFCOMM emulates a serial line. 6.Create an RFCOMM channel: Depending on the needs of the application, an RFCOMM channel (or another channel) is created over the L2CAP channel. Creating an RFCOMM channel allows an existing application that works with serial ports to work with Bluetooth as well, without any modifications. 7.Authenticate: This is the only step that requires input from the user. If the access point requires authentication, it will send an authentication request, and the user will be prompted to enter a PIN to access the service. For security reasons, the PIN code itself is not sent over the wireless link, but rather a key generated from it. 8.Log in: If the devices use the Point-to-Point Protocol (PPP) over RFCOMM, a serial port is emulated, and user may login to the service, such as (if that's the application). 9.Send and receive data: The client and the access point now use standard network protocols like TCP/IP to send and receive data.

Bluetooth Profiles Note that Bluetooth devices cannot interact unless they conform to a particular profile – having the bare minimum Bluetooth stack isn't enough. The Generic Access Profile defines connection procedures, device discovery, and link management. – It also defines procedures related to use of different security models and common format requirements for parameters accessible on the user interface level. At a minimum all Bluetooth devices must support this profile. The Service Discovery Application and Profile defines the features and procedures for an application in a Bluetooth device to discover services registered in other Bluetooth devices, and retrieves information related to the services. The Serial Port Profile defines the requirements for Bluetooth devices that need to set up connections that emulate serial cables and use the RFCOMM protocol. The LAN Access Profile defines how Bluetooth devices can access the services of a LAN using PPP, and shows how PPP mechanisms can be used to form a network consisting of Bluetooth devices. The Synchronization Profile defines the application requirements for Bluetooth devices that need to synchronize data on two or more devices.

Bluetooth Security All Bluetooth-enabled devices must implement the Generic Access Profile, which contains all the Bluetooth protocols and possible devices. This profile defines a security model that includes three security modes: – Mode 1 is an insecure mode of operation. No security procedures are initiated. – Mode 2 is known as service-level enforced security. When devices operate in this mode, no security procedures are initiated before the channel is established. This mode enables applications to have different access policies and run them in parallel. – Mode 3 is known as link-level enforced security. In this mode, security procedures are initiated before link setup is complete.

Standard Bluetooth Applications File transfer. Ad-hoc networking – Communicating devices can spontaneously form a community of networks that persists only as long as it's needed Device synchronization – Seamless connectivity among PDAs, computers, and mobile phones allows applications to update information on multiple devices automatically when data on any one device changes. Peripheral connectivity Car kits – Hands-free packages enable users to access phones and other devices without taking their hands off the steering wheel Mobile payments – Your Bluetooth-enabled phone can communicate with a Bluetooth-enabled vending machine to buy a can of Diet Pepsi, and put the charge on your phone bill.

What is UUID? The UUID class defines universally unique identifiers. These 128-bit unsigned integers are guaranteed to be unique across all time and space. – Accordingly, an instance of this class is immutable. – The Bluetooth specification provides an algorithm describing how a 16-bit or 32-bit UUID could be promoted to a 128-bit UUID. – Accordingly, this class provides an interface that assists applications in creating 16-bit, 32-bit, and 128-bit long UUIDs. – The methods supported by this class allow equality testing of two UUID objects. The Bluetooth Assigned Numbers document ( defines a large number of UUIDs for protocols and service classes.

Most common UUIDs NameValueSize Base UUID Value (Used in promoting 16-bit and 32-bit UUIDs to 128-bit UUIDs) 0x F9B34FB128-bit SDP0x bit RFCOMM0x bit OBEX0x bit HTTP0x000C16-bit L2CAP0x bit BNEP0x000F16-bit Serial Port0x bit ServiceDiscoveryServerServiceClassID0x bit BrowseGroupDescriptorServiceClassID0x bit PublicBrowseGroup0x bit OBEX Object Push Profile0x bit OBEX File Transfer Profile0x bit Personal Area Networking User0x bit Network Access Point0x bit Group Network0x bit

Simulator note No Bluetooth in the android simulators You must use the hardware for testing and you need two (client/server model). – Testing and debuging becomes more difficult – Can you guess why?

Android Does not implement JSR-82 (nor OBEX). – Uses it own functions. – Found in the android.bluetooth package.

android.bluetooth package BluetoothAdapter – Represents the local Bluetooth adapter (Bluetooth radio). The BluetoothAdapter is the entry-point for all Bluetooth interaction. Using this, you can discover other Bluetooth devices, query a list of bonded (paired) devices, instantiate a BluetoothDevice using a known MAC address, and create a BluetoothServerSocket to listen for communications from other devices. BluetoothDevice – Represents a remote Bluetooth device. Use this to request a connection with a remote device through a BluetoothSocket or query information about the device such as its name, address, class, and bonding state. BluetoothSocket – Represents the interface for a Bluetooth socket (similar to a TCP Socket). This is the connection point that allows an application to exchange data with another Bluetooth device via InputStream and OutputStream. BluetoothServerSocket – Represents an open server socket that listens for incoming requests (similar to a TCP ServerSocket). In order to connect two Android devices, one device must open a server socket with this class. When a remote Bluetooth device makes a connection request to the this device, the BluetoothServerSocket will return a connected BluetoothSocket when the connection is accepted. BluetoothClass – Describes the general characteristics and capabilities of a Bluetooth device. This is a read-only set of properties that define the device's major and minor device classes and its services. However, this does not reliably describe all Bluetooth profiles and services supported by the device, but is useful as a hint to the device type.

Bluetooth Permissions Like much of the hardware, you need to add a permission line in the androidManifest.xml file... – Needed if you turn on/off bluetooth or change how the device functions.

Setting Up Bluetooth The BluetoothAdapter is required for any and all Bluetooth activity BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (mBluetoothAdapter == null) { // Device does not support Bluetooth } To check and see if Bluetooth is enabled and enable it private static final int REQUEST_ENABLE_BT = 2 … if (!mBluetoothAdapter.isEnabled()) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); }

Paired devices If the device you need has already been paired, then you can query to find out if it is connected or not. Set pairedDevices = mBluetoothAdapter.getBondedDevices(); // If there are paired devices if (pairedDevices.size() > 0) { // Loop through paired devices for (BluetoothDevice device : pairedDevices) { // Add the name and address to an array adapter to show in a ListView mArrayAdapter.add(device.getName() + "\n" + device.getAddress()); }

Enabling Discoverability Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); discoverableIntent.putExtra( BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300); startActivity(discoverableIntent); By default, the device will become discoverable for 120 seconds, but this code changes it to 300 seconds. Note the user may get this screen

Discovering Devices To find a device, you use startDiscovery(), via a BroadcastReceiver. // Create a BroadcastReceiver for ACTION_FOUND private final BroadcastReceiver mReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { String action = intent.getAction(); // When discovery finds a device if (BluetoothDevice.ACTION_FOUND.equals(action)) { // Get the BluetoothDevice object from the Intent BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); // Add the name and address to an array adapter to show in a ListView mArrayAdapter.add(device.getName() + "\n" + device.getAddress()); } }; // Register the BroadcastReceiver IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND); registerReceiver(mReceiver, filter); // Don't forget to unregister during onDestroy

Managing the devices Before you can connection to each, unpaired devices will be paired. This is done automatically in the framework, but the user will get a pairing dialog – It will fail if the user says no or the pairing times out. Once the two devices are paired, then a connection can be made.

Server Side bluetooth Like networking, you setup a socket (BluetoothServerSocket) and accept a connection. – Use the listenUsingRfcommWithServiceRecord( String, UUID). – String is the Name – UUID is similar to UUID before (see the note on android website)

Server Side bluetooth example // Name for the SDP record when creating server socket private static final String NAME = "BluetoothChat"; // Unique UUID for this application private static final UUID MY_UUID = UUID.fromString("fa87c0d0-afac-11de-8a c9a66"); BluetoothServerSocket mmServerSocket = null; BluetoothSocket socket = null; try { // MY_UUID is the app's UUID string, also used by the client code mmServerSocket = mAdapter.listenUsingRfcommWithServiceRecord(NAME, MY_UUID); socket = mmServerSocket.accept(); } catch (IOException e) { }

Client side bluetooth To initiate a connection with a remote device, first you discover the BluetoothDevice object that represents the remote device. – Shown in Discovering Devices and in paired devices. Using the BluetoothDevice, get a BluetoothSocket by calling createRfcommSocketToServiceRecord(UUID). Initiate the connection by calling connect(). – Note connect is blocking and should be not called when in discovery mode.

Client side bluetooth example // Unique UUID for this application private static final UUID MY_UUID = UUID.fromString("fa87c0d0-afac-11de-8a c9a66"); //find remote device... //from discovery example previously. // Get a BluetoothSocket to connect with the given BluetoothDevice; BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);... BluetoothSocket mmSocket=null; try { // MY_UUID is the app's UUID string, also used by the server code mmSocket = device.createRfcommSocketToServiceRecord(MY_UUID); mmSocket.connect(); } catch (IOException e) { }

Connected via Android bluetooth Once both the client and server are setup with sockets – Now it's just like standard network code. – PrintWriter out = new PrintWriter( new BufferedWriter( new OutputStreamWriter(socket.getOutputStream())),true); – BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); – But you will likely need to deal with disconnections, if either of the "phones" is moved out of connection range, then the connection will fail and have to be restarted once they are in range again.

Android References CN/guide/topics/wireless/bluetooth.html Android BluetoothChat example found in SDK and/or the development website.

Q A &