BLE Services and Characteristics

Intro to Bluetooth Low Energy #7

Services and Characteristics are the fundamental building blocks of BLE communication. BLE devices use services and characteristics to transfer and store data.

Services are used to break data up into logical entities, and contain specific chunks of data called characteristics. Characteristics are the actual logical input and output nodes. A collection of characteristics is called a service.

Services

A Service is a grouping of one or more attributes, some of which are characteristics. It is meant to group related attributes that satisfy a specific functionality on the server.

For example, the SIG-adopted battery service contains one characteristic called the battery level.

A service also contains other attributes (non-characteristics) that help structure the data within a service (such as service declarations, characteristic declarations, and others).

Here is what a service looks like:

Profiles, Services, and Characteristics

From the figure, we can see the different attributes that a service is made up of:

  • One or more include services

  • One or more characteristics

    • Characteristic properties

    • A characteristic value

    • Zero or more characteristic descriptors

An Include Service allows a service to refer to other services for purposes such as extending the included service. There are two types of services:

  1. Primary Service: represents the primary functionality of a device.

  2. Secondary Service: provides auxiliary functionality of a device and is referenced (included) by at least one other primary service on the device.

Characteristics

A characteristic is always part of a service and it represents a piece of information/data that a server wants to expose to a client. For example, the battery level characteristic represents the remaining power level of a battery in a device which can be read by a client.

The characteristic contains other attributes that help define the value it holds:

  • Properties: represented by a number of bits that define how a Characteristic Value can be used. Some examples include: read, write, write without response, notify, indicate.

  • Descriptors: used to contain related information about the Characteristic Value. Some examples include: extended properties, user description, fields used for subscribing to notifications and indications, and a field that defines the presentation of the value such as the format and the unit of the value.

Understanding these concepts is important, however, as an application developer you will probably interface with APIs provided by the chipset or mobile operating system SDK that abstract out many of these concepts.

For example, you may have an API for enabling notifications on a certain characteristic that you can simply call (you do not necessarily need to know that the stack ends up writing a value of 0x0001 to the characteristicʼs Client Characteristic Configuration Descriptor (CCCD) on a server to enable notifications).

It is important to keep in mind that while there are no restrictions or limitations on the characteristics contained within a service, services are meant to group related characteristics that define a specific functionality within a device.

For example, even though it is technically possible — it does not make sense to create a service called the humidity service that includes both a humidity characteristic and a temperature characteristic. Instead, it would make more sense to have two separate services specific to each of these two distinct functionalities (temperature reading, and humidity reading).

Profiles

Profiles are much broader in definition than services. They are concerned with defining the behavior of both the client and server when it comes to services, characteristics and even connections and security requirements. Services and their specifications, on the other hand, deal with the implementation of these services and characteristics on the server side only.

Just like in the case of services, there are also SIG-adopted profiles that have published specifications. In a profile specification, you will generally find the following:

  • Definition of roles and the relationship between the GATT server and client.

  • Required Services.

  • Service Requirements.

  • How the required services and characteristics are used.

  • Details of connection establishment requirements including advertising and connection parameters.

  • Security considerations.

Following is an example of a diagram taken from the Blood Pressure Profile specification document. It shows the relationship between the roles (server, client), services, and characteristics within the profile.

Blood pressure profile

The roles are represented by the yellow boxes, whereas the services are represented by the orange boxes.