26#ifndef DETERMINISTICESPASYNCWEBSERVER_IEC60870_H
27#define DETERMINISTICESPASYNCWEBSERVER_IEC60870_H
31#if DETWS_ENABLE_IEC60870
36#define IEC_START_104 0x68u
37#define IEC_START_FIXED 0x10u
39#define IEC104_APCI_LEN 6u
42#define IEC104_STARTDT_ACT 0x07u
43#define IEC104_STARTDT_CON 0x0Bu
44#define IEC104_STOPDT_ACT 0x13u
45#define IEC104_STOPDT_CON 0x23u
46#define IEC104_TESTFR_ACT 0x43u
47#define IEC104_TESTFR_CON 0x83u
50#define IEC_TYPE_M_SP_NA_1 1
51#define IEC_TYPE_M_DP_NA_1 3
52#define IEC_TYPE_M_ME_NA_1 9
53#define IEC_TYPE_M_ME_NB_1 11
54#define IEC_TYPE_M_ME_NC_1 13
55#define IEC_TYPE_C_SC_NA_1 45
56#define IEC_TYPE_C_DC_NA_1 46
57#define IEC_TYPE_M_EI_NA_1 70
58#define IEC_TYPE_C_IC_NA_1 100
59#define IEC_TYPE_C_CS_NA_1 103
62#define IEC_COT_PERIODIC 1
63#define IEC_COT_SPONTANEOUS 3
64#define IEC_COT_REQUEST 5
65#define IEC_COT_ACTIVATION 6
66#define IEC_COT_ACT_CON 7
67#define IEC_COT_DEACTIVATION 8
68#define IEC_COT_ACT_TERM 10
69#define IEC_COT_INTERROGATED 20
72#define IEC_FC_RESET_LINK 0x00
73#define IEC_FC_TEST_LINK 0x02
74#define IEC_FC_USER_DATA_CONFIRM 0x03
75#define IEC_FC_USER_DATA_NOREPLY 0x04
76#define IEC_FC_REQUEST_CLASS1 0x0A
77#define IEC_FC_REQUEST_CLASS2 0x0B
80enum class Iec104Format : uint8_t
108 uint16_t common_addr;
114size_t iec104_build_i(uint8_t *buf,
size_t cap, uint16_t ns, uint16_t nr,
const uint8_t *asdu,
size_t asdu_len);
117size_t iec104_build_s(uint8_t *buf,
size_t cap, uint16_t nr);
120size_t iec104_build_u(uint8_t *buf,
size_t cap, uint8_t u_cmd);
123bool iec104_parse(
const uint8_t *buf,
size_t len, Iec104Apci *out,
size_t *consumed);
128size_t iec_asdu_build_header(uint8_t *buf,
size_t cap,
const IecAsduHeader *h);
131bool iec_asdu_parse_header(
const uint8_t *buf,
size_t len, IecAsduHeader *out,
size_t *consumed);
134size_t iec_put_ioa(uint8_t *buf,
size_t cap, uint32_t ioa);
137uint32_t iec_get_ioa(
const uint8_t *p);
142size_t iec101_build_fixed(uint8_t *buf,
size_t cap, uint8_t control, uint8_t addr);
145size_t iec101_build_variable(uint8_t *buf,
size_t cap, uint8_t control, uint8_t addr,
const uint8_t *asdu,
159bool iec101_parse(
const uint8_t *buf,
size_t len, Iec101Frame *out,
size_t *consumed);
User-facing configuration for DeterministicESPAsyncWebServer.