When devices whisper to each other – Part 2: Classic Bluetooth

In the last post in this series, I elaborated why it is useful to have short distance communication. In this post, we will look at how classic Bluetooth works. Nearly every electronic device today supports Bluetooth. Some people use it more than others. But what exactly is Bluetooth and when is it useful? Let’s see in this post. We will cover only classic Bluetooth and not the latest Bluetooth Low Energy, also called Bluetooth Smart.

What is Bluetooth?

Bluetooth is a radio communication protocol that uses the radio frequencies between 2.4 to 2.4835 GHz. This range of frequencies is called ISM or Industrial Scientific Medical band. The range is free for everyone to use and unlicensed. This means that you do not need special permits to manufacture, assemble, program and use devices which work in that range. Another popular unlicensed frequency band is WiFi.

This is contrast with the frequency bands operated by an FM music channel or a mobile phone service provider, both of who must bid for frequency bands and buy them in every country they wish to broadcast or operate.

Purpose of Bluetooth

Bluetooth’s main purpose is communication between devices that are in the same room, adjacent rooms or rooms in the same floor / wing / aisle of a building, ensuring that such communication drains as little battery as possible. The aim of such communication is short distance and low battery usage, rather than high speed. Small files can be exchanged, short instructions can be sent or music can be streamed. However, it is sub-optimal to share large files or stream HD videos using Bluetooth.

Why not use WiFi instead?

WiFi transmitters use 100 mW per hour of power as against Bluetooth’s most used class B devices, that transmit at 2.5 mW per hour. This means that WiFi requires a lot more power and can drain a device’s battery really fast. WiFi is more suited for devices like laptops or mobile phones, that have powerful batteries or for devices that are connected to a wall socket. For small devices like a portable headset, that is supposed to run for days before charging, Bluetooth is more favoured. Also for devices that run off the body, such as smart watches or medical monitors, the lower power of Bluetooth induces more confidence than WiFi, the waves of which some believe is a disturbance to the body’s own vibration.

Classes of Bluetooth devices

Based on transmission power, Bluetooth devices are classified into three classes: A, B and C. Class B devices are the most widely used. They transmit at 2.5 mW and their range is upto 10 metres, which is usually within the same room or adjacent rooms. If you are sitting in the inner-most room of your multi-room home, then no one outside your main door can even detect your device in their scan.

Class C devices transmit at an even lower power, i.e. 1 mW. The practical range of these devices is 2 – 3 metres. It is useful as a remote control for devices in the same room or for communication between your phone and your wearable device.

Class A devices are rather powerful, transmitting at 100 mW, which is the same as WiFi. Class ‘A’ devices can be used for applications similar to WiFi, except that they provide some advantages that Bluetooth has gained over the years, such as being able to identify what kind of device is on the other end, e.g. a speaker, phone, laptop, etc. Class ‘A’ devices are mostly used by industrial or medical machines.

Bluetooth address

Each Bluetooth device has a unique Bluetooth address. The address is 48 bytes long. The first 24 bytes represent a code that is unique to a manufacturer. So all devices made by the same manufacturer will have the same first 24 bytes. The next 24 bytes represent the device.

The Bluetooth address is like the Aadhar number (India) or social security number (US). It has to be unique for each device. But the addresses are only used by the devices themselves. Humans give human-readable names to their Bluetooth devices. These names can be seen by the users when they scan for nearby devices.

Inquiry

Inquiry is the process where one Bluetooth device scans the surroundings for other Bluetooth devices. Inquiry is usually started manually from either a laptop or a mobile phone.

Here is the conversation that happens.

Device A: Is there any Bluetooth device around here?
Device B (thinking to itself): Well… my user has not made me ‘discoverable’. So I am keeping quiet.
Device C: Yes, I am device AA:BB:CC:DD:EE:FF (Bluetooth address in hexadecimal representation). But my user calls me ‘Living room speaker’. I am a speaker (see the section on profiles later).
Device D: I am very much here. I am UU:VV:WW:XX:YY:ZZ. My manufacturer named me ‘Fitness band 0101’. My user hasn’t bothered changing my name, so let’s go with what the manufacturer called me. I am a fitness band.

Device A may restrict the inquiry to specific device profiles such as, “Are there any speakers around here?”

Connection

After inquiry, since one device knows the address of another device, a connection can be established. The device that initiates the connection starts as the master, while the one that accepts the connection becomes the slave. But the roles can be reversed after the connection is established.

Once a master and a slave have connected, they form a point-to-point network. While there can only be one master per network, there can be upto 7 slaves. New devices may join a network as slaves, in which case it would become a point-to-multipoint network. A network of one master and 1 – 7 slaves is called a ‘piconet’. An example of a point-to-point piconet is when your fitness band is sending information to your phone, whereas a multi-point piconet would be when your phone is playing a song through your living room speakers and also through your kitchen speakers.

A Bluetooth piconet. Source: Research Gate

Multiple piconets can co-exist in the same room and they can involve the same device across two piconets. E.g. a phone may play a song on a Bluetooth speaker, but at the same time, your phone may be grabbing your heart rate from your fitness band. The first piconet is for streaming audio, while the second is for streaming fitness info. This is possible due to a process called Frequency Hopping Spread Spectrum, which we’ll see shortly.

In recent versions of Bluetooth, connections are more secure. Connections cannot be automatic unless the two devices are already paired (see next section). Instead, it is required that one device should challenge the other device to enter a 4-digit or 6-digit PIN. This PIN is usually shown on the screen of the device that generates the password. If it is a device with no screen, then the manufacturer’s manual mentions the factory default PIN along with instructions on how to change it. The other device is supposed to prompt the PIN from the user, who keys the PIN. The connection is made only if the PIN entered by the user matches the generated PIN, otherwise rejected. After the connection is made, the devices may agree upon an encryption algorithm so that all exchanges are encrypted and no one can intercept the original message.

Pairing

Pairing is a way of authorising two devices to connect to each other as soon as they come within range of each other. This is done for convenience, so that the user need not have to initiate a connection every time he/she needs to use communication between the two devices. E.g. Your phone will connect to your Bluetooth-enabled car dashboard as soon as switch your car on. Your phone will automatically connect to your fitness band and your earphones will automatically connect to your phone or media player.

Pairing follows the same sequence as a secure connection, i.e., one device challenges the other device to enter a PIN and only accepts the pairing in case of the correct PIN.

For a lot of devices in the market, pairing is in fact a prerequisite for a connection. You need to pair the devices once, so that the connection is always automatic from the next time. There is no concept of manually initiating a connection and entering a PIN every time. This is not a requirement according to the Bluetooth specification, but most devices prefer to implement it this way.

Frequency hopping spread spectrum

FHSS is a method using which devices in a Bluetooth piconet communicate with each other, so that they avoid interference with other piconets. FHSS is a  concept complicated to explain, but an analogy with a real life example will hopefully make things clear.

Let’s assume that you regularly visit a local Starbucks with a team of 7 other persons. The cafe is massive with 80 tables, each capable of seating 8 persons.  As you enter the cafe at 9:00 am, you take a table by the window and your team follows. At about 9:05 am, another group of 3 -4 persons sits at a table next to you. Your team’s conversation merges with this team’s conversation and soon there is a lot of misunderstanding. Also, the traffic outside the window is beginning to annoy you. So you get up from your table and pick another table at the far end of the cafe by the wall. Your team has no choice but to follow you.

Now imagine doing this every 10 minutes. You pick a table, carry on the conversation from where it was left off and get some work done. At the end of 10 minutes, you find the current table unsuitable and move to another one. Your team may be bewildered, but they have no choice but to follow you to wherever your next table is. As far as everyone is concerned, you are the master of the discussion and the others are the subordinates. So you call the shots. At 10 minutes per table, you will have changed tables 6 times in an hour. For a nine to five working day, it’d be 48 times through the day.

Also imagine that every team of customers in this Starbucks changes table every 10 minutes to have the best shot at a clear, disturbance-free conversation as patrons arrive, making parts of the cafe noisy, and then leave, thus leaving behind a silent void ready for you to use.

FHSS is quite similar to this approach. Each piconet (just like you and your team), spends some time (625 microseconds) having conversation in one of the 80 Bluetooth channels (tables) available. After 625 microseconds, the master device picks another channel and the slave devices must follow suit. So what you hear as one continuous song on your Bluetooth headset from your phone is actually bursts of short streams of sound, each stream lasting only 625 microseconds. This shows that Bluetooth devices switch (or hop) channels 1600 times per second! Each piconet tries to use as much of the Bluetooth spectrum (2.4 GHz to 2.4835 GHz) as possible in order to have interference-free communication.

Frequency hopping spread spectrum. Source: Polytechnic Hub

In a crowded cafe, it doesn’t matter which table you take, you’ll end up with interference everywhere and the quality of your conversation deteriorates. It’s the same in Bluetooth. If there way too many piconets in the same room, even FHSS is not enough to keep the quality of communication high. In a room with more than 100 Bluetooth devices, you will start hearing clicks, hisses, silent patches and breakages in your Bluetooth headset as devices get in each other’s way.

Bluetooth profiles

A Bluetooth profile sets an expectation of what the device can do. Each profile has a set of functionalities that can be requested for use by another device. When you see an icon against the name of a device, such as a headset icon or a health icon, your device is showing you the profile(s) of the target device. It is common for one device to exhibit multiple profiles, e.g. an earphone is both a headset for audio streaming and also a hands-free device for phone call streaming. A fitness band can measure heart rate or it can share data related to your exercise workouts.

Results of a bluetooth scan along with the profiles discovered on the target device.

There are several profiles possible for a Bluetooth device and new ones are being added every month. Let’s discuss some of the most important ones.

Advanced Audio Distribution Profile (A2DP): is the profile that makes it possible for a device to stream audio to external units. E.g. a mobile phone or media player to stream audio to a wireless earphone or a wireless room speaker. A2DP makes it possible to transfer stereo audio in MP3 and AAC formats.

Audio Video Remote Control Profile (AVRCP): is a profile that allows you to use a Bluetooth-powered remote control to play / pause / stop / skip / rewind audio tracks.

Basic Imaging Profile (BIP): is a profile that allows a bluetooth device to share images between devices, with the option to resize them as per the target device’s screen. The target device can also be a printer. Apart from sending, BIP can also be used to request images from a target device, e.g. requesting a nearby Bluetooth-enabled camera to take a picture and send it over Bluetooth.

File Transfer Profile (FTP): is a commonly used profile to share files among Bluetooth-enabled devices. This protocol treats files as generic objects instead of specific types like images, contacts, video, etc.

Health Device Profile (HDP): is used for medical devices that use a sensor and transfer information to a monitor. E.g. temperature and heart rate measuring and monitoring.

Hands-free profile (HFP): is used to place phone calls, receive them and stream phone call audio from a phone. This is most commonly used in headsets and car dashboards, to receive calls without having to fiddle with a phone’s touchscreen.

Human Interface Device (HID): is used by peripherals that interact with a computer, such as a laptop or a desktop. HID is simply a Bluetooth-layer over standard USB communication. Instead of using a USB cable, the data is transferred to a USB dongle using Bluetooth. From the dongle to the computer, the communication is standard USB. Bluetooth-enabled keyboards, mice, joysticks and drawing devices fall under HID.

Object Push Profile (OPP): is used to share specific objects from one file to another. These objects are often just files, but the source and target devices already identify the type of object from the file, e.g. image file, vCard file for contacts, DAV file for calendar appointments, exercise workout information, etc.

Phone Book Access Profile (PBAP): is used to access the phone / address book of a phone from another device, typically a car dashboard. PBAP is used in conjunction with Hands-free profile to be able to place calls to specific persons and to show the name of the calling person in an incoming call.

Conclusion

Bluetooth’s low power consumption and the resulting small size microchips made it possible for the world’s electronic and software giants to quickly embrace it and build solutions that have made electronics much easier to use than the time when everything was connected by wires.

With Bluetooth Low Energy (BLE), the possibilities for the dominance as the close-range wireless technology of choice have expanded further. We will look at BLE in the next post.

[subscribe_form]

One thought on “When devices whisper to each other – Part 2: Classic Bluetooth”

Leave a Reply

Your email address will not be published.