安卓蓝牙技术之GATT(Generic Attribute Profile)

通过BLE连接,读写属性类小数据的Profile通用规范。现在所有的BLE应用Profile都是基于GATT的。

Designed for use by the application or a profile, so that an attribute client can communicate with attribute server

为应用程序或配置而设计,使属性客户端可以和属性服务端通讯。

GATT defines: 通用属性配置的定义

Procedures for using the attribute protocol (ATT) to discover, read, write, and obtain indications of these attributes

程序使用ATT进行搜索、读写和获取属性指明。

The grouping and relationship of characteristics within a service or profile

在服务或配置中的分组和关系特征

Procedures for configuring the broadcast of attributes

程序配置广播属性

A profile is composed of one or more servicesnecessary to fulfill a use-case 

一个配置由一个或更多服务组成!

A service may contain certain attributes called characteristic values, which are values used by a service (example: in a temperature sensor, the attribute containing the temperature itself is the characteristic value)

一个服务包含特定的属性称为”特征值“,这些值被服务所用。例如:在一个温度传感器中,属性包含温度本身就是特征值。

A characteristic value must have a mandatory characteristic declarationattribute immediately before the value, containing the properties of the characteristic

一个特征值有受托者”特征声明“属性...包含的属性特征

Characteristics may also contain optional descriptorattributes, with fields such as a configuration or a description

特征值可能包含可选的”描述符“属性,”描述符“属性包含配置字段或描述字段。

安卓蓝牙技术之GATT(Generic Attribute Profile)

当两个BLE设备处于连接状态,GATT客户端设备可以执行很多不同子程序去和GATT服务端设备通讯

Discover Characteristic by UUID search the GATT server for all attributes with type that matches the specified UUID 通过UUID搜索特征

Read Characteristic Value read the value of the characteristic at the specified handle 读取特征值

Write Characteristic Value write a new value to the characteristic at the specified handle 写特征值

 

A GATT server device, when configured to do so, can send out messages to the GATT client device without being prompted:

GATT服务端设备,当这样配置,可以发送消息给GATT客户端设备,没有提示

Notification The value a characteristic is sent from the server to the client without receiving a read request, and does not need to be acknowledged

通知——特征值从服务端发送到客户端,没有接收到读请求,以及不需要“承认”      

Indication The value a characteristic is sent from the server to the client without receiving a read request, but must be acknowledged before any further data can be sent

指示——特征值从服务端发送到客户端,没有接收到读请求,但在之后的数据被发送之前必须“承认”。

 

总结:GATT包含若干个Profile,一个Profile包含若干个Services,一个Service包含若干个Characteristics,一个Characteristic包含Properties字段和若干个Descriptor(可选)

GATT调用下层的ATTATTattirbuteGATT中表现为Characteristic