/ coding

BLE GATT Primer

Bluetooth is like a database

You have a bluetooth server, and a bluetooth client. The server is similar to a web database table. This table structure conforms to the GATT (Generic Attribute) Protocol. This defines the structure hierarchy as:

  1. Profile:
    • Service
      • Characteristic

A characteristic is basically a read and/or write value that you can access if you are connected to the bluetooth device. Each service and characteristic has its own corresponding UUID (Universal Unique Identifier).

Proximity Monitor Example

Let's consider a proximity monitor, for example. Bluetooth SIG (Special Interest Group) has defined some standard bluetooth profiles, and one of those is the proximity profile. You can visit their website to view the spedifications of all the adopted Profiles, Services, and Characteristics. The Proximity Profile Specification defines a proximity monitor (such as a mobile phone) and a proximity reporter (such as a wearable device). The profile contains 3 services, Link Loss, Immediate Alert, and TX Power. The profile is broken down as follows:

Schematic

Notice that one characteristic is Read/Write, one is Write Only, and he other is Read Only. Another type is Notify, which will notify the client when the value changes.

Custom Profiles

You are free to create profiles, services, and characteristics however you want. This is typically done in firmware. You have to assign your own UUIDs, and if you are worried about collision, you can register them with the Bluetooth SIG for a fee.

How to communicate

So, in order to communicate, you can either read/write values by accessing the corresponding UUID. Not too difficult, right?

Try connecting to a BLE device using one of many developer apps. Here's one I reccommend, it shows the services and characteristics:

Nrf Connect (iOS)

Nrf Connect (Android)