# GATT profile Brief

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/madannasf/article/details/102571350

I. Introduction

GATT Profile (General attribute profile) is now mainly used for low-power Bluetooth, mainly for the small amount of data transmission environment, such as Bluetooth dating, mobile phones and other small data loss scenarios.
We also need to explain before gatt explain the relationship between the gap and the gatt att, att is the smallest unit of data in bt, and the gap is a prerequisite gatt executed only after gatt connection on the device, gatt related server services have been execution, or the gatt is a service with many att polymeric composition.

Two, GAP

In the Bluetooth protocol layer, gap exists throughout the entire host layer, providing Bluetooth device is connected to the main broadcast and the like.
As shown below for the entire framework agreement bluedroid FIG.

Here Insert Picture Description

2.1 device roles

GAP defines a number of roles to the device, two of which are mainly: a peripheral device (Peripheral) and a central device (Central).

** Peripherals: ** This is generally very small or simple low-power devices, to provide the data, and connect to a relatively more powerful center equipment. E.g. millet bracelet.
Center apparatus **: ** center apparatus is relatively strong, used to connect other peripheral devices. Such as mobile phones.

2.2. Broadcast Data

A peripheral device in the GAP outwardly broadcast data in two ways:

Broadcast data Passive scanning
The maximum length of the data 31byte The maximum length of the data 31byte
Device Initialization Required Optional user functions

Three, ATT property agreement

ble data are also in existence attributes, each attribute consists of four elements constituting the
1, attribute handle (Handler), the handle is in the range 0x0001 ~ 0xffff, it is mainly attribute identifies the location in the database att we can get through to att parameter response handler.
2, property type (UUID), no one has its own data representing, on behalf of the named UUID, such as temperature, transmit power, batteries, Bluetooth protocol official data for some commonly used types are classified as mandatory, such as 0x2a09 information indicating the battery, 0x2a6e information indicates the temperature, may be UUID 16bit, also be 128bit, the Bluetooth low energy, mainly 16bit.
3, the attribute value, the attribute value indicates valid information attribute types bearer.
4, property license, each property has its own access privileges, such as read, CAST, you can read but also write and so on.

四, GATT

gatt mainly to provide information specific implementation, which defines two BLE devices communicate and Characteristic of something called a Service. GATT is the use of ATT (Attribute Protocol) protocol, ATT agreement the Service, Characteristic corresponding data stored in a lookup table (database), the lookup table using the 16 bit ID as an index for each item. when

Metaphor: blood test the hospital's division of people can only detect the content of the various components of the blood, but they do not know how many of these patient's physical condition content expressed out, so we need to "physician" (GATT) magnificent debut.
Note: gatt is an exclusive nature, when ble peripheral is host connection, gatt broadcast will be stopped, know ble peripherals will continue to initiate broadcast after disconnection.

4.1 cs communication architecture

gatt is to use as the basis for communication between att bt device to the host, using cs architectural approach, the att bt equipment maintenance and server create lookup tables and character, so the bt cs set as a server-side, the host device as the client All requests, communications and time are initiated by the client.

Summary: a, gatt operation must gap and after a connection on a specific bt equipment
Basis, gatt is att
Third, the host side as a client of the whole process, bt device side as a server, bt device side is responsible for maintaining find att created table and server to communicate with the client.

Guess you like

Origin blog.csdn.net/madannasf/article/details/102571350