Showing posts with label GATT. Show all posts
Showing posts with label GATT. Show all posts

Sunday, October 26, 2014

Profile, Services and Characteristics


GATT transactions in BLE are based on high-level, nested objects called Profiles, Services and Characteristics, which can be seen in the illustration below:





















Profiles

To use Bluetooth wireless technology, a device must be able to interpret certain Bluetooth profiles. Bluetooth profiles are definitions of possible applications and specify general behaviors that Bluetooth enabled devices use to communicate with other Bluetooth devices.

A Profile doesn't actually exist on the BLE peripheral itself, it's simple a pre-defined collection of Services that has been compiled by either the Bluetooth SIG or by the peripheral designers.

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.). Similarly to Services, each Characteristic distinguishes itself via a pre-defined 16-bit or 128-bit UUID.

Characteristics are the main point that you will interact with your BLE peripheral, so it's important to understand the concept. They are also used to send data back to the BLE peripheral, since you are also able to write to characteristic. You could implement a simple UART-type interface with a custom 'UART Service' and two characteristics, one for the TX channel and one for the RX channel, where one characteristic might be configured as read only and the other would have write privileges.


Saturday, October 25, 2014

Generic Attribute Profile (GATT)

GATT comes into play once a dedicated connection is established between two devices, means you have already gone through the advertising process governed by GAP. GATT defines the way that two BLE devices transfers data back and forth using concepts called Services and Characteristics. It make use of a generic data protocol called Attribute Protocol, which is used ti store Services, Characteristics and related data in simple lookup table using 16 - bit IDs for reach entry in table. These 16 - bit IDs are called UUIDs.

Note: Important thing to note here is, GATT connections are EXCLUSIVE. That means a BLE Peripheral device can only be connected to one central device at a time.


How Connections Works

It is interesting to know, that a peripheral device can only be connected to one central device, such as a mobile device, at a time, but a central device can connect to multiple peripheral.

How Connection Works













Client/Server Relationship

Peripheral act as GATT Server and Central act as GATT Client. GATT Server holds ATT lookup data, services and characteristics, whereas GATT Client sends requests to this server.

All transactions are started by the master device, the GATT Client, which receives 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. Marconi Labs ADA iBeacons is an example of such peripheral device. 



Note: 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.