Files | |
file | gatt_database.h |
file | gatt_db_app_interface.h |
Data Structures | |
struct | gattDbAttribute_t |
Macros | |
#define | gGattDbInvalidHandleIndex_d |
#define | gGattDbInvalidHandle_d |
Functions | |
uint16_t | GattDb_GetIndexOfHandle (uint16_t handle) |
bleResult_t | GattDb_Init () |
bleResult_t | GattDb_WriteAttribute (uint16_t handle, uint16_t valueLength, uint8_t *aValue) |
bleResult_t | GattDb_ReadAttribute (uint16_t handle, uint16_t maxBytes, uint8_t *aOutValue, uint16_t *pOutValueLength) |
bleResult_t | GattDb_FindServiceHandle (uint16_t startHandle, bleUuidType_t serviceUuidType, bleUuid_t *pServiceUuid, uint16_t *pOutServiceHandle) |
bleResult_t | GattDb_FindCharValueHandleInService (uint16_t serviceHandle, bleUuidType_t characteristicUuidType, bleUuid_t *pCharacteristicUuid, uint16_t *pOutCharValueHandle) |
bleResult_t | GattDb_FindCccdHandleForCharValueHandle (uint16_t charValueHandle, uint16_t *pOutCccdHandle) |
bleResult_t | GattDb_FindDescriptorHandleForCharValueHandle (uint16_t charValueHandle, bleUuidType_t descriptorUuidType, bleUuid_t *pDescriptorUuid, uint16_t *pOutDescriptorHandle) |
Variables | |
uint16_t | gGattDbAttributeCount_c |
gattDbAttribute_t * | gattDatabase |
struct gattDbAttribute_t |
Attribute structure.
Data Fields | ||
---|---|---|
uint16_t | handle |
The attribute handle - cannot be 0x0000. The attribute handles need not be consecutive, but must be strictly increasing. |
uint16_t | permissions | Attribute permissions as defined by the ATT. |
uint32_t | uuid | The UUID should be read according to the gattDbAttribute_t.uuidType member: for 2-byte and 4-byte UUIDs, this contains the value of the UUID; for 16-byte UUIDs, this is a pointer to the allocated 16-byte array containing the UUID. |
uint8_t * | pValue | A pointer to allocated value array. |
uint16_t | valueLength | The size of the value array. |
uint16_t | uuidType: 2 | Identifies the length of the UUID; values interpreted according to the bleUuidType_t enumeration. |
uint16_t | maxVariableValueLength: 10 | The maximum length of the attribute value array; if this is set to 0, then the attribute's length is fixed and cannot be changed. |
#define gGattDbInvalidHandleIndex_d |
Special value returned by GattDb_GetIndexOfHandle to signal that an invalid attribute handle was given as parameter.
#define gGattDbInvalidHandle_d |
Special value used to mark an invalid attribute handle.
Attribute handles are strictly positive.
Bit fields for Characteristic properties.
Bit fields for attribute permissions.
enum gattDbAccessType_t |
Attribute access type.
uint16_t GattDb_GetIndexOfHandle | ( | uint16_t | handle | ) |
Returns the database index for a given attribute handle.
[in] | handle | The attribute handle. |
bleResult_t GattDb_Init | ( | ) |
Initializes the GATT database at runtime.
bleResult_t GattDb_WriteAttribute | ( | uint16_t | handle, |
uint16_t | valueLength, | ||
uint8_t * | aValue | ||
) |
Writes an attribute from the application level.
This function can be called by the application code to modify an attribute in the database. It should only be used by the application to modify a Characteristic's value based on the application logic (e.g., external sensor readings).
[in] | handle | The handle of the attribute to be written. |
[in] | valueLength | The number of bytes to be written. |
[in] | aValue | The source buffer containing the value to be written. |
bleResult_t GattDb_ReadAttribute | ( | uint16_t | handle, |
uint16_t | maxBytes, | ||
uint8_t * | aOutValue, | ||
uint16_t * | pOutValueLength | ||
) |
Reads an attribute from the application level.
This function can be called by the application code to read an attribute in the database.
[in] | handle | The handle of the attribute to be read. |
[in] | maxBytes | The maximum number of bytes to be received. |
[out] | aOutValue | The pre-allocated buffer ready to receive the bytes. |
[out] | pOutValueLength | The actual number of bytes received. |
bleResult_t GattDb_FindServiceHandle | ( | uint16_t | startHandle, |
bleUuidType_t | serviceUuidType, | ||
bleUuid_t * | pServiceUuid, | ||
uint16_t * | pOutServiceHandle | ||
) |
Finds the handle of a Service Declaration with a given UUID inside the database.
[in] | startHandle | The handle to start the search. Should be 0x0001 on the first call. |
[in] | serviceUuidType | Service UUID type. |
[in] | pServiceUuid | Service UUID. |
[out] | pOutServiceHandle | Pointer to the service declaration handle to be written. |
gBleSuccess_c | Service Declaration found, handle written in pOutCharValueHandle. |
gGattDbInvalidHandle_c | Invalid Start Handle. |
gGattDbServiceNotFound_c | Service with given UUID not found. |
bleResult_t GattDb_FindCharValueHandleInService | ( | uint16_t | serviceHandle, |
bleUuidType_t | characteristicUuidType, | ||
bleUuid_t * | pCharacteristicUuid, | ||
uint16_t * | pOutCharValueHandle | ||
) |
Finds the handle of a Characteristic Value with a given UUID inside a Service.
The Service is input by its declaration handle.
[in] | serviceHandle | The handle of the Service declaration. |
[in] | characteristicUuidType | Characteristic UUID type. |
[in] | pCharacteristicUuid | Characteristic UUID. |
[out] | pOutCharValueHandle | Pointer to the characteristic value handle to be written. |
gBleSuccess_c | Characteristic Value found, handle written in pOutCharValueHandle. |
gGattDbInvalidHandle_c | Handle not found or not a Service declaration. |
gGattDbCharacteristicNotFound_c | Characteristic Value with given UUID not found. |
bleResult_t GattDb_FindCccdHandleForCharValueHandle | ( | uint16_t | charValueHandle, |
uint16_t * | pOutCccdHandle | ||
) |
Finds the handle of a Characteristic's CCCD given the Characteristic's Value handle.
[in] | charValueHandle | The handle of the Service declaration. |
[out] | pOutCccdHandle | Pointer to the CCCD handle to be written. |
gBleSuccess_c | CCCD found, handle written in pOutCccdHandle. |
gGattDbInvalidHandle_c | Invalid Characteristic Value handle. |
gGattDbCccdNotFound_c | CCCD not found for this Characteristic. |
bleResult_t GattDb_FindDescriptorHandleForCharValueHandle | ( | uint16_t | charValueHandle, |
bleUuidType_t | descriptorUuidType, | ||
bleUuid_t * | pDescriptorUuid, | ||
uint16_t * | pOutDescriptorHandle | ||
) |
Finds the handle of a Characteristic Descriptor given the Characteristic's Value handle and Descriptor's UUID.
[in] | charValueHandle | The handle of the Service declaration. |
[in] | descriptorUuidType | Descriptor's UUID type. |
[in] | pDescriptorUuid | Descriptor's UUID. |
[out] | pOutDescriptorHandle | Pointer to the Descriptor handle to be written. |
gBleSuccess_c | Descriptor found, handle written in pOutDescriptorHandle. |
gGattDbInvalidHandle_c | Invalid Characteristic Value handle. |
gGattDbDescriptorNotFound_c | Descriptor not found for this Characteristic. |
uint16_t gGattDbAttributeCount_c |
The number of attributes in the GATT Database.
gattDbAttribute_t* gattDatabase |
Reference to the GATT database.