LibraryBLE GATT Services and Characteristics

BLE GATT Services and Characteristics

Learn about BLE GATT Services and Characteristics as part of IoT Development with Embedded Systems

Understanding BLE GATT Services and Characteristics

In the world of Bluetooth Low Energy (BLE) for the Internet of Things (IoT), the Generic Attribute Profile (GATT) is the fundamental framework that defines how data is organized and exchanged between BLE devices. At its core, GATT is built upon two primary concepts: Services and Characteristics. Understanding these building blocks is crucial for developing any BLE-enabled IoT application.

What is a BLE GATT Service?

A GATT Service is a collection of related data or functionalities. Think of it as a category or a logical grouping of information that a BLE device can offer. For example, a heart rate monitor might have a 'Heart Rate Service' that encapsulates all the data related to measuring and reporting heart rate.

Services group related data and functionalities.

Services are like folders that organize specific capabilities of a BLE device. Each service has a unique identifier (UUID) and contains one or more characteristics.

Each GATT Service is identified by a Universally Unique Identifier (UUID). These UUIDs can be either standard (16-bit) defined by the Bluetooth SIG for common functionalities like Heart Rate, Battery Service, or Device Information, or custom (128-bit) UUIDs defined by developers for proprietary features. A device can expose multiple services, each serving a distinct purpose.

What are BLE GATT Characteristics?

Characteristics are the actual data points or values within a service. They represent the smallest unit of data that can be read or written by a connected BLE device. Continuing the heart rate monitor example, a 'Heart Rate Measurement' characteristic would hold the actual heart rate value (e.g., 75 BPM).

Characteristics are the actual data values within a service.

Characteristics are the individual pieces of information that can be read or written. They have properties like read, write, notify, and indicate, which define how they can be interacted with.

Like services, characteristics also have unique UUIDs. A characteristic contains a value, and can also include descriptors that provide additional information about the characteristic's value (e.g., units, format). The properties of a characteristic dictate the type of operations that can be performed on its value. Common properties include: Read (client can read the value), Write (client can write a new value), Notify (server can send unsolicited updates to the client when the value changes), and Indicate (similar to Notify, but requires acknowledgment from the client).

The Relationship: Services Contain Characteristics

The hierarchical structure of GATT is essential for organizing data. A GATT profile defines a collection of services, and each service contains one or more characteristics. This layered approach allows for a structured and standardized way of communicating data between BLE devices.

FeatureGATT ServiceGATT Characteristic
PurposeGroups related data and functionalities.Represents an individual data point or value.
IdentifierUnique UUID (16-bit or 128-bit).Unique UUID (16-bit or 128-bit).
ContentsContains one or more characteristics and potentially other services.Contains a value, and optionally descriptors.
AnalogyA folder or category.A file or a specific data entry within a folder.

Practical Application in IoT

When developing an IoT device that uses BLE, you'll define your device's capabilities by creating custom GATT services and characteristics. For instance, a smart sensor might expose a 'Temperature Service' with a 'Current Temperature' characteristic. The embedded firmware will be responsible for reading the sensor data and updating the characteristic's value, allowing a connected smartphone app or gateway to easily access this information.

Imagine a BLE device as a structured database. The GATT Server (the device offering data) acts as the database administrator. The entire database is organized into 'Services,' which are like tables or major sections. Each Service has a unique name (UUID). Within each Service (table), you have individual data fields called 'Characteristics.' These are like columns in a table, holding specific pieces of information (e.g., temperature, battery level, button state). Each Characteristic also has a unique name (UUID) and can be configured with specific permissions (Read, Write, Notify, Indicate), determining how clients can interact with that data. Descriptors provide metadata about the Characteristic's value, like units or descriptions.

📚

Text-based content

Library pages focus on text content

Key Takeaways

What is the primary purpose of a GATT Service?

To group related data and functionalities.

What does a GATT Characteristic represent?

An individual data point or value.

What are the common properties of a GATT Characteristic that define interaction?

Read, Write, Notify, and Indicate.

Understanding UUIDs is critical for both services and characteristics, as they uniquely identify these elements within the BLE ecosystem.

Learning Resources

Bluetooth GATT Overview(documentation)

The official Bluetooth Technology website provides comprehensive documentation on the GATT specification, including services and characteristics.

Understanding GATT Services and Characteristics(blog)

A clear explanation of GATT services and characteristics with practical examples, ideal for beginners.

BLE GATT Explained: Services, Characteristics, and Descriptors(blog)

This blog post breaks down the GATT architecture, focusing on the roles of services, characteristics, and descriptors in BLE communication.

Introduction to Bluetooth Low Energy (BLE) GATT(blog)

A foundational article that introduces the GATT framework, its structure, and how it's used in BLE applications.

Bluetooth GATT Server and Client(blog)

Explains the roles of the GATT server and client in BLE communication, and how services and characteristics facilitate this interaction.

BLE GATT Profile(paper)

An official PDF document from the Bluetooth SIG detailing the GATT profile, its structure, and common services.

BLE GATT Services and Characteristics Explained(video)

A video tutorial that visually explains the concepts of GATT services and characteristics in BLE, making it easier to grasp.

Nordic Semiconductor BLE GATT Tutorial(documentation)

Technical documentation from Nordic Semiconductor, a leading BLE chip manufacturer, covering GATT services and their implementation.

ESP32 BLE GATT Server Example(documentation)

Official documentation for the ESP-IDF framework, showing how to implement a GATT server with custom services and characteristics on an ESP32 microcontroller.

Generic Attribute Profile (GATT)(wikipedia)

Wikipedia provides a general overview of the Generic Attribute Profile, its purpose, and its role in Bluetooth communication.