Hardware Reference
In-Depth Information
Services
GATT services group conceptually related attributes in one common section of the
attribute information set in the GATT server. The specification refers to all the attributes
within a single service as the service definition . Therefore, a GATT server's attributes
are in fact a succession of service definitions, each one starting with a single attribute
that marks the beginning of a service (aptly named a service declaration .) This attribute's
type and value format is strictly specified in GATT, as shown in Table 4-2 .
Table 4-2. Service Declaration attribute
Handle
Type
Permissions
Value
Value length
UUID primary service or UUID secondary service
Read Only
Service UUID
2, 4, or 16 bytes
0xNNNN
In the declaration shown in Table 4-2 , UUID primary service ( 0x2800 ) and UUID secondary service
( 0x2801 ) refer to standard, SIG-assigned UUIDs that are used as the exclusive type to
introduce a service. They are naturally 16-bit UUIDs (because they are fundamental
ones defined by the specfication).
The difference between primary and secondary services is important to note. A primary
service is the standard type of GATT service that includes relevant, standard function‐
ality exposed by the GATT server. A secondary service , on the other hand, is intended
to be included only in other primary services and makes sense only as its modifier,
having no real meaning on its own. In practice, secondary services are rarely used.
The value of the service declaration attribute itself contains a UUID (as mentioned in
“Value” on page 55 , the value of an attribute can be any data type), this time corre‐
sponding to the UUID of the actual service that this declaration introduces.
Although the service declaration must always be the first attribute of the service, many
others can follow it before the next service declaration, usually in the form of charac‐
teristics and descriptors.
Conceptually, you could think of a GATT service as a class in any modern object-
oriented language, complete with instantiation, because a service can be instantiated
multiple times within a single GATT server (however, this is not a common occurrence
and most services would therefore be akin to singletons).
Inside a service definition (that is to say, inside a service), you can add one or more
references to another services, using include definitions . Include definitions consist of
a single attribute (the include declaration ) that contains all the details required for the
client to reference the included service.
Included services can help avoid duplicating data in a GATT server. If a service will be
referenced by other services, you can use this mechanism to save memory and simplify
the layout of the GATT server. In the previous analogy with classes and objects, you
could see include definitions as pointers or references to an existing object instance.
 
Search WWH ::




Custom Search