Bluetooth and Linux

Jarret B

Well-Known Member
Staff member
Joined
May 22, 2017
Messages
340
Reaction score
368
Credits
11,754
Bluetooth is a wireless technology mainly for close range. The technology is managed by the Bluetooth Special Interest Group (SIG).

Most devices have Bluetooth ability such as smart phones, speakers, headphones, laptops, keyboards, mice, printers gaming consoles, etc. Having a basic understanding of Bluetooth will help you when dealing with the devices.

Bluetooth Overview

The name Bluetooth came from the head of the Intel technological development, Jim Kardach. At the time, he was reading ‘The Long Ships’ which is about vikings and the Herald Bluetooth who brought the Danish together into one a kingdom. In connection, the Bluetooth standard would bring together multiple various devices to communicate together.

Bluetooth uses the 2.4 GHz band similar to Wi-Fi, specifically from 2.400-2.485 GHz. The initial Bluetooth standard was created to replace RS-232 connections with a wireless method. The RS-232 connections are for communication (COM) or serial ports on computers.

Bluetooth allows for a connection of seven devices. One device acts as a ‘master’ device, sometimes called a transmitter, while the other devices are considered ‘slaves’, sometimes called receivers. For example, a Bluetooth dongle on a PC (or one built in) will act as a ‘master’ and send audio signals to a headphone, which is the ‘slave’ device. Devices can switch their roles as ‘master’ and ‘slave’. For example, headphones may initiate a call from a smart phone. The headphones are initially the ‘master’. After a call is connected form the smart phone then the phone can become the ‘master’ and the headphones the ‘slave’.

When a device is connected to another device the two devices are considered a ‘piconet’. Again, up to seven devices can be a ‘piconet’. It is possible for a ‘master’ or ‘slave’ to belong to a second ‘piconet’ which is then considered a ‘scatternet’.

When a ‘piconet’ is established it is possible for the ‘master’ device to send a broadcast meant for all devices or to communicate with only one device. A round-robin method is used as needed. The round-robin method is where each device is communicated with one after another in succession. The ‘slave’ devices will receive the signals from the ‘master’, but only act on those meant for itself.

Bluetooth Communications

Packets are sent by Bluetooth on channels. On the used band each channel is 1 MHz from the next channel making for a total of 79 channels. For Low Energy (LE) Bluetooth the channels are separated by 2 MHz allowing for only 40 channels. Around 800 packets can be sent in a second.

Because the ‘piconet’ is set up as a ‘master/slave’ configuration all of the devices work off of the clock of the ‘master’. The ‘master’ clock will ‘tick’ every 312.5 micro-seconds or every 312.5 millionths of a second. The ‘master’ will transmit on even ticks and receive data on odd ticks. The ticks are arranged in ‘slots’ and a packet can take up 1, 3 or 5 slots. Each slot is 625 micro-seconds.

Bluetooth Classes

Each Bluetooth device may be listed under a specific Class. The Class is not to be confused with the Bluetooth Version which describes the protocol standards and abilities. The Class is mainly used to specify the hardware ability for connection range.

There are four Classes used in Bluetooth Hardware.

Class 1 allows for a range for nearly 300 ft (100 m).

Class 2 provides a maximum distance of 30 ft (10 m).

Class 3 give a maximum range of around 3 ft (1 m).

Class 4 has a maximum range of about 1.5 ft (.5 m).

When you buy a Bluetooth device you may want to be aware of the distance limitations of the device if the specific Class under which the device operates is listed.

Bluetooth Versions

Each version of the Bluetooth standard provides various functionality built off of the previous version. There is backwards compatibility, but the devices may not function as planned. For example, some low power functions are not supported by older devices and the two may not work together. Personally, I have a pair of headphones which will not work with an older version Bluetooth dongle.

There are currently 5 main Bluetooth Versions and a few minor versions. The Versions are as follows:

  • Version 1.0 and 1.0b
    • Had problems with devices working together
  • Version 1.1
    • Fixed a lot of errors for Versions 1.0 and 1.0b
  • Version 1.2
    • Provides faster connection and discovery of devices.
    • Allows for Adaptive Frequency Hopping (AFH) to spread the signal over multiple frequencies
    • Higher speeds up to 721 Kb/s
  • Version 2.0+EDR (2004)
    • Enhanced Data Rate (EDR) which if supported by both devices can reach 2 Mb/s
  • Version 2.1+EDR (2007)
    • Included support for secure paining of two devices
    • Extended Inquiry Response (EIR) to provide more device information when two devices inquire about each other
  • Version 3.0+HS (2009)
    • Includes High Speed (HS) which has a theoretical speed of 24 Mb/s. The actual data is transferred over IEEE 802.11 (Wi-Fi)
    • Enhanced power control to reduce or increase range to keep device connected
    • L2CAP to provide a reliable channel connection
    • Streaming Mode (SM) to send data on unreliable channels
    • Unicast Connection to send service data and not have an L2CAP channel connection
  • Version 4.0+LE (2010)
    • Provides low-energy consumption
    • Single-mode – only Low Energy protocols used
    • Dual-mode – uses either a Bluetooth Smart or Classic chip
  • Version 4.1 (2013)
    • Adds features for usability
  • Version 4.2 (2014)
    • Introduces Internet of Things (IoT)
  • Version 5 (2016)
    • Added more features for IoT
    • Decided for no more minor upgrades, only major (no more ‘.#’)
    • Quadrupled effective range
    • Double effective speed
Bluetooth Interference

Because of the transfer within the same band as Wi-Fi there can be interference. Usually interference only occurs when using earlier versions of Bluetooth.

Bluetooth uses the band between 2.400-2.485 GHz. Wi-Fi uses the range from 2.400-2.482 GHz. You can see that nearly the whole range is overlapped.

Since Bluetooth Version 1.2 introduced Adaptive Frequency Hopping most interference has been eliminated. Since the Bluetooth signal is being transferred across frequencies the time that there is interference is only in the milliseconds. If a frequency is found to produce interference then AFH will not use the specific frequency until it is free from interference.

Assume you are using a Bluetooth device such as your phone and a pair of headphones to listen to music. If there is interference it would only last a few milliseconds at a time and you would not notice it. It is possible to get interference from another Bluetooth device such as a mouse. Every time you move your mouse the music becomes ‘choppy’ and when you stop moving the mouse the music is fine. In this case you need to use a new Bluetooth ‘master’ device for the mouse, preferably one that is Bluetooth Version 1.2 or greater.

To find the version of a Bluetooth adapter type the command:

hciconfig -a

You should get an output similar to Figure 1. The third last line shows the information ‘HCI Version: 2.0 (0x3)’ which is Bluetooth Version 2.0.

Figure 01.jpg

FIGURE 1

The address ‘(0x3)’ also shows the address for the Version number as shown:

0 - Bluetooth Core Specification 1.0b
1 - Bluetooth Core Specification 1.1
2 - Bluetooth Core Specification 1.2
3 - Bluetooth Core Specification 2.0 + EDR
4 - Bluetooth Core Specification 2.1 + EDR
5 - Bluetooth Core Specification 3.0 + HS
6 - Bluetooth Core Specification 4.0
7 - Bluetooth Core Specification 4.1
8 - Bluetooth Core Specification 4.2
9 - Bluetooth Core Specification 5.0

As you can see from the chart ‘0x3’ or ‘3’ is for ‘Bluetooth 2.0+EDR’.

If no Bluetooth adapter is found on your system then the command ‘hciconfig -a’ will not return any information. Even if my system has a Bluetooth dongle for a Logitech keyboard and mouse I do not get a result for the dedicated adapter.

Another type of interference is signal blockage. Let’s say you have a Bluetooth single ear piece in your right ear and place your smart phone in your left back pocket. The signal will have to travel through your body to reach the device. In this case your body is blocking the signal between the devices. Try, if possible, to keep all Bluetooth devices in the same ‘piconet’ within close proximity and nothing to block the signal between them.

I hope you understand Bluetooth a little better now and can make your ‘piconets’ work better.
 

Members online


Top