|
ProtoCore v0.0.2
Deterministic, zero-heap network stack for embedded targets
|
Zero-heap CoAP server (RFC 7252): message codec + a fixed resource table. More...
Go to the source code of this file.
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):
The message layer uses the piggybacked-response model: a CON request is answered with a piggybacked ACK, a NON request with a NON response. Message de-duplication (RFC 7252 sec 4.5) is implemented - a retransmitted CON is re-answered from a small cache keyed on (source endpoint, Message-ID) WITHOUT re-running its handler, so a client's retransmission cannot execute a non-idempotent request twice (see PC_COAP_DEDUP_*). Separate (deferred) responses are a deliberate non-goal (this is a synchronous, in-line server: a request is answered before the handler returns), and there is no CON retransmission because the server never sends a Confirmable message - notifications go out Non-confirmable. 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 PC_ENABLE_COAP_BLOCK; resource observation (RFC 7641) under PC_ENABLE_COAP_OBSERVE.
The resource table is a fixed BSS array of PC_COAP_MAX_RESOURCES entries. Register handlers with pc_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.