Espotel / Mbed 2 deprecated LoRaWAN_ELMO_TxRx_Template

Dependencies:   SX1272lib mbed

Embed: (wiki syntax)

« Back to documentation index

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

LoRaMac-board.h

00001 /*
00002  / _____)             _              | |
00003 ( (____  _____ ____ _| |_ _____  ____| |__
00004  \____ \| ___ |    (_   _) ___ |/ ___)  _ \
00005  _____) ) ____| | | || |_| ____( (___| | | |
00006 (______/|_____)_|_|_| \__)_____)\____)_| |_|
00007     (C)2013 Semtech
00008 Description: LoRa MAC layer board dependent definitions
00009 License: Revised BSD License, see LICENSE.TXT file include in the project
00010 Maintainer: Miguel Luis and Gregory Cristian
00011 */
00012 #ifndef __LORAMAC_BOARD_H__
00013 #define __LORAMAC_BOARD_H__
00014 
00015 #include "utilities.h"
00016 
00017 /*!
00018  * Returns individual channel mask
00019  *
00020  * \param[IN] channelIndex Channel index 1 based
00021  * \retval channelMask
00022  */
00023 #define LC( channelIndex )            ( uint16_t )( 1 << ( channelIndex - 1 ) )
00024 
00025 #define USE_BAND_868
00026 
00027 #if defined( USE_BAND_433 )
00028 
00029 /*!
00030  * LoRaMac maximum number of channels
00031  */
00032 #define LORA_MAX_NB_CHANNELS                        16
00033 
00034 /*!
00035  * Minimal datarate that can be used by the node
00036  */
00037 #define LORAMAC_MIN_DATARATE                        DR_0
00038 
00039 /*!
00040  * Minimal datarate that can be used by the node
00041  */
00042 #define LORAMAC_MAX_DATARATE                        DR_7
00043 
00044 /*!
00045  * Default datarate used by the node
00046  */
00047 #define LORAMAC_DEFAULT_DATARATE                    DR_0
00048 
00049 /*!
00050  * Minimal Rx1 receive datarate offset
00051  */
00052 #define LORAMAC_MIN_RX1_DR_OFFSET                   0
00053 
00054 /*!
00055  * Maximal Rx1 receive datarate offset
00056  */
00057 #define LORAMAC_MAX_RX1_DR_OFFSET                   5
00058 
00059 /*!
00060  * Minimal Tx output power that can be used by the node
00061  */
00062 #define LORAMAC_MIN_TX_POWER                        TX_POWER_M5_DBM
00063 
00064 /*!
00065  * Minimal Tx output power that can be used by the node
00066  */
00067 #define LORAMAC_MAX_TX_POWER                        TX_POWER_10_DBM
00068 
00069 /*!
00070  * Default Tx output power used by the node
00071  */
00072 #define LORAMAC_DEFAULT_TX_POWER                    TX_POWER_10_DBM
00073 
00074 /*!
00075  * LoRaMac TxPower definition
00076  */
00077 #define TX_POWER_10_DBM                             0
00078 #define TX_POWER_07_DBM                             1
00079 #define TX_POWER_04_DBM                             2
00080 #define TX_POWER_01_DBM                             3
00081 #define TX_POWER_M2_DBM                             4
00082 #define TX_POWER_M5_DBM                             5
00083 
00084 /*!
00085  * LoRaMac datarates definition
00086  */
00087 #define DR_0                                        0  // SF12 - BW125
00088 #define DR_1                                        1  // SF11 - BW125
00089 #define DR_2                                        2  // SF10 - BW125
00090 #define DR_3                                        3  // SF9  - BW125
00091 #define DR_4                                        4  // SF8  - BW125
00092 #define DR_5                                        5  // SF7  - BW125
00093 #define DR_6                                        6  // SF7  - BW250
00094 #define DR_7                                        7  // FSK
00095 
00096 /*!
00097  * Second reception window channel definition.
00098  */
00099 // Channel = { Frequency [Hz], Datarate }
00100 #define RX_WND_2_CHANNEL                                  { 434665000, DR_0 }
00101 
00102 /*!
00103  * LoRaMac maximum number of bands
00104  */
00105 #define LORA_MAX_NB_BANDS                           1
00106 
00107 // Band = { DutyCycle, TxMaxPower, LastTxDoneTime, TimeOff }
00108 #define BAND0              { 100, TX_POWER_10_DBM, 0,  0 } //  1.0 %
00109 
00110 /*!
00111  * LoRaMac default channels
00112  */
00113 // Channel = { Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
00114 #define LC1                { 433175000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 }
00115 #define LC2                { 433375000, { ( ( DR_7 << 4 ) | DR_0 ) }, 0 }
00116 #define LC3                { 433575000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 }
00117 
00118 #elif defined( USE_BAND_780 )
00119 
00120 /*!
00121  * LoRaMac maximum number of channels
00122  */
00123 #define LORA_MAX_NB_CHANNELS                        16
00124 
00125 /*!
00126  * Minimal datarate that can be used by the node
00127  */
00128 #define LORAMAC_MIN_DATARATE                        DR_0
00129 
00130 /*!
00131  * Minimal datarate that can be used by the node
00132  */
00133 #define LORAMAC_MAX_DATARATE                        DR_7
00134 
00135 /*!
00136  * Default datarate used by the node
00137  */
00138 #define LORAMAC_DEFAULT_DATARATE                    DR_0
00139 
00140 /*!
00141  * Minimal Rx1 receive datarate offset
00142  */
00143 #define LORAMAC_MIN_RX1_DR_OFFSET                   0
00144 
00145 /*!
00146  * Maximal Rx1 receive datarate offset
00147  */
00148 #define LORAMAC_MAX_RX1_DR_OFFSET                   5
00149 
00150 /*!
00151  * Minimal Tx output power that can be used by the node
00152  */
00153 #define LORAMAC_MIN_TX_POWER                        TX_POWER_M5_DBM
00154 
00155 /*!
00156  * Minimal Tx output power that can be used by the node
00157  */
00158 #define LORAMAC_MAX_TX_POWER                        TX_POWER_10_DBM
00159 
00160 /*!
00161  * Default Tx output power used by the node
00162  */
00163 #define LORAMAC_DEFAULT_TX_POWER                    TX_POWER_10_DBM
00164 
00165 /*!
00166  * LoRaMac TxPower definition
00167  */
00168 #define TX_POWER_10_DBM                             0
00169 #define TX_POWER_07_DBM                             1
00170 #define TX_POWER_04_DBM                             2
00171 #define TX_POWER_01_DBM                             3
00172 #define TX_POWER_M2_DBM                             4
00173 #define TX_POWER_M5_DBM                             5
00174 
00175 /*!
00176  * LoRaMac datarates definition
00177  */
00178 #define DR_0                                        0  // SF12 - BW125
00179 #define DR_1                                        1  // SF11 - BW125
00180 #define DR_2                                        2  // SF10 - BW125
00181 #define DR_3                                        3  // SF9  - BW125
00182 #define DR_4                                        4  // SF8  - BW125
00183 #define DR_5                                        5  // SF7  - BW125
00184 #define DR_6                                        6  // SF7  - BW250
00185 #define DR_7                                        7  // FSK
00186 
00187 /*!
00188  * Second reception window channel definition.
00189  */
00190 // Channel = { Frequency [Hz], Datarate }
00191 #define RX_WND_2_CHANNEL                                  { 786000000, DR_0 }
00192 
00193 /*!
00194  * LoRaMac maximum number of bands
00195  */
00196 #define LORA_MAX_NB_BANDS                           1
00197 
00198 // Band = { DutyCycle, TxMaxPower, LastTxDoneTime, TimeOff }
00199 #define BAND0              { 100, TX_POWER_10_DBM, 0,  0 } //  1.0 %
00200 
00201 /*!
00202  * LoRaMac default channels
00203  */
00204 // Channel = { Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
00205 #define LC1                { 779500000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 }
00206 #define LC2                { 779700000, { ( ( DR_7 << 4 ) | DR_0 ) }, 0 }
00207 #define LC3                { 779900000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 }
00208 
00209 #elif defined( USE_BAND_868 )
00210 
00211 /*!
00212  * LoRaMac maximum number of channels
00213  */
00214 #define LORA_MAX_NB_CHANNELS                        16
00215 
00216 /*!
00217  * Minimal datarate that can be used by the node
00218  */
00219 #define LORAMAC_MIN_DATARATE                        DR_0
00220 
00221 /*!
00222  * Minimal datarate that can be used by the node
00223  */
00224 #define LORAMAC_MAX_DATARATE                        DR_7
00225 
00226 /*!
00227  * Default datarate used by the node
00228  */
00229 #define LORAMAC_DEFAULT_DATARATE                    DR_0
00230 
00231 /*!
00232  * Minimal Rx1 receive datarate offset
00233  */
00234 #define LORAMAC_MIN_RX1_DR_OFFSET                   0
00235 
00236 /*!
00237  * Maximal Rx1 receive datarate offset
00238  */
00239 #define LORAMAC_MAX_RX1_DR_OFFSET                   5
00240 
00241 /*!
00242  * Minimal Tx output power that can be used by the node
00243  */
00244 #define LORAMAC_MIN_TX_POWER                        TX_POWER_02_DBM
00245 
00246 /*!
00247  * Minimal Tx output power that can be used by the node
00248  */
00249 #define LORAMAC_MAX_TX_POWER                        TX_POWER_20_DBM
00250 
00251 /*!
00252  * Default Tx output power used by the node
00253  */
00254 #define LORAMAC_DEFAULT_TX_POWER                    TX_POWER_14_DBM
00255 
00256 /*!
00257  * LoRaMac TxPower definition
00258  */
00259 #define TX_POWER_20_DBM                             0
00260 #define TX_POWER_14_DBM                             1
00261 #define TX_POWER_11_DBM                             2
00262 #define TX_POWER_08_DBM                             3
00263 #define TX_POWER_05_DBM                             4
00264 #define TX_POWER_02_DBM                             5
00265 
00266 /*!
00267  * LoRaMac datarates definition
00268  */
00269 #define DR_0                                        0  // SF12 - BW125
00270 #define DR_1                                        1  // SF11 - BW125
00271 #define DR_2                                        2  // SF10 - BW125
00272 #define DR_3                                        3  // SF9  - BW125
00273 #define DR_4                                        4  // SF8  - BW125
00274 #define DR_5                                        5  // SF7  - BW125
00275 #define DR_6                                        6  // SF7  - BW250
00276 #define DR_7                                        7  // FSK
00277 
00278 /*!
00279  * Second reception window channel definition.
00280  */
00281 // Channel = { Frequency [Hz], Datarate }
00282 #define RX_WND_2_CHANNEL                                  { 869525000, DR_0 }
00283 
00284 /*!
00285  * LoRaMac maximum number of bands
00286  */
00287 #define LORA_MAX_NB_BANDS                           5
00288 
00289 /*!
00290  * LoRaMac EU868 default bands
00291  */
00292 typedef enum
00293 {
00294     BAND_G1_0,
00295     BAND_G1_1,
00296     BAND_G1_2,
00297     BAND_G1_3,
00298     BAND_G1_4,
00299 }BandId_t;
00300 
00301 // Band = { DutyCycle, TxMaxPower, LastTxDoneTime, TimeOff }
00302 #define BAND0              { 100 , TX_POWER_14_DBM, 0,  0 } //  1.0 %
00303 #define BAND1              { 100 , TX_POWER_14_DBM, 0,  0 } //  1.0 %
00304 #define BAND2              { 1000, TX_POWER_14_DBM, 0,  0 } //  0.1 %
00305 #define BAND3              { 10  , TX_POWER_14_DBM, 0,  0 } // 10.0 %
00306 #define BAND4              { 100 , TX_POWER_14_DBM, 0,  0 } //  1.0 %
00307 
00308 /*!
00309  * LoRaMac default channels
00310  */
00311 // Channel = { Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
00312 #define LC1                { 868100000, { ( ( DR_5 << 4 ) | DR_0 ) }, 1 }
00313 #define LC2                { 868300000, { ( ( DR_6 << 4 ) | DR_0 ) }, 1 }
00314 #define LC3                { 868500000, { ( ( DR_5 << 4 ) | DR_0 ) }, 1 }
00315 
00316 #elif defined( USE_BAND_915 ) || defined( USE_BAND_915_HYBRID )
00317 
00318 /*!
00319  * LoRaMac maximum number of channels
00320  */
00321 #define LORA_MAX_NB_CHANNELS                        72
00322 
00323 /*!
00324  * Minimal datarate that can be used by the node
00325  */
00326 #define LORAMAC_MIN_DATARATE                        DR_0
00327 
00328 /*!
00329  * Minimal datarate that can be used by the node
00330  */
00331 #define LORAMAC_MAX_DATARATE                        DR_4
00332 
00333 /*!
00334  * Default datarate used by the node
00335  */
00336 #define LORAMAC_DEFAULT_DATARATE                    DR_0
00337 
00338 /*!
00339  * Minimal Rx1 receive datarate offset
00340  */
00341 #define LORAMAC_MIN_RX1_DR_OFFSET                   0
00342 
00343 /*!
00344  * Maximal Rx1 receive datarate offset
00345  */
00346 #define LORAMAC_MAX_RX1_DR_OFFSET                   3
00347 
00348 /*!
00349  * Minimal Tx output power that can be used by the node
00350  */
00351 #define LORAMAC_MIN_TX_POWER                        TX_POWER_10_DBM
00352 
00353 /*!
00354  * Minimal Tx output power that can be used by the node
00355  */
00356 #define LORAMAC_MAX_TX_POWER                        TX_POWER_30_DBM
00357 
00358 /*!
00359  * Default Tx output power used by the node
00360  */
00361 #define LORAMAC_DEFAULT_TX_POWER                    TX_POWER_20_DBM
00362 
00363 /*!
00364  * LoRaMac TxPower definition
00365  */
00366 #define TX_POWER_30_DBM                             0
00367 #define TX_POWER_28_DBM                             1
00368 #define TX_POWER_26_DBM                             2
00369 #define TX_POWER_24_DBM                             3
00370 #define TX_POWER_22_DBM                             4
00371 #define TX_POWER_20_DBM                             5
00372 #define TX_POWER_18_DBM                             6
00373 #define TX_POWER_16_DBM                             7
00374 #define TX_POWER_14_DBM                             8
00375 #define TX_POWER_12_DBM                             9
00376 #define TX_POWER_10_DBM                             10
00377 
00378 /*!
00379  * LoRaMac datarates definition
00380  */
00381 #define DR_0                                        0  // SF10 - BW125 |
00382 #define DR_1                                        1  // SF9  - BW125 |
00383 #define DR_2                                        2  // SF8  - BW125 +-> Up link
00384 #define DR_3                                        3  // SF7  - BW125 |
00385 #define DR_4                                        4  // SF8  - BW500 |
00386 #define DR_5                                        5  // RFU
00387 #define DR_6                                        6  // RFU
00388 #define DR_7                                        7  // RFU
00389 #define DR_8                                        8  // SF12 - BW500 |
00390 #define DR_9                                        9  // SF11 - BW500 |
00391 #define DR_10                                       10 // SF10 - BW500 |
00392 #define DR_11                                       11 // SF9  - BW500 |
00393 #define DR_12                                       12 // SF8  - BW500 +-> Down link
00394 #define DR_13                                       13 // SF7  - BW500 |
00395 #define DR_14                                       14 // RFU          |
00396 #define DR_15                                       15 // RFU          |
00397 
00398 /*!
00399  * Second reception window channel definition.
00400  */
00401 // Channel = { Frequency [Hz], Datarate }
00402 #define RX_WND_2_CHANNEL                                  { 923300000, DR_8 }
00403 
00404 /*!
00405  * LoRaMac maximum number of bands
00406  */
00407 #define LORA_MAX_NB_BANDS                           1
00408 
00409 // Band = { DutyCycle, TxMaxPower, LastTxDoneTime, TimeOff }
00410 #define BAND0              { 1, TX_POWER_20_DBM, 0,  0 } //  100.0 %
00411 
00412 /*!
00413  * LoRaMac default channels
00414  */
00415 // Channel = { Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
00416 /*
00417  * US band channels are initialized using a loop in LoRaMacInit function
00418  * \code
00419  * // 125 kHz channels
00420  * for( uint8_t i = 0; i < LORA_MAX_NB_CHANNELS - 8; i++ )
00421  * {
00422  *     Channels[i].Frequency = 902.3e6 + i * 200e3;
00423  *     Channels[i].DrRange.Value = ( DR_3 << 4 ) | DR_0;
00424  *     Channels[i].Band = 0;
00425  * }
00426  * // 500 kHz channels
00427  * for( uint8_t i = LORA_MAX_NB_CHANNELS - 8; i < LORA_MAX_NB_CHANNELS; i++ )
00428  * {
00429  *     Channels[i].Frequency = 903.0e6 + ( i - ( LORA_MAX_NB_CHANNELS - 8 ) ) * 1.6e6;
00430  *     Channels[i].DrRange.Value = ( DR_4 << 4 ) | DR_4;
00431  *     Channels[i].Band = 0;
00432  * }
00433  * \endcode
00434  */
00435 #else
00436     #error "Please define a frequency band in the compiler options."
00437 #endif
00438 
00439 #endif // __LORAMAC_BOARD_H__