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

Zero-heap CoAP server (RFC 7252): message codec + a fixed resource table. More...

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

Go to the source code of this file.

Detailed Description

Zero-heap CoAP server (RFC 7252): message codec + a fixed resource table.

The server is split into a pure, host-testable core and an ESP32-only UDP transport (mirroring the SNMP agent's split):

  • coap_server_process() takes a complete request datagram and produces a complete response datagram in a caller buffer - no sockets, no heap. It is unit-tested on the host (env:native_coap).
  • coap_server_begin_udp() binds the transport-layer UDP service on :5683 (Arduino only) and feeds received datagrams through coap_server_process().

Only the message layer's piggybacked-response model is implemented: a CON request is answered with a piggybacked ACK, a NON request with a NON response. Separate responses and retransmission/deduplication are out of scope (a deterministic, constrained server typically replies in-line); the /.well-known/core resource-discovery listing (RFC 6690) is served. The codec understands the Uri-Path, Uri-Query and Content-Format options; other options are skipped. Block-wise transfer (RFC 7959, the Block1/Block2 options) is available under DETWS_ENABLE_COAP_BLOCK; resource observation (RFC 7641) under DETWS_ENABLE_COAP_OBSERVE.

The resource table is a fixed BSS array of DETWS_COAP_MAX_RESOURCES entries. Register handlers with coap_server_add_resource(); the path string is referenced by pointer and must outlive the server (point it at flash/static data, like the rest of the library's strings).

Definition in file coap.h.