Mistake on this page?
Report an issue in GitHub or email us
Public Types | Public Member Functions | Static Public Attributes
GattAttribute Class Reference

#include <GattAttribute.h>

Public Types

typedef ble::attribute_handle_t Handle_t
 
typedef ble::att_security_requirement_t Security_t
 

Public Member Functions

 GattAttribute (const UUID &uuid, uint8_t *valuePtr=NULL, uint16_t len=0, uint16_t maxLen=0, bool hasVariableLen=true)
 
Handle_t getHandle (void) const
 
const UUIDgetUUID (void) const
 
uint16_t getLength (void) const
 
uint16_t getMaxLength (void) const
 
uint16_t * getLengthPtr (void)
 
void setHandle (Handle_t id)
 
uint8_t * getValuePtr (void)
 
bool hasVariableLength (void) const
 
void allowRead (bool allow_read)
 
bool isReadAllowed (void) const
 
void setReadSecurityRequirement (Security_t requirement)
 
Security_t getReadSecurityRequirement () const
 
void allowWrite (bool allow_write)
 
bool isWriteAllowed (void) const
 
void setWriteSecurityRequirement (Security_t requirement)
 
Security_t getWriteSecurityRequirement () const
 

Static Public Attributes

static const Handle_t INVALID_HANDLE = 0x0000
 

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.

Member Typedef Documentation

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.

Constructor & Destructor Documentation

GattAttribute::GattAttribute ( const UUID uuid,
uint8_t *  valuePtr = NULL,
uint16_t  len = 0,
uint16_t  maxLen = 0,
bool  hasVariableLen = true 
)
inline

Construct an attribute.

Application code uses attributes to model characteristic descriptors and characteristics values.

Parameters
[in]uuidThe type of the attribute.
[in]valuePtrPointer 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]lenThe length in bytes of this attribute's value.
[in]maxLenThe length in bytes of the memory buffer containing the attribute value. It must be greater than or equal to len.
[in]hasVariableLenFlag 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 };
0x2A19, // attribute type
attribute_value,
2, // length of the current value
sizeof(attribute_value), // length of the buffer containing the value
true // variable length
);
Note
By default, read and write operations are allowed and does not require any security.

Member Function Documentation

void GattAttribute::allowRead ( bool  allow_read)
inline

Allow or disallow read operation from a client.

Parameters
allow_readRead is allowed if true.
void GattAttribute::allowWrite ( bool  allow_write)
inline

Allow or disallow write operation from a client.

Parameters
allow_writeWrite is allowed if true.
Handle_t GattAttribute::getHandle ( void  ) const
inline

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.
uint16_t GattAttribute::getLength ( void  ) const
inline

Get the current length of the attribute value.

Returns
The current length of the attribute value.
uint16_t* GattAttribute::getLengthPtr ( void  )
inline

Get a pointer to the current length of the attribute value.

Attention
note Do not use this function.
Returns
A pointer to the current length of the attribute value.
uint16_t GattAttribute::getMaxLength ( void  ) const
inline

Get the maximum length of the attribute value.

The maximum length of the attribute value.

Security_t GattAttribute::getReadSecurityRequirement ( ) const
inline

Return the security level required by read operations.

Returns
The security level of the read operations.
const UUID& GattAttribute::getUUID ( void  ) const
inline

Get the UUID of the attribute.

The UUID identifies the type of the attribute.

Returns
The attribute.
uint8_t* GattAttribute::getValuePtr ( void  )
inline

Get a pointer to the attribute value.

Returns
A pointer to the attribute value.
Security_t GattAttribute::getWriteSecurityRequirement ( ) const
inline

Return the security level required by write operations.

Returns
The security level of the write operations.
bool GattAttribute::hasVariableLength ( void  ) const
inline

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.
bool GattAttribute::isReadAllowed ( void  ) const
inline

Indicate if a client is allowed to read the attribute.

Returns
true if a client is allowed to read the attribute.
bool GattAttribute::isWriteAllowed ( void  ) const
inline

Indicate if a client is allowed to write the attribute.

Returns
true if a client is allowed to write the attribute.
void GattAttribute::setHandle ( Handle_t  id)
inline

Set the attribute handle.

Attention
The GattServer uses this function internally. Application code must not use it.
Parameters
[in]idThe new attribute handle.
void GattAttribute::setReadSecurityRequirement ( Security_t  requirement)
inline

Set the security requirements of the read operations.

Parameters
requirementThe security level required by the read operations.
void GattAttribute::setWriteSecurityRequirement ( Security_t  requirement)
inline

Set the security requirements of the write operations.

Parameters
requirementThe security level required by the write operations.

Field Documentation

const Handle_t GattAttribute::INVALID_HANDLE = 0x0000
static

Invalid attribute handle.


The documentation for this class was generated from the following file:
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.