27 #include "ble/common/blecommon.h" 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;
185 if (baseIndex == LENGTH_OF_LONG_UUID) {
188 const uint8_t sig[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
189 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB };
220 UUID(ShortUUIDBytes_t _shortUUID) :
223 shortUUID(_shortUUID) {
234 shortUUID = source.shortUUID;
235 memcpy(baseUUID, source.baseUUID, LENGTH_OF_LONG_UUID);
272 std::reverse_copy(longUUID, longUUID + LENGTH_OF_LONG_UUID, baseUUID);
274 std::copy(longUUID, longUUID + LENGTH_OF_LONG_UUID, baseUUID);
276 shortUUID = (uint16_t)((baseUUID[13] << 8) | (baseUUID[12]));
300 return (
const uint8_t*)&shortUUID;
327 sizeof(ShortUUIDBytes_t) :
328 LENGTH_OF_LONG_UUID);
341 (this->shortUUID == other.shortUUID)) {
346 (memcmp(this->baseUUID, other.baseUUID, LENGTH_OF_LONG_UUID) == 0)) {
362 return !(*
this == other);
374 LongUUIDBytes_t baseUUID;
379 ShortUUIDBytes_t shortUUID;
387 #endif // ifndef MBED_UUID_H__ uint8_t getLen() const
Get the length (in bytes) of the internal UUID representation.
ByteOrder_t
Enumeration of byte ordering.
const uint8_t * getBaseUUID() const
Get a pointer to the UUID value based on the current UUID type.
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(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).
static const unsigned MAX_UUID_STRING_LENGTH
Maximum length for the string representation of a UUID excluding the null terminator.
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.
ShortUUIDBytes_t getShortUUID() const
Get the uint16_t value of the UUID.
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.
UUID()
Default constructor.
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.
UUID & operator=(const UUID &source)=default
UUID copy assignment.
bool operator!=(const UUID &other) const
Not equal to operator.
16-bit wide UUID representation.
UUID_Type_t shortOrLong() const
Return the internal type of the UUID.
128-bit wide UUID representation.