DeterministicESPAsyncWebServer v6.28.0
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
utmc.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 utmc.h
6 * @brief UTMC (Urban Traffic Management and Control) common-database codec (DETWS_ENABLE_UTMC).
7 *
8 * UTMC is the UK/EU modular framework for sharing traffic data across heterogeneous municipal systems.
9 * Its common-database exchange is an HTTP + XML message set: a client requests the value of an object
10 * (a detector, a sign, a signal) by its UTMC object id, and the server replies with the object's value
11 * + a data-quality flag + a timestamp. This builds the two documents over the existing HTTP stack:
12 *
13 * - **request**: `<UTMCRequest><object id="..."/></UTMCRequest>`.
14 * - **response**: `<UTMCResponse><object id=".." value=".." quality=".." timestamp=".."/></UTMCResponse>`.
15 *
16 * Values are XML-escaped. Pure text framing, zero heap, no stdlib, host-testable; the HTTP transport is
17 * the shipped server.
18 */
19
20#ifndef DETERMINISTICESPASYNCWEBSERVER_UTMC_H
21#define DETERMINISTICESPASYNCWEBSERVER_UTMC_H
22
23#include "ServerConfig.h"
24#include <stddef.h>
25#include <stdint.h>
26
27#if DETWS_ENABLE_UTMC
28
29/** @brief UTMC data-quality flags. */
30// UTMC value-quality codes: wire values compared, so integer constants in a namespacing struct.
31struct Utmc
32{
33 static constexpr uint8_t UTMC_QUALITY_GOOD = 0; ///< the value is good.
34 static constexpr uint8_t UTMC_QUALITY_SUSPECT = 1; ///< the value is suspect.
35 static constexpr uint8_t UTMC_QUALITY_ABSENT = 2; ///< no value available.
36};
37
38/**
39 * @brief Build a UTMC request document for one object id. @return length written, or 0 on overflow.
40 */
41size_t detws_utmc_request(const char *object_id, char *out, size_t cap);
42
43/**
44 * @brief Build a UTMC response document for one object.
45 * @param object_id the UTMC object id (escaped).
46 * @param value the object value text (escaped).
47 * @param quality a UTMC_QUALITY_* flag.
48 * @param timestamp an ISO-8601 timestamp (escaped).
49 * @return length written, or 0 on overflow.
50 */
51size_t detws_utmc_response(const char *object_id, const char *value, uint8_t quality, const char *timestamp, char *out,
52 size_t cap);
53
54/**
55 * @brief Extract the object id from a UTMC request document into @p out.
56 * @return the id length, or 0 if no `<object id="..."/>` is found.
57 */
58size_t detws_utmc_parse_request(const char *xml, size_t len, char *out, size_t cap);
59
60#endif // DETWS_ENABLE_UTMC
61#endif // DETERMINISTICESPASYNCWEBSERVER_UTMC_H
User-facing configuration for DeterministicESPAsyncWebServer.