DEV Community

Cover image for Intro to Bluetooth
ccaldwell11
ccaldwell11

Posted on

Intro to Bluetooth

Introduction

There is a very good chance that you currently own a Bluetooth device, if not multiple, thanks to how dynamic it allows us to become as users no matter the use case. Although it seems to be everywhere we seem to step foot, not many people know how it works or all that it takes to get a successful Bluetooth-enabled product working. Bluetooth helps free up cables to allow us to move how we please while the tech and guidelines behind Bluetooth involve rapidly moving connections and a thorough app screening process.

What is Bluetooth?

Bluetooth is a wireless technology that uses radio waves along the 2.4GHz ISM band to transmit data to and from compatible Bluetooth devices. The current Bluetooth range has a common average of around 35 feet, giving users a significant amount of space to move about freely. Giving developers the freedom to select from two different Bluetooth “radio options”, is also favored by many for the flexibility that it provides.

Bluetooth Classic

Bluetooth Classic can utilize up to 79 channels to stream data and uses peer-to-peer connection strictly. Although Bluetooth Classic may appear restrictive due to its sole connectivity option, the 3Mb/s data transfer speeds more than makeup for it. Bluetooth Classic's radio is primarily used for streaming audio as that has become the "standard radio protocol behind wireless speakers, headphones, and in-car entertainment systems" as the years progressed (Bluetooth).

Bluetooth Low Energy (LE)

Bluetooth Low Energy differs from Bluetooth Classic in one way: it only uses 40 channels instead of 79. The data transfer speed of Bluetooth Low Energy (LE) is also a bit slower in comparison to Bluetooth Classic with LE having a speed of 2Mb/s. Another more significant difference between the two Bluetooth radios is the additional two connectivity options for Low Energy that include broadcast and mesh.

Image description

  • Peer-to-peer

    • Direct connection between devices
    • Ex: Bluetooth speaker pairing, Apple CarPlay
  • Broadcast

    • Sending data without establishing a direct connection
    • Ex: Retail beacons ("walk past, get notified")
  • Mesh

    • Compatible technology with established connections to other tech creating a "web" of interconnected devices
    • Ex: Smart homes

How Does Bluetooth Work?

Bluetooth operates on an industrial, scientific, and medical (ISM) frequency band whose range is divided between various channels. When potentially connecting devices are within range of each other, they bounce between these channels to establish and continue to maintain their wireless communication. Due to this unique method of connection and the low power usage that Bluetooth consumes, other technologies that use the same ISM band, such as Wi-Fi and microwaves, do not interfere with the functionality of the Bluetooth-enabled devices when in use.

Image description

Developing with Bluetooth

Bluetooth does not have an explicit programming language that devs can use to create/connect Bluetooth-compatible devices, however, there are a few ways to go about creating with Bluetooth with plenty of community support and documentation made available from Bluetooth directly as well as other dev-focused forums. To begin development with Bluetooth technology, certain prerequisites are required to ensure the quality of the product created is up to Bluetooth's standards.

  1. Register as a member Before anything can be done involving the Bluetooth tech that is so common around the world, you must first register! A Bluetooth Special Interest Group (SIG) membership is required to have the proper permissions and necessary information to develop with BT incorporation in mind. Upon registration, a member receives:
  • A license to build products using Bluetooth
  • A license to use Bluetooth trademarks
  • Access to certain development and testing tools
  1. Build a product
    With the provided resources given to you along with your other SIG membership credentials and perks, it is now time to actually begin the incorporation of the tech into your product.

  2. Qualify the product
    A qualification check is to ensure that both the Bluetooth Patent & Copyright License Agreement and the Bluetooth Trademark License Agreement are being adhered to accordingly when it comes to how your product is used and has set up Bluetooth. This must be completed before the finished product can be placed on the market for its public release

  3. Brand the product
    Not known by many, Bluetooth SIG owns the trademark for the word 'Bluetooth' and all associated imaging and references. To uphold the brand image of Bluetooth and its tech outreach, Bluetooth SIG ensures that proper logos, themes, and other related concerns align with the organization's predetermined guidelines from its brand style guide. One of these interests pertains to ensuring that the Bluetooth logo remains blue

from bluetooth import * 

target_name = "My Phone" # looking for device with this name
target_address = None

nearby_devices = discover_devices() # receives all nearby & detected devices

for address in nearby_devices:
if target_name == lookup_name( address ): # connects to each device to receive name
target_address = address
break

if target_address is not None:
print "found target bluetooth device with address ", target_address
else:
print "could not find target bluetooth device nearby"
Enter fullscreen mode Exit fullscreen mode
The above code snippet is an example of how Bluetooth devices may "choose a communication partner" using a library called PyBluez. Functions from the library allow for Python programming with Bluetooth connectivity.
# python findmyphone.py
found target bluetooth device with address 01:23:45:67:89:AB



from bluetooth import * 

target_name = "My Phone"
target_address = 01:23:45:67:89:AB

Enter fullscreen mode Exit fullscreen mode
This is an example of how the above code snipped would update if the targeted device was found.

Conclusion

Bluetooth technology is a very useful technology that involves a more incremental approach when building a product, but that is simply to ensure consistency, reliability, and quality are present at all times when navigating the product that was created. It establishes connections by rapidly hopping between channels which also helps avoid interference from other wireless connections. Bluetooth helps connect us to the products and interests that we own and the Bluetooth SIG will do its best to make sure the name of Bluetooth presents itself nicely no matter who dons it.

Sources

https://people.csail.mit.edu/rudolph/Teaching/Articles/BTBook.pdf

https://developer.android.com/develop/connectivity/bluetooth/find-bluetooth-devices

https://www.bluetooth.com/

https://www.intel.com/content/www/us/en/products/docs/wireless/what-is-bluetooth.html

https://www.britannica.com/story/how-does-bluetooth-work

Top comments (0)