27#include "ble/common/blecommon.h"
44static uint8_t char2int(
char c)
46 if ((c >=
'0') && (c <=
'9')) {
48 }
else if ((c >=
'a') && (c <=
'f')) {
50 }
else if ((c >=
'A') && (c <=
'F')) {
156 size_t baseIndex = 0;
164 if (stringUUID[index] ==
'\0') {
167 }
else if (stringUUID[index] ==
'-') {
172 byte |= char2int(stringUUID[index]);
176 tempUUID[baseIndex++] = byte;
179 byte = char2int(stringUUID[index]) << 4;
188 const uint8_t sig[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
189 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB };
223 shortUUID(_shortUUID) {
234 shortUUID = source.shortUUID;
276 shortUUID = (uint16_t)((baseUUID[13] << 8) | (baseUUID[12]));
300 return (
const uint8_t*)&shortUUID;
341 (this->shortUUID == other.shortUUID)) {
362 return !(*
this == other);
Representation of a Universally Unique Identifier (UUID).
bool operator==(const UUID &other) const
Equal to operator between UUIDs.
uint8_t getLen() const
Get the length (in bytes) of the internal UUID representation.
static const unsigned LENGTH_OF_LONG_UUID
Length in bytes of a long UUID.
uint16_t ShortUUIDBytes_t
Type for a 16-bit UUID.
const uint8_t * getBaseUUID() const
Get a pointer to the UUID value based on the current UUID type.
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.
ShortUUIDBytes_t getShortUUID() const
Get the uint16_t value of the UUID.
UUID(const char *stringUUID)
Construct a 128-bit UUID from a string.
UUID_Type_t shortOrLong() const
Return the internal type of the UUID.
void setupLong(const LongUUIDBytes_t longUUID, ByteOrder_t order=UUID::MSB)
Replace existing value with a 128-bit UUID.
UUID & operator=(const UUID &source)=default
UUID copy assignment.
static const unsigned MAX_UUID_STRING_LENGTH
Maximum length for the string representation of a UUID excluding the null terminator.
UUID(const UUID &source)
UUID copy constructor.
uint8_t LongUUIDBytes_t[LENGTH_OF_LONG_UUID]
Type for a 128-bit UUID.
ByteOrder_t
Enumeration of byte ordering.
@ MSB
Most significant byte first (at the smallest address).
@ LSB
Least significant byte first (at the smallest address).
bool operator!=(const UUID &other) const
Not equal to operator.
UUID_Type_t
Enumeration of the types of UUIDs.
@ UUID_TYPE_LONG
128-bit wide UUID representation.
@ UUID_TYPE_SHORT
16-bit wide UUID representation.
UUID()
Default constructor.
@ BLE_UUID_UNKNOWN
Reserved UUID.