Introduction

In part 1, we explored Bluetooth® advertising and the various roles devices may assume. In part 2, we’ll take a closer look at what can be inside advertising packets and consider how developers can receive and process them.

AD Types Used in Bluetooth Low Energy Advertising Packets

The current version of CSS is version 6 and this defines the AD Types which may be used in Bluetooth Low Energy advertising packets or Scan Response PDUs. Data type values are defined in the Assigned Number for GAP document.

Some of the types defined in the CSS which are more commonly used in advertising packets are explained next.

Service UUID

This refers to six distinct data types. The purpose of each of them is to provide a list of the UUIDs of the services supported by the device. The list can either represent the complete set of UUIDs or it can be incomplete and it can contain either 16-bit, 32-bit or 128-bit UUID values. So that’s 2 x 3 = 6. Get it?

Only UUIDs issued by the Bluetooth SIG may appear in the 16- or 32-bit lists.

Service Data

The Service Data AD Type allows arbitrary data associated with a specific UUID to be included in advertising packets or scan response PDUs. There are three variations of this type; one for 16-bit UUIDs, one for 32-bit UUIDs and one for 128-bit UUIDs. Google’s EddyStone beacon frame format uses this field with the 16-bit UUID 0xFEAA followed by service data which may be of one of three sub-types, UID, URL or TLM (telemetry).

Local Name

This is the device’s name or a shortened version of it.

Flags

This is an important AD Type and it is almost always included in advertising packets (It can’t be included in scan response PDUs). It tells you about the advertising state of the device and which of the two transports, Bluetooth® low energy and Bluetooth BR/EDR it supports.

A device which is discoverable can either be in Limited Discoverable Mode or General Discoverable Mode. Limited Discoverable Mode is used to suggest that the device should have a high priority to scanning devices and often the advertising interval used when in this mode is faster than when in the General Discoverable Mode. A device will be in Limited Discoverable Mode for a limited time only and the core specification recommends this be no more than one minute. A device whose Flags field indicates it is not discoverable just means scanning devices should ignore it.

TX Power Level

The transmitted power of the packet in dBm.

Service Solicitation

This type is not commonly used but it isn’t the easiest to understand so I’ve included it here in the hope that my explanation is useful.

GAP and GATT are not coupled in any way. A device may have any one of the GAP roles and at the same time be either a GATT-client or a GATT-server. Of course, some combinations are more common than others. A GAP Peripheral is very often a GATT server but it doesn’t have to be. It’s just as valid for a GAP Peripheral to be a GATT =Client. When this is the case, the discovery process works as it always does, with the GAP Peripheral advertising and the GAP Central scanning. The Central device will make the connection to the Peripheral but once that’s been achieved, the GAP Peripheral—now acting as a GATT Client—will use the Attribute Protocol (ATT) to exploit the GATT services on the GAP Central/GATT server device. This AD Type allows the GAP Peripheral to effectively say, “I’m interested in devices which have the following GATT services…”

Handling Advertising Packets in Code

How much work is involved in writing code which scans for and extracts information from advertising packets depends on the platform you’re developing on. Some platforms provide APIs to parse advertising packets and give you ready access to at least some of the fields but others may only give you a byte array. Others let you specify sophisticated filtering rules so you only “see” advertising packets relevant to your application whilst others send your application all advertising packets received. Some perform active scanning automatically. Some have explicit APIs that you must use to invoke active scanning.

Understanding what to do with a raw advertising packet in the form of a byte array will stand you in good stead for any platform and it’s really not difficult. To help you get started, I’ve created an Android application called AdvScanner which includes a full advertising packet parser. You can download the source code.

Browse through the code in the advscanner/advertising directory to see how parsing works in the AdvScanner application or run the application on your Android phone to explore the advertising packets being emitted by devices in your environment. You’ll need a device which supports Android 5 at a minimum to use the application.

Conclusion

Tardis
Bluetooth Advertising – more available space than you might think!

Advertising is a crucial part of Bluetooth® low energy and one which developers can exploit in various ways. I hope this guided tour has been useful!

Bluetooth Developer Journey

As a leading player in the semiconductor industry committed to the development of cutting-edge…

Generic Health Sensor Design and Implementation Guide

The Generic Health Sensor (GHS) Design and Implementation Guide guides implementers of health sensor…

Doom running on Silicon Labs & Sparkfun Microcontrollers: A Quick Look

Doom has recently reached its 30th anniversary, yet it remains a masterpiece and a…

Auracast Simple Transmitter Best Practices Guide

This paper provides a set of clear, concise, and useful recommendations for product makers interested in building Auracast transmitter products.

5.7 km of Bluetooth® Range

40 km from Irvine, California gets you to beautiful Newport Beach Pier, and 5.7…

Synthesize and Transmit Audio Using LE Audio

The application is assembled as a sound-generating device, the synthesizer, and a receiving headphone.…

Unveiling the Truth: Debunking Bluetooth’s Biggest Myth

Bluetooth Low Energy was designed to considerably reduce power consumption and cost while maintaining…

Bluetooth® Mesh Feature Enhancements Summary

This paper summarizes the recent Bluetooth® Mesh feature enhancements and provides references to other…

The Latest in HADM with Bluetooth LE

HADM, or high accuracy distance measurement using Bluetooth does exactly what it says –…

Mr. Beacon Podcast: Snapdragon Sound with Mike Canevaro

This episode of the Mr. Beacon Podcast explores the revolutionary world of Bluetooth audio.…

Top 10 Auracast™ Resources

It’s been almost a year since the Bluetooth Special Interest Group (SIG) released Auracast™…

Features and Benefits of Bluetooth Mesh 1.1 for Wireless Mesh Networking

Commercial and industrial applications like lighting require large-scale, low-power device networks where thousands of…

The Bluetooth® Low Energy Primer

Are you new to Bluetooth Low Energy? Learn about its constituent parts, features, and how it works.

Bluetooth® Technology for Linux Developers

Learn how to use the interprocess communication system D-Bus and the BlueZ APIs to create Bluetooth applications for Linux computers.

Designing and Developing Bluetooth® Internet Gateways

Learn about Bluetooth® internet gateways, how to make them secure and scalable, and design and implement your own...

 Get Help