DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
device_id.h
Go to the documentation of this file.
1// Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4/**
5 * @file device_id.h
6 * @brief Stable device UUID derived from the chip MAC (DETWS_ENABLE_DEVICE_ID).
7 *
8 * detws_uuid_from_mac() computes a deterministic RFC 4122 version-5 UUID from a
9 * 6-byte MAC: namespace = the RFC 4122 DNS namespace, name = the lowercase MAC
10 * hex, hashed with the library's SHA-1. The same MAC always yields the same
11 * UUID, so it is a stable device identity (mDNS hostname, MQTT client ID, ...)
12 * that needs no storage. detws_device_uuid() reads the ESP32 factory MAC and
13 * formats it (ESP32 only). Pure, host-testable core; no heap.
14 *
15 * @author Douglas Quigg (dstroy0)
16 * @date 2026
17 */
18
19#ifndef DETERMINISTICESPASYNCWEBSERVER_DEVICE_ID_H
20#define DETERMINISTICESPASYNCWEBSERVER_DEVICE_ID_H
21
22#include "ServerConfig.h"
23#include <stdint.h>
24
25#if DETWS_ENABLE_DEVICE_ID
26
27/** @brief Length of a formatted UUID string including the null terminator. */
28#define DETWS_UUID_STR_LEN 37
29
30/**
31 * @brief Format a deterministic RFC 4122 v5 UUID from a 6-byte MAC.
32 *
33 * @param mac six MAC bytes.
34 * @param out buffer of at least DETWS_UUID_STR_LEN bytes; receives
35 * "xxxxxxxx-xxxx-5xxx-yxxx-xxxxxxxxxxxx" (lowercase, null-terminated).
36 */
37void detws_uuid_from_mac(const uint8_t mac[6], char out[DETWS_UUID_STR_LEN]);
38
39#ifdef ARDUINO
40/**
41 * @brief Format this device's UUID from its ESP32 factory (WiFi STA) MAC.
42 * @param out buffer of at least DETWS_UUID_STR_LEN bytes.
43 */
44void detws_device_uuid(char out[DETWS_UUID_STR_LEN]);
45#endif
46
47#endif // DETWS_ENABLE_DEVICE_ID
48#endif // DETERMINISTICESPASYNCWEBSERVER_DEVICE_ID_H
User-facing configuration for DeterministicESPAsyncWebServer.