DeterministicESPAsyncWebServer v6.28.0
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
sep2.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 sep2.h
6 * @brief IEEE 2030.5 (Smart Energy Profile 2.0) resource codec (DETWS_ENABLE_SEP2).
7 *
8 * IEEE 2030.5 (SEP 2.0) is the RESTful smart-grid protocol: a device is a set of HTTP resources encoded
9 * as XML in the `urn:ieee:std:2030.5:ns` namespace. This builds the core resource documents into a
10 * caller buffer, so the web server is a 2030.5 server / client over the existing HTTP stack:
11 *
12 * - **DeviceCapability** - the root: hrefs to the function-set list resources the device offers.
13 * - **EndDevice** - a device registration (its sFDI/lFDI identity).
14 * - **DERControl** - a Distributed-Energy-Resource control event (interval + a target power factor /
15 * real-power setpoint), the payload that curtails or dispatches a DER.
16 *
17 * Pure text framing, zero heap, no stdlib, host-testable; values are XML-escaped where they can carry
18 * text. The EXI binary encoding + the resource discovery walk layer on top.
19 */
20
21#ifndef DETERMINISTICESPASYNCWEBSERVER_SEP2_H
22#define DETERMINISTICESPASYNCWEBSERVER_SEP2_H
23
24#include "ServerConfig.h"
25#include <stddef.h>
26#include <stdint.h>
27
28#if DETWS_ENABLE_SEP2
29
30/**
31 * @brief Build a DeviceCapability document with hrefs to the EndDeviceList and the DER-program list.
32 * @param poll_rate the recommended pollRate (seconds).
33 * @return length written, or 0 on overflow.
34 */
35size_t detws_sep2_device_capability(uint32_t poll_rate, const char *edev_list_href, const char *derp_list_href,
36 char *out, size_t cap);
37
38/**
39 * @brief Build an EndDevice document.
40 * @param sfdi the short-form device identifier (a 36-bit-ish decimal id).
41 * @param lfdi the long-form device identifier (hex string; borrowed).
42 * @param href the resource href (borrowed).
43 * @return length written, or 0 on overflow.
44 */
45size_t detws_sep2_end_device(uint64_t sfdi, const char *lfdi, const char *href, char *out, size_t cap);
46
47/**
48 * @brief Build a DERControl event document.
49 * @param mrid the message RID (hex string; borrowed).
50 * @param start interval start (epoch seconds).
51 * @param duration interval duration (seconds).
52 * @param opmod_target_w the real-power setpoint (opModFixedW), in watts (may be negative to absorb).
53 * @return length written, or 0 on overflow.
54 */
55size_t detws_sep2_der_control(const char *mrid, uint32_t start, uint32_t duration, int32_t opmod_target_w, char *out,
56 size_t cap);
57
58#endif // DETWS_ENABLE_SEP2
59#endif // DETERMINISTICESPASYNCWEBSERVER_SEP2_H
User-facing configuration for DeterministicESPAsyncWebServer.