adaptation for book and plug demo

Dependents:   BookAndPlug

Fork of BLE_API by Bluetooth Low Energy

Embed: (wiki syntax)

« Back to documentation index

GattAttribute Class Reference

Instances of this class encapsulate the data that belongs to a Bluetooth Low Energy attribute. More...

#include <GattAttribute.h>

Public Types

typedef uint16_t Handle_t
 Type for the handle or ID of the attribute in the ATT table.

Public Member Functions

 GattAttribute (const UUID &uuid, uint8_t *valuePtr=NULL, uint16_t len=0, uint16_t maxLen=0, bool hasVariableLen=true)
 Creates a new GattAttribute using the specified UUID, value length, and inital value.
Handle_t getHandle (void) const
 Get the attribute's handle in the ATT table.
const UUIDgetUUID (void) const
 The UUID of the characteristic that this attribute belongs to.
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 over time.

Static Public Attributes

static const Handle_t INVALID_HANDLE = 0x0000
 Define the value of an invalid attribute handle.

Detailed Description

Instances of this class encapsulate the data that belongs to a Bluetooth Low Energy attribute.

Definition at line 26 of file GattAttribute.h.


Member Typedef Documentation

typedef uint16_t Handle_t

Type for the handle or ID of the attribute in the ATT table.

These are unique and are usually generated by the underlying BLE stack.

Definition at line 32 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 
)

Creates a new GattAttribute using the specified UUID, value length, and inital value.

Parameters:
[in]uuidThe UUID to use for this attribute.
[in]valuePtrThe memory holding the initial value.
[in]lenThe length in bytes of this attribute's value.
[in]maxLenThe max length in bytes of this attribute's value.
[in]hasVariableLenWhether the attribute's value length changes overtime.

EXAMPLE

  // UUID = 0x2A19, Min length 2, Max len = 2
  GattAttribute attr = GattAttribute(0x2A19, &someValue, 2, 2);

Definition at line 63 of file GattAttribute.h.


Member Function Documentation

Handle_t getHandle ( void   ) const

Get the attribute's handle in the ATT table.

Returns:
The attribute's handle.

Definition at line 74 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 92 of file GattAttribute.h.

uint16_t* getLengthPtr ( void   )

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

Returns:
A pointer to the current length of the attribute value.

Definition at line 110 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 101 of file GattAttribute.h.

const UUID& getUUID ( void   ) const

The UUID of the characteristic that this attribute belongs to.

Returns:
The characteristic's UUID.

Definition at line 83 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 129 of file GattAttribute.h.

bool hasVariableLength ( void   ) const

Check whether the length of the attribute's value can change over time.

Returns:
true if the attribute has variable length, false otherwise.

Definition at line 138 of file GattAttribute.h.

void setHandle ( Handle_t  id )

Set the attribute handle.

Parameters:
[in]idThe new attribute handle.

Definition at line 120 of file GattAttribute.h.


Field Documentation

const Handle_t INVALID_HANDLE = 0x0000 [static]

Define the value of an invalid attribute handle.

Definition at line 36 of file GattAttribute.h.