Loading...
Searching...
No Matches
coap.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2018 Freie Universität Berlin
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
28#define COAP_PORT (5683)
29
33#define COAPS_PORT (5684)
34
35#define COAP_V1 (1)
36
41#define COAP_OPT_IF_MATCH (1)
42#define COAP_OPT_URI_HOST (3)
43#define COAP_OPT_ETAG (4)
44#define COAP_OPT_IF_NONE_MATCH (5)
45#define COAP_OPT_OBSERVE (6)
46#define COAP_OPT_LOCATION_PATH (8)
55#define COAP_OPT_OSCORE (9)
56#define COAP_OPT_URI_PATH (11)
57#define COAP_OPT_CONTENT_FORMAT (12)
58#define COAP_OPT_MAX_AGE (14)
59#define COAP_OPT_URI_QUERY (15)
67#define COAP_OPT_HOP_LIMIT (16)
68#define COAP_OPT_ACCEPT (17)
76#define COAP_OPT_Q_BLOCK1 (19)
77#define COAP_OPT_LOCATION_QUERY (20)
86#define COAP_OPT_EDHOC (21)
87#define COAP_OPT_BLOCK2 (23)
88#define COAP_OPT_BLOCK1 (27)
99#define COAP_OPT_SIZE2 (28)
107#define COAP_OPT_Q_BLOCK2 (31)
108#define COAP_OPT_PROXY_URI (35)
109#define COAP_OPT_PROXY_SCHEME (39)
122#define COAP_OPT_SIZE1 (60)
131#define COAP_OPT_ECHO (252)
136#define COAP_OPT_NO_RESPONSE (258)
145#define COAP_OPT_REQUEST_TAG (292)
147
152#define COAP_TYPE_CON (0)
153#define COAP_TYPE_NON (1)
154#define COAP_TYPE_ACK (2)
155#define COAP_TYPE_RST (3)
157
162#define COAP_CLASS_REQ (0)
163
176
177
182#define COAP_CODE_EMPTY (0)
184
189#define COAP_CLASS_SUCCESS (2)
191#define COAP_CODE_CREATED ((2 << 5) | 1)
192#define COAP_CODE_DELETED ((2 << 5) | 2)
193#define COAP_CODE_VALID ((2 << 5) | 3)
194#define COAP_CODE_CHANGED ((2 << 5) | 4)
195#define COAP_CODE_204 ((2 << 5) | 4)
197#define COAP_CODE_CONTENT ((2 << 5) | 5)
198#define COAP_CODE_205 ((2 << 5) | 5)
200#define COAP_CODE_CONTINUE ((2 << 5) | 31)
201#define COAP_CODE_231 ((2 << 5) | 31)
204
209#define COAP_CLASS_CLIENT_FAILURE (4)
211#define COAP_CODE_BAD_REQUEST ((4 << 5) | 0)
212#define COAP_CODE_UNAUTHORIZED ((4 << 5) | 1)
213#define COAP_CODE_BAD_OPTION ((4 << 5) | 2)
214#define COAP_CODE_FORBIDDEN ((4 << 5) | 3)
215#define COAP_CODE_PATH_NOT_FOUND ((4 << 5) | 4)
216#define COAP_CODE_404 ((4 << 5) | 4)
218#define COAP_CODE_METHOD_NOT_ALLOWED ((4 << 5) | 5)
219#define COAP_CODE_NOT_ACCEPTABLE ((4 << 5) | 6)
220#define COAP_CODE_REQUEST_ENTITY_INCOMPLETE ((4 << 5) | 8)
221#define COAP_CODE_CONFLICT ((4 << 5) | 9)
222#define COAP_CODE_PRECONDITION_FAILED ((4 << 5) | 12)
223#define COAP_CODE_REQUEST_ENTITY_TOO_LARGE ((4 << 5) | 13)
224#define COAP_CODE_UNSUPPORTED_CONTENT_FORMAT ((4 << 5) | 15)
225#define COAP_CODE_UNPROCESSABLE_ENTITY ((4 << 5) | 22)
226#define COAP_CODE_TOO_MANY_REQUESTS ((4 << 5) | 29)
228
233#define COAP_CLASS_SERVER_FAILURE (5)
235#define COAP_CODE_INTERNAL_SERVER_ERROR ((5 << 5) | 0)
236#define COAP_CODE_NOT_IMPLEMENTED ((5 << 5) | 1)
237#define COAP_CODE_BAD_GATEWAY ((5 << 5) | 2)
238#define COAP_CODE_SERVICE_UNAVAILABLE ((5 << 5) | 3)
239#define COAP_CODE_GATEWAY_TIMEOUT ((5 << 5) | 4)
240#define COAP_CODE_PROXYING_NOT_SUPPORTED ((5 << 5) | 5)
242
252#define COAP_FORMAT_TEXT (0)
257#define COAP_FORMAT_COSE_ENCRYPT0 (16)
262#define COAP_FORMAT_COSE_MAC0 (17)
267#define COAP_FORMAT_COSE_SIGN1 (18)
272#define COAP_FORMAT_ACE_CBOR (19)
277#define COAP_FORMAT_IMAGE_GIF (21)
282#define COAP_FORMAT_IMAGE_JPEG (22)
287#define COAP_FORMAT_IMAGE_PNG (23)
288#define COAP_FORMAT_LINK (40)
289#define COAP_FORMAT_XML (41)
290#define COAP_FORMAT_OCTET (42)
291#define COAP_FORMAT_EXI (47)
292#define COAP_FORMAT_JSON (50)
293#define COAP_FORMAT_JSON_PATCH_JSON (51)
294#define COAP_FORMAT_MERGE_PATCH_JSON (52)
295#define COAP_FORMAT_CBOR (60)
300#define COAP_FORMAT_CWT (61)
305#define COAP_FORMAT_MULTIPART_CORE (62)
310#define COAP_FORMAT_CBOR_SEQ (63)
315#define COAP_FORMAT_COSE_ENCRYPT (96)
320#define COAP_FORMAT_COSE_MAC (97)
325#define COAP_FORMAT_COSE_SIGN (98)
330#define COAP_FORMAT_COSE_KEY (101)
335#define COAP_FORMAT_COSE_KEY_SET (102)
336#define COAP_FORMAT_SENML_JSON (110)
337#define COAP_FORMAT_SENSML_JSON (111)
338#define COAP_FORMAT_SENML_CBOR (112)
339#define COAP_FORMAT_SENSML_CBOR (113)
340#define COAP_FORMAT_SENML_EXI (114)
341#define COAP_FORMAT_SENSML_EXI (115)
346#define COAP_FORMAT_YANG_DATA_CBOR_SID (140)
351#define COAP_FORMAT_COAP_GROUP_JSON (256)
356#define COAP_FORMAT_PROBLEM_DETAILS_CBOR (257)
361#define COAP_FORMAT_SWID_CBOR (258)
367#define COAP_FORMAT_PKIXCMP (259)
372#define COAP_FORMAT_DOTS_CBOR (271)
377#define COAP_FORMAT_MISSING_BLOCKS_CBOR_SEQ (272)
384#define COAP_FORMAT_PKCS7_MIME_SERVER_GEN (280)
390#define COAP_FORMAT_PKCS7_MIME_CERTS_ONLY (281)
397#define COAP_FORMAT_PKCS8 (284)
403#define COAP_FORMAT_CSRATTRS (285)
410#define COAP_FORMAT_PKCS10 (286)
416#define COAP_FORMAT_PKIX_CERT (287)
421#define COAP_FORMAT_AIF_CBOR (290)
426#define COAP_FORMAT_AIF_JSON (291)
427#define COAP_FORMAT_SENML_XML (310)
428#define COAP_FORMAT_SENSML_XML (311)
433#define COAP_FORMAT_SNML_ETCH_JSON (320)
438#define COAP_FORMAT_SNML_ETCH_CBOR (322)
443#define COAP_FORMAT_YAML_DATA_CBOR (340)
448#define COAP_FORMAT_YAML_DATA_CBOR_ID_NAME (341)
453#define COAP_FORMAT_TD_JSON (432)
458#define COAP_FORMAT_TM_JSON (433)
463#define COAP_FORMAT_DNS_MESSAGE (553)
469#define COAP_FORMAT_VOUCER_COSE_CBOR (836)
473#define COAP_FORMAT_VND_OCF_CBOR (10000)
478#define COAP_FORMAT_OSCORE (10001)
483#define COAP_FORMAT_JAVASCRIPT (10002)
489#define COAP_FORMAT_JSON_DEFLATE (11050)
495#define COAP_FORMAT_CBOR_DEFLATE (11060)
500#define COAP_FORMAT_VND_OMA_LWM2M_TLV (11542)
505#define COAP_FORMAT_VND_OMA_LWM2M_JSON (11543)
510#define COAP_FORMAT_VND_OMA_LWM2M_CBOR (11544)
515#define COAP_FORMAT_TEXT_CSS (20000)
520#define COAP_FORMAT_IMAGE_SVG_XML (30000)
522
527#define COAP_OBS_REGISTER (0)
528#define COAP_OBS_DEREGISTER (1)
529#define COAP_OBS_MAX_VALUE_MASK (0xffffff)
531
536#define COAP_TOKEN_LENGTH_MAX (8)
538
543#define COAP_ETAG_LENGTH_MAX (8U)
545
549#define COAP_PAYLOAD_MARKER (0xFF)
550#define COAP_PAYLOAD_MARKER_SIZE (1U)
551
574#ifndef CONFIG_COAP_ACK_TIMEOUT_MS
575#define CONFIG_COAP_ACK_TIMEOUT_MS (2000)
576#endif
577
587#ifndef CONFIG_COAP_RANDOM_FACTOR_1000
588#define CONFIG_COAP_RANDOM_FACTOR_1000 (1500)
589#endif
590
595#ifndef CONFIG_COAP_SEPARATE_RESPONSE_TIMEOUT_MS
596#define CONFIG_COAP_SEPARATE_RESPONSE_TIMEOUT_MS (10 * MS_PER_SEC)
597#endif
598
600#ifndef CONFIG_COAP_MAX_RETRANSMIT
601#define CONFIG_COAP_MAX_RETRANSMIT (4)
602#endif
605
610#define COAP_NSTART (1)
611#define COAP_DEFAULT_LEISURE (5)
613
618#define COAP_BLOCKWISE_NUM_OFF (4)
619#define COAP_BLOCKWISE_MORE_OFF (3)
620#define COAP_BLOCKWISE_SZX_MASK (0x07)
621#define COAP_BLOCKWISE_SZX_MAX (7)
623
627typedef enum {
628 COAP_BLOCKSIZE_16 = 0,
629 COAP_BLOCKSIZE_32,
630 COAP_BLOCKSIZE_64,
631 COAP_BLOCKSIZE_128,
632 COAP_BLOCKSIZE_256,
633 COAP_BLOCKSIZE_512,
634 COAP_BLOCKSIZE_1024,
636
637#ifdef __cplusplus
638}
639#endif
640
coap_blksize_t
Coap block-wise-transfer size SZX.
Definition coap.h:627
coap_method_t
CoAP method codes used in request.
Definition coap.h:167
@ COAP_METHOD_GET
GET request (no paylod)
Definition coap.h:168
@ COAP_METHOD_IPATCH
iPATCH request (RFC 8132)
Definition coap.h:174
@ COAP_METHOD_PUT
PUT request (update resource with payload)
Definition coap.h:170
@ COAP_METHOD_POST
POST request (resource processes payload)
Definition coap.h:169
@ COAP_METHOD_PATCH
PATCH request (RFC 8132)
Definition coap.h:173
@ COAP_METHOD_DELETE
DELETE request (no payload, remove resource)
Definition coap.h:171
@ COAP_METHOD_FETCH
FETCH request (RFC 8132)
Definition coap.h:172