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)
77 COAP_RSP_CREATED = COAP_CODE(2, 1),
78 COAP_RSP_DELETED = COAP_CODE(2, 2),
79 COAP_RSP_VALID = COAP_CODE(2, 3),
80 COAP_RSP_CHANGED = COAP_CODE(2, 4),
81 COAP_RSP_CONTENT = COAP_CODE(2, 5),
82 COAP_RSP_CONTINUE = COAP_CODE(2, 31),
83 COAP_RSP_BAD_REQUEST = COAP_CODE(4, 0),
84 COAP_RSP_BAD_OPTION = COAP_CODE(4, 2),
85 COAP_RSP_NOT_FOUND = COAP_CODE(4, 4),
86 COAP_RSP_METHOD_NOT_ALLOWED = COAP_CODE(4, 5),
87 COAP_RSP_NOT_ACCEPTABLE = COAP_CODE(4, 6),
88 COAP_RSP_REQUEST_ENTITY_INCOMPLETE = COAP_CODE(4, 8),
89 COAP_RSP_REQUEST_ENTITY_TOO_LARGE = COAP_CODE(4, 13),
90 COAP_RSP_INTERNAL_SERVER_ERROR = COAP_CODE(5, 0),
91 COAP_RSP_NOT_IMPLEMENTED = COAP_CODE(5, 1),
103 COAP_CF_NONE = 0xFFFF,
116 const uint8_t *payload;
118 CoapContentFormat content_format;
130 CoapContentFormat content_format;
137typedef void (*CoapHandler)(
const CoapRequest *req, CoapResponse *resp);
210 CoapResourceArgs resource;
212 CoapObserveArgs observe;
213 CoapExchangeArgs exchange;
217 const uint8_t *bytes;
218#if PROTOCORE_COAP_DEDUP_ENTRIES > 0
220#if PROTOCORE_ENABLE_COAP_OBSERVE
225extern CoapVars CoapV;
230 void (*
const reset)(uint8_t *work);
231 void (*
const add_resource)(uint8_t *work);
232 void (*
const process)(uint8_t *work);
233 void (*
const process_observe)(uint8_t *work);
234 void (*
const dedup_lookup)(uint8_t *work);
235 void (*
const dedup_store)(uint8_t *work);
236 void (*
const begin)(uint8_t *work);
237 void (*
const notify)(uint8_t *work);
242void protocore_coap_reset(uint8_t *work);
243void protocore_coap_add_resource(uint8_t *work);
244void protocore_coap_process(uint8_t *work);
245void protocore_coap_process_observe(uint8_t *work);
246#if PROTOCORE_COAP_DEDUP_ENTRIES > 0
247void protocore_coap_dedup_lookup(uint8_t *work);
248void protocore_coap_dedup_store(uint8_t *work);
250void protocore_coap_begin(uint8_t *work);
251#if PROTOCORE_ENABLE_COAP_OBSERVE
252void protocore_coap_notify(uint8_t *work);
259static const CoapNs Coap __attribute__((unused)) = {
260 .reset = protocore_coap_reset,
261 .add_resource = protocore_coap_add_resource,
262 .process = protocore_coap_process,
263 .process_observe = protocore_coap_process_observe,
264#if PROTOCORE_COAP_DEDUP_ENTRIES > 0
265 .dedup_lookup = protocore_coap_dedup_lookup,
266 .dedup_store = protocore_coap_dedup_store,
268 .begin = protocore_coap_begin,
269#if PROTOCORE_ENABLE_COAP_OBSERVE
270 .notify = protocore_coap_notify,
283uint8_t *protocore_coap_span(
void);
PROTO_ENUM_PACKED
Application protocol spoken on a listener port or connection slot.
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
_Bool proto_bool
The truth value.
#define PROTOCORE_END_DECLS