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=NULL, uint16_t len=0, uint16_t maxLen=0, bool hasVariableLen=true) | |
Construct an attribute. More... | |
Handle_t | getHandle (void) const |
Get the attribute's handle in the ATT table. More... | |
const UUID & | getUUID (void) const |
Get the UUID of the attribute. More... | |
uint16_t | getLength (void) const |
Get the current length of the attribute value. More... | |
uint16_t | getMaxLength (void) const |
Get the maximum length of the attribute value. More... | |
uint16_t * | getLengthPtr (void) |
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 (void) |
Get a pointer to the attribute value. More... | |
bool | hasVariableLength (void) 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 (void) 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 (void) 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 58 of file 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 67 of file GattAttribute.h.
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.
[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 112 of file 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 226 of file 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 262 of file GattAttribute.h.
Handle_t getHandle | ( | void | ) | const |
Get the attribute's handle in the ATT table.
Definition at line 139 of file GattAttribute.h.
uint16_t getLength | ( | void | ) | const |
Get the current length of the attribute value.
Definition at line 161 of file GattAttribute.h.
uint16_t* getLengthPtr | ( | void | ) |
Get a pointer to the current length of the attribute value.
Definition at line 183 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 171 of file GattAttribute.h.
Security_t getReadSecurityRequirement | ( | ) | const |
Return the security level required by read operations.
Definition at line 253 of file GattAttribute.h.
const UUID& getUUID | ( | void | ) | const |
Get the UUID of the attribute.
The UUID identifies the type of the attribute.
Definition at line 151 of file GattAttribute.h.
uint8_t* getValuePtr | ( | void | ) |
Get a pointer to the attribute value.
Definition at line 206 of file GattAttribute.h.
Security_t getWriteSecurityRequirement | ( | ) | const |
Return the security level required by write operations.
Definition at line 289 of file GattAttribute.h.
bool hasVariableLength | ( | void | ) | const |
Check whether the length of the attribute's value can change throughout time.
Definition at line 217 of file GattAttribute.h.
bool isReadAllowed | ( | void | ) | const |
Indicate if a client is allowed to read the attribute.
Definition at line 235 of file GattAttribute.h.
bool isWriteAllowed | ( | void | ) | const |
Indicate if a client is allowed to write the attribute.
Definition at line 271 of file GattAttribute.h.
void setHandle | ( | Handle_t | id | ) |
Set the attribute handle.
[in] | id | The new attribute handle. |
Definition at line 196 of file 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 244 of file 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 280 of file GattAttribute.h.
|
static |
Invalid attribute handle.
Definition at line 72 of file GattAttribute.h.