37#ifndef PROTOCORE_COAP_H
38#define PROTOCORE_COAP_H
42#if PROTOCORE_ENABLE_COAP
47#define COAP_CODE(c, dd) ((uint8_t)(((c) << 5) | ((dd) & 0x1F)))
51#define COAP_ALLOW_GET (1u << 1)
52#define COAP_ALLOW_POST (1u << 2)
53#define COAP_ALLOW_PUT (1u << 3)
54#define COAP_ALLOW_DELETE (1u << 4)
74 CoapResponseCode, COAP_RSP_CREATED = COAP_CODE(2, 1),
75 COAP_RSP_DELETED = COAP_CODE(2, 2),
76 COAP_RSP_VALID = COAP_CODE(2, 3),
77 COAP_RSP_CHANGED = COAP_CODE(2, 4),
78 COAP_RSP_CONTENT = COAP_CODE(2, 5),
79 COAP_RSP_CONTINUE = COAP_CODE(2, 31),
80 COAP_RSP_BAD_REQUEST = COAP_CODE(4, 0),
81 COAP_RSP_BAD_OPTION = COAP_CODE(4, 2),
82 COAP_RSP_NOT_FOUND = COAP_CODE(4, 4),
83 COAP_RSP_METHOD_NOT_ALLOWED = COAP_CODE(4, 5),
84 COAP_RSP_NOT_ACCEPTABLE = COAP_CODE(4, 6),
85 COAP_RSP_REQUEST_ENTITY_INCOMPLETE = COAP_CODE(4, 8),
86 COAP_RSP_REQUEST_ENTITY_TOO_LARGE = COAP_CODE(4, 13),
87 COAP_RSP_INTERNAL_SERVER_ERROR = COAP_CODE(5, 0),
88 COAP_RSP_NOT_IMPLEMENTED = COAP_CODE(5, 1),
99 COAP_CF_NONE = 0xFFFF,
112 const uint8_t *payload;
114 CoapContentFormat content_format;
126 CoapContentFormat content_format;
133typedef void (*CoapHandler)(
const CoapRequest *req, CoapResponse *resp);
206 CoapResourceArgs resource;
208 CoapObserveArgs observe;
209 CoapExchangeArgs exchange;
213 const uint8_t *bytes;
214#if PROTOCORE_COAP_DEDUP_ENTRIES > 0
216#if PROTOCORE_ENABLE_COAP_OBSERVE
221extern CoapVars CoapV;
226 void (*
const reset)(uint8_t *work);
227 void (*
const add_resource)(uint8_t *work);
228 void (*
const process)(uint8_t *work);
229 void (*
const process_observe)(uint8_t *work);
230 void (*
const dedup_lookup)(uint8_t *work);
231 void (*
const dedup_store)(uint8_t *work);
232 void (*
const begin)(uint8_t *work);
233 void (*
const notify)(uint8_t *work);
238void protocore_coap_reset(uint8_t *work);
239void protocore_coap_add_resource(uint8_t *work);
240void protocore_coap_process(uint8_t *work);
241void protocore_coap_process_observe(uint8_t *work);
242#if PROTOCORE_COAP_DEDUP_ENTRIES > 0
243void protocore_coap_dedup_lookup(uint8_t *work);
244void protocore_coap_dedup_store(uint8_t *work);
246void protocore_coap_begin(uint8_t *work);
247#if PROTOCORE_ENABLE_COAP_OBSERVE
248void protocore_coap_notify(uint8_t *work);
255static const CoapNs Coap __attribute__((unused)) = {
256 .reset = protocore_coap_reset,
257 .add_resource = protocore_coap_add_resource,
258 .process = protocore_coap_process,
259 .process_observe = protocore_coap_process_observe,
260#if PROTOCORE_COAP_DEDUP_ENTRIES > 0
261 .dedup_lookup = protocore_coap_dedup_lookup,
262 .dedup_store = protocore_coap_dedup_store,
264 .begin = protocore_coap_begin,
265#if PROTOCORE_ENABLE_COAP_OBSERVE
266 .notify = protocore_coap_notify,
279uint8_t *protocore_coap_span(
void);
EMBED_ENUM_BYTE(ProtoConn, PROTO_NONE=0, PROTO_HTTP=1, PROTO_TELNET=2, PROTO_SSH=3, PROTO_MODBUS=4, PROTO_OPCUA=5, PROTO_SSH_RFWD=6, PROTO_RELAY=7, PROTO_BRIDGE=8, PROTO_NTRIP_CASTER=9, PROTO_MESH=10, PROTO_UDP=11,)
Application protocol spoken on a listener port or connection slot.