1# Copyright Runtime.io 2018. All rights reserved.
2# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
3# SPDX-License-Identifier: Apache-2.0
4
5# The Kconfig file is dedicated to smp subdirectory of MCUmgr
6# subsystem and provides Kconfig options to control aspects of
7# Simple Management Protocol (SMP) processing source code provided
8# under the subdirectory.
9#
10# Options defined in this file should be prefixed:
11#  MCUMGR_SMP_ -- for general SMP options;
12#  MCUMGR_SMP_CBOR -- for CBOR encoding specific options;
13
14config MCUMGR_SMP_CBOR_MAX_MAIN_MAP_ENTRIES
15	int "Number of predicted maximum entries to main response map"
16	default 15
17	help
18	  This is number of predicted entries in main response map,
19	  the one that encapsulates everything within response.
20	  This value is used by zcbor to predict needed map encoding,
21	  and does not affect memory allocation or usage.
22	  Builtin command processors rarely add large amounts of
23	  data directly to main map, creating sub-maps instead so
24	  the default value works fine with them.
25	  If your app directly adds fields to main map, without
26	  encapsulating them, you may want to increase this value
27	  in case when encoding starts to fail.
28
29config MCUMGR_SMP_CBOR_MIN_DECODING_LEVELS
30	int
31	help
32	  Minimal decoding levels, map/list encapsulation, required
33	  to be supported by zcbor decoding of SMP responses
34	  is auto genereated from MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_? options.
35	  A group or command that adds additional maps/lists above the
36	  base map, which is already taken into account, should
37	  select one of the MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_?.
38	default 7 if MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_7
39	default 6 if MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_6
40	default 5 if MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_5
41	default 4 if MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_4
42	default 3 if MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_3
43	default 2 if MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_2
44	default 1 if MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_1
45	default 0
46
47config MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_1
48	bool
49
50config MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_2
51	bool
52
53config MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_3
54	bool
55
56config MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_4
57	bool
58
59config MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_5
60	bool
61
62config MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_6
63	bool
64
65config MCUMGR_SMP_CBOR_MIN_DECODING_LEVEL_7
66	bool
67
68config MCUMGR_SMP_CBOR_MAX_DECODING_LEVELS
69	int "Number of map/list encapsulations allowed for SMP decoding"
70	range MCUMGR_SMP_CBOR_MIN_DECODING_LEVELS 15
71	default MCUMGR_SMP_CBOR_MIN_DECODING_LEVELS
72	help
73	  This is a maximum number of levels of maps/lists that will
74	  be expected to be decoded within different command groups.
75	  SMP commands/groups that provide no CBOR encoded payload
76	  have no requirements.
77	  Commands that provide CBOR payload require at least 1 level,
78	  and additional levels for each map/list encapsulation.
79	  For example if command accepts payload of map of parameters
80	  it will need 2 levels.
81	  This number translates to zcbor backup states, it increases
82	  size of cbor_nb_reader structure by zcbor_state_t size per
83	  one unit selected here.
84
85config MCUMGR_SMP_CBOR_MIN_ENCODING_LEVELS
86	int
87	help
88	  Minimal encoding levels, map/list encapsulation, required
89	  to be supported by zcbor encoding of SMP responses
90	  is auto genereated from MCUMGR_SMP_CBOR_MIN_ENCODING_LEVEL_? options.
91	  A group or command that adds additional maps/lists above the
92	  base map, which is already taken into account, should
93	  select one of the MCUMGR_SMP_CBOR_MIN_ENCODING_LEVEL_?.
94	default 7 if MCUMGR_SMP_CBOR_MIN_ENCODING_LEVEL_7
95	default 6 if MCUMGR_SMP_CBOR_MIN_ENCODING_LEVEL_6
96	default 5 if MCUMGR_SMP_CBOR_MIN_ENCODING_LEVEL_5
97	default 4 if MCUMGR_SMP_CBOR_MIN_ENCODING_LEVEL_4
98	default 3 if MCUMGR_SMP_CBOR_MIN_ENCODING_LEVEL_3
99	default 2 if MCUMGR_SMP_CBOR_MIN_ENCODING_LEVEL_2
100	default 1 if MCUMGR_SMP_CBOR_MIN_ENCODING_LEVEL_1 || ZCBOR_CANONICAL
101	default 0
102
103config MCUMGR_SMP_CBOR_MIN_ENCODING_LEVEL_1
104	bool
105
106config MCUMGR_SMP_CBOR_MIN_ENCODING_LEVEL_2
107	bool
108
109config MCUMGR_SMP_CBOR_MIN_ENCODING_LEVEL_3
110	bool
111
112config MCUMGR_SMP_CBOR_MIN_ENCODING_LEVEL_4
113	bool
114
115config MCUMGR_SMP_CBOR_MIN_ENCODING_LEVEL_5
116	bool
117
118config MCUMGR_SMP_CBOR_MIN_ENCODING_LEVEL_6
119	bool
120
121config MCUMGR_SMP_CBOR_MIN_ENCODING_LEVEL_7
122	bool
123
124config MCUMGR_SMP_CBOR_MAX_ENCODING_LEVELS
125	int "Number of map/list encapsulations allowed for SMP encoding"
126	range MCUMGR_SMP_CBOR_MIN_ENCODING_LEVELS 15
127	default MCUMGR_SMP_CBOR_MIN_ENCODING_LEVELS
128	help
129	  This is a maximum number of levels of maps/lists that will
130	  be encoded within different comm&& groups.
131	  This number translates to zcbor backup states, it increases
132	  size of cbor_nb_writer structure by zcbor_state_t size per
133	  one unit selected here.
134
135config MCUMGR_SMP_COMMAND_STATUS_HOOKS
136	bool "SMP command status hooks"
137	depends on MCUMGR_MGMT_NOTIFICATION_HOOKS
138	help
139	  This will enable SMP command status notification hooks for when an SMP message is
140	  received or processed.
141
142config MCUMGR_SMP_SUPPORT_ORIGINAL_PROTOCOL
143	bool "Support original protocol"
144	default y
145	help
146	  This option will enable supporting the original SMP protocol whereby
147	  all errors are returned in the "rc" field as well as the new protocol
148	  whereby there is a dedicated entry for command error/result codes.
149	  The protocol selection is indicated by the request header sent by the
150	  client.
151
152config MCUMGR_SMP_VERBOSE_ERR_RESPONSE
153	bool "Support verbose error response"
154	depends on MCUMGR_SMP_SUPPORT_ORIGINAL_PROTOCOL
155	help
156	  Support for encoding "rc" code explanation in form of "rsn"
157	  text string.  This is useful, when returning MGMT_ERR_EUNKNOWN,
158	  to add additional information on the source of an error.
159	  Note that the "rsn" is string additional to "rc" code,
160	  so MCUMGR_TRANSPORT_NETBUF_SIZE should be large enough to be able
161	  to encode both.
162