High level Bluetooth Low Energy API and radio abstraction layer

Dependents:   BLE_ANCS_SDAPI BLE_temperature BLE_HeartRate BLE_ANCS_SDAPI_IRC ... more

Embed: (wiki syntax)

« Back to documentation index

UUID Class Reference

An instance of this class represents a Universally Unique Identifier (UUID) in the BLE API. More...

#include <UUID.h>

Public Types

enum  UUID_Type_t { UUID_TYPE_SHORT = 0, UUID_TYPE_LONG = 1 }
 

Enumeration of the possible types of UUIDs in BLE with regards to length.

More...
enum  ByteOrder_t { MSB, LSB }
 

Enumeration to specify byte ordering of the long version of the UUID.

More...
typedef uint16_t ShortUUIDBytes_t
 Type for a 16-bit UUID.
typedef uint8_t LongUUIDBytes_t [LENGTH_OF_LONG_UUID]
 Type for a 128-bit UUID.

Public Member Functions

 UUID (const char *stringUUID)
 Creates a new 128-bit UUID.
 UUID (const LongUUIDBytes_t longUUID, ByteOrder_t order=UUID::MSB)
 Creates a new 128-bit UUID.
 UUID (ShortUUIDBytes_t _shortUUID)
 Creates a new 16-bit UUID.
 UUID (const UUID &source)
 Copy constructor.
 UUID (void)
 The empty constructor.
void setupLong (const LongUUIDBytes_t longUUID, ByteOrder_t order=UUID::MSB)
 Fill in a 128-bit UUID; this is useful when the UUID is not known at the time of the object construction.
UUID_Type_t shortOrLong (void) const
 Check whether this UUID is short or long.
const uint8_t * getBaseUUID (void) const
 Get a pointer to the UUID value based on the current UUID type.
ShortUUIDBytes_t getShortUUID (void) const
 Get the short UUID.
uint8_t getLen (void) const
 Get the length (in bytes) of the UUID based on its type.
bool operator== (const UUID &other) const
 Overload == operator to enable UUID comparisons.
bool operator!= (const UUID &other) const
 Overload != operator to enable UUID comparisons.

Static Public Attributes

static const unsigned LENGTH_OF_LONG_UUID = 16
 Length of a long UUID in bytes.
static const unsigned MAX_UUID_STRING_LENGTH = LENGTH_OF_LONG_UUID * 2 + 4
 Maximum length of a string representation of a UUID not including the null termination ('\0'): two characters per byte plus four '-' characters.

Detailed Description

An instance of this class represents a Universally Unique Identifier (UUID) in the BLE API.

Definition at line 50 of file UUID.h.


Member Typedef Documentation

Type for a 128-bit UUID.

Definition at line 80 of file UUID.h.

typedef uint16_t ShortUUIDBytes_t

Type for a 16-bit UUID.

Definition at line 71 of file UUID.h.


Member Enumeration Documentation

Enumeration to specify byte ordering of the long version of the UUID.

Enumerator:
MSB 

Most-significant byte first (at the smallest address)

LSB 

least-significant byte first (at the smallest address)

Definition at line 63 of file UUID.h.

Enumeration of the possible types of UUIDs in BLE with regards to length.

Enumerator:
UUID_TYPE_SHORT 

Short 16-bit UUID.

UUID_TYPE_LONG 

Full 128-bit UUID.

Definition at line 55 of file UUID.h.


Constructor & Destructor Documentation

UUID ( const char *  stringUUID )

Creates a new 128-bit UUID.

Note:
The UUID is a unique 128-bit (16 byte) ID used to identify different service or characteristics on the BLE device.
Parameters:
stringUUIDThe 128-bit (16-byte) UUID as a human readable const-string. Format: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX Upper and lower case supported. Hyphens are optional, but only upto four of them. The UUID is stored internally as a 16 byte array, LSB (little endian), which is opposite from the string.

Definition at line 104 of file UUID.h.

UUID ( const LongUUIDBytes_t  longUUID,
ByteOrder_t  order = UUID::MSB 
)

Creates a new 128-bit UUID.

Parameters:
[in]longUUIDThe 128-bit (16-byte) UUID value.
[in]orderThe bit order of the UUID, MSB by default.
Note:
The UUID is a unique 128-bit (16 byte) ID used to identify different service or characteristics on the BLE device.

Definition at line 156 of file UUID.h.

UUID ( ShortUUIDBytes_t  _shortUUID )

Creates a new 16-bit UUID.

For efficiency, and because 16 bytes would take a large chunk of the 27-byte data payload length of the Link Layer, the BLE specification adds two additional UUID formats: 16-bit and 32-bit UUIDs. These shortened formats can be used only with UUIDs that are defined in the Bluetooth specification (listed by the Bluetooth SIG as standard Bluetooth UUIDs).

To reconstruct the full 128-bit UUID from the shortened version, insert the 16-bit short value (indicated by xxxx, including leading zeros) into the Bluetooth Base UUID:

0000xxxx-0000-1000-8000-00805F9B34FB

Parameters:
[in]_shortUUIDThe short UUID value.
Note:
Shortening is not available for UUIDs that are not derived from the Bluetooth Base UUID. Such non-standard UUIDs are commonly called vendor-specific UUIDs. In these cases, you’ll need to use the full 128-bit UUID value at all times.
The UUID is a unique 16-bit (2 byte) ID used to identify different service or characteristics on the BLE device.
We do not yet support 32-bit shortened UUIDs.

Definition at line 189 of file UUID.h.

UUID ( const UUID source )

Copy constructor.

Parameters:
[in]sourceThe UUID to copy.

Definition at line 199 of file UUID.h.

UUID ( void   )

The empty constructor.

Note:
The type of the resulting UUID instance is UUID_TYPE_SHORT and the value BLE_UUID_UNKNOWN.

Definition at line 211 of file UUID.h.


Member Function Documentation

const uint8_t* getBaseUUID ( void   ) const

Get a pointer to the UUID value based on the current UUID type.

Returns:
A pointer to the short UUID if the type is set to UUID_TYPE_SHORT. Otherwise, a pointer to the long UUID if the type is set to UUID_TYPE_LONG.

Definition at line 255 of file UUID.h.

uint8_t getLen ( void   ) const

Get the length (in bytes) of the UUID based on its type.

Return values:
sizeof(ShortUUIDBytes_t)if the UUID type is UUID_TYPE_SHORT.
LENGTH_OF_LONG_UUIDif the UUID type is UUID_TYPE_LONG.

Definition at line 278 of file UUID.h.

ShortUUIDBytes_t getShortUUID ( void   ) const

Get the short UUID.

Returns:
The short UUID.

Definition at line 268 of file UUID.h.

bool operator!= ( const UUID other ) const

Overload != operator to enable UUID comparisons.

Parameters:
[in]otherThe other UUID in the comparison.
Returns:
true if this != other, false otherwise.

Definition at line 312 of file UUID.h.

bool operator== ( const UUID other ) const

Overload == operator to enable UUID comparisons.

Parameters:
[in]otherThe other UUID in the comparison.
Returns:
true if this == other, false otherwise.

Definition at line 290 of file UUID.h.

void setupLong ( const LongUUIDBytes_t  longUUID,
ByteOrder_t  order = UUID::MSB 
)

Fill in a 128-bit UUID; this is useful when the UUID is not known at the time of the object construction.

Parameters:
[in]longUUIDThe UUID value to copy.
[in]orderThe byte ordering of the UUID at longUUID.

Definition at line 224 of file UUID.h.

UUID_Type_t shortOrLong ( void   ) const

Check whether this UUID is short or long.

Returns:
UUID_TYPE_SHORT if the UUID is short, UUID_TYPE_LONG otherwise.

Definition at line 244 of file UUID.h.


Field Documentation

const unsigned LENGTH_OF_LONG_UUID = 16 [static]

Length of a long UUID in bytes.

Definition at line 76 of file UUID.h.

const unsigned MAX_UUID_STRING_LENGTH = LENGTH_OF_LONG_UUID * 2 + 4 [static]

Maximum length of a string representation of a UUID not including the null termination ('\0'): two characters per byte plus four '-' characters.

Definition at line 87 of file UUID.h.