1# LoRaWAN Services configuration
2#
3# Copyright (c) 2022 Martin Jäger <martin@libre.solar>
4# Copyright (c) 2022 tado GmbH
5#
6# SPDX-License-Identifier: Apache-2.0
7
8menuconfig LORAWAN_SERVICES
9	bool "LoRaWAN Services backend"
10	depends on LORAWAN
11	select ENTROPY_GENERATOR
12	help
13	  Enables the LoRaWAN background services, e.g. used for
14	  firmware-upgrade over the air (FUOTA).
15
16	  The services use a dedicated thread and a work queue.
17
18if LORAWAN_SERVICES
19
20module = LORAWAN_SERVICES
21module-str = lorawan_services
22source "subsys/logging/Kconfig.template.log_config"
23
24config LORAWAN_SERVICES_THREAD_STACK_SIZE
25	int "Services thread stack size"
26	default 2048
27	help
28	  Stack size of thread running LoRaWAN background services.
29
30config LORAWAN_SERVICES_THREAD_PRIORITY
31	int "Services thread priority"
32	default 2
33	help
34	  Priority of the thread running LoRaWAN background services.
35
36config LORAWAN_APP_CLOCK_SYNC
37	bool "Application Layer Clock Synchronization"
38	help
39	  Enables the LoRaWAN Application Layer Clock Synchronization service
40	  according to LoRa Alliance TS003-2.0.0.
41
42	  The service uses the default port 202.
43
44config LORAWAN_APP_CLOCK_SYNC_PERIODICITY
45	int "Application Layer Clock Synchronization periodicity"
46	depends on LORAWAN_APP_CLOCK_SYNC
47	range 128 4194304
48	default 86400
49	help
50	  Initial setting for clock synchronization periodicity in seconds.
51
52	  The value can be updated remotely by the application server within a
53	  range from 128 (0x80) to 4194304 (0x400000).
54
55	  Default setting: 24h.
56
57config LORAWAN_FRAG_TRANSPORT
58	bool "Fragmented Data Block Transport"
59	select FLASH_MAP
60	select FLASH_PAGE_LAYOUT
61	select IMG_MANAGER
62	help
63	  Enables the LoRaWAN Fragmented Data Block Transport service
64	  according to TS004-1.0.0 as published by the LoRa Alliance.
65
66	  The used default port for this service is 201.
67
68choice LORAWAN_FRAG_TRANSPORT_DECODER
69	bool "Fragmented Data Block Transport decoder implementation"
70	depends on LORAWAN_FRAG_TRANSPORT
71	default LORAWAN_FRAG_TRANSPORT_DECODER_SEMTECH
72
73config LORAWAN_FRAG_TRANSPORT_DECODER_SEMTECH
74	bool "Semtech"
75	help
76	  The default decoder implementation from LoRaMAC-node.
77
78config LORAWAN_FRAG_TRANSPORT_DECODER_LOWMEM
79	bool "Low Memory Footprint Algorithm"
80	help
81	  Alternate implementation with reduced RAM footprint.
82
83endchoice # LORAWAN_FRAG_TRANSPORT_DECODER
84
85DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition
86
87config LORAWAN_FRAG_TRANSPORT_IMAGE_SIZE
88	int "Total size of firmware image"
89	depends on LORAWAN_FRAG_TRANSPORT
90	default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_CODE_PARTITION))
91	help
92	  Size of the flash partition for the application firmware image
93	  in bytes.
94
95	  The minimum number of fragments to be transferred is calculated from
96	  this value divided by the fragment size.
97
98	  This setting has significant influence on RAM usage.
99
100config LORAWAN_FRAG_TRANSPORT_MAX_FRAG_SIZE
101	int "Maximum size of transported fragments"
102	depends on LORAWAN_FRAG_TRANSPORT
103	range 1 239
104	default 232
105	help
106	  Maximum size of one fragment transferred during the fragmented data
107	  block transport session of the FUOTA process. It is chosen on the
108	  server side.
109
110	  The fragment has to fit into the LoRaWAN payload, which can be up to
111	  242 bytes depending on the region and frequency settings. 3 bytes of
112	  the payload are consumed for protocol information.
113
114	  For some MCUs like the STM32WL the fragment size has to be a multiple
115	  of 8 (see flash driver for further information).
116
117	  This setting has significant influence on RAM usage. If the exact
118	  fragment size is known, use that value for MIN and MAX config to
119	  reduce memory consumption.
120
121config LORAWAN_FRAG_TRANSPORT_MIN_FRAG_SIZE
122	int "Minimum size of transported fragments"
123	depends on LORAWAN_FRAG_TRANSPORT
124	range 1 239
125	default 48
126	help
127	  Minimum size of one fragment transferred during the fragmented data
128	  block transport session of the FUOTA process. It is chosen on the
129	  server side.
130
131	  The fragment has to fit into the LoRaWAN payload, which can be up to
132	  242 bytes depending on the region and frequency settings. 3 bytes of
133	  the payload are consumed for protocol information.
134
135	  For some MCUs like the STM32WL the fragment size has to be a multiple
136	  of 8 (see flash driver for further information).
137
138	  This setting has significant influence on RAM usage. If the exact
139	  fragment size is known, use that value for MIN and MAX config to
140	  reduce memory consumption.
141
142config LORAWAN_FRAG_TRANSPORT_MAX_REDUNDANCY
143	int "Percentage of redundant fragments"
144	depends on LORAWAN_FRAG_TRANSPORT
145	range 1 100
146	default 20
147	help
148	  The built-in forward error correction (FEC) mechanism allows to
149	  reconstruct missed packages from additional redundant packages
150	  sent by the server after all packages have been sent.
151
152	  This parameter specifies the maximum amount of packet loss (in
153	  percent) for which it should be possible to reconstruct the full
154	  firmware image.
155
156	  This setting has significant influence on RAM usage.
157
158config LORAWAN_REMOTE_MULTICAST
159	bool "Remote Multicast Setup"
160	depends on LORAWAN_APP_CLOCK_SYNC
161	depends on !LORAWAN_NVM_NONE
162	help
163	  Enables the LoRaWAN Remote Multicast Setup service according to
164	  TS005-1.0.0 as published by the LoRa Alliance.
165
166	  The service is run automatically in the background. It is responsible
167	  for multicast session key exchange and setting up a class C session.
168	  The exchanged keys are stored in the non-volatile memory.
169
170	  The used default port for this service is 200.
171
172endif # LORAWAN_SERVICES
173