Basics of Bluetooth for software engineers
Did you use Bluetooth today?
Although software engineers use Bluetooth in daily life, most are unfamiliar with how it works technically.1
In this article, I share the fundamental knowledge of Bluetooth.
What is Bluetooth?
Bluetooth is a wireless communication technology that allows devices to communicate directly over short distances.
The range is around 10 meters, with a maximum reach of up to 30 meters.
The wave length is 2.4GHz band.2
The packets contain a UUID to distinguish them from packets of other devices.
What uses Bluetooth?
Bluetooth is commonly used with
Audio devices: to send and receive audio data
Peripheral devices: such as keyboards and mice, to input to laptop
Smartphones: to transfer files to each other
Beacons: to detect nearby devices’ presence and estimate the location3
Why to choose Bluetooth?
Bluetooth is optimized for low battery usage.
Bluetooth’s hardware and development cost are relatively cheaper.
Bluetooth is de facto standard, so more likely to be compatible with other products4.
Bluetooth doesn’t need to rely on internet connection, so
network stability is more controllable and reliable
the network roundtrip time is significantly shorter
How does it work? (2 main processes)
1. Advertise
Bluetooth device broadcasts information to nearby devices without a connection. During advertising, the device sends out small packets containing its name. Other devices can detect these advertisements.
For example, when your phone show the list of nearby Bluetooth devices to you, your phone detects the advertise packages from the devices around you.
In this advertise process, one device can estimate the location of the other.5
2. Connect
Two Bluetooth devices establish a direct communication link after a device detects an advertisement and decides to interact with the advertiser. Once connected, the devices can exchange data in real-time.
For example, you can connect your phone with your headset, by choosing it from the nearby devices list. Then your headset starts to receive audio data from your phone.
Because my company is a manufacturer, the services and software designs are hardware-based. The software engineers are required to learn the communication protocols between devices and servers.
Since the 2.4GHz band is also used by other products, such as microwaves, Bluetooth connections are may sometimes interfered.
Beacons only use advertising. One of the beacons usage examples is to provide precise location data within buildings where we cannot expect the accurate GPS location.
Of course, the devices can estimate their distance even when they are connected.