Telink TLSR8232 BLE SDK Developer Handbook
AN-19112700-E1
93
Ver.1.0.0
1) T
he “attNum” can be used to indicate the number of valid Attributes in current
Attribute Table, i.e. the maximum Attribute Handle value. This number is only used in
the invalid Attribute item 0 of Attribute Table array.
{49,0,0,0,0,0},//ATT_END_H
– 1 = 49 in “5316_ble_remote”
“attNum = 49” indicates there are 49 valid Attributes in current Attribute Table.
In BLE, Attribute Handle value starts from 0x0001 with increment step of 1, while the
array index starts from 0. When this virtual Attribute is added to the Attribute Table,
each Attribute index equals its Attribute Handle value. After the Attribute Table is
defined, Attribute Handle value of an Attribute can be obtained by counting its index
in current Attribute Table array.
The final index is the number of valid Attributes (i.e. attNum) in current Attribute
Table. In current SDK, the attNum is set as 49; if user adds or deletes any Attribute,
the attNum needs to be modified correspondingly.
2) T
he “attNum” can also be used to specify Attributes constituting current Service.
The UUID of the first Attribute for each Service must be
“GATT_UUID_PRIMARY_SERVICE (0x2800)”; the first Attribute of a Service sets
“attNum” and it indicates following “attNum” Attributes constitute current Service.
As shown in
, for the gap service, the Attribute with UUID of
“GATT_UUID_PRIMARY_SERVICE” sets the “attNum” as 7, it indicates the seven
Attributes from Attribute Handle 1 to Attribute Handle 7 constitute the gap service.
Similarly, for the HID service
, the “attNum” of the first Attribute is set as 27, and it
indicates the following 27 Attributes constitute the HID service.
Except for Attribute item 0 and the first Attribute of each Service, attNum values of all
Attributes must be set as 0.
3.4.2.2 perm
The “perm” is short for “permission” and it serves to specify access permission of current
Attribute by Client.
The “perm” of each Attribute is configurable as one or combination of following values.
#define
ATT_PERMISSIONS_READ 0x01
#define
ATT_PERMISSIONS_WRITE 0x02
#define
ATT_PERMISSIONS_AUTHEN_READ 0x04
#define
ATT_PERMISSIONS_AUTHEN_WRITE 0x08
#define
ATT_PERMISSIONS_AUTHOR_READ 0x10
#define
ATT_PERMISSIONS_AUTHOR_WRITE 0x20
#define
ATT_PERMISSIONS_ENCRYPT_READ 0x40
#define
ATT_PERMISSIONS_ENCRYPT_WRITE 0x80