Purpose

BLE discovery mechanism

  • Make nearby devices aware of advertiser’s existence
  • Communicate some information from or about advertiser
  • Traditional purpose is to enable connections, but this is also useful for general communication

Overview

  • Periodic broadcast messages with data
  • Scan Requests/Responses
    • Scanner sends responses after getting a request
    • Only occurs when scanner is listening
  • Almost literally “bonus advertisement data”

Advertisement Packet Layering

Inside the PDU, the range of bytes, it has a specific structure

Header   2 Bytes
Payload  0-37 Bytes

The header has the following possibilities

Header TypeBitsDescription
ADV_IND0000Advertisement, Allows Connections/Scan Requests
ADV_NONCONN_IND0010Advertisement, No Connections/Scan Requests
ADV_SCAN_IND0110Advertisement, No connections but allows Scan Requests
SCAN_REQ0011Scan Request
SCAN_RSP0100Scan Response
The last bits are used for other things. There are bits dedicated to the length of the payload. There is also bit called TxAdd or Transmitter Address.

The first octets are address of the advertiser (AdvA) and the remaining octets (up to , if any) are for data.

The AdvA has two types:

  • Public: first bits of company ID (a company will purchase these rights from IEEE), last bits of company assigned number (specific to device or randomly generated via hash)
  • Private: top two MSBs (remember it is little endian, so MSB is on the right) specify type. bits of random or hash of identity key

A receiver will know the AdvA is public or private via the TxAdd bit flag in the advertisement header.

When a device receives ADV_IND or ADC_SCAN_IND, it will send a SCAN_REQ to the peripheral. The payload is just octets for its address, and octets of the advertiser’s address.

The peripheral will send a SCAN_RSP. It is identical to an advertisement, but only occurs after a request. At this points, both devices will be “paired” or “connected”.

Advertising Timing

Advertising events occur periodically, ms to s or longer (in increments of ms). There is some random delay ( to ms) after each instance to ensure two separate devices do not sync up and destroy the signal quality.

Transmissions always occur in channels in that order (so the scanner knows where to look if it misses one). But in between each transmission, there is a listening window on the same frequency. Once the receiver gets the advertisement, there is a gap between the advertiser and the scanner, enough time for the hardware to switch from talk to listen.

So,

adv payload @37 -> listen -> payload @38 -> listen -> payload @39 -> listen

This is what makes bluetooth “low energy” since most energy is spent listening.

Payload Types

Payload data (AdvData) follow the TLV format:

For BLE specifically, it uses Length-Type-Value. This allows the scanner to hop through length-type pairs to parse information it cares about.

  • Flags
    • One bit Boolean flags. It tells scanners if the advertiser is in Limited Discovery or General Discovery mode.
  • Name (name of device)
  • Service UUID
  • TX Power Level
  • Manufacturer-specific data
  • And more!

Scanning Pattern

The scanner iterates through channels listening for advertisements. The controls the rate the scanner switches channels. The controls the duty cycle or how long the scanner stays awake.

A low duty cycle saves phone battery. In general,

inside the channels.

Scanning Expectations

Packets are lost due to (in roughly descending order):

  • duty cycle
  • sharing GHz antenna with WiFi
  • retune period after each scanning interval
  • dropped packets in the receive software
  • packet collisions

Advertising Only Applications

There are some devices that only do advertisements.

  • Beacons: iBeacon, Eddystone (you have to run an application registered to listen to these devices to do something with them)
  • Tracking: Tile, Apple AirTag
  • Local communication: Apple Continuity

Energy Costs

Configuration

  • nrf51822
  • Max Payload Size
  • Max transmit power
  • Connectable Advertisement
  • Sleep power . One packet per second will last days on a CR2032. One packet pet minute is years.