A generic structure used to create the GATT service.
Synopsis:
typedef struct {
char * service ;
uint16_t handle ;
bt_gatt_srv_att_type_t attrType ;
union {
struct {
uint16_t cnt ;
uint16_t startHandle ;
uint16_t numHandles ;
bt_gatt_srv_att_service_t type ;
uint8_t useSDP ;
} service ;
struct {
char service[39];
uint16_t incServiceHandle;
uint16_t endGroupHandle;
} include ;
struct {
bt_gatt_srv_att_properties_t properties ;
bt_gatt_srv_att_permissions_t permission ;
uint8_t encryptKeySize;
uint16_t valueHandle ;
} characteristic ;
struct {
bt_gatt_srv_att_permissions_t permission ;
uint8_t encryptKeySize;
} descriptor ;
} dcl ;
bt_gatt_srv_att_value_t valueType ;
union {
struct {
uint16_t valueLen ;
uint16_t maxValueLen ;
} dyn ;
struct {
uint16_t valueLen ;
uint8_t *value;
} sta ;
struct {
uint16_t valueLen;
uint16_t maxValueLen;
uint8_t *value;
} vol ;
} value ;
} bt_gatt_srv_attrvalue_t;
Data:
-
char service[39]
- The UUID is represented as a NULL-terminated string value. An example of the string representation for GATT services is 0x1435. The 128-bit
UUID is traditionally represented as 0xF0000000-0451-4000-B000-000000000000.
-
uint16_t handle
- The handle value for this attribute. This value should start at zero for the primary service and increment for each
attribute.
-
Characteristics use an extra handle for the valueHandle.
-
attrib_type_t attrType
- Attribute entry type stored in dcl.
-
union dcl
- Union of four structures containing details of the attribute.
-
service
-
The
service struct is used to hold data for a
GATT_SRV_ATTRIB_SERVICE entry type.
-
uint16_t cnt
- The total number of attributes in the service (including the
service).
-
uint16_t startHandle
- The desired starting handle for the given service. If set to zero then
the starting handle will be automatically assigned.
-
uint16_t numHandles
- The number of handles to allocate for this service.
-
attrib_service_type_t type
- The type of service.
-
uint8_t useSDP
- Set to 1 to include the service in SDP record for
classic links. This should be set only if the type of service is set to
GATT_SRV_ATTRIB_PRIMARY_SERVICE.
-
If a name is provided for the SDP record, it must be provided in the
value structure with the valueType
set to GATT_SRV_ATTRIB_VALUE_STATIC. The maximum size
of the name is 255 bytes.
-
include
-
The
include struct is used to hold data for a
GATT_SRV_ATTRIB_INCLUDE_SERVICE entry type.
-
char service[39]
- The UUID of the included service represented as a NULL-terminated string
value. An example of the string representation for GATT services is
0x1435. The 128-bit UUID is traditionally represented
as 0xF0000000-0451-4000-B000-000000000000.
-
uint16_t incServiceHandle
- The handle of the service to be included in the current service.
-
uint16_t endGroupHandle
- The handle of the last attribute of the included service.
-
characteristic
-
The
characteristic struct is used to hold data for a
GATT_SRV_ATTRIB_CHARACTERISTIC entry type.
-
attrib_properties_t properties
- Bitmask representing the properties of the characteristic.
-
attrib_permissions_t permission
- The permissions to access this characteristic.
-
uint8_t encryptKeySize
- Encryption key size for the attribute. Valid range is 7 to 16 bytes;
0 indicates no key is required.
-
uint16_t valueHandle
- The value handle of the data for the characteristic. This handle will be
passed in the callback if the data type for this attribute is
GATT_SRV_ATTRIB_DATA_DYNAMIC.
-
descriptor
-
The
descriptor struct is used to hold data for a
GATT_SRV_ATTRIB_DESCRIPTOR entry type.
-
attrib_permissions_t permission
- The permissions to access this descriptor.
-
uint8_t encryptKeySize
- Encryption key size for the attribute. Valid range is 7 to 16 bytes;
0 indicates no key is required.
-
attrib_value_type_t valueType
- The type of data stored in value. For GATT_SRV_ATTRIB_SERVICE types,
this is set to GATT_SRV_ATTRIB_DATA_NONE.
-
union value
- Union of three structures containing details of the dynamic, static, or volatile data
stored.
-
dyn
-
The
dyn struct is used to represent dynamic value when
dataType is set to
GATT_SRV_ATTRIB_DATA_DYNAMIC. Callbacks are invoked to
retrieve the data from the application on read or write operations.
-
uint16_t valueLen
- The current length of the value. This must be less than or equal to
maxValueLen.
-
uint16_t maxValueLen
- The maximum allowable size of the data to be retrieved.
-
sta
-
The
sta struct is used to represent the static value when
dataType is set to
GATT_SRV_ATTRIB_DATA_STATIC. This is the value that is
returned when read/write operations are performed.
-
uint16_t valueLen
- The size of the static value to be included.
-
uint8_t * value
- Pointer to the static value.
-
vol
-
The
vol struct is used to represent the volatile value when
dataType is set to
GATT_SRV_ATTRIB_DATA_VOLATILE. This is the initial value that
will be returned when a read operation is performed.
-
uint16_t valueLen
- The size of the volatile value to be included.
-
uint16_t maxValueLen
- The maximum allowable size of the data to be retrieved.
-
uint8_t *value
- Pointer to the volatile value.
Library:
libbtapi
Description: