Representation of a GattServer attribute. More...
#include <GattAttribute.h>
Public Types | |
typedef ble::attribute_handle_t | Handle_t |
Representation of an attribute handle. More... | |
Public Member Functions | |
GattAttribute (const UUID &uuid, uint8_t *valuePtr=nullptr, uint16_t len=0, uint16_t maxLen=0, bool hasVariableLen=true) | |
Construct an attribute. More... | |
Handle_t | getHandle () const |
Get the attribute's handle in the ATT table. More... | |
const UUID & | getUUID () const |
Get the UUID of the attribute. More... | |
uint16_t | getLength () const |
Get the current length of the attribute value. More... | |
uint16_t | getMaxLength () const |
Get the maximum length of the attribute value. More... | |
uint16_t * | getLengthPtr () |
Get a pointer to the current length of the attribute value. More... | |
void | setHandle (Handle_t id) |
Set the attribute handle. More... | |
uint8_t * | getValuePtr () |
Get a pointer to the attribute value. More... | |
bool | hasVariableLength () const |
Check whether the length of the attribute's value can change throughout time. More... | |
void | allowRead (bool allow_read) |
Allow or disallow read operation from a client. More... | |
bool | isReadAllowed () const |
Indicate if a client is allowed to read the attribute. More... | |
void | setReadSecurityRequirement (Security_t requirement) |
Set the security requirements of the read operations. More... | |
Security_t | getReadSecurityRequirement () const |
Return the security level required by read operations. More... | |
void | allowWrite (bool allow_write) |
Allow or disallow write operation from a client. More... | |
bool | isWriteAllowed () const |
Indicate if a client is allowed to write the attribute. More... | |
void | setWriteSecurityRequirement (Security_t requirement) |
Set the security requirements of the write operations. More... | |
Security_t | getWriteSecurityRequirement () const |
Return the security level required by write operations. More... | |
Static Public Attributes | |
static const Handle_t | INVALID_HANDLE = 0x0000 |
Invalid attribute handle. More... | |
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.
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.
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.
Definition at line 60 of file gatt/GattAttribute.h.
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 69 of file gatt/GattAttribute.h.
GattAttribute | ( | const UUID & | uuid, |
uint8_t * | valuePtr = nullptr , |
||
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.
[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. |
Definition at line 114 of file gatt/GattAttribute.h.
void allowRead | ( | bool | allow_read | ) |
Allow or disallow read operation from a client.
allow_read | Read is allowed if true. |
Definition at line 231 of file gatt/GattAttribute.h.
void allowWrite | ( | bool | allow_write | ) |
Allow or disallow write operation from a client.
allow_write | Write is allowed if true. |
Definition at line 267 of file gatt/GattAttribute.h.
Handle_t getHandle | ( | ) | const |
Get the attribute's handle in the ATT table.
Definition at line 144 of file gatt/GattAttribute.h.
uint16_t getLength | ( | ) | const |
Get the current length of the attribute value.
Definition at line 166 of file gatt/GattAttribute.h.
uint16_t* getLengthPtr | ( | ) |
Get a pointer to the current length of the attribute value.
Definition at line 188 of file gatt/GattAttribute.h.
uint16_t getMaxLength | ( | ) | const |
Get the maximum length of the attribute value.
The maximum length of the attribute value.
Definition at line 176 of file gatt/GattAttribute.h.
Security_t getReadSecurityRequirement | ( | ) | const |
Return the security level required by read operations.
Definition at line 258 of file gatt/GattAttribute.h.
const UUID& getUUID | ( | ) | const |
Get the UUID of the attribute.
The UUID identifies the type of the attribute.
Definition at line 156 of file gatt/GattAttribute.h.
uint8_t* getValuePtr | ( | ) |
Get a pointer to the attribute value.
Definition at line 211 of file gatt/GattAttribute.h.
Security_t getWriteSecurityRequirement | ( | ) | const |
Return the security level required by write operations.
Definition at line 294 of file gatt/GattAttribute.h.
bool hasVariableLength | ( | ) | const |
Check whether the length of the attribute's value can change throughout time.
Definition at line 222 of file gatt/GattAttribute.h.
bool isReadAllowed | ( | ) | const |
Indicate if a client is allowed to read the attribute.
Definition at line 240 of file gatt/GattAttribute.h.
bool isWriteAllowed | ( | ) | const |
Indicate if a client is allowed to write the attribute.
Definition at line 276 of file gatt/GattAttribute.h.
void setHandle | ( | Handle_t | id | ) |
Set the attribute handle.
[in] | id | The new attribute handle. |
Definition at line 201 of file gatt/GattAttribute.h.
void setReadSecurityRequirement | ( | Security_t | requirement | ) |
Set the security requirements of the read operations.
requirement | The security level required by the read operations. |
Definition at line 249 of file gatt/GattAttribute.h.
void setWriteSecurityRequirement | ( | Security_t | requirement | ) |
Set the security requirements of the write operations.
requirement | The security level required by the write operations. |
Definition at line 285 of file gatt/GattAttribute.h.
|
static |
Invalid attribute handle.
Definition at line 74 of file gatt/GattAttribute.h.