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

Representation of a Universally Unique Identifier (UUID). More...

#include <UUID.h>

Public Types

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

Public Member Functions

 UUID (const char *stringUUID)
 Construct a 128-bit UUID from a string. More...
 
 UUID (const LongUUIDBytes_t longUUID, ByteOrder_t order=UUID::MSB)
 Construct a new UUID from a 128-bit representation. More...
 
 UUID (ShortUUIDBytes_t _shortUUID)
 Creates a new 16-bit UUID. More...
 
 UUID (const UUID &source)
 UUID copy constructor. More...
 
 UUID (void)
 Default constructor. More...
 
void setupLong (const LongUUIDBytes_t longUUID, ByteOrder_t order=UUID::MSB)
 Replace existing value with a 128-bit UUID. More...
 
UUID_Type_t shortOrLong (void) const
 Return the internal type of the UUID. More...
 
const uint8_t * getBaseUUID (void) const
 Get a pointer to the UUID value based on the current UUID type. More...
 
ShortUUIDBytes_t getShortUUID (void) const
 Get the uint16_t value of the UUID. More...
 
uint8_t getLen (void) const
 Get the length (in bytes) of the internal UUID representation. More...
 
bool operator== (const UUID &other) const
 Equal to operator between UUIDs. More...
 
bool operator!= (const UUID &other) const
 Not equal to operator. More...
 

Static Public Attributes

static const unsigned LENGTH_OF_LONG_UUID = 16
 Length in bytes of a long UUID. More...
 
static const unsigned MAX_UUID_STRING_LENGTH = LENGTH_OF_LONG_UUID * 2 + 4
 Maximum length for the string representation of a UUID excluding the null terminator. More...
 

Detailed Description

Representation of a Universally Unique Identifier (UUID).

UUIDs are 128-bit wide numbers used to identify data type and elements in many layers of the Bluetooth specification.

Two representations of UUIDS exist:

This class acts as an adapter over these two kinds of UUIDs to allow indiscriminate use of both forms in Mbed BLE APIs.

Note
32-bit UUID representation is not supported currently.

Definition at line 74 of file UUID.h.

Member Typedef Documentation

typedef uint8_t LongUUIDBytes_t[LENGTH_OF_LONG_UUID]

Type for a 128-bit UUID.

Definition at line 122 of file UUID.h.

typedef uint16_t ShortUUIDBytes_t

Type for a 16-bit UUID.

Definition at line 112 of file UUID.h.

Member Enumeration Documentation

Enumeration of byte ordering.

It is used to construct 128-byte UUIDs.

Enumerator
MSB 

Most significant byte first (at the smallest address).

LSB 

Least significant byte first (at the smallest address).

Definition at line 97 of file UUID.h.

Enumeration of the types of UUIDs.

Enumerator
UUID_TYPE_SHORT 

16-bit wide UUID representation.

UUID_TYPE_LONG 

128-bit wide UUID representation.

Definition at line 80 of file UUID.h.

Constructor & Destructor Documentation

UUID ( const char *  stringUUID)

Construct a 128-bit UUID from a string.

Parameters
[in]stringUUIDHuman readable representation of the UUID following the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.
Note
Upper and lower case are supported.
Hyphens are optional. The string must include at most four hyphens.
Internally, the UUID is stored in the little endian order as a 16-byte array.

Definition at line 147 of file UUID.h.

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

Construct a new UUID from a 128-bit representation.

Parameters
[in]longUUIDThe 128-bit (16-byte) of the UUID value.
[in]orderBytes order of longUUID.

Definition at line 198 of file UUID.h.

UUID ( ShortUUIDBytes_t  _shortUUID)

Creates a new 16-bit UUID.

The Bluetooth standard body defines 16-bit wide UUIDs. They are the shortened version of the UUID 0000xxxx-0000-1000-8000-00805F9B34FB, where xxxx is the value of the 16-bit UUID.

Attention
16-bit UUIDs are not used in user defined data type or user defined element ID.
Parameters
[in]_shortUUID16-bit part of the standard UUID. The short UUID value.
Note
User defined UUIDs are commonly named vendor-specific UUIDs across the Bluetooth literature.

Definition at line 218 of file UUID.h.

UUID ( const UUID source)

UUID copy constructor.

Parameters
[in]sourceThe UUID to copy.

Definition at line 229 of file UUID.h.

UUID ( void  )

Default constructor.

Construct an invalid UUID.

Postcondition
shortOrLong() returns the value UUID_TYPE_SHORT.
getShortUUID() returns the value BLE_UUID_UNKNOWN.

Definition at line 244 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 an uint16_t object if the UUID is 16 bits long.
A pointer to an array of 16 bytes if the UUID is 128 bits long.

Definition at line 288 of file UUID.h.

uint8_t getLen ( void  ) const

Get the length (in bytes) of the internal UUID representation.

Returns
sizeof(ShortUUIDBytes_t) if the UUID type is UUID_TYPE_SHORT.
LENGTH_OF_LONG_UUID if the UUID type is UUID_TYPE_LONG.

Definition at line 315 of file UUID.h.

ShortUUIDBytes_t getShortUUID ( void  ) const

Get the uint16_t value of the UUID.

Attention
This function is not used on long UUIDs.
Returns
The value of the shortened UUID.

Definition at line 304 of file UUID.h.

bool operator!= ( const UUID other) const

Not equal to operator.

Parameters
[in]otherThe UUID compared to this.
Returns
true if both UUIDs are not equal and false otherwise.

Definition at line 351 of file UUID.h.

bool operator== ( const UUID other) const

Equal to operator between UUIDs.

Parameters
[in]otherThe UUID to compare to this.
Returns
true if both UUIDs are equal and false otherwise.

Definition at line 329 of file UUID.h.

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

Replace existing value with a 128-bit UUID.

Parameters
[in]longUUIDNew 16-byte wide UUID value.
[in]orderByte ordering of longUUID.

Definition at line 255 of file UUID.h.

UUID_Type_t shortOrLong ( void  ) const

Return the internal type of the UUID.

Returns
UUID_TYPE_SHORT if the UUID is 16-bit wide.
UUID_TYPE_LONG if the UUID is 128-bit wide.

Definition at line 277 of file UUID.h.

Field Documentation

const unsigned LENGTH_OF_LONG_UUID = 16
static

Length in bytes of a long UUID.

Definition at line 117 of file UUID.h.

const unsigned MAX_UUID_STRING_LENGTH = LENGTH_OF_LONG_UUID * 2 + 4
static

Maximum length for the string representation of a UUID excluding the null terminator.

The string is composed of two characters per byte plus four '-' characters.

Definition at line 131 of file UUID.h.

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.