ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
sep2.h
Go to the documentation of this file.
1// ProtoCore v1.0.16 - 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 (PROTOCORE_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 PROTOCORE_SEP2_H
22#define PROTOCORE_SEP2_H
23
24#include "protocore_config.h" // the entry point: protocore_types.h for the widths
25
26#if PROTOCORE_ENABLE_SEP2
27
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 protocore_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 protocore_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 protocore_sep2_der_control(const char *mrid, uint32_t start, uint32_t duration, int32_t opmod_target_w,
56 char *out, size_t cap);
57
59
60#endif // PROTOCORE_ENABLE_SEP2
61
62#endif // PROTOCORE_SEP2_H
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
Definition types.h:96
#define PROTOCORE_END_DECLS
Definition types.h:97