Project Report - Lighting Control via Bluetooth using Android

50
TABLE OF CONTENTS Hardware Used................................................ 3 Softwares Used............................................... 3 Control Flow................................................. 4 Bluetooth Module............................................4 LPC Xplorer Board...........................................4 Android Application.........................................5 UART Interfacing............................................6 Hardware Details............................................. 8 Roving Network Bluetooth Module (rn41-ek)...................8 Pin-out................................................... 9 Command Mode v/s Data Mode................................9 LPC1830 Xplorer Board......................................11 Introduction............................................. 11 Board Features........................................... 11 Block Diagram............................................ 12 Setup for NXP LPCLink and LPC1830 Xplorer Board..........12 Steps to setup the LPC-Link and LPC1830 Xplorer Board....13 Software Details............................................ 14 LPCXpresso.................................................14 Features................................................. 14 Development Boards....................................... 15 LPC-Link and LPC-Link2...................................16 Android Developer Tools (ADT)..............................17 Integrated Android project creation, building, packaging, installation, and debugging..............................17 SDK Tools integration.................................... 17 Java programming language and XML editors................18

Transcript of Project Report - Lighting Control via Bluetooth using Android

Page 1: Project Report - Lighting Control via Bluetooth using Android

TABLE OF CONTENTS

Hardware Used............................................................................................3Softwares Used............................................................................................3Control Flow................................................................................................4

Bluetooth Module.....................................................................................4LPC Xplorer Board.....................................................................................4Android Application..................................................................................5UART Interfacing.......................................................................................6

Hardware Details.........................................................................................8Roving Network Bluetooth Module (rn41-ek)............................................8

Pin-out...................................................................................................9Command Mode v/s Data Mode.............................................................9

LPC1830 Xplorer Board..........................................................................11Introduction.........................................................................................11Board Features....................................................................................11Block Diagram.....................................................................................12Setup for NXP LPCLink and LPC1830 Xplorer Board............................12Steps to setup the LPC-Link and LPC1830 Xplorer Board....................13

Software Details........................................................................................14LPCXpresso.............................................................................................14

Features...............................................................................................14Development Boards...........................................................................15LPC-Link and LPC-Link2.......................................................................16

Android Developer Tools (ADT)..............................................................17Integrated Android project creation, building, packaging, installation, and debugging.....................................................................................17SDK Tools integration..........................................................................17Java programming language and XML editors.....................................18SDK Tools Integration..........................................................................19

Bluetooth Technology................................................................................20Bluetooth Core Specification..................................................................20

Page 2: Project Report - Lighting Control via Bluetooth using Android

Spectrum.............................................................................................21Interference.........................................................................................21Range..................................................................................................21Power...................................................................................................22Piconet.................................................................................................22Scatternet............................................................................................23GATT Based.........................................................................................24BR/EDR Profiles....................................................................................25BR/EDR Protocols.................................................................................27

Bluetooth Layers....................................................................................28Bluetooth Profile – SPP (Service Port Profile).......................................28SDP (Service Discovery Protocol)........................................................29RFCOMM..............................................................................................29L2CAP (Logical Link Control and Adaptation Protocol).........................30HCI (Host Controller Interface)............................................................32Link Manager.......................................................................................33Baseband Layer...................................................................................33

Future Scope.............................................................................................35References................................................................................................36

Table Of Contents 2

Page 3: Project Report - Lighting Control via Bluetooth using Android

HARDWARE USED

1. Bluetooth Module: Roving Networks rn 41-ek2. Base Board: LPC1830 Xplorer Board3. Program flash/Debugger: LPC Link 24. Cables for connection:

Single pin female headers for connection between Bluetooth module and base board.

One USB to mini B for serial data transfer to LPC link 2. One mini USB for powering up of base board

SOFTWARES USED

1. LPC Xpresso2. Android Development Tool (ADT)

Table Of Contents 3

Page 4: Project Report - Lighting Control via Bluetooth using Android

CONTROL FLOW

BLUETOOTH MODULE

1. Configured in Slave Mode whereby other Bluetooth devices can discover and connect to the module.

2. The serial port settings are set to: a. Baud rate 115,200 b. 8 bits c. No Parity d. 1 stop bit e. Hardware flow control enabled

3. Acts as a gateway passing data to/from the UART

LPC XPLORER BOARD

1. Configures the Bluetooth module2. Sends and receives data from UART3. Decodes commands received to control the LEDS

Table Of Contents 4

Page 5: Project Report - Lighting Control via Bluetooth using Android

ANDROID APPLICATION

The android application has the following features:-

1. Menu Itemsa. Turn Bluetooth Onb. Turn Off Bluetoothc. Connect to Remote Device

Shows list of Paired Devices to select from Also Scans for New Devices

d. Disconnect the Connection

2. Connection Statusa. Gives the status of whether connection was established

successfully or not.

3. Switchesa. To control the turning on and off of different LEDS

Program code for the Android Application is provided separately in CD.

Table Of Contents 5

Page 6: Project Report - Lighting Control via Bluetooth using Android

Table Of Contents 6

Page 7: Project Report - Lighting Control via Bluetooth using Android

UART INTERFACING

A universal asynchronous receiver/transmitter, abbreviated UART, is a piece of computer hardware that translates data between parallel and serial forms. UARTs are commonly used in conjunction with communication standards such as EIA, RS-232, RS-422 or RS-485. The universal designation indicates that the data format and transmission speeds are configurable. The electric signaling levels and methods (such as differential signaling etc.) are handled by a driver circuit external to the UART.

A UART usually contains the following components:

a clock generator, usually a multiple of the bit rate to allow sampling in the middle of a bit period.

input and output shift registers transmit/receive control read/write control logic transmit/receive buffers (optional) parallel data bus buffer (optional) First-in, first-out (FIFO) buffer memory (optional)

LPC1830 includes four 550 UARTs with DMA support: one UART with full modem interface; oneUART with IrDA interface; three USARTs support synchronous mode and a smartcard interface conforming to ISO7816 specification.

Description of 550 UARTs:

This UART has 16-byte FIFO buffers. Its receive interrupt trigger levels can be set to 1, 4, 8, or 14 characters. Its maximum standard serial port speed if the operating system has a 1 millisecond interrupt latency is 115.2 Kbit/s. Operating systems with lower interrupt latencies could handle higher baud rates like 230.4 Kbit/s or 460.8 Kbit/s. This chip can provide signals to facilitate a third party DMA controller perform DMA transfers to and from the UART. This was known as DMA mode because it was meant to be coupled with a DMA controller in this mode to perform the transfers on behalf of the CPU. It was introduced by National

Table Of Contents 7

Page 8: Project Report - Lighting Control via Bluetooth using Android

Semiconductor, which has been sold to Texas Instruments. National Semiconductor claimed that this UART could physically run at up to 1.5 Mbit/s.

UART coding

In the project UART of the base board is configured for receive mode. It works in a continuous polling mode. Configuration of UART is:

Data flow rate= 9600bps Data length=8 data bit Parity= None Stop bit= 1 No flow control Receive enable

Program code for the UART transmission is provided separately in CD.

Description about coding:

Firstly the UART is configured to function according to user need. As the board has to receive data only therefore only receive mode is enabled.

UART_Init ((LPC_USARTn_Type*) DEBUG_UART_PORT, &UARTConfigStruct);

As LPC1830 pins are multifunctional, therefore, the pins that provide UART functionality are configures as Rx and Tx pins.

scu_pinmux (0x6, 5, MD_PDN|MD_EZI, FUNC2);

UART Rx FIFO buffer is initialized to receive data sent by Bluetooth module.

UART_FIFOConfigStructInit (&UARTFIFOConfigStruct);

After that the code runs in a while loop where it waits for the character received and after receiving a character it is compared with the predefined character which on success turns on/off the LEDs of the base board.

The receive methods on successfully receiving the character returns the number of bytes sent which is used as a counter for inner loop.

len = UART_Receive ((LPC_USARTn_Type*) DEBUG_UART_PORT, buffer, sizeof(buffer), NONE_BLOCKING);

Table Of Contents 8

Page 9: Project Report - Lighting Control via Bluetooth using Android

After the end of main method there is check fail method which is used for debugging. Inside this method user can add his own implementation to report the file name and line number.

Ex: printf ("Wrong parameters value: file %s on line %d\r\n", file, line)

HARDWARE DETAILS

ROVING NETWORK BLUETOOTH MODULE (RN41-EK)

The RN-41-EK evaluation board is field-ready, Bluetooth SIG qualified prototyping platforms for the RN41 and RN42 modules, respectively. The boards have the flexibility to connect directly to PCs via a standard USB interface (via the FTDI chipset) or to embedded processors through the TTL UART interface. The status LEDs, dipswitches, and signal headers enable rapid prototyping and integration into existing systems.You configure and control the modules from a console with a simple ASCII command language.Once the configuration is set up, the module can connect over Bluetooth.

Evaluation kit is used to configure the Bluetooth module using the command interface, create connections, and transfer data.The RN-41-EK and RN-42-EK evaluation boards support the serial port profile (SPP) and human interface device (HID) profiles. The evaluation kit includes:

Table Of Contents 9

Page 10: Project Report - Lighting Control via Bluetooth using Android

a. Evaluation board contains the Bluetooth module, status LEDs, and dipswitches.

b. Mini-USB cable Links your computer to the evaluation board.

Roving Networks Bluetooth devices can be programmed over the Bluetooth link or through the serial interface (USB port) using a simple ASCII command language, which is similar to the industry standard Hayes AT protocol.

PIN-OUT

COMMAND MODE V/S DATA MODE

Table Of Contents 10

Page 11: Project Report - Lighting Control via Bluetooth using Android

The Bluetooth device operates in two modes: data mode (default) and command mode. Upon power up the device is in data mode. While in data mode, the module is essentially a data pipe. When the module receives data from a remote Bluetooth device over a serial port profile (SPP) connection, it strips the Bluetooth headers and trailers and passes the user data to the UART.

When data is written to the UART, the module constructs the Bluetooth packet and sends it out over the Bluetooth SPP connection. Thus, the entire process of sending/receiving data to the host is transparent to the end microprocessor.

The default configuration for the Bluetooth device is:

Bluetooth Slave Mode Keyboard default authentication mode (no pin code required)

o Serial port o 115,200 Kbps Baud Rateo 8 bits Datao No Parityo 1 Stop Bit

Serial port flow control disabled Low power mode off

Table Of Contents 11

Page 12: Project Report - Lighting Control via Bluetooth using Android

LPC1830 XPLORER BOARD

INTRODUCTION

LPC1830-Xplorer has been developed in partnership with NXP semiconductors Inc. It is a compact and versatile evaluation platform for the NXP's Cortex-M3 based MCUS.

BOARD FEATURES

Dimensions: 86mm X 40mm Controller: LPC1830, 100 pin BGA PCB: 4-layer (RoHS complaint) Two LEDs One user switch and one reset switch Boot select switch 32Mb Quad flash On board crystals for controller, RTC and audio codec On board Ethernet PHY, 50 MHz Oscillator and RJ45 connector with

magnetics

Table Of Contents 12

Page 13: Project Report - Lighting Control via Bluetooth using Android

On board audio codec and audio jacks On board USB host power switch Two USB ports, one HS (High speed) port and one FS (Full Speed)

port 10-pin cortex debug header The board is shipped with two USB cables, one USB device cable

and one USB host adapter cable Unused I/Os brought to a header.

BLOCK DIAGRAM

SETUP FOR NXP LPCLINK AND LPC1830 XPLORER BOARD

To run the code following components are provided:

NXP LPC-Link2 10-pin ribbon cable LPC1830 Xplorer Board One USB AM to Micro B cable

Table Of Contents 13

Page 14: Project Report - Lighting Control via Bluetooth using Android

One USB type mini B

STEPS TO SETUP THE LPC-LINK AND LPC1830 XPLORER BOARD

STEP 1:Connect one end of 10-pin ribbon cable to ‘LPCLink 10-pin

connector’; the 10-pin ribbon cable header notch should facing towards the ‘NXP LPCLink2’ mark as shown in the following image.

STEP 2:Connect other end of 10-pin ribbon cable to ‘10-pin box header’ of

the LPC1830 Xplorer board and connect one end of ‘USB AM to Micro B’ cable to LPC1830 Xplorer board and other end to computer, then connect one end of ‘USB type mini B’ to LPCLink2 and other end to computer.

STEP 3: The setup is now ready to be used for development with LPCXpresso

and NXP LPCLink2.

Table Of Contents 14

Page 15: Project Report - Lighting Control via Bluetooth using Android

SOFTWARE DETAILS

LPCXPRESSO

LPCXpresso is a low-cost development tool platform, available directly from NXP, that provides a quick way to develop advanced applications using NXP’s highly efficient and low-power LPC microcontrollers. It includes everything to take end users from evaluation to final production.

FEATURES

Low-cost development tool platform for LPC MCUs Eclipse-based IDE Low-cost target board Integrated debug probe (separate debug probe not required) End-to-end solution supports evaluation to production Free Edition supports code sizes up to 256 kb after activation and

can be upgraded to unlimited code size by purchasing a Pro Edition license

Supports C++ application and library projects Instruction Trace support Red State state machine editor and code generator supports

software state machines, plus state machines for the State Configurable Timer (SCT) peripheral

Table Of Contents 15

Page 16: Project Report - Lighting Control via Bluetooth using Android

LPCXpresso's IDE is a highly-integrated software development environment for NXP's LPC microcontrollers, which includes all the tools necessary to develop high-quality software solutions in a timely and cost effective manner. LPCXpresso is based on Eclipse with many LPC-specific enhancements. It also features the latest version of the industry standard GNU tool chain with a proprietary optimized C library providing professional quality tools at low cost.

DEVELOPMENT BOARDS

The LPCXpresso target boards include an integrated JTAG debugger, so there's no need for a separate JTAG debug probe. The target portion of the board can connect to expansion boards to provide a variety of interfaces and I/O devices. The on-board JTAG debugger provides a high-speed USB to JTAG/SWD interface to the IDE, and it can be connected to other debug targets such as a customer prototype. Users can also use the LPCXpresso IDE with the LPC-Link2 debug probe, Segger J-link, or any probe supporting CMSIS-DAP.

Table Of Contents 16

Page 17: Project Report - Lighting Control via Bluetooth using Android

Table Of Contents 17

Page 18: Project Report - Lighting Control via Bluetooth using Android

LPC-LINK AND LPC-LINK2

The JTAG/SWD debugger portion of an LPCXpresso board is called the LPC-Link, or LPC-Link2 on version 2 boards. The LPC-Link is equipped with a 10-pin JTAG header, and it seamlessly connects to a target via USB (the USB interface and other debug features are provided by an NXP MCU on board). On the original LPC-Link the traces between the LPC-link and the target can be cut to make the LPC-Link a stand-alone JTAG debugger. On the version 2 LPCXpresso boards it can be done with a simple jumper setting. This enables the LPCXpresso platform to be connected to an external target and used to develop for a wide variety of NXP's Cortex-M0, Cortex-M3, and Cortex-M4 based applications.

Table Of Contents 18

Page 19: Project Report - Lighting Control via Bluetooth using Android

ANDROID DEVELOPER TOOLS (ADT)

ADT (Android Developer Tools) is a plugin for Eclipse that provides a suite of tools that are integrated with the Eclipse IDE. It offers you access too many features that help you develop Android applications quickly. ADT provides GUI access to many of the command line SDK tools as well as a UI design tool for rapid prototyping, designing, and building of your application's user interface.

Because ADT is a plugin for Eclipse, you get the functionality of a well-established IDE, along with Android-specific features that are bundled with ADT. The following describes important features of Eclipse and ADT:

INTEGRATED ANDROID PROJECT CREATION, BUILDING, PACKAGING, INSTALLATION, AND DEBUGGING

ADT integrates many development workflow tasks into Eclipse, making it easy for you to rapidly develop and test your Android applications.

SDK TOOLS INTEGRATION

Many of the SDK tools are integrated into Eclipse's menus, perspectives, or as a part of background processes ran by ADT.

Table Of Contents 19

Page 20: Project Report - Lighting Control via Bluetooth using Android

JAVA PROGRAMMING LANGUAGE AND XML EDITORS

The Java programming language editor contains common IDE features such as compile time syntax checking, auto-completion, and integrated documentation for the Android framework APIs. ADT also provides custom XML editors that let you edit Android-specific XML files in a form-based UI. A graphical layout editor lets you design user interfaces with a drag and drop interface.

Table Of Contents 20

Page 21: Project Report - Lighting Control via Bluetooth using Android

SDK TOOLS INTEGRATION

Many of the tools that you can start or run from the command line are integrated into ADT. They include:

Traceview: Allows you to profile your program's execution (Window > Open Perspective > Traceview).

Android: Provides access to the Android SDK Manager and AVD Manager. Other android features such as creating or updating projects (application and library) are integrated throughout the Eclipse IDE.

Hierarchy Viewer: Allows you to visualize your application's view hierarchy to find inefficiencies (Window > Open Perspective > Hierarchy Viewer).

Pixel Perfect: Allows you to closely examine your UI to help with designing and building. (Window > Open Perspective > Pixel Perfect).

DDMS: Provides debugging features including: screen capturing, thread and heap information, and logcat (Window > Open Perspective > DDMS).

adb: Provides access to a device from your development system. Some features of adb are integrated into ADT such as project installation (Eclipse run menu), file transfer, device enumeration, and logcat (DDMS). You must access the more advanced features of adb, such as shell commands, from the command line.

ProGuard: Allows code obfuscation, shrinking, and optimization. ADT integrates ProGuard as part of the build, if you enable it.

Table Of Contents 21

Page 22: Project Report - Lighting Control via Bluetooth using Android

Table Of Contents 22

Page 23: Project Report - Lighting Control via Bluetooth using Android

BLUETOOTH TECHNOLOGY

Bluetooth technology is a wireless communications technology that is simple, secure, and everywhere. You can find it in billions of devices ranging from mobile phones and computers to medical devices and home entertainment products. It is intended to replace the cables connecting devices, while maintaining high levels of security.

The key features of Bluetooth technology are ubiquitousness, low power, and low cost. The Bluetooth Specification defines a uniform structure for a wide range of devices to connect and communicate with each other.

A fundamental strength of Bluetooth wireless technology is the ability to simultaneously handle data and voice transmissions. which provides users with a variety of innovative solutions such as hands-free headsets for voice calls, printing and fax capabilities, and synchronization for PCs and mobile phones, just to name a few.

BLUETOOTH CORE SPECIFICATION

Unlike other wireless standards, the Bluetooth Core Specification provides product developers both link layer and application layer definitions, which support data and voice applications.

Table Of Contents 23

Page 24: Project Report - Lighting Control via Bluetooth using Android

Table Of Contents 24

Page 25: Project Report - Lighting Control via Bluetooth using Android

SPECTRUM

Bluetooth technology operates in the unlicensed industrial, scientific and medical (ISM) band at 2.4 to 2.485 GHz, using a spread spectrum, frequency hopping, full-duplex signal at a nominal rate of 1600 hops/sec. The 2.4 GHz ISM band is available and unlicensed in most countries.

INTERFERENCE

Bluetooth technology's adaptive frequency hopping (AFH) capability was designed to reduce interference between wireless technologies sharing the 2.4 GHz spectrum. AFH works within the spectrum to take advantage of the available frequency. This is done by the technology detecting other devices in the spectrum and avoiding the frequencies they are using. This adaptive hopping among 79 frequencies at 1 MHz intervals gives a high degree of interference immunity and also allows for more efficient transmission within the spectrum. For users of Bluetooth technology this hopping provides greater performance even when other technologies are being used along with Bluetooth technology.

RANGE

The range of Bluetooth technology is application specific. The Core Specification mandates a minimum range of 10 meters or 30 feet, but there is no set limit and manufacturers can tune their implementations to provide the range needed to support the use cases for their solutions.

Range is application specific and although a minimum range is mandated by the Core Specification, there is not a limit and manufacturers can tune their implementation to support the use case they are enabling.

Range may vary depending on class of radio used in an implementation:

Class 3 radios – have a range of up to 1 meter or 3 feet Class 2 radios – most commonly found in mobile devices –

have a range of 10 meters or 33 feet

Table Of Contents 25

Page 26: Project Report - Lighting Control via Bluetooth using Android

Class 1 radios – used primarily in industrial use cases – have a range of 100 meters or 300 feet.

POWER

The most commonly used radio is Class 2 and uses 2.5 mW of power. Bluetooth technology is designed to have very low power consumption. This is reinforced in the specification by allowing radios to be powered down when inactive.

The Generic Alternate MAC/PHY in Version 3.0 HS enables the discovery of remote AMPs for high speed devices and turns on the radio only when needed for data transfer giving a power optimization benefit as well as aiding in the security of the radios.

Bluetooth low energy technology, optimized for devices requiring maximum battery life instead of a high data transfer rate, consumes between 1/2 and 1/100 the power of classic Bluetooth technology.

Architecture

Bluetooth defines two types of networks: Piconet and scatternet.

PICONET

Table Of Contents 26

Page 27: Project Report - Lighting Control via Bluetooth using Android

A Bluetooth network is called a piconet, or a small net. A piconet can have up to eight stations, one of which is called the primary; rest is called secondary. All the secondary stations synchronize their clocks and hopping sequence with the primary.

Although a piconet can have a maximum of seven secondaries, an additional eighth secondary can be in parked state. A secondary in parked state is synchronized with the primary, but cannot take part in communication until it is moved from the parked state. Because only eight stations can be active in a piconet, activating a station from parked state means that an active station must go to the parked state. Piconets are established dynamically and automatically as Bluetooth enabled devices enter and leave radio proximity meaning that you can easily connect whenever and wherever it's convenient for you.

SCATTERNET

Piconet can be combined to form what is called a scatternet. A secondary station in one piconet can be the primary in another piconet. This station can receive messages from the primary in the first piconet (as a secondary) and, acting as a primary, deliver them to secondaries in the second piconet. A station can be member of two piconets.

Bluetooth Profiles

Table Of Contents 27

Page 28: Project Report - Lighting Control via Bluetooth using Android

To use Bluetooth wireless technology, a device must be able to interpret certain Bluetooth profiles. Bluetooth profiles are definitions of possible applications and specify general behaviors that Bluetooth enabled devices use to communicate with other Bluetooth devices. There is a wide range of Bluetooth profiles describing many different types of applications or use cases for devices. By following the guidance provided by the Bluetooth specification, developers can create applications to work with other Bluetooth devices. At a minimum, each Bluetooth profile contains information on the following topics:

Dependencies on other profiles, Suggested user interface formats

Specific parts of the Bluetooth protocol stack used by the profile. To perform its task, each profile uses particular options and parameters at each layer of the stack and this may include, if appropriate, an outline of the required service record

GATT BASED

GATT Based DescriptionANP Alert Notification

Profile enables a client device to receive different types of alerts and event information, as well as information on the count of new alerts and unread items, which exist in the server device.

ANS Alert Notification Service

exposes different types of alerts.

BAS Battery Service exposes the state of a battery within a device.BLP Blood Pressure Profile enables a device to connect and interact with a

Blood Pressure Sensor device for use in consumer and professional health care applications.

BLS Blood Pressure Service

exposes blood pressure and other data from a blood pressure monitor for use in consumer and professional healthcare applications.

CTS Current Time Service defines how the current time can be exposed using the Generic Attribute Profile (GATT).

DIS Device Information Service

exposes manufacturer information about a device.

FMP Find Me Profile defines the behavior when a button is pressed on one device to cause an alerting signal on a peer device.

HTP Health Thermometer Profile

enables a Collector device to connect and interact with a Thermometer sensor for use in healthcare applications.

HRP Heart Rate Profile enables a Collector device to connect and interact with a Heart Rate Sensor for use in fitness applications.

Table Of Contents 28

Page 29: Project Report - Lighting Control via Bluetooth using Android

HRS Heart Rate Service exposes heart rate and other data from a Heart Rate Sensor intended for fitness applications.

HIDS HID Service exposes HID reports and other HID data intended for HID Hosts and HID Devices.

HOGP HID Over GATT Profile defines how a device with Bluetooth low energy wireless communications can support HID services over the Bluetooth low energy protocol stack using the Generic Attribute Profile.

IAS Immediate Alert Service

exposes a control point to allow a peer device to cause the device to immediately alert.

LLS Link Loss Service defines behavior when a link is lost between two devices.

NDCS Next DST Change Service

defines how the information about an upcoming DST change can be exposed using the Generic Attribute Profile (GATT).

PASP Phone Alert Status Profile

enables a PUID device to alert its user about the alert status of a phone connected to the PUID device.

PASS Phone Alert Status Service

exposes the phone alert status when in a connection.

PXP Proximity Profile enables proximity monitoring between two devices.RTUS Reference Time

Update Service defines how a client can request an update from a reference time source from a time server using the Generic Attribute Profile (GATT).

ScPP Scan Parameters Profile

defines how a Scan Client device with Bluetooth low energy wireless communications can write its scanning behavior to a Scan Server, and how a Scan Server can request updates of a Scan Client scanning behavior.

ScPS Scan Parameters Service

enables a GATT Client to store the LE scan parameters it is using on a GATT Server device so that the GATT Server can utilize the information to adjust behavior to optimize power consumption and/or reconnection latency.

TIP Time Profile enables the device to get the date, time, time zone, and DST information and control the functions related the time.

TPS Tx Power Service exposes a device's current transmit power level when in a connection.

BR/EDR PROFILES

BR/EDR Profiles DescriptionA2DP Advanced Audio

Distribution Profile describes how stereo quality audio can be streamed from a media source to a sink.

AVRCP Audio/Video Remote Control Profile

is designed to provide a standard interface to control TVs, stereo audio equipment, or other A/V devices. This profile allows a single remote control (or other device) to control all A/V equipment to which a user has access.

BIP Basic Imaging Profile defines how an imaging device can be remotely controlled, how an imaging device may print, and how an imaging device can transfer images to a storage device.

Table Of Contents 29

Page 30: Project Report - Lighting Control via Bluetooth using Android

BPP Basic Printing Profile allows devices to send text, e-mails, v-cards, images or other information to printers based on print jobs.

DI Device ID Profile provides additional information above and beyond the Bluetooth Class of Device and to incorporate the information into both the Service Discovery Profile (SDP) record and the EIR response.

DUN Dial-Up Network Profile

provides a standard to access the Internet and other dial-up services via Bluetooth technology.

FTP File Transfer Profile defines how folders and files on a server device can be browsed by a client device.

GAVDP

Generic Audio/Video Distribution Profile

provides the basis for A2DP and VDP, which are the basis of the systems designed for distributing video and audio streams using Bluetooth technology.

GOEP Generic Object Profile is used to transfer an object from one device to another.

HFP Hands-Free Profile HFP describes how a gateway device can be used to place and receive calls for a hand-free device.

HCRP Hard Copy Cable Replacement Profile

defines how driver-based printing is accomplished over a Bluetooth wireless link.

HDP Health Device Profile enables Healthcare and Fitness device usage models.

HSP Headset Profile describes how a Bluetooth enabled headset should communicate with a Bluetooth enabled device.

HID Human Interface Device Profile

defines the protocols, procedures and features to be used by Bluetooth keyboards, mice, pointing and gaming devices and remote monitoring devices.

MAP Message Access Profile

defines a set of features and procedures to exchange messages between devices.

MPS Multi Profile defines a set of features and procedures between Multiple Profiles Single Device and Multiple Profiles Multiple Devices

OPP Object Push Profile defines the roles of push server and push client.PBAP Phone Book Access

Profiledefines the procedures and protocols to exchange Phone Book objects between devices.

PAN Personal Area Networking Profile

describes how two or more Bluetooth enabled devices can form an ad-hoc network and how the same mechanism can be used to access a remote network through a network access point.

SAP SIM Access Profile defines the protocols and procedures that shall be used to access a GSM SIM card, a UICC card or an R-UIM card via a Bluetooth link.

SDAP Service Discovery Application Profile

describes how an application should use SDP to discover services on a remote device.

SPP Service Port Profile defines how to set-up virtual serial ports and connect two Bluetooth enabled devices.

SYNC Synchronization Profile

used in conjunction with GOEP to enable synchronization of calendar and address information (personal information manager (PIM) items) between Bluetooth enabled devices.

VDP Video Distribution Profile

defines how a Bluetooth enabled device streams video over Bluetooth wireless technology.

BR/EDR PROTOCOLS

Table Of Contents 30

Page 31: Project Report - Lighting Control via Bluetooth using Android

BR/EDR Protocols DescriptionAVCTP Audio/Video Control

Transport Protocol describes the transport mechanisms to exchange messages for controlling A/V devices.

AVDTP Audio/Video Distribution Transport Protocol

defines A/V stream negotiation, establishment and transmission procedures

BNEP Bluetooth Network Encapsulation Protocol

is used to transport common networking protocols over the Bluetooth media such as IPv4 and IPv6.

IrDA IrDA Interoperability offers the same features for applications as within the IrDA protocol hierarchy, enabling the applications to work over the Bluetooth protocol stack as well as the IrDA stack.

OBEX Object Exchange a transfer protocol that defines data objects and a communication protocol two devices can use to exchange those objects.

RFCOMM

RFCOMM with TS 07.10

emulates the serial cable line settings and status of an RS-232 serial port and is used for providing serial data transfer.

Table Of Contents 31

Page 32: Project Report - Lighting Control via Bluetooth using Android

BLUETOOTH LAYERS

BLUETOOTH PROFILE – SPP (SERVICE PORT PROFILE)

SPP defines how to set up virtual serial ports and connect two Bluetooth enabled devices. A scenario would be using two devices, such as PCs or laptops, as virtual serial ports and then connecting the two devices via Bluetooth technology.

The SPP defines two roles, Device A and Device B.

Device A – This is the device that takes initiative to form a connection to another device (initiator).

Table Of Contents 32

Page 33: Project Report - Lighting Control via Bluetooth using Android

Device B – This is the device that waits for another device to take initiative to connect (acceptor).

The Baseband, LMP and L2CAP are the OSI layer 1 and 2 Bluetooth protocols. RFCOMM is the Bluetooth adaptation of GSM TS 07.10, providing a transport protocol for serial port emulation. SDP is the Bluetooth Service Discovery Protocol.

The port emulation layer shown in the figure to the left is the entity emulating the serial port, or providing an API to applications.

The applications on both sides are typically legacy applications, able and wanting to communicate over a serial cable (which in this case is emulated). But legacy applications cannot know about Bluetooth procedures for setting up emulated serial cables, which is why they need help from some sort of Bluetooth aware helper application on both sides. (These issues are not explicitly addressed in this profile; the major concern here is for Bluetooth interoperability.)

SDP (SERVICE DISCOVERY PROTOCOL)

The SDP is used for location of services provided by or available through a Bluetooth device and it facilitates the following:

The client’s ability to search for the services in the piconet Services to be discovered based on class of services (such as print

service) The capability to browse services To find out when a service becomes unavailable (device goes out of

range) The discovery of new services (within range) The details of services such as classes and attributes When a device wants to discover a service the client and the server

exchange SDP messages.

The attributes can be a service class ID list, a service ID, a protocol description, a provider name, an icon URL, a service name, and a service description.

RFCOMM

Table Of Contents 33

Page 34: Project Report - Lighting Control via Bluetooth using Android

RFCOMM is a transport protocol to emulate serial communication (RS232 serial ports) over L2CAP. Two devices can communicate through RFCOMM over Bluetooth radio. RFCOMM emulates the nine connections of RS232 such as Request to Send, Transmit Data and Clear to Send. It supports two types of devices. Type 1 is communication end points (computers, printers) and type 2 devices are part of a communication segment such as a modem.

L2CAP (LOGICAL LINK CONTROL AND ADAPTATION PROTOCOL)

The Bluetooth logical link control and adaptation protocol (L2CAP) supports higher-level protocol multiplexing, packet segmentation and reassembly, and the conveying of quality of service information.

L2CAP permits higher level protocols and applications to transmit and receive upper layer data packets(L2CAP Service Data Units, SDU) up to 64 kilobytes in length. L2CAP also permits per-channel flow control and retransmission via the Flow Control and Retransmission Modes. The L2CAP layer provides logical channels, named L2CAP channels, which map to L2CAP logical links supported by an ACL logical transport

L2CAP is based around the concept of 'channels'. Each one of the endpoints of an L2CAP channel is referred to by a channel identifier (CID).

CHANNEL IDENTIFIERS

A channel identifier (CID) is the local name representing a logical channel endpoint on the device. CID assignment is relative to a particular device and a device can assign CIDs independently from other devices (unless it needs to use any of the several reserved CIDs)

OPERATION BETWEEN DEVICES

The connection oriented data channels represent a connection between two devices, where a CID identifies each endpoint of the channel.

Table Of Contents 34

Page 35: Project Report - Lighting Control via Bluetooth using Android

The connectionless channels restrict data flow to a single direction. These channels are used to support a channel 'group' where the CID on the source represents one or more remote devices. There are also a number of CIDs reserved for special purposes. The signaling channel is one example of a reserved channel. This channel is used to create and establish connection-oriented data channels and to negotiate changes in the characteristics of connection oriented and connectionless channels.

Table Of Contents 35

Page 36: Project Report - Lighting Control via Bluetooth using Android

MODES OF OPERATION

L2CAP may operate in one of three different modes as selected for each L2CAP channel by an upper layer. The modes are:

Basic L2CAP Mode (equivalent to L2CAP specification in Bluetooth v1.1) 1

Flow Control Mode Retransmission Mode

DATA PACKET FORMAT

L2CAP is packet-based but follows a communication model based on channels. A channel represents a data flow between L2CAP entities in remote devices. Channels may be connection-oriented or connectionless.

SIGNALING PACKET FORMATS

This section describes the signaling commands passed between two L2CAP entities on peer devices. All signaling commands are sent to the signaling channel with CID 0x0001. This signaling channel is available as soon as an ACL logical transport is set up and L2CAP traffic is enabled on the L2CAP logical link. Multiple commands may be sent in a single signaling command (C-frame). Commands take the form of Requests and Responses. All L2CAP implementations support the reception of C-frames with a payload length that does not exceed the signaling MTU. The minimum supported payload length for the C-frame (MTUsig) is 48 octets. L2CAP implementations should not use C-frames that exceed the MTUsig of the peer device. If they ever do, the peer device shall send a Command Reject containing the supported MTUsig.

CONFIGURATION PARAMETER OPTIONS

Table Of Contents 36

Page 37: Project Report - Lighting Control via Bluetooth using Android

Options are a mechanism to extend the configuration parameters. Options are transmitted as information elements containing an option type, an option length, and one or more option data fields.

HCI (HOST CONTROLLER INTERFACE)

A Bluetooth device can have two parts: a module implementing the lower layers (LMP and under) and a software module (L2CAP and over) in the host. The Host Controller Interface handles communications between a separate host and a Bluetooth module

The HCI provides an interface so that the two modules can be from different vendors. The functions of HCI are:

Setting up disconnecting, and configuring the links Control of baseband features such as timeouts Retrieving status information Local testing of the hardware module

OVERVIEW OF HCI COMMANDS AND EVENTSGeneric Events The generic events can occur due to multiple commands, or

events that can occur at any time.Device Setup The device setup commands are used to place the Controller

into a known state.Controller Flow Control

The controller flow control commands and events are used to control data flow from the Host to the controller.

Controller Information

The controller information commands allow the Host to discover local information about the device.

Controller Configuration

The controller configuration commands and events allow the global configuration parameters to be configured.

Device Discovery The device discovery commands and events allow a device to discover other devices in the surrounding area.

Connection Setup The connection setup commands and events allow a device to make a connection to another device.

Remote Information

The remote information commands and events allow information about a remote device's configuration to be discovered.

Synchronous Connections

The synchronous connection commands and events allow synchronous connections to be created.

Connection State The connection state commands and events allow the configuration of a link, especially for low power operation.

Piconet Structure The piconet structure commands and events allow the discovery and reconfiguration of piconet.

Quality of Service The quality of service commands and events allow quality of service parameters to be specified.

Physical Links The physical link commands and events allow the configuration of a physical link.

Table Of Contents 37

Page 38: Project Report - Lighting Control via Bluetooth using Android

Host Flow Control The Host flow control commands and events allow flow control to be used towards the Host.

Link Information The link information commands and events allow information about a link to be read.

Authentication and Encryption

The authentication and encryption commands and events allow authentication of a remote device and then encryption of the link.

LINK MANAGER

The Link Manager controls and configures links to other devices. It translates the commands into operations at the Baseband level, managing the following operations.

Attaching slaves to piconets, and allocating their active member addresses.

Breaking connections to detach Slaves from a piconet. Configuring the link including Master/Slave switches Establishing ACL and SCO links. Putting connections into Low Power modes: Hold, Sniff and Park. Controlling test modes.

BASEBAND LAYER

The Baseband is the physical layer of the Bluetooth. It manages physical channels and links apart from other services like error correction, data whitening, hop selection and Bluetooth security. The Baseband layer lies on top of the Bluetooth radio layer in the bluetooth stack.

The baseband protocol is implemented as a Link Controller, which works with the link manager for carrying out link level routines like link connection and power control. The baseband also manages asynchronous and synchronous links, handles packets and does paging and inquiry to access and inquire Bluetooth devices in the area. The baseband transceiver applies a time-division duplex (TDD) scheme. (Alternate transmit and receive). Therefore apart from different hopping frequency (frequency division), the time is also slotted.

Table Of Contents 38

Page 39: Project Report - Lighting Control via Bluetooth using Android

PACKET FORMAT

Each packet consists of 3 entities, the access code (68/72 bits), the header (54 bits), and the payload (0-2745 bits).

ACCESS CODE:

Access codes are used for timing synchronization, offset compensation, paging and inquiry. There are three different types of Access code:

1. Channel Access Code (CAC)2. Device Access Code (DAC)3. Inquiry Access Code (IAC)

The channel access code identifies a unique piconet while the DAC is used for paging and its responses. IAC is used for inquiry purpose.

HEADER:

The header contains information for packet acknowledgement, packet numbering for out-of-order packet reordering, flow control, slave address and error check for header.

PAYLOAD:

The packet payload can contain either voice field, data field or both. It has a data field; the payload will also contain a payload header.

Table Of Contents 39

Page 40: Project Report - Lighting Control via Bluetooth using Android

FUTURE SCOPE

Getting a light to turn on and off may sound easy and probably even useless. But if we come to think of it, there’s much more to this project than just this much. The project can just be modified a little bit to have real life implementations which would do wonders.

Imagine having something similar in the Kitchen. A kitchen area with a LED strip/ lamp placed on top of the stove, preferably as long as the kitchen bench. What if this was controlled automatically by an Android phone? The phone could be made to automatically connect to the controller device for the LED strip/lamp, via Bluetooth, & turn on/off the lamp whenever a person enters/leaves.

Not only that, the device could be made smarter by using an LED strip of light which changes colors/patterns on receiving phone calls/messages. This would really be an added advantage as the kitchen is generally a noisy place with the air extractor, microwave, blender and other appliances used frequently. Some kind of hands free notifications in such environments would surely be appreciated.

Table Of Contents 40

Page 41: Project Report - Lighting Control via Bluetooth using Android

Table Of Contents 41

Page 42: Project Report - Lighting Control via Bluetooth using Android

REFERENCES

1) Bluetooth SIG, Specification of the Bluetooth System Version 1.0B volume 1, 1999.

http://www.bluetooth.com/developer/specification/core_10_b.pdf.

2) Guo, Y. Philips FM/IF systems for GMSK/GFSK receivers, Philips Semiconductors 1997

http://www.semiconductors.com/acrobat/applicationnotes/AN1997.pdf. Referred 5/10/2000

3) Markovic, V. Gaussian Minimum Shift Keying. Presentation given in course “Advanced Course in Digital Transmission” at Tampere University of Technology, 1999

http://www.cs.tut.fi/kurssit/83090/S13.ps. Referred 5/10/2000

4) Oraskari, Jyrki, Bluetooth 2000

http://www.hut.fi/~joraskur/bluetooth.html

5) Specification of the Bluetooth System Wireless connections madeeasy Core Version 1.1 February 22, 2001.

http://www.ece.virgina.edu/~mmz4s/papers/ECE613project_bluetooth.pdf

6) Wireless Communications Information & Services “Bluetooth Specification; Bluetooth Technology overview”,

http://www.thewirelessdirectory.com/BluetoothOverview/BluetoothSpecification.htm.

7) http://www.developer.android.com8) http://www.nxp.com/LPC-Overview/18xx-series-Specifications.html9) http://www.lpcware.com/UserManual/LPC1830FET100-Board.htm10) http://www.ngxtech.com/Support/Starter-LPCXpresso.html

Table Of Contents 42