Rtos API example
GattAttribute Class Reference
[Server]
Representation of a GattServer attribute. More...
#include <GattAttribute.h>
Public Types | |
typedef ble::attribute_handle_t | Handle_t |
Representation of an attribute handle. | |
Public Member Functions | |
GattAttribute (const UUID &uuid, uint8_t *valuePtr=NULL, uint16_t len=0, uint16_t maxLen=0, bool hasVariableLen=true) | |
Construct an attribute. | |
Handle_t | getHandle (void) const |
Get the attribute's handle in the ATT table. | |
const UUID & | getUUID (void) const |
Get the UUID of the attribute. | |
uint16_t | getLength (void) const |
Get the current length of the attribute value. | |
uint16_t | getMaxLength (void) const |
Get the maximum length of the attribute value. | |
uint16_t * | getLengthPtr (void) |
Get a pointer to the current length of the attribute value. | |
void | setHandle (Handle_t id) |
Set the attribute handle. | |
uint8_t * | getValuePtr (void) |
Get a pointer to the attribute value. | |
bool | hasVariableLength (void) const |
Check whether the length of the attribute's value can change throughout time. | |
Static Public Attributes | |
static const Handle_t | INVALID_HANDLE = 0x0000 |
Invalid attribute handle. |
Detailed Description
Representation of a GattServer attribute.
Attributes are the building block of GATT servers: services are attributes, characteristics are groups of attributes and characteristic descriptors are attributes, too.
- Typed values
Attributes are typed values composed of a type and its associated value. The attribute type identifies the attribute purpose. A UUID read by the client during the discovery of the GATT server models the attribute type. The value of the attribute is an array of bytes; its length may be fixed or variable.
As an example, a primary service is declared by an attribute with the type 0x2800, and the value of the attribute is the UUID of the service.
- Attribute Access
The GATT server is an array of attributes in which a unique index identifies each of the attributes within the array. That index is called the attribute handle, and clients use it to access to attributes within the server.
- Note:
- Attributes do not contain information related to their permissions, grouping or semantic. Higher level specifications define these concepts.
Definition at line 58 of file GattAttribute.h.
Member Typedef Documentation
typedef ble::attribute_handle_t Handle_t |
Representation of an attribute handle.
Each attribute in a GattServer has a unique handle that clients can use to identify the attribute. The underlying BLE stack usually generates and assigns handles to attributes.
Definition at line 67 of file GattAttribute.h.
Constructor & Destructor Documentation
GattAttribute | ( | const UUID & | uuid, |
uint8_t * | valuePtr = NULL , |
||
uint16_t | len = 0 , |
||
uint16_t | maxLen = 0 , |
||
bool | hasVariableLen = true |
||
) |
Construct an attribute.
Application code uses attributes to model characteristic descriptors and characteristics values.
- Parameters:
-
[in] uuid The type of the attribute. [in] valuePtr Pointer to the memory buffer, which contains the initial value of the attribute. The constructor does not make a copy of the attribute buffer; as a consequence, the memory buffer must remain valid during the lifetime of the attribute. [in] len The length in bytes of this attribute's value. [in] maxLen The length in bytes of the memory buffer containing the attribute value. It must be greater than or equal to len
.[in] hasVariableLen Flag that indicates whether the attribute's value length can change throughout time.
- Example
// declare a value of 2 bytes within a 10 bytes buffer const uint8_t attribute_value[10] = { 10, 50 }; GattAttribute attr = GattAttribute( 0x2A19, // attribute type attribute_value, 2, // length of the current value sizeof(attribute_value), // length of the buffer containing the value true // variable length );
Definition at line 106 of file GattAttribute.h.
Member Function Documentation
Handle_t getHandle | ( | void | ) | const |
Get the attribute's handle in the ATT table.
- Note:
- The GattServer sets the attribute's handle when services are inserted.
- Returns:
- The attribute's handle.
Definition at line 129 of file GattAttribute.h.
uint16_t getLength | ( | void | ) | const |
Get the current length of the attribute value.
- Returns:
- The current length of the attribute value.
Definition at line 151 of file GattAttribute.h.
uint16_t* getLengthPtr | ( | void | ) |
Get a pointer to the current length of the attribute value.
note Do not use this function.
- Returns:
- A pointer to the current length of the attribute value.
Definition at line 173 of file GattAttribute.h.
uint16_t getMaxLength | ( | void | ) | const |
Get the maximum length of the attribute value.
The maximum length of the attribute value.
Definition at line 161 of file GattAttribute.h.
const UUID& getUUID | ( | void | ) | const |
Get the UUID of the attribute.
The UUID identifies the type of the attribute.
- Returns:
- The attribute.
Definition at line 141 of file GattAttribute.h.
uint8_t* getValuePtr | ( | void | ) |
Get a pointer to the attribute value.
- Returns:
- A pointer to the attribute value.
Definition at line 196 of file GattAttribute.h.
bool hasVariableLength | ( | void | ) | const |
Check whether the length of the attribute's value can change throughout time.
- Returns:
- true if the attribute value has a variable length and false otherwise.
Definition at line 207 of file GattAttribute.h.
void setHandle | ( | Handle_t | id ) |
Set the attribute handle.
The GattServer uses this function internally. Application code must not use it.
- Parameters:
-
[in] id The new attribute handle.
Definition at line 186 of file GattAttribute.h.
Field Documentation
const Handle_t INVALID_HANDLE = 0x0000 [static] |
Invalid attribute handle.
Definition at line 72 of file GattAttribute.h.
Generated on Sun Jul 17 2022 08:25:40 by 1.7.2