SensESP 2.7.2
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
uuid.cpp
Go to the documentation of this file.
1#include "uuid.h"
2
3namespace sensesp {
4
6 // implementation copied from https://github.com/protohaus/ESP_UUID
7 // to avoid additional external dependencies.
10
11 // Generate 16 random bytes. On ESP32, these are actually random if the
12 // radio is enabled.
13 for (int i = 0; i < 16; i += 4) {
15 memcpy(&buffer_[i], &random, 4);
16 }
17
18 uuid_str.reserve(36 + 1); // Include NULL / terminator byte
19
20 for (int i = 0; i < 16; i++) {
21 if (i == 4 || i == 6 || i == 8 || i == 10) {
22 uuid_str += "-";
23 }
24 uuid_str += String(buffer_[i] >> 4, HEX);
25 uuid_str += String(buffer_[i] & 0x0F, HEX);
26 }
27 return uuid_str;
28}
29
30} // namespace sensesp
Construct a new transform based on a single function.
String generate_uuid4()
Generate a random UUIDv4 string.
Definition uuid.cpp:5