loramac.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Inria
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
22 #ifndef NET_LORAMAC_H
23 #define NET_LORAMAC_H
24 
25 #include <stdint.h>
26 #include <stdlib.h>
27 
28 #include "kernel_defines.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
44 #ifndef LORAMAC_DEV_EUI_DEFAULT
45 #define LORAMAC_DEV_EUI_DEFAULT { 0x00, 0x00, 0x00, 0x00, \
46  0x00, 0x00, 0x00, 0x00 }
47 #endif
48 
54 #ifndef LORAMAC_APP_EUI_DEFAULT
55 #define LORAMAC_APP_EUI_DEFAULT { 0x00, 0x00, 0x00, 0x00, \
56  0x00, 0x00, 0x00, 0x00 }
57 #endif
58 
64 #ifndef LORAMAC_APP_KEY_DEFAULT
65 #define LORAMAC_APP_KEY_DEFAULT { 0x00, 0x00, 0x00, 0x00, \
66  0x00, 0x00, 0x00, 0x00, \
67  0x00, 0x00, 0x00, 0x00, \
68  0x00, 0x00, 0x00, 0x00 }
69 #endif
70 
76 #ifndef LORAMAC_APP_SKEY_DEFAULT
77 #define LORAMAC_APP_SKEY_DEFAULT { 0x00, 0x00, 0x00, 0x00, \
78  0x00, 0x00, 0x00, 0x00, \
79  0x00, 0x00, 0x00, 0x00, \
80  0x00, 0x00, 0x00, 0x00 }
81 #endif
82 
88 #ifndef LORAMAC_NWK_SKEY_DEFAULT
89 #define LORAMAC_NWK_SKEY_DEFAULT { 0x00, 0x00, 0x00, 0x00, \
90  0x00, 0x00, 0x00, 0x00, \
91  0x00, 0x00, 0x00, 0x00, \
92  0x00, 0x00, 0x00, 0x00 }
93 #endif
94 
98 #ifndef LORAMAC_DEV_ADDR_DEFAULT
99 #define LORAMAC_DEV_ADDR_DEFAULT { 0x00, 0x00, 0x00, 0x00 }
100 #endif
101 
110 #if !IS_ACTIVE(CONFIG_LORAMAC_REGION_EU_868) \
111  && !IS_ACTIVE(CONFIG_LORAMAC_REGION_IN_865)
112 #define CONFIG_LORAMAC_REGION_EU_868 1
113 #endif
114 
118 #ifndef LORAMAC_DEFAULT_DEVICE_CLASS
119 #define LORAMAC_DEFAULT_DEVICE_CLASS (LORAMAC_CLASS_A)
120 #endif
121 
125 #ifndef LORAMAC_DEFAULT_NETID
126 #define LORAMAC_DEFAULT_NETID (1U)
127 #endif
128 
132 #ifndef LORAMAC_DEFAULT_PUBLIC_NETWORK
133 #define LORAMAC_DEFAULT_PUBLIC_NETWORK (true)
134 #endif
135 
138 #ifndef LORAMAC_DEFAULT_DR
139 #define LORAMAC_DEFAULT_DR (LORAMAC_DR_0)
140 #endif
141 
145 #ifndef LORAMAC_DEFAULT_TX_POWER
146 #define LORAMAC_DEFAULT_TX_POWER (LORAMAC_TX_PWR_1)
147 #endif
148 
152 #ifndef LORAMAC_DEFAULT_TX_PORT
153 #define LORAMAC_DEFAULT_TX_PORT (2U)
154 #endif
155 
159  #ifndef LORAMAC_DEFAULT_TX_MODE
160  #define LORAMAC_DEFAULT_TX_MODE (LORAMAC_TX_CNF)
161  #endif
162 
166 #ifndef LORAMAC_DEFAULT_TX_POWER
167 #define LORAMAC_DEFAULT_TX_POWER (LORAMAC_TX_PWR_1)
168 #endif
169 
173 #ifndef LORAMAC_DEFAULT_ADR
174 #define LORAMAC_DEFAULT_ADR (false)
175 #endif
176 
180 #ifndef LORAMAC_DEFAULT_RETX
181 #define LORAMAC_DEFAULT_RETX (5U)
182 #endif
183 
189 #ifndef LORAMAC_DEFAULT_LINKCHK
190 #define LORAMAC_DEFAULT_LINKCHK (0U)
191 #endif
192 
196 #ifndef LORAMAC_DEFAULT_RX1_DELAY
197 #define LORAMAC_DEFAULT_RX1_DELAY (1000U)
198 #endif
199 
203 #define LORAMAC_DEFAULT_RX2_DELAY (1000U + LORAMAC_DEFAULT_RX1_DELAY)
204 
208 #ifndef LORAMAC_DEFAULT_AR
209 #define LORAMAC_DEFAULT_AR (false)
210 #endif
211 
215 #ifndef LORAMAC_DEFAULT_RX2_DR
216 #if IS_ACTIVE(CONFIG_LORAMAC_REGION_EU_868)
217 #define LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_0)
218 #elif IS_ACTIVE(CONFIG_LORAMAC_REGION_IN_865)
219 #define LORAMAC_DEFAULT_RX2_DR (LORAMAC_DR_2)
220 #endif
221 #endif
222 
226 #ifndef LORAMAC_DEFAULT_RX2_FREQ
227 #if IS_ACTIVE(CONFIG_LORAMAC_REGION_EU_868)
228 #define LORAMAC_DEFAULT_RX2_FREQ (869525000UL)
229 #elif IS_ACTIVE(CONFIG_LORAMAC_REGION_IN_865)
230 #define LORAMAC_DEFAULT_RX2_FREQ (866550000UL)
231 #endif
232 #endif
233 
237 #ifndef LORAMAC_DEFAULT_JOIN_PROCEDURE
238 #define LORAMAC_DEFAULT_JOIN_PROCEDURE (LORAMAC_JOIN_OTAA)
239 #endif
240 
244 #ifndef LORAMAC_DEFAULT_JOIN_DELAY1
245 #define LORAMAC_DEFAULT_JOIN_DELAY1 (5U)
246 #endif
247 
251 #ifndef LORAMAC_DEFAULT_JOIN_DELAY2
252 #define LORAMAC_DEFAULT_JOIN_DELAY2 (6U)
253 #endif
254 
258 #ifndef LORAMAC_DEFAULT_MAX_FCNT_GAP
259 #define LORAMAC_DEFAULT_MAX_FCNT_GAP (16384U)
260 #endif
261 
265 #ifndef LORAMAC_DEFAULT_ADR_ACK_LIMIT
266 #define LORAMAC_DEFAULT_ADR_ACK_LIMIT (64U)
267 #endif
268 
272 #ifndef LORAMAC_DEFAULT_ADR_ACK_DELAY
273 #define LORAMAC_DEFAULT_ADR_ACK_DELAY (32U)
274 #endif
275 
279 #ifndef LORAMAC_DEFAULT_ADR_TIMEOUT
280 #define LORAMAC_DEFAULT_ADR_TIMEOUT (3U)
281 #endif
282 
286 #ifndef LORAMAC_DEFAULT_SYSTEM_MAX_RX_ERROR
287 #define LORAMAC_DEFAULT_SYSTEM_MAX_RX_ERROR (50)
288 #endif
289 
293 #ifndef LORAMAC_DEFAULT_MIN_RX_SYMBOLS
294 #define LORAMAC_DEFAULT_MIN_RX_SYMBOLS (12)
295 #endif
296 
305 #define LORAMAC_DEVEUI_LEN (8U)
306 
310 #define LORAMAC_DEVADDR_LEN (4U)
311 
315 #define LORAMAC_APPEUI_LEN (8U)
316 
320 #define LORAMAC_APPKEY_LEN (16U)
321 
325 #define LORAMAC_APPSKEY_LEN (16U)
326 
330 #define LORAMAC_NWKSKEY_LEN (16U)
331 
335 #define LORAMAC_PORT_MIN (1U)
336 
340 #define LORAMAC_PORT_MAX (223U)
341 
345 #define LORAMAC_APP_NONCE_LEN (3U)
346 
350 #define LORAMAC_NETWORK_ID_LEN (3U)
351 
361 typedef enum {
366 
370 typedef enum {
374 
378 typedef enum {
382 
389 typedef enum {
569 
576 typedef enum {
761  typedef struct {
762  uint32_t freq;
763  uint8_t index;
764  uint8_t bw;
765  uint8_t dr_min;
766  uint8_t dr_max;
767  uint8_t dcycle;
769 
770 #ifdef __cplusplus
771 }
772 #endif
773 
774 #endif /* NET_LORAMAC_H */
775 
LORAMAC_DR_15
@ LORAMAC_DR_15
Definition: loramac.h:567
LORAMAC_DR_0
@ LORAMAC_DR_0
Definition: loramac.h:402
LORAMAC_CLASS_C
@ LORAMAC_CLASS_C
Class C device.
Definition: loramac.h:364
LORAMAC_TX_UNCNF
@ LORAMAC_TX_UNCNF
Unconfirmable transmission mode.
Definition: loramac.h:380
LORAMAC_DR_11
@ LORAMAC_DR_11
Definition: loramac.h:523
LORAMAC_DR_8
@ LORAMAC_DR_8
Definition: loramac.h:490
loramac_channel_t::dr_max
uint8_t dr_max
Maximum datarate index.
Definition: loramac.h:766
LORAMAC_TX_CNF
@ LORAMAC_TX_CNF
Confirmable transmission mode.
Definition: loramac.h:379
LORAMAC_TX_PWR_2
@ LORAMAC_TX_PWR_2
Definition: loramac.h:611
kernel_defines.h
Common macros and compiler attributes/pragmas configuration.
LORAMAC_DR_6
@ LORAMAC_DR_6
Definition: loramac.h:468
LORAMAC_TX_PWR_15
@ LORAMAC_TX_PWR_15
Definition: loramac.h:754
LORAMAC_TX_PWR_9
@ LORAMAC_TX_PWR_9
Definition: loramac.h:688
loramac_channel_t::bw
uint8_t bw
Bandwidth index.
Definition: loramac.h:764
LORAMAC_TX_PWR_10
@ LORAMAC_TX_PWR_10
Definition: loramac.h:699
LORAMAC_DR_4
@ LORAMAC_DR_4
Definition: loramac.h:446
loramac_dr_idx_t
loramac_dr_idx_t
LoRaMAC datarate indexes.
Definition: loramac.h:389
LORAMAC_TX_PWR_1
@ LORAMAC_TX_PWR_1
Definition: loramac.h:600
LORAMAC_JOIN_ABP
@ LORAMAC_JOIN_ABP
Activation by personnalization.
Definition: loramac.h:372
LORAMAC_CLASS_A
@ LORAMAC_CLASS_A
Class A device.
Definition: loramac.h:362
loramac_channel_t::dr_min
uint8_t dr_min
Minimum datarate index.
Definition: loramac.h:765
loramac_channel_t::index
uint8_t index
Channel index in defined list.
Definition: loramac.h:763
LORAMAC_DR_3
@ LORAMAC_DR_3
Definition: loramac.h:435
LORAMAC_DR_10
@ LORAMAC_DR_10
Definition: loramac.h:512
loramac_channel_t::dcycle
uint8_t dcycle
Duty cycle to use on this channel (1 to 100)
Definition: loramac.h:767
LORAMAC_DR_5
@ LORAMAC_DR_5
Definition: loramac.h:457
LORAMAC_TX_PWR_11
@ LORAMAC_TX_PWR_11
Definition: loramac.h:710
LORAMAC_TX_PWR_12
@ LORAMAC_TX_PWR_12
Definition: loramac.h:721
LORAMAC_DR_2
@ LORAMAC_DR_2
Definition: loramac.h:424
loramac_tx_pwr_idx_t
loramac_tx_pwr_idx_t
LoRaMAC transmission power indexes.
Definition: loramac.h:576
LORAMAC_TX_PWR_5
@ LORAMAC_TX_PWR_5
Definition: loramac.h:644
LORAMAC_TX_PWR_7
@ LORAMAC_TX_PWR_7
Definition: loramac.h:666
loramac_join_mode_t
loramac_join_mode_t
LoRaMAC network join procedure type.
Definition: loramac.h:370
LORAMAC_DR_7
@ LORAMAC_DR_7
Definition: loramac.h:479
LORAMAC_TX_PWR_4
@ LORAMAC_TX_PWR_4
Definition: loramac.h:633
LORAMAC_TX_PWR_13
@ LORAMAC_TX_PWR_13
Definition: loramac.h:732
LORAMAC_DR_14
@ LORAMAC_DR_14
Definition: loramac.h:556
loramac_class_t
loramac_class_t
Device class.
Definition: loramac.h:361
LORAMAC_TX_PWR_14
@ LORAMAC_TX_PWR_14
Definition: loramac.h:743
LORAMAC_TX_PWR_6
@ LORAMAC_TX_PWR_6
Definition: loramac.h:655
LORAMAC_DR_13
@ LORAMAC_DR_13
Definition: loramac.h:545
LORAMAC_CLASS_B
@ LORAMAC_CLASS_B
Class B device.
Definition: loramac.h:363
LORAMAC_TX_PWR_3
@ LORAMAC_TX_PWR_3
Definition: loramac.h:622
loramac_tx_mode_t
loramac_tx_mode_t
LoRaMAC transmission mode.
Definition: loramac.h:378
loramac_channel_t
A LoRaMAC network channel.
Definition: loramac.h:761
LORAMAC_TX_PWR_0
@ LORAMAC_TX_PWR_0
Definition: loramac.h:587
loramac_channel_t::freq
uint32_t freq
Center frequency in Hz.
Definition: loramac.h:762
LORAMAC_DR_9
@ LORAMAC_DR_9
Definition: loramac.h:501
LORAMAC_TX_PWR_8
@ LORAMAC_TX_PWR_8
Definition: loramac.h:677
LORAMAC_DR_12
@ LORAMAC_DR_12
Definition: loramac.h:534
LORAMAC_JOIN_OTAA
@ LORAMAC_JOIN_OTAA
Other-the-air activation.
Definition: loramac.h:371
LORAMAC_DR_1
@ LORAMAC_DR_1
Definition: loramac.h:413