Christopher De Bank / LoRaWAN-lib

Fork of LoRaWAN-lib by Semtech

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LoRaMac-definitions.h Source File

LoRaMac-definitions.h

00001 /*
00002  / _____)             _              | |
00003 ( (____  _____ ____ _| |_ _____  ____| |__
00004  \____ \| ___ |    (_   _) ___ |/ ___)  _ \
00005  _____) ) ____| | | || |_| ____( (___| | | |
00006 (______/|_____)_|_|_| \__)_____)\____)_| |_|
00007     (C)2013 Semtech
00008 
00009 Description: LoRa MAC layer global definitions
00010 
00011 License: Revised BSD License, see LICENSE.TXT file include in the project
00012 
00013 Maintainer: Miguel Luis and Gregory Cristian
00014 */
00015 #ifndef __LORAMAC_BOARD_H__
00016 #define __LORAMAC_BOARD_H__
00017 
00018 /*!
00019  * Returns individual channel mask
00020  *
00021  * \param[IN] channelIndex Channel index 1 based
00022  * \retval channelMask
00023  */
00024 #define LC( channelIndex )            ( uint16_t )( 1 << ( channelIndex - 1 ) )
00025 
00026 #if defined( USE_BAND_433 )
00027 
00028 /*!
00029  * LoRaMac maximum number of channels
00030  */
00031 #define LORA_MAX_NB_CHANNELS                        16
00032 
00033 /*!
00034  * Minimal datarate that can be used by the node
00035  */
00036 #define LORAMAC_TX_MIN_DATARATE                     DR_0
00037 
00038 /*!
00039  * Maximal datarate that can be used by the node
00040  */
00041 #define LORAMAC_TX_MAX_DATARATE                     DR_7
00042 
00043 /*!
00044  * Minimal datarate that can be used by the node
00045  */
00046 #define LORAMAC_RX_MIN_DATARATE                     DR_0
00047 
00048 /*!
00049  * Maximal datarate that can be used by the node
00050  */
00051 #define LORAMAC_RX_MAX_DATARATE                     DR_7
00052 
00053 /*!
00054  * Default datarate used by the node
00055  */
00056 #define LORAMAC_DEFAULT_DATARATE                    DR_0
00057 
00058 /*!
00059  * Minimal Rx1 receive datarate offset
00060  */
00061 #define LORAMAC_MIN_RX1_DR_OFFSET                   0
00062 
00063 /*!
00064  * Maximal Rx1 receive datarate offset
00065  */
00066 #define LORAMAC_MAX_RX1_DR_OFFSET                   5
00067 
00068 /*!
00069  * Minimal Tx output power that can be used by the node
00070  */
00071 #define LORAMAC_MIN_TX_POWER                        TX_POWER_M5_DBM
00072 
00073 /*!
00074  * Maximal Tx output power that can be used by the node
00075  */
00076 #define LORAMAC_MAX_TX_POWER                        TX_POWER_10_DBM
00077 
00078 /*!
00079  * Default Tx output power used by the node
00080  */
00081 #define LORAMAC_DEFAULT_TX_POWER                    TX_POWER_10_DBM
00082 
00083 /*!
00084  * LoRaMac TxPower definition
00085  */
00086 #define TX_POWER_10_DBM                             0
00087 #define TX_POWER_07_DBM                             1
00088 #define TX_POWER_04_DBM                             2
00089 #define TX_POWER_01_DBM                             3
00090 #define TX_POWER_M2_DBM                             4
00091 #define TX_POWER_M5_DBM                             5
00092 
00093 /*!
00094  * LoRaMac datarates definition
00095  */
00096 #define DR_0                                        0  // SF12 - BW125
00097 #define DR_1                                        1  // SF11 - BW125
00098 #define DR_2                                        2  // SF10 - BW125
00099 #define DR_3                                        3  // SF9  - BW125
00100 #define DR_4                                        4  // SF8  - BW125
00101 #define DR_5                                        5  // SF7  - BW125
00102 #define DR_6                                        6  // SF7  - BW250
00103 #define DR_7                                        7  // FSK
00104 
00105 /*!
00106  * Verification of default datarate
00107  */
00108 #if ( LORAMAC_DEFAULT_DATARATE > DR_5 )
00109 #error "A default DR higher than DR_5 may lead to connectivity loss."
00110 #endif
00111 
00112 /*!
00113  * Second reception window channel definition.
00114  */
00115 // Channel = { Frequency [Hz], Datarate }
00116 #define RX_WND_2_CHANNEL                                  { 434665000, DR_0 }
00117 
00118 /*!
00119  * LoRaMac maximum number of bands
00120  */
00121 #define LORA_MAX_NB_BANDS                           1
00122 
00123 // Band = { DutyCycle, TxMaxPower, LastTxDoneTime, TimeOff }
00124 #define BAND0              { 100, TX_POWER_10_DBM, 0,  0 } //  1.0 %
00125 
00126 /*!
00127  * LoRaMac default channels
00128  */
00129 // Channel = { Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
00130 #define LC1                { 433175000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 }
00131 #define LC2                { 433375000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 }
00132 #define LC3                { 433575000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 }
00133 
00134 /*!
00135  * LoRaMac channels which are allowed for the join procedure
00136  */
00137 #define JOIN_CHANNELS      ( uint16_t )( LC( 1 ) | LC( 2 ) | LC( 3 ) )
00138 
00139 #elif defined( USE_BAND_470 )
00140 
00141 /*!
00142  * LoRaMac maximum number of channels
00143  */
00144 #define LORA_MAX_NB_CHANNELS                        96
00145 
00146 /*!
00147  * Minimal datarate that can be used by the node
00148  */
00149 #define LORAMAC_TX_MIN_DATARATE                     DR_0
00150 
00151 /*!
00152  * Maximal datarate that can be used by the node
00153  */
00154 #define LORAMAC_TX_MAX_DATARATE                     DR_5
00155 
00156 /*!
00157  * Minimal datarate that can be used by the node
00158  */
00159 #define LORAMAC_RX_MIN_DATARATE                     DR_0
00160 
00161 /*!
00162  * Maximal datarate that can be used by the node
00163  */
00164 #define LORAMAC_RX_MAX_DATARATE                     DR_5
00165 
00166 /*!
00167  * Default datarate used by the node
00168  */
00169 #define LORAMAC_DEFAULT_DATARATE                    DR_0
00170 
00171 /*!
00172  * Minimal Rx1 receive datarate offset
00173  */
00174 #define LORAMAC_MIN_RX1_DR_OFFSET                   0
00175 
00176 /*!
00177  * Maximal Rx1 receive datarate offset
00178  */
00179 #define LORAMAC_MAX_RX1_DR_OFFSET                   3
00180 
00181 /*!
00182  * Minimal Tx output power that can be used by the node
00183  */
00184 #define LORAMAC_MIN_TX_POWER                        TX_POWER_2_DBM
00185 
00186 /*!
00187  * Maximal Tx output power that can be used by the node
00188  */
00189 #define LORAMAC_MAX_TX_POWER                        TX_POWER_17_DBM
00190 
00191 /*!
00192  * Default Tx output power used by the node
00193  */
00194 #define LORAMAC_DEFAULT_TX_POWER                    TX_POWER_14_DBM
00195 
00196 /*!
00197  * LoRaMac TxPower definition
00198  */
00199 #define TX_POWER_17_DBM                             0
00200 #define TX_POWER_16_DBM                             1
00201 #define TX_POWER_14_DBM                             2
00202 #define TX_POWER_12_DBM                             3
00203 #define TX_POWER_10_DBM                             4
00204 #define TX_POWER_7_DBM                              5
00205 #define TX_POWER_5_DBM                              6
00206 #define TX_POWER_2_DBM                              7
00207 
00208 
00209 /*!
00210  * LoRaMac datarates definition
00211  */
00212 #define DR_0                                        0  // SF12 - BW125 |
00213 #define DR_1                                        1  // SF11 - BW125 |
00214 #define DR_2                                        2  // SF10 - BW125 |
00215 #define DR_3                                        3  // SF9  - BW125 |
00216 #define DR_4                                        4  // SF8  - BW125 |
00217 #define DR_5                                        5  // SF7  - BW125 |
00218 
00219 /*!
00220  * Second reception window channel definition.
00221  */
00222 // Channel = { Frequency [Hz], Datarate }
00223 #define RX_WND_2_CHANNEL                                  { 505300000, DR_0 }
00224 
00225 /*!
00226  * LoRaMac maximum number of bands
00227  */
00228 #define LORA_MAX_NB_BANDS                           1
00229 
00230 // Band = { DutyCycle, TxMaxPower, LastTxDoneTime, TimeOff }
00231 #define BAND0              { 1, TX_POWER_17_DBM, 0,  0 } //  100.0 %
00232 
00233 #elif defined( USE_BAND_780 )
00234 
00235 /*!
00236  * LoRaMac maximum number of channels
00237  */
00238 #define LORA_MAX_NB_CHANNELS                        16
00239 
00240 /*!
00241  * Minimal datarate that can be used by the node
00242  */
00243 #define LORAMAC_TX_MIN_DATARATE                     DR_0
00244 
00245 /*!
00246  * Maximal datarate that can be used by the node
00247  */
00248 #define LORAMAC_TX_MAX_DATARATE                     DR_7
00249 
00250 /*!
00251  * Minimal datarate that can be used by the node
00252  */
00253 #define LORAMAC_RX_MIN_DATARATE                     DR_0
00254 
00255 /*!
00256  * Maximal datarate that can be used by the node
00257  */
00258 #define LORAMAC_RX_MAX_DATARATE                     DR_7
00259 
00260 /*!
00261  * Default datarate used by the node
00262  */
00263 #define LORAMAC_DEFAULT_DATARATE                    DR_0
00264 
00265 /*!
00266  * Minimal Rx1 receive datarate offset
00267  */
00268 #define LORAMAC_MIN_RX1_DR_OFFSET                   0
00269 
00270 /*!
00271  * Maximal Rx1 receive datarate offset
00272  */
00273 #define LORAMAC_MAX_RX1_DR_OFFSET                   5
00274 
00275 /*!
00276  * Minimal Tx output power that can be used by the node
00277  */
00278 #define LORAMAC_MIN_TX_POWER                        TX_POWER_M5_DBM
00279 
00280 /*!
00281  * Maximal Tx output power that can be used by the node
00282  */
00283 #define LORAMAC_MAX_TX_POWER                        TX_POWER_10_DBM
00284 
00285 /*!
00286  * Default Tx output power used by the node
00287  */
00288 #define LORAMAC_DEFAULT_TX_POWER                    TX_POWER_10_DBM
00289 
00290 /*!
00291  * LoRaMac TxPower definition
00292  */
00293 #define TX_POWER_10_DBM                             0
00294 #define TX_POWER_07_DBM                             1
00295 #define TX_POWER_04_DBM                             2
00296 #define TX_POWER_01_DBM                             3
00297 #define TX_POWER_M2_DBM                             4
00298 #define TX_POWER_M5_DBM                             5
00299 
00300 /*!
00301  * LoRaMac datarates definition
00302  */
00303 #define DR_0                                        0  // SF12 - BW125
00304 #define DR_1                                        1  // SF11 - BW125
00305 #define DR_2                                        2  // SF10 - BW125
00306 #define DR_3                                        3  // SF9  - BW125
00307 #define DR_4                                        4  // SF8  - BW125
00308 #define DR_5                                        5  // SF7  - BW125
00309 #define DR_6                                        6  // SF7  - BW250
00310 #define DR_7                                        7  // FSK
00311 
00312 /*!
00313  * Verification of default datarate
00314  */
00315 #if ( LORAMAC_DEFAULT_DATARATE > DR_5 )
00316 #error "A default DR higher than DR_5 may lead to connectivity loss."
00317 #endif
00318 
00319 /*!
00320  * Second reception window channel definition.
00321  */
00322 // Channel = { Frequency [Hz], Datarate }
00323 #define RX_WND_2_CHANNEL                                  { 786000000, DR_0 }
00324 
00325 /*!
00326  * LoRaMac maximum number of bands
00327  */
00328 #define LORA_MAX_NB_BANDS                           1
00329 
00330 // Band = { DutyCycle, TxMaxPower, LastTxDoneTime, TimeOff }
00331 //#define BAND0              { 100, TX_POWER_10_DBM, 0,  0 } //  1.0 %
00332 #define BAND0              { 100, TX_POWER_10_DBM, 0,  0 } //  1.0 %
00333 
00334 /*!
00335  * LoRaMac default channels
00336  */
00337 // Channel = { Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
00338 #define LC1                { 779500000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 }
00339 #define LC2                { 779700000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 }
00340 #define LC3                { 779900000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 }
00341 
00342 /*!
00343  * LoRaMac channels which are allowed for the join procedure
00344  */
00345 #define JOIN_CHANNELS      ( uint16_t )( LC( 1 ) | LC( 2 ) | LC( 3 ) )
00346 
00347 #elif defined( USE_BAND_868 )
00348 
00349 /*!
00350  * LoRaMac maximum number of channels
00351  */
00352 #define LORA_MAX_NB_CHANNELS                        16
00353 
00354 /*!
00355  * Minimal datarate that can be used by the node
00356  */
00357 #define LORAMAC_TX_MIN_DATARATE                     DR_0
00358 
00359 /*!
00360  * Maximal datarate that can be used by the node
00361  */
00362 #define LORAMAC_TX_MAX_DATARATE                     DR_7
00363 
00364 /*!
00365  * Minimal datarate that can be used by the node
00366  */
00367 #define LORAMAC_RX_MIN_DATARATE                     DR_0
00368 
00369 /*!
00370  * Maximal datarate that can be used by the node
00371  */
00372 #define LORAMAC_RX_MAX_DATARATE                     DR_7
00373 
00374 /*!
00375  * Default datarate used by the node
00376  */
00377 #define LORAMAC_DEFAULT_DATARATE                    DR_0
00378 
00379 /*!
00380  * Minimal Rx1 receive datarate offset
00381  */
00382 #define LORAMAC_MIN_RX1_DR_OFFSET                   0
00383 
00384 /*!
00385  * Maximal Rx1 receive datarate offset
00386  */
00387 #define LORAMAC_MAX_RX1_DR_OFFSET                   5
00388 
00389 /*!
00390  * Minimal Tx output power that can be used by the node
00391  */
00392 #define LORAMAC_MIN_TX_POWER                        TX_POWER_02_DBM
00393 
00394 /*!
00395  * Maximal Tx output power that can be used by the node
00396  */
00397 #define LORAMAC_MAX_TX_POWER                        TX_POWER_20_DBM
00398 
00399 /*!
00400  * Default Tx output power used by the node
00401  */
00402 #define LORAMAC_DEFAULT_TX_POWER                    TX_POWER_14_DBM
00403 
00404 /*!
00405  * LoRaMac TxPower definition
00406  */
00407 #define TX_POWER_20_DBM                             0
00408 #define TX_POWER_14_DBM                             1
00409 #define TX_POWER_11_DBM                             2
00410 #define TX_POWER_08_DBM                             3
00411 #define TX_POWER_05_DBM                             4
00412 #define TX_POWER_02_DBM                             5
00413 
00414 /*!
00415  * LoRaMac datarates definition
00416  */
00417 #define DR_0                                        0  // SF12 - BW125
00418 #define DR_1                                        1  // SF11 - BW125
00419 #define DR_2                                        2  // SF10 - BW125
00420 #define DR_3                                        3  // SF9  - BW125
00421 #define DR_4                                        4  // SF8  - BW125
00422 #define DR_5                                        5  // SF7  - BW125
00423 #define DR_6                                        6  // SF7  - BW250
00424 #define DR_7                                        7  // FSK
00425 
00426 /*!
00427  * Verification of default datarate
00428  */
00429 #if ( LORAMAC_DEFAULT_DATARATE > DR_5 )
00430 #error "A default DR higher than DR_5 may lead to connectivity loss."
00431 #endif
00432 
00433 /*!
00434  * Second reception window channel definition.
00435  */
00436 // Channel = { Frequency [Hz], Datarate }
00437 #define RX_WND_2_CHANNEL                                  { 869525000, DR_0 }
00438 
00439 /*!
00440  * LoRaMac maximum number of bands
00441  */
00442 #define LORA_MAX_NB_BANDS                           5
00443 
00444 /*!
00445  * LoRaMac EU868 default bands
00446  */
00447 typedef enum
00448 {
00449     BAND_G1_0,
00450     BAND_G1_1,
00451     BAND_G1_2,
00452     BAND_G1_3,
00453     BAND_G1_4,
00454 }BandId_t;
00455 
00456 // Band = { DutyCycle, TxMaxPower, LastTxDoneTime, TimeOff }
00457 #define BAND0              { 100 , TX_POWER_14_DBM, 0,  0 } //  1.0 %
00458 #define BAND1              { 100 , TX_POWER_14_DBM, 0,  0 } //  1.0 %
00459 #define BAND2              { 1000, TX_POWER_14_DBM, 0,  0 } //  0.1 %
00460 #define BAND3              { 10  , TX_POWER_14_DBM, 0,  0 } // 10.0 %
00461 #define BAND4              { 100 , TX_POWER_14_DBM, 0,  0 } //  1.0 %
00462 
00463 /*!
00464  * LoRaMac default channels
00465  */
00466 // Channel = { Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
00467 //Commented out by Chris
00468 //#define LC1                { 868100000, { ( ( DR_5 << 4 ) | DR_0 ) }, 1 }
00469 //#define LC2                { 868300000, { ( ( DR_5 << 4 ) | DR_0 ) }, 1 }
00470 //#define LC3                { 868500000, { ( ( DR_5 << 4 ) | DR_0 ) }, 1 }
00471 
00472 #define LC1                { 869400000, { ( ( DR_5 << 4 ) | DR_5 ) }, 3 }
00473 
00474 /*!
00475  * LoRaMac channels which are allowed for the join procedure
00476  */
00477 //Commented out by Chris
00478 //#define JOIN_CHANNELS      ( uint16_t )( LC( 1 ) | LC( 2 ) | LC( 3 ) )
00479 #define JOIN_CHANNELS      ( uint16_t )( LC( 1 ))
00480 
00481 #elif defined( USE_BAND_915 ) || defined( USE_BAND_915_HYBRID )
00482 
00483 /*!
00484  * LoRaMac maximum number of channels
00485  */
00486 #define LORA_MAX_NB_CHANNELS                        72
00487 
00488 /*!
00489  * Minimal datarate that can be used by the node
00490  */
00491 #define LORAMAC_TX_MIN_DATARATE                     DR_0
00492 
00493 /*!
00494  * Maximal datarate that can be used by the node
00495  */
00496 #define LORAMAC_TX_MAX_DATARATE                     DR_4
00497 
00498 /*!
00499  * Minimal datarate that can be used by the node
00500  */
00501 #define LORAMAC_RX_MIN_DATARATE                     DR_8
00502 
00503 /*!
00504  * Maximal datarate that can be used by the node
00505  */
00506 #define LORAMAC_RX_MAX_DATARATE                     DR_13
00507 
00508 /*!
00509  * Default datarate used by the node
00510  */
00511 #define LORAMAC_DEFAULT_DATARATE                    DR_0
00512 
00513 /*!
00514  * Minimal Rx1 receive datarate offset
00515  */
00516 #define LORAMAC_MIN_RX1_DR_OFFSET                   0
00517 
00518 /*!
00519  * Maximal Rx1 receive datarate offset
00520  */
00521 #define LORAMAC_MAX_RX1_DR_OFFSET                   3
00522 
00523 /*!
00524  * Minimal Tx output power that can be used by the node
00525  */
00526 #define LORAMAC_MIN_TX_POWER                        TX_POWER_10_DBM
00527 
00528 /*!
00529  * Maximal Tx output power that can be used by the node
00530  */
00531 #define LORAMAC_MAX_TX_POWER                        TX_POWER_30_DBM
00532 
00533 /*!
00534  * Default Tx output power used by the node
00535  */
00536 #define LORAMAC_DEFAULT_TX_POWER                    TX_POWER_20_DBM
00537 
00538 /*!
00539  * LoRaMac TxPower definition
00540  */
00541 #define TX_POWER_30_DBM                             0
00542 #define TX_POWER_28_DBM                             1
00543 #define TX_POWER_26_DBM                             2
00544 #define TX_POWER_24_DBM                             3
00545 #define TX_POWER_22_DBM                             4
00546 #define TX_POWER_20_DBM                             5
00547 #define TX_POWER_18_DBM                             6
00548 #define TX_POWER_16_DBM                             7
00549 #define TX_POWER_14_DBM                             8
00550 #define TX_POWER_12_DBM                             9
00551 #define TX_POWER_10_DBM                             10
00552 
00553 /*!
00554  * LoRaMac datarates definition
00555  */
00556 #define DR_0                                        0  // SF10 - BW125 |
00557 #define DR_1                                        1  // SF9  - BW125 |
00558 #define DR_2                                        2  // SF8  - BW125 +-> Up link
00559 #define DR_3                                        3  // SF7  - BW125 |
00560 #define DR_4                                        4  // SF8  - BW500 |
00561 #define DR_5                                        5  // RFU
00562 #define DR_6                                        6  // RFU
00563 #define DR_7                                        7  // RFU
00564 #define DR_8                                        8  // SF12 - BW500 |
00565 #define DR_9                                        9  // SF11 - BW500 |
00566 #define DR_10                                       10 // SF10 - BW500 |
00567 #define DR_11                                       11 // SF9  - BW500 |
00568 #define DR_12                                       12 // SF8  - BW500 +-> Down link
00569 #define DR_13                                       13 // SF7  - BW500 |
00570 #define DR_14                                       14 // RFU          |
00571 #define DR_15                                       15 // RFU          |
00572 
00573 /*!
00574  * Second reception window channel definition.
00575  */
00576 // Channel = { Frequency [Hz], Datarate }
00577 #define RX_WND_2_CHANNEL                                  { 923300000, DR_8 }
00578 
00579 /*!
00580  * LoRaMac maximum number of bands
00581  */
00582 #define LORA_MAX_NB_BANDS                           1
00583 
00584 // Band = { DutyCycle, TxMaxPower, LastTxDoneTime, TimeOff }
00585 #define BAND0              { 1, TX_POWER_20_DBM, 0,  0 } //  100.0 %
00586 
00587 /*!
00588  * LoRaMac default channels
00589  */
00590 // Channel = { Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
00591 /*
00592  * US band channels are initialized using a loop in LoRaMacInit function
00593  * \code
00594  * // 125 kHz channels
00595  * for( uint8_t i = 0; i < LORA_MAX_NB_CHANNELS - 8; i++ )
00596  * {
00597  *     Channels[i].Frequency = 902.3e6 + i * 200e3;
00598  *     Channels[i].DrRange.Value = ( DR_3 << 4 ) | DR_0;
00599  *     Channels[i].Band = 0;
00600  * }
00601  * // 500 kHz channels
00602  * for( uint8_t i = LORA_MAX_NB_CHANNELS - 8; i < LORA_MAX_NB_CHANNELS; i++ )
00603  * {
00604  *     Channels[i].Frequency = 903.0e6 + ( i - ( LORA_MAX_NB_CHANNELS - 8 ) ) * 1.6e6;
00605  *     Channels[i].DrRange.Value = ( DR_4 << 4 ) | DR_4;
00606  *     Channels[i].Band = 0;
00607  * }
00608  * \endcode
00609  */
00610 #else
00611     #error "Please define a frequency band in the compiler options."
00612 #endif
00613 
00614 #endif // __LORAMAC_BOARD_H__