PebbleOS
Loading...
Searching...
No Matches
Data Structures | Macros | Functions

128-bit universally unique identifiers. More...

Data Structures

struct  Uuid
 A 128-bit UUID, with its bytes in the order they are written in string form. More...
 

Macros

#define UUID_SIZE   16
 Size of a UUID, in bytes.
 
#define UUID_SYSTEM   {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
 Initializer of the all-zero UUID that identifies the system.
 
#define UUID_INVALID_INIT    {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
 Initializer of the all-ones invalid UUID.
 
#define UUID_INVALID   ((const Uuid)UUID_INVALID_INIT)
 The invalid UUID, all bytes 0xff.
 
#define UuidMake(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15)    ((Uuid){p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15})
 Make a Uuid object from sixteen bytes.
 
#define UuidMakeFromBEBytes(b)
 Creates a Uuid from an array of bytes with 16 bytes in Big Endian order.
 
#define UuidMakeFromLEBytes(b)
 Creates a Uuid from an array of bytes with 16 bytes in Little Endian order.
 
#define UUID_STRING_BUFFER_LENGTH   (32 + 4 + 2 + 1)
 The minimum required length of a string used to hold a uuid (including null).
 

Functions

bool uuid_equal (const Uuid *uu1, const Uuid *uu2)
 Compares two UUIDs.
 
void uuid_generate (Uuid *uuid_out)
 Generate a random (version 4) UUID.
 
bool uuid_is_system (const Uuid *uuid)
 Check whether a UUID is the system UUID (all zeros).
 
bool uuid_is_invalid (const Uuid *uuid)
 Check whether a UUID is invalid.
 
void uuid_to_string (const Uuid *uuid, char *buffer)
 Writes UUID in a string form into buffer that looks like the following... {12345678-1234-5678-1234-567812345678} or {NULL UUID} if NULL was passed.
 

Detailed Description

128-bit universally unique identifiers.

Uuid, its constructors, uuid_equal() and uuid_to_string() are also part of the app SDK.

Uuid uuid;
uuid_to_string(&uuid, str);
A 128-bit UUID, with its bytes in the order they are written in string form.
Definition uuid.h:32
void uuid_generate(Uuid *uuid_out)
Generate a random (version 4) UUID.
#define UUID_STRING_BUFFER_LENGTH
The minimum required length of a string used to hold a uuid (including null).
Definition uuid.h:139
void uuid_to_string(const Uuid *uuid, char *buffer)
Writes UUID in a string form into buffer that looks like the following... {12345678-1234-5678-1234-56...

Data Structure Documentation

◆ Uuid

struct Uuid

A 128-bit UUID, with its bytes in the order they are written in string form.

Data Fields
uint8_t byte0 Byte 0.
uint8_t byte1 Byte 1.
uint8_t byte10 Byte 10.
uint8_t byte11 Byte 11.
uint8_t byte12 Byte 12.
uint8_t byte13 Byte 13.
uint8_t byte14 Byte 14.
uint8_t byte15 Byte 15.
uint8_t byte2 Byte 2.
uint8_t byte3 Byte 3.
uint8_t byte4 Byte 4.
uint8_t byte5 Byte 5.
uint8_t byte6 Byte 6.
uint8_t byte7 Byte 7.
uint8_t byte8 Byte 8.
uint8_t byte9 Byte 9.

Macro Definition Documentation

◆ UUID_INVALID

#define UUID_INVALID   ((const Uuid)UUID_INVALID_INIT)

The invalid UUID, all bytes 0xff.

◆ UUID_INVALID_INIT

#define UUID_INVALID_INIT    {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}

Initializer of the all-ones invalid UUID.

◆ UUID_SIZE

#define UUID_SIZE   16

Size of a UUID, in bytes.

◆ UUID_STRING_BUFFER_LENGTH

#define UUID_STRING_BUFFER_LENGTH   (32 + 4 + 2 + 1)

The minimum required length of a string used to hold a uuid (including null).

◆ UUID_SYSTEM

#define UUID_SYSTEM   {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

Initializer of the all-zero UUID that identifies the system.

◆ UuidMake

#define UuidMake (   p0,
  p1,
  p2,
  p3,
  p4,
  p5,
  p6,
  p7,
  p8,
  p9,
  p10,
  p11,
  p12,
  p13,
  p14,
  p15 
)     ((Uuid){p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15})

Make a Uuid object from sixteen bytes.

Parameters
p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15Bytes, in string order.
Returns
A Uuid structure representing the bytes p0 to p15.

◆ UuidMakeFromBEBytes

#define UuidMakeFromBEBytes (   b)
Value:
((Uuid){ \
b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], b[8], b[9], b[10], b[11], b[12], b[13], b[14], \
b[15] \
})

Creates a Uuid from an array of bytes with 16 bytes in Big Endian order.

Parameters
bArray of 16 bytes.
Returns
The created Uuid

◆ UuidMakeFromLEBytes

#define UuidMakeFromLEBytes (   b)
Value:
((Uuid){ \
b[15], b[14], b[13], b[12], b[11], b[10], b[9], b[8], b[7], b[6], b[5], b[4], b[3], b[2], \
b[1], b[0] \
})

Creates a Uuid from an array of bytes with 16 bytes in Little Endian order.

Parameters
bArray of 16 bytes.
Returns
The created Uuid

Function Documentation

◆ uuid_equal()

bool uuid_equal ( const Uuid *  uu1,
const Uuid *  uu2 
)

Compares two UUIDs.

Parameters
uu1First UUID.
uu2Second UUID.
Returns
True if the two UUIDs are equal, false if they are not or either is NULL.

◆ uuid_generate()

void uuid_generate ( Uuid *  uuid_out)

Generate a random (version 4) UUID.

Uses pbl_rand32().

Parameters
[out]uuid_outGenerated UUID.

◆ uuid_is_invalid()

bool uuid_is_invalid ( const Uuid *  uuid)

Check whether a UUID is invalid.

Parameters
uuidUUID to test.
Returns
true if uuid is NULL or equals UUID_INVALID.

◆ uuid_is_system()

bool uuid_is_system ( const Uuid *  uuid)

Check whether a UUID is the system UUID (all zeros).

Parameters
uuidUUID to test.
Returns
true if uuid equals UUID_SYSTEM, false otherwise or for NULL.

◆ uuid_to_string()

void uuid_to_string ( const Uuid *  uuid,
char *  buffer 
)

Writes UUID in a string form into buffer that looks like the following... {12345678-1234-5678-1234-567812345678} or {NULL UUID} if NULL was passed.

Parameters
uuidThe Uuid to write into the buffer as human-readable string
[out]bufferMemory to write the string to. Must be at least UUID_STRING_BUFFER_LENGTH bytes long.