DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
opcua.h File Reference

OPC UA Binary server: handshake + SecureChannel + Session + Read/Write + Browse (DETWS_ENABLE_OPCUA). More...

#include "ServerConfig.h"
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Detailed Description

OPC UA Binary server: handshake + SecureChannel + Session + Read/Write + Browse (DETWS_ENABLE_OPCUA).

OPC UA (IEC 62541) is large; this is built in increments. Increment 1 is the foundation every OPC UA server needs:

  • the OPC UA Binary built-in-type codec (little-endian writer/reader for Boolean, integers, Float/Double, String, ByteString - bounds-checked, the basis for every later structure/service),
  • the UA-TCP connection protocol (UACP) message framing (MessageType + chunk byte + MessageSize), and
  • the Hello / Acknowledge handshake (OPC UA Part 6 §7.1.2): parse a client HEL, negotiate buffer sizes, emit an ACK.

The codec + framing + handshake are pure and host-tested; opcua_rx() is the ConnProto::PROTO_OPCUA TCP data handler (ESP32) - listen(4840, ConnProto::PROTO_OPCUA) and a client gets through the handshake. Session and the Read service are later increments. SecurityPolicy is None (no encryption) for now.

Increment 2 adds the SecureChannel: NodeId / ExtensionObject / DateTime encoding on top of the increment-1 codec, then parsing an OpenSecureChannel (OPN) request and answering with an OpenSecureChannelResponse - the server assigns a SecureChannelId + security token (SecurityPolicy None, OPC UA Part 6 §7.1.3 / Part 4 §5.5.2).

Increment 3 adds the Session: MSG (secure conversation) service calls dispatched by their body TypeId - CreateSession (the server assigns a SessionId and AuthenticationToken) and ActivateSession (OPC UA Part 4 §5.6).

Increment 4 adds the Read service (OPC UA Part 4 §5.10): scalar Variant + DataValue encoding and a registered resolver that maps a NodeId/attribute to a value - the first service that returns live data.

Increment 5 adds the Browse service (OPC UA Part 4 §5.8.2) via a registered resolver (ReferenceDescription / QualifiedName / LocalizedText encoding) and CloseSession; CloseSecureChannel arrives as a CLO message and closes the slot.

Later increments add GetEndpoints + a ServiceFault fallback (so standard clients interoperate) and the Write service (DataValue/Variant decode + a registered write resolver). Verified end to end with python asyncua.

No heap, no stdlib.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file opcua.h.