| SX126x-Arduino 2.0.1

LoRaMac-definitions.h
Go to the documentation of this file.
1 /*
2 / _____) _ | |
3 ( (____ _____ ____ _| |_ _____ ____| |__
4 \____ \| ___ | (_ _) ___ |/ ___) _ \
5 _____) ) ____| | | || |_| ____( (___| | | |
6 (______/|_____)_|_|_| \__)_____)\____)_| |_|
7 (C)2013 Semtech
8
9 Description: LoRa MAC layer global definitions
10
11 License: Revised BSD License, see LICENSE.TXT file include in the project
12
13 Maintainer: Miguel Luis and Gregory Cristian
14 */
15 #ifndef __LORAMAC_BOARD_H__
16 #define __LORAMAC_BOARD_H__
17
18 extern "C"
19 {
20
27 #define LC(channelIndex) (uint16_t)(1 << (channelIndex - 1))
28
29 #if defined(USE_BAND_433)
30
34 #define LORA_MAX_NB_CHANNELS 16
35
39 #define LORAMAC_TX_MIN_DATARATE DR_0
40
44 #define LORAMAC_TX_MAX_DATARATE DR_7
45
49 #define LORAMAC_RX_MIN_DATARATE DR_0
50
54 #define LORAMAC_RX_MAX_DATARATE DR_7
55
59 #define LORAMAC_DEFAULT_DATARATE DR_0
60
64 #define LORAMAC_MIN_RX1_DR_OFFSET 0
65
69 #define LORAMAC_MAX_RX1_DR_OFFSET 5
70
74 #define LORAMAC_MIN_TX_POWER TX_POWER_M5_DBM
75
79 #define LORAMAC_MAX_TX_POWER TX_POWER_10_DBM
80
84 #define LORAMAC_DEFAULT_TX_POWER TX_POWER_10_DBM
85
89 #define TX_POWER_10_DBM 0
90 #define TX_POWER_07_DBM 1
91 #define TX_POWER_04_DBM 2
92 #define TX_POWER_01_DBM 3
93 #define TX_POWER_M2_DBM 4
94 #define TX_POWER_M5_DBM 5
95
99 #define DR_0 0 // SF12 - BW125
100 #define DR_1 1 // SF11 - BW125
101 #define DR_2 2 // SF10 - BW125
102 #define DR_3 3 // SF9 - BW125
103 #define DR_4 4 // SF8 - BW125
104 #define DR_5 5 // SF7 - BW125
105 #define DR_6 6 // SF7 - BW250
106 #define DR_7 7 // FSK
107
111 #if (LORAMAC_DEFAULT_DATARATE > DR_5)
112 #error "A default DR higher than DR_5 may lead to connectivity loss."
113 #endif
114
118 // Channel = { Frequency [Hz], Datarate }
119 #define RX_WND_2_CHANNEL \
120 { \
121 434665000, DR_0 \
122 }
123
127 #define LORA_MAX_NB_BANDS 1
128
129 // Band = { DutyCycle, TxMaxPower, LastTxDoneTime, TimeOff }
130 #define BAND0 \
131 { \
132 100, TX_POWER_10_DBM, 0, 0 \
133 } // 1.0 %
134
138 // Channel = { Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
139 #define LC1 \
140 { \
141 433175000, {((DR_5 << 4) | DR_0)}, 0 \
142 }
143 #define LC2 \
144 { \
145 433375000, {((DR_5 << 4) | DR_0)}, 0 \
146 }
147 #define LC3 \
148 { \
149 433575000, {((DR_5 << 4) | DR_0)}, 0 \
150 }
151
155 #define JOIN_CHANNELS (uint16_t)(LC(1) | LC(2) | LC(3))
156
157 #elif defined(USE_BAND_470)
158
162 #define LORA_MAX_NB_CHANNELS 96
163
167 #define LORAMAC_TX_MIN_DATARATE DR_0
168
172 #define LORAMAC_TX_MAX_DATARATE DR_5
173
177 #define LORAMAC_RX_MIN_DATARATE DR_0
178
182 #define LORAMAC_RX_MAX_DATARATE DR_5
183
187 #define LORAMAC_DEFAULT_DATARATE DR_0
188
192 #define LORAMAC_MIN_RX1_DR_OFFSET 0
193
197 #define LORAMAC_MAX_RX1_DR_OFFSET 3
198
202 #define LORAMAC_MIN_TX_POWER TX_POWER_2_DBM
203
207 #define LORAMAC_MAX_TX_POWER TX_POWER_17_DBM
208
212 #define LORAMAC_DEFAULT_TX_POWER TX_POWER_14_DBM
213
217 #define TX_POWER_17_DBM 0
218 #define TX_POWER_16_DBM 1
219 #define TX_POWER_14_DBM 2
220 #define TX_POWER_12_DBM 3
221 #define TX_POWER_10_DBM 4
222 #define TX_POWER_7_DBM 5
223 #define TX_POWER_5_DBM 6
224 #define TX_POWER_2_DBM 7
225
229 #define DR_0 0 // SF12 - BW125 |
230 #define DR_1 1 // SF11 - BW125 |
231 #define DR_2 2 // SF10 - BW125 |
232 #define DR_3 3 // SF9 - BW125 |
233 #define DR_4 4 // SF8 - BW125 |
234 #define DR_5 5 // SF7 - BW125 |
235
239 // Channel = { Frequency [Hz], Datarate }
240 #define RX_WND_2_CHANNEL \
241 { \
242 505300000, DR_0 \
243 }
244
248 #define LORA_MAX_NB_BANDS 1
249
250 // Band = { DutyCycle, TxMaxPower, LastTxDoneTime, TimeOff }
251 #define BAND0 \
252 { \
253 1, TX_POWER_17_DBM, 0, 0 \
254 } // 100.0 %
255
256 #elif defined(USE_BAND_780)
257
261 #define LORA_MAX_NB_CHANNELS 16
262
266 #define LORAMAC_TX_MIN_DATARATE DR_0
267
271 #define LORAMAC_TX_MAX_DATARATE DR_7
272
276 #define LORAMAC_RX_MIN_DATARATE DR_0
277
281 #define LORAMAC_RX_MAX_DATARATE DR_7
282
286 #define LORAMAC_DEFAULT_DATARATE DR_0
287
291 #define LORAMAC_MIN_RX1_DR_OFFSET 0
292
296 #define LORAMAC_MAX_RX1_DR_OFFSET 5
297
301 #define LORAMAC_MIN_TX_POWER TX_POWER_M5_DBM
302
306 #define LORAMAC_MAX_TX_POWER TX_POWER_10_DBM
307
311 #define LORAMAC_DEFAULT_TX_POWER TX_POWER_10_DBM
312
316 #define TX_POWER_10_DBM 0
317 #define TX_POWER_07_DBM 1
318 #define TX_POWER_04_DBM 2
319 #define TX_POWER_01_DBM 3
320 #define TX_POWER_M2_DBM 4
321 #define TX_POWER_M5_DBM 5
322
326 #define DR_0 0 // SF12 - BW125
327 #define DR_1 1 // SF11 - BW125
328 #define DR_2 2 // SF10 - BW125
329 #define DR_3 3 // SF9 - BW125
330 #define DR_4 4 // SF8 - BW125
331 #define DR_5 5 // SF7 - BW125
332 #define DR_6 6 // SF7 - BW250
333 #define DR_7 7 // FSK
334
338 #if (LORAMAC_DEFAULT_DATARATE > DR_5)
339 #error "A default DR higher than DR_5 may lead to connectivity loss."
340 #endif
341
345 // Channel = { Frequency [Hz], Datarate }
346 #define RX_WND_2_CHANNEL \
347 { \
348 786000000, DR_0 \
349 }
350
354 #define LORA_MAX_NB_BANDS 1
355
356 // Band = { DutyCycle, TxMaxPower, LastTxDoneTime, TimeOff }
357 #define BAND0 \
358 { \
359 100, TX_POWER_10_DBM, 0, 0 \
360 } // 1.0 %
361
365 // Channel = { Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
366 #define LC1 \
367 { \
368 779500000, {((DR_5 << 4) | DR_0)}, 0 \
369 }
370 #define LC2 \
371 { \
372 779700000, {((DR_5 << 4) | DR_0)}, 0 \
373 }
374 #define LC3 \
375 { \
376 779900000, {((DR_5 << 4) | DR_0)}, 0 \
377 }
378
382 #define JOIN_CHANNELS (uint16_t)(LC(1) | LC(2) | LC(3))
383
384 #elif defined(USE_BAND_868)
385
389 #define LORA_MAX_NB_CHANNELS 16
390
394 #define LORAMAC_TX_MIN_DATARATE DR_0
395
399 #define LORAMAC_TX_MAX_DATARATE DR_7
400
404 #define LORAMAC_RX_MIN_DATARATE DR_0
405
409 #define LORAMAC_RX_MAX_DATARATE DR_7
410
414 #define LORAMAC_DEFAULT_DATARATE DR_0
415
419 #define LORAMAC_MIN_RX1_DR_OFFSET 0
420
424 #define LORAMAC_MAX_RX1_DR_OFFSET 5
425
429 #define LORAMAC_MIN_TX_POWER TX_POWER_02_DBM
430
434 #define LORAMAC_MAX_TX_POWER TX_POWER_20_DBM
435
439 #define LORAMAC_DEFAULT_TX_POWER TX_POWER_14_DBM
440
444 #define TX_POWER_20_DBM 0
445 #define TX_POWER_14_DBM 1
446 #define TX_POWER_11_DBM 2
447 #define TX_POWER_08_DBM 3
448 #define TX_POWER_05_DBM 4
449 #define TX_POWER_02_DBM 5
450
454 #define DR_0 0 // SF12 - BW125
455 #define DR_1 1 // SF11 - BW125
456 #define DR_2 2 // SF10 - BW125
457 #define DR_3 3 // SF9 - BW125
458 #define DR_4 4 // SF8 - BW125
459 #define DR_5 5 // SF7 - BW125
460 #define DR_6 6 // SF7 - BW250
461 #define DR_7 7 // FSK
462
466 #if (LORAMAC_DEFAULT_DATARATE > DR_5)
467 #error "A default DR higher than DR_5 may lead to connectivity loss."
468 #endif
469
473 // Channel = { Frequency [Hz], Datarate }
474 #define RX_WND_2_CHANNEL \
475 { \
476 869525000, DR_0 \
477 }
478
482 #define LORA_MAX_NB_BANDS 5
483
487 typedef enum
488 {
489 BAND_G1_0,
490 BAND_G1_1,
491 BAND_G1_2,
492 BAND_G1_3,
493 BAND_G1_4,
494 } BandId_t;
495
496 // Band = { DutyCycle, TxMaxPower, LastTxDoneTime, TimeOff }
497 #define BAND0 \
498 { \
499 100, TX_POWER_14_DBM, 0, 0 \
500 } // 1.0 %
501 #define BAND1 \
502 { \
503 100, TX_POWER_14_DBM, 0, 0 \
504 } // 1.0 %
505 #define BAND2 \
506 { \
507 1000, TX_POWER_14_DBM, 0, 0 \
508 } // 0.1 %
509 #define BAND3 \
510 { \
511 10, TX_POWER_14_DBM, 0, 0 \
512 } // 10.0 %
513 #define BAND4 \
514 { \
515 100, TX_POWER_14_DBM, 0, 0 \
516 } // 1.0 %
517
521 // Channel = { Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
522 #define LC1 \
523 { \
524 868100000, {((DR_5 << 4) | DR_0)}, 1 \
525 }
526 #define LC2 \
527 { \
528 868300000, {((DR_5 << 4) | DR_0)}, 1 \
529 }
530 #define LC3 \
531 { \
532 868500000, {((DR_5 << 4) | DR_0)}, 1 \
533 }
534
538 #define JOIN_CHANNELS (uint16_t)(LC(1) | LC(2) | LC(3))
539
540 #elif defined(USE_BAND_915) || defined(USE_BAND_915_HYBRID)
541
545 #define LORA_MAX_NB_CHANNELS 72
546
550 #define LORAMAC_TX_MIN_DATARATE DR_0
551
555 #define LORAMAC_TX_MAX_DATARATE DR_4
556
560 #define LORAMAC_RX_MIN_DATARATE DR_8
561
565 #define LORAMAC_RX_MAX_DATARATE DR_13
566
570 #define LORAMAC_DEFAULT_DATARATE DR_0
571
575 #define LORAMAC_MIN_RX1_DR_OFFSET 0
576
580 #define LORAMAC_MAX_RX1_DR_OFFSET 3
581
585 #define LORAMAC_MIN_TX_POWER TX_POWER_10_DBM
586
590 #define LORAMAC_MAX_TX_POWER TX_POWER_30_DBM
591
595 #define LORAMAC_DEFAULT_TX_POWER TX_POWER_20_DBM
596
600 #define TX_POWER_30_DBM 0
601 #define TX_POWER_28_DBM 1
602 #define TX_POWER_26_DBM 2
603 #define TX_POWER_24_DBM 3
604 #define TX_POWER_22_DBM 4
605 #define TX_POWER_20_DBM 5
606 #define TX_POWER_18_DBM 6
607 #define TX_POWER_16_DBM 7
608 #define TX_POWER_14_DBM 8
609 #define TX_POWER_12_DBM 9
610 #define TX_POWER_10_DBM 10
611
615 #define DR_0 0 // SF10 - BW125 |
616 #define DR_1 1 // SF9 - BW125 |
617 #define DR_2 2 // SF8 - BW125 +-> Up link
618 #define DR_3 3 // SF7 - BW125 |
619 #define DR_4 4 // SF8 - BW500 |
620 #define DR_5 5 // RFU
621 #define DR_6 6 // RFU
622 #define DR_7 7 // RFU
623 #define DR_8 8 // SF12 - BW500 |
624 #define DR_9 9 // SF11 - BW500 |
625 #define DR_10 10 // SF10 - BW500 |
626 #define DR_11 11 // SF9 - BW500 |
627 #define DR_12 12 // SF8 - BW500 +-> Down link
628 #define DR_13 13 // SF7 - BW500 |
629 #define DR_14 14 // RFU |
630 #define DR_15 15 // RFU |
631
635 // Channel = { Frequency [Hz], Datarate }
636 #define RX_WND_2_CHANNEL \
637 { \
638 923300000, DR_8 \
639 }
640
644 #define LORA_MAX_NB_BANDS 1
645
646 // Band = { DutyCycle, TxMaxPower, LastTxDoneTime, TimeOff }
647 #define BAND0 \
648 { \
649 1, TX_POWER_20_DBM, 0, 0 \
650 } // 100.0 %
651
655 // Channel = { Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
656 /*
657 * US band channels are initialized using a loop in LoRaMacInit function
658 * \code
659 * // 125 kHz channels
660 * for( uint8_t i = 0; i < LORA_MAX_NB_CHANNELS - 8; i++ )
661 * {
662 * Channels[i].Frequency = 902.3e6 + i * 200e3;
663 * Channels[i].DrRange.Value = ( DR_3 << 4 ) | DR_0;
664 * Channels[i].Band = 0;
665 * }
666 * // 500 kHz channels
667 * for( uint8_t i = LORA_MAX_NB_CHANNELS - 8; i < LORA_MAX_NB_CHANNELS; i++ )
668 * {
669 * Channels[i].Frequency = 903.0e6 + ( i - ( LORA_MAX_NB_CHANNELS - 8 ) ) * 1.6e6;
670 * Channels[i].DrRange.Value = ( DR_4 << 4 ) | DR_4;
671 * Channels[i].Band = 0;
672 * }
673 * \endcode
674 */
675 #else
676 #error "Please define a frequency band in the compiler options."
677 #endif
678 };
679 #endif // __LORAMAC_BOARD_H__