IoT Communication Technologies Part 2 #day2_amebaiot

image

BLE (Bluetooth Low Energy)
The Bluetooth Low Energy, as the name indicates consumes less power than classic Bluetooth. It is achieved by sending data as needed with pre-defined periodic updates. But unlike classic Bluetooth, it is not used to transfer Files or Music.

GAP
GAP is an acronym for the Generic Access Profile, and it controls connections and advertising in Bluetooth. GAP is what makes your device visible to the outside world, and determines how two devices can (or can’t) interact with each other.

Device Roles
GAP defines various roles for devices, but the two key concepts to keep in mind are Central devices and Peripheral devices.

  • Peripheral devices are small, low power, resource-constrained devices that can connect to a much more powerful central device. Peripheral devices are things like a heart rate monitor, a BLE enabled proximity tag, etc.
  • Central devices are usually the mobile phone or tablet that you connect to with far more processing power and memory.

Once you establish a connection between your peripheral and a central device, the advertising process will generally stop and you will typically no longer be able to send advertising packets out anymore, and you will use GATT services and characteristics to communicate in both directions.

GATT
GATT is an acronym for the Generic Attribute Profile , and it defines the way that two Bluetooth Low Energy devices transfer data back and forth using concepts called Services and Characteristics . It makes use of a generic data protocol called the Attribute Protocol (ATT) , which is used to store Services.

Note : GATT comes into play once a dedicated connection is established between two devices, meaning that you have already gone through the advertising process governed by GAP.

A BLE peripheral can only be connected to one central device (a mobile phone, etc.) at a time! As soon as a peripheral connects to a central device, it will stop advertising itself and other devices will no longer be able to see it or connect to it until the existing connection is broken.

GATT Transactions
An important concept to understand with GATT is the server/client relationship.

The peripheral is known as the GATT Serve r, which holds the ATT lookup data and service and characteristic definitions, and the GATT Client (the phone/tablet), which sends requests to this server.

All transactions are started by the master device, the GATT Client, which receives a response from the slave device, the GATT Server.

When establishing a connection, the peripheral will suggest a ‘Connection Interval’ to the central device, and the central device will try to reconnect every connection interval to see if any new data is available, etc. It’s important to keep in mind that this connection interval is really just a suggestion, though! Your central device may not be able to honor the request because it’s busy talking to another peripheral or the required system resources just aren’t available.

Services and Characteristics
GATT transactions in BLE are based on high-level, nested objects called Profiles, Services and Characteristics

image

Profiles
A Profile doesn’t actually exist on the BLE peripheral itself, it’s simply a pre-defined collection of Services that has been compiled by either the Bluetooth SIG or by the peripheral designers. The Heart Rate Profile, for example, combines the Heart Rate Service and the Device Information Service. The complete list of officially adopted GATT-based profiles can be seen here: Profiles Overview.

Services
Services are used to break data up into logic entities and contain specific chunks of data called characteristics. A service can have one or more characteristics, and each service distinguishes itself from other services by means of a unique numeric ID called a UUID, which can be either 16-bit (for officially adopted BLE Services) or 128-bit (for custom services).

Characteristics
The lowest level concept in GATT transactions is the Characteristic, which encapsulates a single data point (though it may contain an array of related data, such as X/Y/Z values from a 3-axis accelerometer, etc.).

conclusion: we can see that it was a little bit different from Bluetooth classic that we used before, and now you can use the service and Characteristics to communicate with the BLE devices, also there is example code provided with esp32 board manager.

Resources :

1 Like