Bluetooth low energy SensorTag
When we interact with a SensorTag device, we interact with a specific element named Attribute . Services , Characteristics , Descriptors , and Declaration are different types of Attribute .
The behavior of a BLE device (a SensorTag) is given by the different Services that encapsulate different parts of this behavior. Mainly, a service is a container for different data items – these data items can be read (e.g. a sensor value from a SensorTag) or write (e.g. we must write a value in order to configure a sensor – for example, to set the dynamic range for the accelerometer sensor). For example, the behavior of the ThunderBoard Sense SensorTag is encapsulated in the following services :
- Generic Access Service ( UUID = 0x1800 );
- Generic Attribute Service ( UUID = 0x1801 );
- Device Information Service ( UUID = 0x180A );
- Battery Service ( UUID = 0x180F );
- Environment Sensing Service ( UUID = 0x181A );
- Power Management Service ( UUID = EC61A454-ED00-A5E8-B8F9-DE9EC026EC51 );
- Indoor Air Quality Service ( UUID = EFD658AE-C400-EF33-76E7-91B00019103B );
- User Interface Service ( UUID = FCB89C40-C600-59F3-7DC3-5ECE444A401B );
- Automation IO Service ( UUID = 0x1815 ) and
- Acceleration Orientation Service ( UUID = A4E649F4-4BE5-11E5-885D-FEFF819CDC9F ).
As a conclusion, a service represents a specific hardware feature of a SensorTag (or to other type of Bluetooth device) – e.g. in ThunderBoard Sense SensorTag the sensors values related with the air quality (these sensors can detect the existence of ethanol and hazardous gases such as carbon monoxide and a wide range of volatile organic compounds) are grouped in Indoor Air Quality Service. The complete table with all information regarding the services for ThunderBoard Sense SensorTag can be found here. The blessTags software gives the possibility to interrogate different types of unknown BLE devices – in order to be able to obtain the complete GATT attribute table for an unknown BLE device several steps must be done, such example can be found here.
In a Bluetooth device, a service contains, at least, one or more characteristics . A characteristic owns none or more descriptors . The descriptors are completely optional, but a service must contain at least one characteristic . Each service , characteristic and descriptor must be identified by a unique identifier ( UUID ). UUID s can be 16- or 128-bit values. For example, the Generic Access Service (presented above) have a UUID on 16 bits value ( 0x1800 ) while the service Acceleration Orientation Service (presented above) have a UUID on 128 bits value ( A4E649F4-4BE5-11E5-885D-FEFF819CDC9F ).
A characteristic of a service is related to an internal state of a BLE device – e.g. a value that quantifies the volatile organic compounds from the air, obtained from the CCS811 digital gas sensor embedded inside the ThunderBoard Sense SensorTag. Also, Characteristics contain various properties. A property describes what another device (a client) can do with a characteristic over Bluetooth. The operations such as READ, WRITE, NOTIFY or INDICATE are permitted or not, functions of specific value defined by a property associated with a characteristic . For a deep description of properties please visit the post “Reading vs. notifying”.
Example 1: So, let’s take an example. The Service Automation IO Service (with the short UUID = 0x1815 and with the long UUID = 00001815-0000-1000-8000-00805F9B34FB ) have two Characteristics . The first one with UUID_0 = 0x2a56 and the second one with UUID_1 = 0x2a56 . The first Characteristics owns three Descriptors, with UUID s: 0x2902 , 0x2904 and 0x2909 . The second Characteristics owns only two descriptors with the UUID s: 0x2902 and 0x2909 . See the figure from below (the figure was obtained with the developer function of the blessTags application).
The characteristics UUID can be predefined ones — like the ones presented above with the UUID = 0x2a56 . These predefine UUID s have specific functions associated by the Bluetooth BLE standard. The Characteristic ’s UUID s defined by Bluetooth BLE standard always follow the formats: (a) 0x2A[xx] – where the [xx] are two hex values and (b) 0x2B[yy] – where the [yy] are hex values.
The Descriptors are special types of attributes that describe a characteristic value (they contain different type of metadata, based on this information they augment a characteristic ) with which they are associated. A very important descriptor is the Client Characteristic Configuration Descriptor (abbreviated to CCCD) – based on this descriptor the notification messages can be switched on or off. Up to now, descriptors have associated only short UUIDs (16 bits value). The descriptor ’s UUIDs identifiers always follow the format: 0x290[y] – where the [y] value is a hex number.
A special type of attribute is the declarations . The declarations are used to separate distinct group of attributes: in services and inside a service in characteristics . A Service Declaration attribute has always the standard UUID the 0x2800 value. The Characteristic Declaration have the standard UUID the 0x2803 value. Please see this in the figure presented above. The declaration ’s UUIDs identifiers always follow the format: 0x280[z] – where the [z] value is a hex number as follow .
Example 2: In ThunderBoard Sense, the service Indoor Air Quality Service has three characteristics – the service attribute table is presented in the above picture. A service starts with a Service Declaration attribute ( UUID = 0x2800 ) and each characteristic is separated by the other characteristics with a Characteristic Declaration ( UUID = 0x2803 ). All the characteristics UUID s, of this service , are not defined in Bluetooth BLE standard – have UUID s different from 0x2A[xx] and 0x2AB[yy] format. In this case, the UUID s values are defined by the producer of the ThunderBoard Sense SensorTag – the Silicon Labs company. The third characteristic has associated only one descriptor – the CCCD. To access the data from the first two characteristics, a READ operation must be initiated – the [R] property in the figure.
Starting with the version 11.0.0.0 of the blessTags application all the characteristics (more than 200 characteristics) defined by the Bluetooth BLE standard are identified and presented to the user.
Example 3: To understand better the advantage of knowing the characteristics defined by the Bluetooth BLE standard, below are presented: (a) the attribute table for the Device Information Service ( UUID = 0x180A ) knowing the characteristics defined by the Bluetooth BLE standard – the first figure presented below and (b) the same table unknowing the characteristics defined by the Bluetooth BLE standard – the second image presented below.
The blessTags application can be downloaded from the Windows Store Apps: https://www.microsoft.com/store/apps/9p054xsjjr1n.
The blessTags Lite application (the free version of blessTags) can be downloaded from the Windows Store Apps: https://www.microsoft.com/store/apps/9mt2kgztfjf5.
Thank you very much for reading this article and your interest in Bluetooth LE technology!