How Bluetooth Works
Written by Harry Fairhead   
Friday, 19 August 2022
Article Index
How Bluetooth Works
Security

Programming is about software, but we need to know how the hardware works to get the best out of it. The rapid rise of Bluetooth in mobile devices means that it is a good idea to understand how it works.

Currently it is still fairly standard to use cables to connect keyboard, mice, printers, computers, etc, and you have to have the right cable for the job. But Bluetooth - a wireless protocol - could replace all of the cables and connections by a single standard wireless link. Today we tend to encounter Bluetooth as a way of using headphones and other audio devices but its a general purpose wireless "wire".

Although the work on the technology needed to achieve this was started in 1998 Bluetooth devices still have a way to go to be considered the universal connection method it was intended to be but lower cost hardware and better software is getting us there.

So how does it work?

The answer will enable you to understand the basics of BlueTooth and cover what some of the software manuals assume you know. There have been so many additions to the standard, many optional, that it is difficult to keep up. What is described here is usually called Classic Bluetooth - you need to add to this Bluetooth High Speed which uses WiFi to increase the data rate and Bluetooth Low Energy (BLE) which is a completely new standard designed for simple low power links between IoT like devices.

Why “Bluetooth”?

Harald Bluetooth was a Viking king of Denmark between 940 and 981. Legend has it that as well as having stained teeth, he was good at getting people to talk to one another. Whatever the truth of the matter the two main companies involved in the development of Bluetooth, Ericsson and Nokia, decided to honour a Nordic hero in the name they chose for their project back in 1994. Put simply there is nothing "blue" or "toothy" about the wireless tech we call Bluetooth.

Frequency hopping

The huge growth of wireless devices started even before Bluetooth came along.

Nearly all of them use one small section of the radio spectrum – the Industrial, Scientific and Medical band. The ISM band occupies the frequency range 2400-2483.5MHz and it is already used by outside broadcast links, radio frequency identification, microwave ovens, WiFi networks and some types of lighting.

As you might expect, the first problem that the Bluetooth designers had to overcome was finding a way of avoiding interference. The problem is all the more difficult because devices that work in the ISM band have to be low power.

There are three classes of Bluetooth devices.

  • Class 1 transmits using 100mW of power and has a range of 100m.
  • Most mobile Bluetooth devices are Class 3, which use just 1mW to save batteries, but only achieve a 10m range.
  • Class 2 devices fall between these two and transmit at 2.5mW. The low power and limited range is also a way to allow many Bluetooth devices to work without interfering with one another.

To avoid interference from other ISM devices Bluetooth uses a sophisticated frequency hopping technique. The ISM band is spit into 79 channels each 1MHz wide. The transmitter in a Bluetooth device changes its channel 1600 times a second in a pseudo random way.

This is called Frequency Hopping Spread Spectrum (FHSS) and it was invented by the military to make its communications less prone to interference, jamming and eavesdropping. Using FHSS a Bluetooth device can create a two-way radio link capable of working at up to 720Kbits per second. Data is sent in packets containing up to 2745 bits. If a packet is lost due to interference on a channel then it is automatically retransmitted again on another channel as the frequency hopping occurs.

Keeping in step

This is all very well but how do two devices manage to communicate when they are changing the channels used in a seemingly random way?

The answer is that when a Bluetooth device isn’t connected to another device it doesn’t frequency hop at the top speed of 1600 hops per second. Instead is uses a slow scan of the available channels in an attempt to find other Bluetooth devices.

Thus when two Bluetooth devices are brought into each other’s range they will eventually notice each other and make a connection. This is called “paging”. Each device uses one of the frequency hopping channels to transmit an “I’m here” message and it changes the transmission channel every 312.5 seconds.

At the same time each device listens on a channel which it changes every 1.28 seconds. You can see that in principle it could take a few minutes for the two devices to hit on the same transmit and receive frequency. It is one of the reasons why connecting a new device can seem very slow.

Once they do hit on a common frequency, the device that “found” the other device becomes a master and the other becomes a slave. Then the master sends the slave device a frequency hopping scheme and they start to change frequency in step with each other at full speed.

Notice that any Bluetooth device is capable of being a master or a slave.

The radio link established between a master and a slave can be used for up to three simultaneous voice channels – each working at 64Kbits per second – or an asynchronous data channel. The data channel can be asymmetrical 720Kbps with a return channel of 57Kbps or symmetrical at 433.9Kbps.

Piconet and Scatternet

 

nets
A piconet and a scatternet are built of master and slave devices (click to enlarge)

When two Bluetooth devices notice each other they create a network – called a Piconet - consisting of one master and one slave. If another Bluetooth device is detected then it joins the network as another slave. All of the devices connect to a piconet use the same frequency hopping schedule and are controlled by the master. The channel is divided into 625 microsecond time slots and its shared between the master and the slaves using the simple rule that the master transmits on even time slots and the slaves transmit in odd time slots.

The Bluetooth software creates two types of data transfers between devices in a piconet– synchronous (SCO) and asynchronous (ACL). SCO is a 64Kbps point-to-point transfer between the master and a single slave. A piconet can have three SCO connections active at any one time. To make sure that the capacity is available for an SCO link the master reserves time slots. An ACL connection can use any time slot not reserved for an SCO link. It can be used as a point-to-point connection but the master can also broadcast data to multiple slaves. Another difference is that a slave can only transmit data when requested to do so by the master.

As you can see a piconet is sophisticated enough to service the needs of a wide variety of different types of hardware including phones, PDAs, printers and so on.

A piconet can have up to seven slaves but in principle the number can be extended to 255 slaves by the use of “virtual” connections. In this case all but seven of the slaves are active at any one time but which particular seven are active can be changed every 2ms.

Another way to increase the size of a Bluetooth network is to create a “Scatternet”.

The master in one piconet can be a slave in another so linking the two networks together. The resulting scatternet can link together up to 10 piconets that are within range.



Last Updated ( Friday, 19 August 2022 )