coap.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Freie Universit├Ąt Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
22 #ifndef NET_COAP_H
23 #define NET_COAP_H
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
32 #define COAP_PORT (5683)
33 
37 #define COAPS_PORT (5684)
38 
39 #define COAP_V1 (1)
45 #define COAP_OPT_IF_MATCH (1)
46 #define COAP_OPT_URI_HOST (3)
47 #define COAP_OPT_ETAG (4)
48 #define COAP_OPT_IF_NONE_MATCH (5)
49 #define COAP_OPT_OBSERVE (6)
50 #define COAP_OPT_LOCATION_PATH (8)
51 #define COAP_OPT_URI_PATH (11)
52 #define COAP_OPT_CONTENT_FORMAT (12)
53 #define COAP_OPT_MAX_AGE (14)
54 #define COAP_OPT_URI_QUERY (15)
55 #define COAP_OPT_ACCEPT (17)
56 #define COAP_OPT_LOCATION_QUERY (20)
57 #define COAP_OPT_BLOCK2 (23)
58 #define COAP_OPT_BLOCK1 (27)
69 #define COAP_OPT_SIZE2 (28)
70 #define COAP_OPT_PROXY_URI (35)
71 #define COAP_OPT_PROXY_SCHEME (39)
84 #define COAP_OPT_SIZE1 (60)
89 #define COAP_OPT_NO_RESPONSE (258)
96 #define COAP_TYPE_CON (0)
97 #define COAP_TYPE_NON (1)
98 #define COAP_TYPE_ACK (2)
99 #define COAP_TYPE_RST (3)
106 #define COAP_CLASS_REQ (0)
107 #define COAP_METHOD_GET (1)
108 #define COAP_METHOD_POST (2)
109 #define COAP_METHOD_PUT (3)
110 #define COAP_METHOD_DELETE (4)
111 #define COAP_METHOD_FETCH (5)
112 #define COAP_METHOD_PATCH (6)
113 #define COAP_METHOD_IPATCH (7)
120 #define COAP_CODE_EMPTY (0)
127 #define COAP_CLASS_SUCCESS (2)
128 #define COAP_CODE_CREATED ((2 << 5) | 1)
129 #define COAP_CODE_DELETED ((2 << 5) | 2)
130 #define COAP_CODE_VALID ((2 << 5) | 3)
131 #define COAP_CODE_CHANGED ((2 << 5) | 4)
132 #define COAP_CODE_204 ((2 << 5) | 4)
133 #define COAP_CODE_CONTENT ((2 << 5) | 5)
134 #define COAP_CODE_205 ((2 << 5) | 5)
135 #define COAP_CODE_CONTINUE ((2 << 5) | 31)
136 #define COAP_CODE_231 ((2 << 5) | 31)
143 #define COAP_CLASS_CLIENT_FAILURE (4)
144 #define COAP_CODE_BAD_REQUEST ((4 << 5) | 0)
145 #define COAP_CODE_UNAUTHORIZED ((4 << 5) | 1)
146 #define COAP_CODE_BAD_OPTION ((4 << 5) | 2)
147 #define COAP_CODE_FORBIDDEN ((4 << 5) | 3)
148 #define COAP_CODE_PATH_NOT_FOUND ((4 << 5) | 4)
149 #define COAP_CODE_404 ((4 << 5) | 4)
150 #define COAP_CODE_METHOD_NOT_ALLOWED ((4 << 5) | 5)
151 #define COAP_CODE_NOT_ACCEPTABLE ((4 << 5) | 6)
152 #define COAP_CODE_REQUEST_ENTITY_INCOMPLETE ((4 << 5) | 8)
153 #define COAP_CODE_CONFLICT ((4 << 5) | 9)
154 #define COAP_CODE_PRECONDITION_FAILED ((4 << 5) | 12)
155 #define COAP_CODE_REQUEST_ENTITY_TOO_LARGE ((4 << 5) | 13)
156 #define COAP_CODE_UNSUPPORTED_CONTENT_FORMAT ((4 << 5) | 15)
157 #define COAP_CODE_UNPROCESSABLE_ENTITY ((4 << 5) | 22)
158 #define COAP_CODE_TOO_MANY_REQUESTS ((4 << 5) | 29)
165 #define COAP_CLASS_SERVER_FAILURE (5)
166 #define COAP_CODE_INTERNAL_SERVER_ERROR ((5 << 5) | 0)
167 #define COAP_CODE_NOT_IMPLEMENTED ((5 << 5) | 1)
168 #define COAP_CODE_BAD_GATEWAY ((5 << 5) | 2)
169 #define COAP_CODE_SERVICE_UNAVAILABLE ((5 << 5) | 3)
170 #define COAP_CODE_GATEWAY_TIMEOUT ((5 << 5) | 4)
171 #define COAP_CODE_PROXYING_NOT_SUPPORTED ((5 << 5) | 5)
179 #define COAP_FORMAT_TEXT (0)
180 #define COAP_FORMAT_LINK (40)
181 #define COAP_FORMAT_XML (41)
182 #define COAP_FORMAT_OCTET (42)
183 #define COAP_FORMAT_EXI (47)
184 #define COAP_FORMAT_JSON (50)
185 #define COAP_FORMAT_JSON_PATCH_JSON (51)
186 #define COAP_FORMAT_MERGE_PATCH_JSON (52)
187 #define COAP_FORMAT_CBOR (60)
188 #define COAP_FORMAT_SENML_JSON (110)
189 #define COAP_FORMAT_SENSML_JSON (111)
190 #define COAP_FORMAT_SENML_CBOR (112)
191 #define COAP_FORMAT_SENSML_CBOR (113)
192 #define COAP_FORMAT_SENML_EXI (114)
193 #define COAP_FORMAT_SENSML_EXI (115)
194 #define COAP_FORMAT_SENML_XML (310)
195 #define COAP_FORMAT_SENSML_XML (311)
196 #define COAP_FORMAT_DNS_MESSAGE (65053)
203 #define COAP_OBS_REGISTER (0)
204 #define COAP_OBS_DEREGISTER (1)
211 #define COAP_TOKEN_LENGTH_MAX (8)
218 #define COAP_ETAG_LENGTH_MAX (8U)
243 #ifndef CONFIG_COAP_ACK_TIMEOUT_MS
244 #define CONFIG_COAP_ACK_TIMEOUT_MS (2000UL)
245 #endif
246 
256 #ifndef CONFIG_COAP_RANDOM_FACTOR_1000
257 #define CONFIG_COAP_RANDOM_FACTOR_1000 (1500)
258 #endif
259 
264 #ifndef CONFIG_COAP_SEPARATE_RESPONSE_TIMEOUT_MS
265 #define CONFIG_COAP_SEPARATE_RESPONSE_TIMEOUT_MS (10 * MS_PER_SEC)
266 #endif
267 
269 #ifndef CONFIG_COAP_MAX_RETRANSMIT
270 #define CONFIG_COAP_MAX_RETRANSMIT (4)
271 #endif
279 #define COAP_NSTART (1)
280 #define COAP_DEFAULT_LEISURE (5)
287 #define COAP_BLOCKWISE_NUM_OFF (4)
288 #define COAP_BLOCKWISE_MORE_OFF (3)
289 #define COAP_BLOCKWISE_SZX_MASK (0x07)
290 #define COAP_BLOCKWISE_SZX_MAX (7)
296 typedef enum {
297  COAP_BLOCKSIZE_16 = 0,
298  COAP_BLOCKSIZE_32,
299  COAP_BLOCKSIZE_64,
300  COAP_BLOCKSIZE_128,
301  COAP_BLOCKSIZE_256,
302  COAP_BLOCKSIZE_512,
303  COAP_BLOCKSIZE_1024,
305 
306 #ifdef __cplusplus
307 }
308 #endif
309 
310 #endif /* NET_COAP_H */
coap_blksize_t
Coap block-wise-transfer size SZX.
Definition: coap.h:296