25 #include "blecommon.h" 44 if ((c >=
'0') && (c <=
'9')) {
46 }
else if ((c >=
'a') && (c <=
'f')) {
48 }
else if ((c >=
'A') && (c <=
'F')) {
154 size_t baseIndex = 0;
162 if (stringUUID[index] ==
'\0') {
165 }
else if (stringUUID[index] ==
'-') {
170 byte |=
char2int(stringUUID[index]);
174 tempUUID[baseIndex++] = byte;
177 byte =
char2int(stringUUID[index]) << 4;
183 if (baseIndex == LENGTH_OF_LONG_UUID) {
186 const uint8_t sig[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
187 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB };
218 UUID(ShortUUIDBytes_t _shortUUID) :
221 shortUUID(_shortUUID) {
232 shortUUID = source.shortUUID;
233 memcpy(baseUUID, source.baseUUID, LENGTH_OF_LONG_UUID);
263 std::reverse_copy(longUUID, longUUID + LENGTH_OF_LONG_UUID, baseUUID);
265 std::copy(longUUID, longUUID + LENGTH_OF_LONG_UUID, baseUUID);
267 shortUUID = (uint16_t)((baseUUID[13] << 8) | (baseUUID[12]));
291 return (
const uint8_t*)&shortUUID;
318 sizeof(ShortUUIDBytes_t) :
319 LENGTH_OF_LONG_UUID);
332 (this->shortUUID == other.shortUUID)) {
337 (memcmp(this->baseUUID, other.baseUUID, LENGTH_OF_LONG_UUID) == 0)) {
353 return !(*
this == other);
365 LongUUIDBytes_t baseUUID;
370 ShortUUIDBytes_t shortUUID;
378 #endif // ifndef MBED_UUID_H__ ByteOrder_t
Enumeration of byte ordering.
UUID(ShortUUIDBytes_t _shortUUID)
Creates a new 16-bit UUID.
static const unsigned LENGTH_OF_LONG_UUID
Length in bytes of a long UUID.
Least significant byte first (at the smallest address).
UUID(const UUID &source)
UUID copy constructor.
UUID_Type_t shortOrLong(void) const
Return the internal type of the UUID.
UUID(const char *stringUUID)
Construct a 128-bit UUID from a string.
UUID_Type_t
Enumeration of the types of UUIDs.
Most significant byte first (at the smallest address).
ShortUUIDBytes_t getShortUUID(void) const
Get the uint16_t value of the UUID.
static const unsigned MAX_UUID_STRING_LENGTH
Maximum length for the string representation of a UUID excluding the null terminator.
UUID(void)
Default constructor.
uint8_t LongUUIDBytes_t[LENGTH_OF_LONG_UUID]
Type for a 128-bit UUID.
bool operator==(const UUID &other) const
Equal to operator between UUIDs.
Representation of a Universally Unique Identifier (UUID).
UUID(const LongUUIDBytes_t longUUID, ByteOrder_t order=UUID::MSB)
Construct a new UUID from a 128-bit representation.
uint16_t ShortUUIDBytes_t
Type for a 16-bit UUID.
static uint8_t char2int(char c)
Convert a character containing an hexadecimal digit into an unsigned integer.
void setupLong(const LongUUIDBytes_t longUUID, ByteOrder_t order=UUID::MSB)
Replace existing value with a 128-bit UUID.
uint8_t getLen(void) const
Get the length (in bytes) of the internal UUID representation.
bool operator!=(const UUID &other) const
Not equal to operator.
const uint8_t * getBaseUUID(void) const
Get a pointer to the UUID value based on the current UUID type.
16-bit wide UUID representation.
128-bit wide UUID representation.