Bluetooth radio tutorail – bluetooth programming in c

 

 

Bluetooth radio tutorail Bluetooth Development Course · Free Course

Bluetooth radio tutorail – Bluetooth Lower Layers

A deep dive into the Bluetooth Radio , Baseband Controller, Piconet & Scatternet topology — the foundation of every BT stack.

📡 Wireless Protocol🔗 BR/EDR & BLE🎓 EmbeddedPathashala⚡ Free Embedded Systems Course

Hello students, welcome to the Bluetooth Development in C course by EmbeddedPathashala — part of our free embedded systems course series.

In today’s Bluetooth radio tutorial, we will explore Bluetooth Lower Layers in detail. In the previous lecture, we discussed that Bluetooth uses a layered architecture. We covered the Bluetooth Radio and Bluetooth Lower Layers at a high level — now let us go deeper into each of them.

  ╔══════════════════════════════════════════════════════╗
  ║              HOST  (Linux / RTOS / Bare-metal)       ║
  ╠══════════════════════════════════════════════════════╣
  ║           HCI  (Host Controller Interface)           ║  ← Common for BR/EDR & LE
  ╠══════════════════════════════════════════════════════╣
  ║         Link Manager Protocol  (LMP / LL)            ║
  ╠══════════════════════════════════════════════════════╣
  ║              Baseband Controller                     ║  ← Physical channel &
  ║         (Link Controller / Packet Engine)            ║    link management
  ╠══════════════════════════════════════════════════════╣
  ║              Bluetooth Radio                         ║  ← 2.4 GHz ISM Band
  ║             (BR/EDR  &  BLE)                         ║    Frequency Hopping
  ╚══════════════════════════════════════════════════════╝
📌 Key Point: The HCI (Host Controller Interface) layer is shared between both BR/EDR and Bluetooth Low Energy (LE). This is a critical architectural distinction — the HCI acts as a clean boundary between the Host software and the Controller hardware.

Bluetooth Radio

Bluetooth is a wireless communication technology, and like all wireless systems, it requires a defined frequency band to operate. Bluetooth uses the 2.4 GHz ISM band (Industrial, Scientific and Medical). Both BR/EDR (Classic Bluetooth) and LE (Bluetooth Low Energy) operate within this same frequency band.

As we discussed in the first lecture, the ISM band is freely available for unlicensed use worldwide — no regulatory license is required to operate devices in this band.

Frequency Hopping Spread Spectrum (FHSS)

To avoid interference and improve robustness, Bluetooth uses a technique called Frequency Hopping Spread Spectrum (FHSS). The 2.4 GHz band is divided into 79 channels (numbered 0 to 78), each 1 MHz wide. The Bluetooth radio continuously hops across these channels during operation.

f(k) = 2402 + k   MHz,   k = 0, 1, 2, … , 78

Bluetooth hops through channels at a rate of up to 1,600 hops per second. This rapid hopping ensures that even if interference is present on one channel, the very next transmission will move to a different channel which may be noise-free.

Bluetooth also uses a Time Division Duplex (TDD) scheme to achieve full-duplex transmission — the device alternates between transmitting and receiving in separate time slots on the same channel.

  2.4 GHz ISM Band  →  79 Channels, each 1 MHz wide

  Ch:  0     1     2    3    4    5   ...  37   ...  78
  f:  2402  2403  2404 2405 2406 2407 ... 2439 ... 2480  (MHz)

  Time →
  ┌──────┐      ┌──────┐      ┌──────┐      ┌──────┐
  │ Ch37 │      │ Ch 5 │      │ Ch72 │      │ Ch19 │  ...
  └──────┘      └──────┘      └──────┘      └──────┘
    Tx/Rx         Tx/Rx         Tx/Rx         Tx/Rx

  ↑ 1600 hops/second — pseudo-random pattern, both devices stay in sync

Modulation Schemes

Packets are transmitted using phase modulation. Bluetooth defines two modulation modes:

Basic Rate (BR)
1 Mbps
Uses GFSK — Gaussian Frequency Shift Keying (shaped binary FM). Designed to minimise transceiver complexity while achieving 1 Mbps air data rate.
Enhanced Data Rate (EDR)
2 – 3 Mbps
Uses PSK — Phase Shift Keying modulation (π/4-DQPSK for 2 Mbps, 8DPSK for 3 Mbps). Delivers higher throughput for data-intensive applications.

Power Classes in Bluetooth

The Bluetooth specification defines 3 power classes based on the maximum transmit power output. A higher maximum output power corresponds to a longer operating range.

Power Class Max Output Power dBm Typical Range
Class 1 100 mW +20 dBm ~100 metres
Class 2 2.5 mW +4 dBm ~10 metres
Class 3 1 mW 0 dBm ~1 metre
💡 Note: Most smartphones and consumer headsets are Class 2 devices. Class 1 is typically found in industrial equipment and long-range Bluetooth dongles.

Frequency Band and Hopping — Detailed View

Bluetooth uses the unlicensed 2.4 GHz ISM band which is globally available without a licence. The band is divided into 79 channels, each 1 MHz wide.

Multiple devices can operate in the same 2.4 GHz band simultaneously — including Wi-Fi devices. To combat interference, the Bluetooth device changes channels at a rate of up to 1,600 times per second. Even if noise is present on one channel, the next transmission is on a different channel which may be noise-free.

Channel Switching — How It Works

The pattern of channel changes in Bluetooth is pseudo-random. All devices participating in the same connection agree on the hopping pattern in advance — so every device knows exactly which frequency to hop to next. This keeps all communicating devices in perfect synchronisation.

Channel frequencies are calculated using the formula:

f(k) = 2402 + k   MHz,   k = 0, 1, 2, … , 78

Baseband Controller (Link Controller)

The Baseband Controller is also called the Link Controller. It sits directly above the Bluetooth Radio in the stack and is responsible for the following core functions:

  • Management of physical channels and link management
  • Selecting the next hopping frequency for TX and RX operations
  • Piconet and Scatternet handling
  • Packet formation and passing packets to the Bluetooth Radio
  • Inquiry, Inquiry Scan, Connection, and Page Scan operations
  • Data encryption and power management

Piconet and Scatternet Topology

Bluetooth supports both point-to-point connections and point-to-multipoint connections. In point-to-point communication, the physical channel is shared between two devices. In point-to-multipoint, the physical channel is shared among all participating devices.

What is a Piconet?

A Piconet is the smallest Bluetooth network. It is formed when two or more devices share the same physical channel. A piconet consists of:

  • Exactly one Master device
  • Up to seven active Slave devices

All devices in the piconet are synchronised with each other in terms of clock frequency and hopping mechanism. The standard piconet clock is the same as the Master’s clock. The hopping frequency of the piconet is calculated using the Master’s Bluetooth Device Address (BD_ADDR) and the Master’s clock.

                      ┌──────────────────┐
                      │    MASTER  (M)   │
                      │   BD_ADDR + CLK  │
                      └────────┬─────────┘
              ┌────────────────┼────────────────┐
              │                │                │
        ┌─────▼──┐       ┌─────▼──┐       ┌─────▼──┐
        │Slave S1│       │Slave S2│       │Slave S3│
        └────────┘       └────────┘       └────────┘
              │                │                │
        ┌─────▼──┐       ┌─────▼──┐       ┌─────▼──┐
        │Slave S4│       │Slave S5│  ...  │Slave S7│
        └────────┘       └────────┘       └────────┘

  All 8 devices share the SAME hopping pattern derived from
  Master's BD_ADDR and Master's clock.
💡 Remember: Multiple piconets can coexist in the same area without interfering with each other, because each piconet has its own Master — and therefore its own unique BD_ADDR and clock — producing a different pseudo-random hopping sequence across the same 79 channels.

What is a Scatternet?

A Scatternet is formed when two piconets share a common device (called a bridge device). The bridge device participates in both piconets using Time Division Multiplexing (TDM) — it is active in the first piconet for a period of time, then participates in the second piconet for the remaining time.

When the bridge device moves to the second piconet, it places itself into a low-power mode in the first piconet. The remaining devices in the first piconet are aware of this temporary absence.

  ◄─────────── Piconet 1 ──────────►   ◄───────── Piconet 2 ──────────►

      ┌────────┐                              ┌────────┐
      │Master  │                              │Master  │
      │  M1    │                              │  M2    │
      └────┬───┘                              └────┬───┘
           │                                       │
     ┌─────┴──────┐                          ┌─────┴──────┐
     │            │                          │            │
  ┌──▼──┐     ┌───▼──────────────────────────▼──┐     ┌──▼──┐
  │ S1  │     │       BRIDGE DEVICE (B)          │     │ S3  │
  └─────┘     │  Slave in Piconet 1              │     └─────┘
              │  Master in Piconet 2             │
              └──────────────────────────────────┘
                         ↑↑↑
              Uses TDM: active in Piconet 1
              for time T1, then switches to
              Piconet 2 for time T2, and repeats.

  Examples:
    B can be: Slave in Piconet 1 + Master in Piconet 2
    B can be: Slave in Piconet 1 + Slave in Piconet 2
⚠️ Key Rule: A device cannot be Master in two piconets simultaneously. This is because a piconet is uniquely defined by the Master’s BD_ADDR and clock — so a single device acting as Master in two piconets would create an ambiguous, conflicting hopping pattern. A bridge device can only be Master in one piconet and Slave in another.

Quick Reference Summary

Concept Key Detail
Frequency Band 2.4 GHz ISM (unlicensed, global)
Channels (BR/EDR) 79 channels, 1 MHz each (Ch 0–78)
Channel Formula f(k) = 2402 + k MHz, k = 0…78
Hopping Rate Up to 1,600 hops/second
Duplex Method Time Division Duplex (TDD)
Basic Rate Modulation GFSK — 1 Mbps
Enhanced Data Rate PSK (π/4-DQPSK / 8DPSK) — 2–3 Mbps
Piconet 1 Master + up to 7 active Slaves
Scatternet 2+ piconets connected via a bridge device (TDM)
HCI Shared between BR/EDR and LE

📖
Up Next in the Series
Time Division Duplex · Adaptive Frequency Hopping · Master-Slave Roles & Role Switching · Physical Channels, Logical Channels & Links in Bluetooth

Leave a Reply

Your email address will not be published. Required fields are marked *