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 ZVFS
170	select ZVFS_EVENTFD
171	help
172	  This option enables the API for CoAP-services to register resources.
173
174if COAP_SERVER
175
176config COAP_SERVER_STACK_SIZE
177	int "CoAP server thread stack size"
178	default 4096
179	help
180	  CoAP server thread stack size for processing RX/TX events.
181
182config COAP_SERVER_BLOCK_SIZE
183	int "CoAP server block-wise transfer size"
184	default 256
185	range 64 1024
186	help
187	  CoAP block size used by CoAP server resources when performing block-wise
188	  transfers. Possible values: 64, 128, 256, 512 and 1024.
189
190config COAP_SERVER_MESSAGE_SIZE
191	int "CoAP server message payload size"
192	default COAP_SERVER_BLOCK_SIZE
193	help
194	  CoAP server message payload size. Can't be smaller than COAP_SERVER_BLOCK_SIZE.
195
196config COAP_SERVER_MESSAGE_OPTIONS
197	int "CoAP server message options"
198	default 16
199	help
200	  CoAP server message maximum number of options to parse.
201
202config COAP_SERVER_WELL_KNOWN_CORE
203	bool "CoAP server support ./well-known/core service"
204	default y
205	help
206	  Enable responding to the ./well-known/core service resource.
207
208config COAP_SERVICE_PENDING_MESSAGES
209	int "CoAP service pending messages"
210	default 10
211	help
212	  Maximum number of pending CoAP messages to retransmit per active service.
213
214config COAP_SERVICE_OBSERVERS
215	int "CoAP service observers"
216	default 3
217	help
218	  Maximum number of CoAP observers per active service.
219
220choice COAP_SERVER_PENDING_ALLOCATOR
221	prompt "Pending data allocator"
222	default COAP_SERVER_PENDING_ALLOCATOR_STATIC
223
224config COAP_SERVER_PENDING_ALLOCATOR_NONE
225	bool "No pending packets"
226	help
227	  Never allocate data for pending requests, this disables retransmits for confirmable
228	  packets.
229
230config COAP_SERVER_PENDING_ALLOCATOR_STATIC
231	bool "Static reserved memory"
232	help
233	  Static memory will be reserved for pending messages. The total size is equal to
234	  COAP_SERVER_PENDING_ALLOCATOR_STATIC_BLOCKS * COAP_SERVER_MESSAGE_SIZE.
235
236config COAP_SERVER_PENDING_ALLOCATOR_SYSTEM_HEAP
237	bool "System heap allocator"
238	depends on HEAP_MEM_POOL_SIZE > 0
239	help
240	  Use k_malloc/k_free for pending data.
241
242endchoice
243
244config COAP_SERVER_PENDING_ALLOCATOR_STATIC_BLOCKS
245	int "Number of pending data blocks"
246	default COAP_SERVICE_PENDING_MESSAGES
247	depends on COAP_SERVER_PENDING_ALLOCATOR_STATIC
248	help
249	  The number of data blocks to reserve for pending messages to retransmit.
250
251config COAP_SERVER_TRUNCATE_MSGS
252	bool "Handle truncated messages"
253	default y
254	help
255	  Include ZSOCK_MSG_TRUNC in flags passed to zsock_recvfrom() to
256	  receive network stack notifications about block truncation.
257	  Otherwise it happens silently.
258
259config COAP_SERVER_SHELL
260	bool "CoAP service shell commands"
261	depends on SHELL
262	help
263	  Enable CoAP service shell commands.
264
265endif
266
267module = COAP
268module-dep = NET_LOG
269module-str = Log level for CoAP
270module-help = Enables CoAP debug messages.
271source "subsys/net/Kconfig.template.log_config.net"
272
273endif # COAP
274