Fork of Semtech LoRaWAN stack

Fork of LoRaWAN-lib by canuck lehead

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