41 #ifndef CONFIG_LORAMAC_DEV_EUI_DEFAULT
42 #define CONFIG_LORAMAC_DEV_EUI_DEFAULT "0000000000000000"
50 #ifndef CONFIG_LORAMAC_JOIN_EUI_DEFAULT
51 #define CONFIG_LORAMAC_JOIN_EUI_DEFAULT "0000000000000000"
59 #ifndef CONFIG_LORAMAC_APP_EUI_DEFAULT
60 #define CONFIG_LORAMAC_APP_EUI_DEFAULT "0000000000000000"
68 #ifndef CONFIG_LORAMAC_APP_KEY_DEFAULT
69 #define CONFIG_LORAMAC_APP_KEY_DEFAULT "00000000000000000000000000000000"
77 #ifndef CONFIG_LORAMAC_NWK_KEY_DEFAULT
78 #define CONFIG_LORAMAC_NWK_KEY_DEFAULT "00000000000000000000000000000000"
86 #ifndef CONFIG_LORAMAC_APP_SKEY_DEFAULT
87 #define CONFIG_LORAMAC_APP_SKEY_DEFAULT "00000000000000000000000000000000"
95 #ifndef CONFIG_LORAMAC_NWK_SKEY_DEFAULT
96 #define CONFIG_LORAMAC_NWK_SKEY_DEFAULT "00000000000000000000000000000000"
104 #ifndef CONFIG_LORAMAC_FNWKSINT_KEY_DEFAULT
105 #define CONFIG_LORAMAC_FNWKSINT_KEY_DEFAULT "00000000000000000000000000000000"
113 #ifndef CONFIG_LORAMAC_SNWKSINT_KEY_DEFAULT
114 #define CONFIG_LORAMAC_SNWKSINT_KEY_DEFAULT "00000000000000000000000000000000"
122 #ifndef CONFIG_LORAMAC_NWKSENC_KEY_DEFAULT
123 #define CONFIG_LORAMAC_NWKSENC_KEY_DEFAULT "00000000000000000000000000000000"
129 #ifndef CONFIG_LORAMAC_DEV_ADDR_DEFAULT
130 #define CONFIG_LORAMAC_DEV_ADDR_DEFAULT "00000000"
136 #if !IS_ACTIVE(CONFIG_LORAMAC_REGION_EU_868) \
137 && !IS_ACTIVE(CONFIG_LORAMAC_REGION_IN_865)
138 #define CONFIG_LORAMAC_REGION_EU_868 1
153 #if IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_DEVICE_CLASS_A)
154 #define CONFIG_LORAMAC_DEFAULT_DEVICE_CLASS (LORAMAC_CLASS_A)
155 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_DEVICE_CLASS_B)
156 #define CONFIG_LORAMAC_DEFAULT_DEVICE_CLASS (LORAMAC_CLASS_B)
157 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_DEVICE_CLASS_C)
158 #define CONFIG_LORAMAC_DEFAULT_DEVICE_CLASS (LORAMAC_CLASS_C)
161 #ifndef CONFIG_LORAMAC_DEFAULT_DEVICE_CLASS
162 #define CONFIG_LORAMAC_DEFAULT_DEVICE_CLASS (LORAMAC_CLASS_A)
173 #ifndef CONFIG_LORAMAC_DEFAULT_NETID
174 #define CONFIG_LORAMAC_DEFAULT_NETID (1U)
186 #define CONFIG_LORAMAC_DEFAULT_PRIVATE_NETWORK
198 #if IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_DR_0)
199 #define CONFIG_LORAMAC_DEFAULT_DR (LORAMAC_DR_0)
200 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_DR_1)
201 #define CONFIG_LORAMAC_DEFAULT_DR (LORAMAC_DR_1)
202 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_DR_2)
203 #define CONFIG_LORAMAC_DEFAULT_DR (LORAMAC_DR_2)
204 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_DR_3)
205 #define CONFIG_LORAMAC_DEFAULT_DR (LORAMAC_DR_3)
206 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_DR_4)
207 #define CONFIG_LORAMAC_DEFAULT_DR (LORAMAC_DR_4)
208 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_DR_5)
209 #define CONFIG_LORAMAC_DEFAULT_DR (LORAMAC_DR_5)
210 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_DR_6)
211 #define CONFIG_LORAMAC_DEFAULT_DR (LORAMAC_DR_6)
212 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_DR_7)
213 #define CONFIG_LORAMAC_DEFAULT_DR (LORAMAC_DR_7)
214 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_DR_8)
215 #define CONFIG_LORAMAC_DEFAULT_DR (LORAMAC_DR_8)
216 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_DR_9)
217 #define CONFIG_LORAMAC_DEFAULT_DR (LORAMAC_DR_9)
218 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_DR_10)
219 #define CONFIG_LORAMAC_DEFAULT_DR (LORAMAC_DR_10)
220 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_DR_11)
221 #define CONFIG_LORAMAC_DEFAULT_DR (LORAMAC_DR_11)
222 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_DR_12)
223 #define CONFIG_LORAMAC_DEFAULT_DR (LORAMAC_DR_12)
224 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_DR_13)
225 #define CONFIG_LORAMAC_DEFAULT_DR (LORAMAC_DR_13)
226 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_DR_14)
227 #define CONFIG_LORAMAC_DEFAULT_DR (LORAMAC_DR_14)
228 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_DR_15)
229 #define CONFIG_LORAMAC_DEFAULT_DR (LORAMAC_DR_15)
232 #ifndef CONFIG_LORAMAC_DEFAULT_DR
233 #define CONFIG_LORAMAC_DEFAULT_DR (LORAMAC_DR_0)
242 #if IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_TX_POWER_0)
243 #define CONFIG_LORAMAC_DEFAULT_TX_POWER (LORAMAC_TX_PWR_0)
244 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_TX_POWER_1)
245 #define CONFIG_LORAMAC_DEFAULT_TX_POWER (LORAMAC_TX_PWR_1)
246 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_TX_POWER_2)
247 #define CONFIG_LORAMAC_DEFAULT_TX_POWER (LORAMAC_TX_PWR_2)
248 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_TX_POWER_3)
249 #define CONFIG_LORAMAC_DEFAULT_TX_POWER (LORAMAC_TX_PWR_3)
250 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_TX_POWER_4)
251 #define CONFIG_LORAMAC_DEFAULT_TX_POWER (LORAMAC_TX_PWR_4)
252 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_TX_POWER_5)
253 #define CONFIG_LORAMAC_DEFAULT_TX_POWER (LORAMAC_TX_PWR_5)
254 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_TX_POWER_6)
255 #define CONFIG_LORAMAC_DEFAULT_TX_POWER (LORAMAC_TX_PWR_6)
256 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_TX_POWER_7)
257 #define CONFIG_LORAMAC_DEFAULT_TX_POWER (LORAMAC_TX_PWR_7)
258 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_TX_POWER_8)
259 #define CONFIG_LORAMAC_DEFAULT_TX_POWER (LORAMAC_TX_PWR_8)
260 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_TX_POWER_9)
261 #define CONFIG_LORAMAC_DEFAULT_TX_POWER (LORAMAC_TX_PWR_9)
262 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_TX_POWER_10)
263 #define CONFIG_LORAMAC_DEFAULT_TX_POWER (LORAMAC_TX_PWR_10)
264 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_TX_POWER_11)
265 #define CONFIG_LORAMAC_DEFAULT_TX_POWER (LORAMAC_TX_PWR_11)
266 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_TX_POWER_12)
267 #define CONFIG_LORAMAC_DEFAULT_TX_POWER (LORAMAC_TX_PWR_12)
268 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_TX_POWER_13)
269 #define CONFIG_LORAMAC_DEFAULT_TX_POWER (LORAMAC_TX_PWR_13)
270 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_TX_POWER_14)
271 #define CONFIG_LORAMAC_DEFAULT_TX_POWER (LORAMAC_TX_PWR_14)
272 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_TX_POWER_15)
273 #define CONFIG_LORAMAC_DEFAULT_TX_POWER (LORAMAC_TX_PWR_15)
276 #ifndef CONFIG_LORAMAC_DEFAULT_TX_POWER
277 #define CONFIG_LORAMAC_DEFAULT_TX_POWER (LORAMAC_TX_PWR_1)
289 #ifndef CONFIG_LORAMAC_DEFAULT_TX_PORT
290 #define CONFIG_LORAMAC_DEFAULT_TX_PORT (2U)
301 #if IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_TX_MODE_CNF)
302 #define CONFIG_LORAMAC_DEFAULT_TX_MODE (LORAMAC_TX_CNF)
303 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_TX_MODE_UNCNF)
304 #define CONFIG_LORAMAC_DEFAULT_TX_MODE (LORAMAC_TX_UNCNF)
307 #ifndef CONFIG_LORAMAC_DEFAULT_TX_MODE
308 #define CONFIG_LORAMAC_DEFAULT_TX_MODE (LORAMAC_TX_CNF)
322 #ifndef CONFIG_LORAMAC_DEFAULT_REDUNDANCY
323 #define CONFIG_LORAMAC_DEFAULT_REDUNDANCY (0U)
335 #define CONFIG_LORAMAC_DEFAULT_ADR
344 #ifndef CONFIG_LORAMAC_DEFAULT_RETX
345 #define CONFIG_LORAMAC_DEFAULT_RETX (5U)
356 #ifndef CONFIG_LORAMAC_DEFAULT_LINKCHK
357 #define CONFIG_LORAMAC_DEFAULT_LINKCHK (0U)
366 #ifndef CONFIG_LORAMAC_DEFAULT_RX1_DELAY
367 #define CONFIG_LORAMAC_DEFAULT_RX1_DELAY (1000U)
376 #if IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_0)
377 #define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_0)
378 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_1)
379 #define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_1)
380 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_2)
381 #define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_2)
382 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_3)
383 #define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_3)
384 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_4)
385 #define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_4)
386 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_5)
387 #define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_5)
388 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_6)
389 #define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_6)
390 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_7)
391 #define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_7)
392 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_8)
393 #define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_8)
394 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_9)
395 #define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_9)
396 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_10)
397 #define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_10)
398 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_11)
399 #define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_11)
400 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_12)
401 #define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_12)
402 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_13)
403 #define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_13)
404 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_14)
405 #define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_14)
406 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_RX2_DR_15)
407 #define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_15)
410 #ifndef CONFIG_LORAMAC_DEFAULT_RX2_DR
411 #if IS_ACTIVE(CONFIG_LORAMAC_REGION_EU_868)
412 #define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_0)
413 #elif IS_ACTIVE(CONFIG_LORAMAC_REGION_IN_865)
414 #define CONFIG_LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_2)
421 #ifndef CONFIG_LORAMAC_DEFAULT_RX2_FREQ
422 #if IS_ACTIVE(CONFIG_LORAMAC_REGION_EU_868)
423 #define CONFIG_LORAMAC_DEFAULT_RX2_FREQ (869525000UL)
424 #elif IS_ACTIVE(CONFIG_LORAMAC_REGION_IN_865)
425 #define CONFIG_LORAMAC_DEFAULT_RX2_FREQ (866550000UL)
439 #if IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_JOIN_PROCEDURE_OTAA)
440 #define CONFIG_LORAMAC_DEFAULT_JOIN_PROCEDURE (LORAMAC_JOIN_OTAA)
441 #elif IS_ACTIVE(CONFIG_LORAMAC_DEFAULT_JOIN_PROCEDURE_ABP)
442 #define CONFIG_LORAMAC_DEFAULT_JOIN_PROCEDURE (LORAMAC_JOIN_ABP)
445 #ifndef CONFIG_LORAMAC_DEFAULT_JOIN_PROCEDURE
446 #define CONFIG_LORAMAC_DEFAULT_JOIN_PROCEDURE (LORAMAC_JOIN_OTAA)
456 #ifndef CONFIG_LORAMAC_DEFAULT_JOIN_DELAY1
457 #define CONFIG_LORAMAC_DEFAULT_JOIN_DELAY1 (5U)
467 #ifndef CONFIG_LORAMAC_DEFAULT_JOIN_DELAY2
468 #define CONFIG_LORAMAC_DEFAULT_JOIN_DELAY2 (6U)
477 #ifndef CONFIG_LORAMAC_DEFAULT_MAX_FCNT_GAP
478 #define CONFIG_LORAMAC_DEFAULT_MAX_FCNT_GAP (16384U)
488 #ifndef CONFIG_LORAMAC_DEFAULT_SYSTEM_MAX_RX_ERROR
489 #define CONFIG_LORAMAC_DEFAULT_SYSTEM_MAX_RX_ERROR (50)
500 #ifndef CONFIG_LORAMAC_DEFAULT_MIN_RX_SYMBOLS
501 #define CONFIG_LORAMAC_DEFAULT_MIN_RX_SYMBOLS (12)
512 #ifndef LORAMAC_DEFAULT_ADR_ACK_LIMIT
513 #define LORAMAC_DEFAULT_ADR_ACK_LIMIT (64U)
521 #ifndef LORAMAC_DEFAULT_ADR_ACK_DELAY
522 #define LORAMAC_DEFAULT_ADR_ACK_DELAY (32U)
530 #ifndef LORAMAC_DEFAULT_ADR_TIMEOUT
531 #define LORAMAC_DEFAULT_ADR_TIMEOUT (3U)
537 #define LORAMAC_DEFAULT_RX2_DELAY (1000U + CONFIG_LORAMAC_DEFAULT_RX1_DELAY)
546 #define LORAMAC_DEVEUI_LEN (8U)
551 #define LORAMAC_DEVADDR_LEN (4U)
556 #define LORAMAC_APPEUI_LEN (8U)
561 #define LORAMAC_JOINEUI_LEN (8U)
566 #define LORAMAC_APPKEY_LEN (16U)
571 #define LORAMAC_NWKKEY_LEN (16U)
576 #define LORAMAC_APPSKEY_LEN (16U)
581 #define LORAMAC_NWKSKEY_LEN (16U)
586 #define LORAMAC_FNWKSINTKEY_LEN (16U)
591 #define LORAMAC_SNWKSINTKEY_LEN (16U)
596 #define LORAMAC_NWKSENCKEY_LEN (16U)
601 #define LORAMAC_JSINTKEY_LEN (16U)
606 #define LORAMAC_JSENCKEY_LEN (16U)
611 #define LORAMAC_JSINTKEY_LEN (16U)
616 #define LORAMAC_PORT_MIN (1U)
621 #define LORAMAC_PORT_MAX (223U)
626 #define LORAMAC_APP_NONCE_LEN (3U)
631 #define LORAMAC_JOIN_NONCE_LEN (3U)
636 #define LORAMAC_NETWORK_ID_LEN (3U)
643 #if defined(REGION_AU915) || defined(REGION_CN470) || defined(REGION_US915) || defined(REGION_US915_HYBRID) || defined(REGION_AS923)
644 #define LORAMAC_CHANNELS_MASK_LEN (6U)
646 #define LORAMAC_CHANNELS_MASK_LEN (1U)
1081 const uint8_t _K[6][4] = {
1090 uint32_t t_sym = 1 << (15 - dr);
1091 uint32_t t_preamble = (t_sym << 3) + (t_sym << 2) + (t_sym >> 2);
1094 uint8_t n0 = _K[index][0];
1095 uint32_t nb_symbols;
1097 uint8_t offset = _K[index][1];
1099 if (pkt_len < offset) {
1100 nb_symbols = 8 + n0 * (cr + 4);
1103 uint8_t c1 = _K[index][2];
1104 uint8_t c2 = _K[index][3];
1105 uint8_t pos = (pkt_len - offset) % (c1 + c2);
1106 uint8_t cycle = (pkt_len - offset) / (c1 + c2);
1107 nb_symbols = 8 + (n0 + 2 * cycle + 1 + (pos > (c1 - 1))) * (cr + 4);
1110 uint32_t t_payload = t_sym * nb_symbols;
1112 return t_preamble + t_payload;
POSIX.1-2008 compliant version of the assert macro.
#define assert(cond)
abort the program if assertion is false
loramac_join_mode_t
LoRaMAC network join procedure type.
loramac_tx_mode_t
LoRaMAC transmission mode.
loramac_dr_idx_t
LoRaMAC datarate indexes.
static uint32_t lora_time_on_air(size_t pkt_len, loramac_dr_idx_t dr, uint8_t cr)
Compute the time on air of a LoRa packet.
loramac_class_t
Device class.
loramac_tx_pwr_idx_t
LoRaMAC transmission power indexes.
@ LORAMAC_JOIN_ABP
Activation by personnalization.
@ LORAMAC_JOIN_OTAA
Other-the-air activation.
@ LORAMAC_TX_CNF
Confirmable transmission mode.
@ LORAMAC_TX_UNCNF
Unconfirmable transmission mode.
@ LORAMAC_CLASS_C
Class C device.
@ LORAMAC_CLASS_B
Class B device.
@ LORAMAC_CLASS_A
Class A device.
Common macros and compiler attributes/pragmas configuration.
A LoRaMAC network channel.
uint8_t dr_max
Maximum datarate index.
uint8_t index
Channel index in defined list.
uint8_t bw
Bandwidth index.
uint8_t dcycle
Duty cycle to use on this channel (1 to 100)
uint32_t freq
Center frequency in Hz.
uint8_t dr_min
Minimum datarate index.