Generic Attribute Profile (GATT) is built on top of the Attribute Protocol (ATT) and establishes common operations and a framework for the data transported and stored by the Attribute Protocol. GATT defines two roles: Server and Client. The GATT roles are not
necessarily tied to specific GAP roles and may be specified by higher layer profiles. GATT and ATT are not transport specific and can be used in both BR/EDR and LE. However, GATT and ATT are mandatory to implement in LE since it is used for discovering services.
The GATT server stores the data transported over the Attribute Protocol and accepts Attribute Protocol requests, commands and confirmations from the GATT client. The GATT server sends responses to requests and when configured, sends indication and notifications
asynchronously to the GATT client when specified events occur on the GATT server. GATT also specifies the format of data contained on the GATT server.
Attributes, as transported by the Attribute Protocol, are formatted as services and characteristics. Services may contain a collection of characteristics. Characteristics contain a single value and any number of descriptors describing the characteristic value.
With the defined structure of services, characteristics and characteristic descriptors a GATT client that is not specific to a profile can still traverse the GATT server and display characteristic values to the user. The characteristic descriptors can be used
to display descriptions of the characteristic values that may make the value understandable by the user.
GATT-based Profile Hierarchy
The GATT Profile specifies the structure in which profile data is exchanged. This structure defines basic elements such as services and characteristics, used in a profile. The top level of the hierarchy is a profile. A profile is composed of one
or more services necessary to fulfill a use case. A service is composed of characteristics or references to other services. Each characteristic contains a value and may contain optional information about the value. The service and characteristic and the components
of the characteristic (i.e., value and descriptors) contain the profile data and are all stored in attributes on the server.
GATT profile hierarchy
A service is a collection of data and associated behaviors to accomplish a particular function or feature of a device or portions of a device. A service may reference other primary or secondary services and/or a set of characteristics that make
up the service.
There are two types of services: primary and secondary. A primary service provides the primary functionality of a device. A secondary service provides auxiliary functionality of a device and is referenced from at least one primary service on the device.
To maintain backward compatibility with earlier clients, later revisions of a service definition can only add new referenced services or optional characteristics. Later revisions of a service definition are also forbidden from changing behaviors
from previous revision of the service definition. Services may be used in one or more profiles to fulfill a particular use case.
A referenced service is a method incorporating another service definition on the server as part of the service referencing it. When a service references another service, the entire referenced service becomes part of the new service including any
nested referenced services and characteristics. The referenced service still exists as an independent service. There are no limits to the depth of nested references.
A characteristic is a value used in a service along with properties and configuration information about how the value is accessed and information about how the value is displayed or represented. A characteristic definition contains a characteristic
declaration, characteristic properties, and a value. It may also contain descriptors that describe the value or permit configuration of the server with respect to the characteristic value.