Rtos API example

Embed: (wiki syntax)

« Back to documentation index

UUID Class Reference

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

#include <UUID.h>

Public Types

enum  UUID_Type_t { UUID_TYPE_SHORT = 0, UUID_TYPE_LONG = 1 }
 

Enumeration of the types of UUIDs.

More...
enum  ByteOrder_t { MSB, LSB }
 

Enumeration of byte ordering.

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)
 Construct a 128-bit UUID from a string.
 UUID (const LongUUIDBytes_t longUUID, ByteOrder_t order=UUID::MSB)
 Construct a new UUID from a 128-bit representation.
 UUID (ShortUUIDBytes_t _shortUUID)
 Creates a new 16-bit UUID.
 UUID (const UUID &source)
 UUID copy constructor.
 UUID (void)
 Default constructor.
void setupLong (const LongUUIDBytes_t longUUID, ByteOrder_t order=UUID::MSB)
 Replace existing value with a 128-bit UUID.
UUID_Type_t shortOrLong (void) const
 Return the internal type of the UUID.
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 uint16_t value of the UUID.
uint8_t getLen (void) const
 Get the length (in bytes) of the internal UUID representation.
bool operator== (const UUID &other) const
 Equal to operator between UUIDs.
bool operator!= (const UUID &other) const
 Not equal to operator.

Static Public Attributes

static const unsigned LENGTH_OF_LONG_UUID = 16
 Length in bytes of a long UUID.
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.

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:

  • 16-bit UUIDs: Shortened representation of the 128 bit UUID 0000xxxx-0000-1000-8000-00805F9B34FB where xxxx is the 16 bit UUID. Values of those UUIDs are defined by the Bluetooth body. The short representation saves bandwidth during protocol transactions.
  • 128-bit UUIDs: Complete representation of a UUID. They are commonly used for user defined UUID.

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 73 of file UUID.h.


Member Typedef Documentation

Type for a 128-bit UUID.

Definition at line 121 of file UUID.h.

typedef uint16_t ShortUUIDBytes_t

Type for a 16-bit UUID.

Definition at line 111 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 96 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 79 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 146 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 197 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.

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 217 of file UUID.h.

UUID ( const UUID source )

UUID copy constructor.

Parameters:
[in]sourceThe UUID to copy.

Definition at line 228 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 243 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 287 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 314 of file UUID.h.

ShortUUIDBytes_t getShortUUID ( void   ) const

Get the uint16_t value of the UUID.

This function is not used on long UUIDs.

Returns:
The value of the shortened UUID.

Definition at line 303 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 350 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 328 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 254 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 276 of file UUID.h.


Field Documentation

const unsigned LENGTH_OF_LONG_UUID = 16 [static]

Length in bytes of a long UUID.

Definition at line 116 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 130 of file UUID.h.