1# CoAP implementation for Zephyr
2
3# Copyright (c) 2017 Intel Corporation
4# SPDX-License-Identifier: Apache-2.0
5
6config COAP
7	bool "CoAP Support"
8	help
9	  This option enables the CoAP implementation.
10
11
12if COAP
13
14# This setting is only used by unit test. Do not enable it in applications
15config COAP_TEST_API_ENABLE
16	bool "Test API for CoAP unit tests"
17	help
18	  Do not enable this for normal use.
19
20config COAP_WELL_KNOWN_BLOCK_WISE
21	bool "CoAP ./well-known/core services block wise support"
22	help
23	  This option enables the block wise support of CoAP response
24	  to ./well-known/core request. Without this option all resource's
25	  information will be sent in a single IP packet (can be multiple
26	  fragments depends on MTU size). This will be useful in mesh kind
27	  of networks.
28
29config COAP_WELL_KNOWN_BLOCK_WISE_SIZE
30	int "CoAP ./well-known/core services block wise support"
31	default 32
32	depends on COAP_WELL_KNOWN_BLOCK_WISE
33	help
34	  Maximum size of CoAP block. Valid values are 16, 32, 64, 128,
35	  256, 512 and 1024.
36
37config COAP_EXTENDED_OPTIONS_LEN
38	bool "Support for CoAP extended options"
39	help
40	  This option enables the parsing of extended CoAP options length.
41	  CoAP extended options length can be 2 byte value, which
42	  requires more memory. User can save memory by disabling this.
43	  That means only length of maximum 12 bytes are supported by default.
44	  Enable this if length field going to bigger that 12.
45
46config COAP_EXTENDED_OPTIONS_LEN_VALUE
47	int "CoAP extended options length value"
48	default 13
49	depends on COAP_EXTENDED_OPTIONS_LEN
50	help
51	  This option specifies the maximum value of length field when
52	  COAP_EXTENDED_OPTIONS_LEN is enabled. Define the value according to
53	  user requirement.
54
55config COAP_INIT_ACK_TIMEOUT_MS
56	int "base length of the random generated initial ACK timeout in ms"
57	default 2000
58	range 1000 100000
59	help
60	  This value is used as a base value to retry pending CoAP packets.
61
62config COAP_RANDOMIZE_ACK_TIMEOUT
63	bool "Randomize initial ACK timeout, as specified in RFC 7252"
64	default y
65	help
66	  If enabled, the initial ACK timeout will be randomized, as specified
67	  in RFC 7252, i.e. will be a random number between ACK_TIMEOUT and
68	  ACK_TIMEOUT * ACK_RANDOM_FACTOR (where ACK_TIMEOUT is specified by
69	  COAP_INIT_ACK_TIMEOUT_MS option). Otherwise, the initial ACK timeout
70	  will be fixed to the value of COAP_INIT_ACK_TIMEOUT_MS option.
71
72config COAP_ACK_RANDOM_PERCENT
73	int "Random factor for ACK timeout described as percentage"
74	default 150
75	depends on COAP_RANDOMIZE_ACK_TIMEOUT
76	help
77	  Factor described as percentage to extend CoAP ACK timeout. A value
78	  of 150 means a factor of 1.50.
79
80config COAP_MAX_RETRANSMIT
81	int "Max retransmission of a CoAP packet"
82	default 4
83	range 1 100
84
85config COAP_BACKOFF_PERCENT
86	int "Retransmission backoff factor for ACK timeout described as percentage"
87	default 200
88	help
89	  Factor described as percentage to extend CoAP ACK timeout for retransmissions.
90	  A value of 200 means a factor of 2.0.
91
92config COAP_URI_WILDCARD
93	bool "Wildcards in CoAP resource path"
94	default y
95	help
96	  This option enables MQTT-style wildcards in path. Disable it if
97	  resource path may contain plus or hash symbol.
98
99config COAP_KEEP_USER_DATA
100	bool "Keeping user data in the CoAP packet"
101	help
102	  This option enables keeping application-specific user data
103
104config COAP_CLIENT
105	bool "CoAP client support [EXPERIMENTAL]"
106	select EXPERIMENTAL
107	help
108	  This option enables the API for CoAP-client for sending CoAP requests
109
110if COAP_CLIENT
111
112config COAP_CLIENT_THREAD_PRIORITY
113	int "Coap client thread priority"
114	default NUM_PREEMPT_PRIORITIES
115	help
116	  Priority of receive thread of the CoAP client.
117
118config COAP_CLIENT_BLOCK_SIZE
119	int "LWM2M CoAP block-wise transfer size"
120	default 256
121	range 64 1024
122	help
123	  CoAP block size used by CoAP client when performing block-wise
124	  transfers. Possible values: 64, 128, 256, 512 and 1024.
125
126config COAP_CLIENT_MESSAGE_SIZE
127	int "Message payload size"
128	default COAP_CLIENT_BLOCK_SIZE
129	help
130	  CoAP client message payload size. Can't be smaller than COAP_CLIENT_BLOCK_SIZE.
131
132config COAP_CLIENT_MESSAGE_HEADER_SIZE
133	int "Room for CoAP header data"
134	default 48
135	range 24 128
136	help
137	  Extra room allocated to handle CoAP header data
138
139config COAP_CLIENT_STACK_SIZE
140	int "Stack size of the CoAP client thread"
141	default 1024
142
143config COAP_CLIENT_MAX_INSTANCES
144	int "Maximum number of CoAP clients"
145	default 2
146	help
147	  Maximum number of CoAP clients
148
149config COAP_CLIENT_MAX_REQUESTS
150	int "Maximum number of simultaneous requests per client"
151	default 2
152	help
153	  Maximum number of CoAP requests a single client can handle at a time
154
155config COAP_CLIENT_TRUNCATE_MSGS
156	bool "Receive notification when blocks are truncated"
157	default y
158	help
159	  Include ZSOCK_MSG_TRUNC in flags passed to zsock_recvfrom() to
160	  receive network stack notifications about block truncation.
161	  Otherwise it happens silently.
162
163endif # COAP_CLIENT
164
165config COAP_SERVER
166	bool "CoAP server support [EXPERIMENTAL]"
167	select EXPERIMENTAL
168	select NET_SOCKETS
169	select NET_SOCKETPAIR
170	help
171	  This option enables the API for CoAP-services to register resources.
172
173if COAP_SERVER
174
175config COAP_SERVER_STACK_SIZE
176	int "CoAP server thread stack size"
177	default 4096
178	help
179	  CoAP server thread stack size for processing RX/TX events.
180
181config COAP_SERVER_BLOCK_SIZE
182	int "CoAP server block-wise transfer size"
183	default 256
184	range 64 1024
185	help
186	  CoAP block size used by CoAP server resources when performing block-wise
187	  transfers. Possible values: 64, 128, 256, 512 and 1024.
188
189config COAP_SERVER_MESSAGE_SIZE
190	int "CoAP server message payload size"
191	default COAP_SERVER_BLOCK_SIZE
192	help
193	  CoAP server message payload size. Can't be smaller than COAP_SERVER_BLOCK_SIZE.
194
195config COAP_SERVER_MESSAGE_OPTIONS
196	int "CoAP server message options"
197	default 16
198	help
199	  CoAP server message maximum number of options to parse.
200
201config COAP_SERVER_WELL_KNOWN_CORE
202	bool "CoAP server support ./well-known/core service"
203	default y
204	help
205	  Enable responding to the ./well-known/core service resource.
206
207config COAP_SERVICE_PENDING_MESSAGES
208	int "CoAP service pending messages"
209	default 10
210	help
211	  Maximum number of pending CoAP messages to retransmit per active service.
212
213config COAP_SERVICE_OBSERVERS
214	int "CoAP service observers"
215	default 3
216	help
217	  Maximum number of CoAP observers per active service.
218
219choice COAP_SERVER_PENDING_ALLOCATOR
220	prompt "Pending data allocator"
221	default COAP_SERVER_PENDING_ALLOCATOR_STATIC
222
223config COAP_SERVER_PENDING_ALLOCATOR_NONE
224	bool "No pending packets"
225	help
226	  Never allocate data for pending requests, this disables retransmits for confirmable
227	  packets.
228
229config COAP_SERVER_PENDING_ALLOCATOR_STATIC
230	bool "Static reserved memory"
231	help
232	  Static memory will be reserved for pending messages. The total size is equal to
233	  COAP_SERVER_PENDING_ALLOCATOR_STATIC_BLOCKS * COAP_SERVER_MESSAGE_SIZE.
234
235config COAP_SERVER_PENDING_ALLOCATOR_SYSTEM_HEAP
236	bool "System heap allocator"
237	depends on HEAP_MEM_POOL_SIZE > 0
238	help
239	  Use k_malloc/k_free for pending data.
240
241endchoice
242
243config COAP_SERVER_PENDING_ALLOCATOR_STATIC_BLOCKS
244	int "Number of pending data blocks"
245	default COAP_SERVICE_PENDING_MESSAGES
246	depends on COAP_SERVER_PENDING_ALLOCATOR_STATIC
247	help
248	  The number of data blocks to reserve for pending messages to retransmit.
249
250config COAP_SERVER_SHELL
251	bool "CoAP service shell commands"
252	depends on SHELL
253	help
254	  Enable CoAP service shell commands.
255
256endif
257
258module = COAP
259module-dep = NET_LOG
260module-str = Log level for CoAP
261module-help = Enables CoAP debug messages.
262source "subsys/net/Kconfig.template.log_config.net"
263
264endif # COAP
265