Fork of Semtech LoRaWAN stack
Fork of LoRaWAN-lib by
Diff: LoRaMac-board.h
- Branch:
- SenetNetTool
- Revision:
- 49:8b9e6442a02a
- Parent:
- 31:930f949fdd9e
--- a/LoRaMac-board.h Tue Aug 08 11:21:18 2017 -0400 +++ b/LoRaMac-board.h Mon Oct 15 09:15:20 2018 -0400 @@ -26,462 +26,486 @@ * \param[IN] channelIndex Channel index 1 based * \retval channelMask */ -#define LC( channelIndex ) ( uint16_t )( 1 << ( channelIndex - 1 ) ) +#define LC(channelIndex) (uint16_t)(1 << (channelIndex - 1)) -#if defined( USE_BAND_433 ) +#if defined(USE_BAND_433) /*! * LoRaMac maximum number of channels */ -#define LORA_MAX_NB_CHANNELS 16 +#define LORA_MAX_NB_CHANNELS 16 /*! * Minimal datarate that can be used by the node */ -#define LORAMAC_TX_MIN_DATARATE DR_0 +#define LORAMAC_TX_MIN_DATARATE DR_0 /*! * Minimal datarate that can be used by the node */ -#define LORAMAC_TX_MAX_DATARATE DR_7 +#define LORAMAC_TX_MAX_DATARATE DR_7 /*! * Minimal datarate that can be used by the node */ -#define LORAMAC_RX_MIN_DATARATE DR_0 +#define LORAMAC_RX_MIN_DATARATE DR_0 /*! * Minimal datarate that can be used by the node */ -#define LORAMAC_RX_MAX_DATARATE DR_7 +#define LORAMAC_RX_MAX_DATARATE DR_7 /*! * Default datarate used by the node */ -#define LORAMAC_DEFAULT_DATARATE DR_0 +#define LORAMAC_DEFAULT_DATARATE DR_0 /*! * Minimal Rx1 receive datarate offset */ -#define LORAMAC_MIN_RX1_DR_OFFSET 0 +#define LORAMAC_MIN_RX1_DR_OFFSET 0 /*! * Maximal Rx1 receive datarate offset */ -#define LORAMAC_MAX_RX1_DR_OFFSET 5 +#define LORAMAC_MAX_RX1_DR_OFFSET 5 /*! * Minimal Tx output power that can be used by the node */ -#define LORAMAC_MIN_TX_POWER TX_POWER_M5_DBM +#define LORAMAC_MIN_TX_POWER TX_POWER_M5_DBM /*! * Minimal Tx output power that can be used by the node */ -#define LORAMAC_MAX_TX_POWER TX_POWER_10_DBM +#define LORAMAC_MAX_TX_POWER TX_POWER_10_DBM /*! * Default Tx output power used by the node */ -#define LORAMAC_DEFAULT_TX_POWER TX_POWER_10_DBM +#define LORAMAC_DEFAULT_TX_POWER TX_POWER_10_DBM /*! * LoRaMac TxPower definition */ -#define TX_POWER_10_DBM 0 -#define TX_POWER_07_DBM 1 -#define TX_POWER_04_DBM 2 -#define TX_POWER_01_DBM 3 -#define TX_POWER_M2_DBM 4 -#define TX_POWER_M5_DBM 5 +#define TX_POWER_10_DBM 0 +#define TX_POWER_07_DBM 1 +#define TX_POWER_04_DBM 2 +#define TX_POWER_01_DBM 3 +#define TX_POWER_M2_DBM 4 +#define TX_POWER_M5_DBM 5 /*! * LoRaMac datarates definition */ -#define DR_0 0 // SF12 - BW125 -#define DR_1 1 // SF11 - BW125 -#define DR_2 2 // SF10 - BW125 -#define DR_3 3 // SF9 - BW125 -#define DR_4 4 // SF8 - BW125 -#define DR_5 5 // SF7 - BW125 -#define DR_6 6 // SF7 - BW250 -#define DR_7 7 // FSK +#define DR_0 0 // SF12 - BW125 +#define DR_1 1 // SF11 - BW125 +#define DR_2 2 // SF10 - BW125 +#define DR_3 3 // SF9 - BW125 +#define DR_4 4 // SF8 - BW125 +#define DR_5 5 // SF7 - BW125 +#define DR_6 6 // SF7 - BW250 +#define DR_7 7 // FSK /*! * Second reception window channel definition. */ // Channel = { Frequency [Hz], Datarate } -#define RX_WND_2_CHANNEL { 434665000, DR_0 } +#define RX_WND_2_CHANNEL \ + { 434665000, DR_0 } /*! * LoRaMac maximum number of bands */ -#define LORA_MAX_NB_BANDS 1 +#define LORA_MAX_NB_BANDS 1 // Band = { DutyCycle, TxMaxPower, LastTxDoneTime, TimeOff } -#define BAND0 { 100, TX_POWER_10_DBM, 0, 0 } // 1.0 % +#define BAND0 \ + { 100, TX_POWER_10_DBM, 0, 0 } // 1.0 % /*! * LoRaMac default channels */ // Channel = { Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band } -#define LC1 { 433175000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } -#define LC2 { 433375000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } -#define LC3 { 433575000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } +#define LC1 \ + { 433175000, {((DR_5 << 4) | DR_0)}, 0 } +#define LC2 \ + { 433375000, {((DR_5 << 4) | DR_0)}, 0 } +#define LC3 \ + { 433575000, {((DR_5 << 4) | DR_0)}, 0 } /*! * LoRaMac duty cycle for the join procedure */ -#define JOIN_DC 1000 +#define JOIN_DC 1000 /*! * LoRaMac channels which are allowed for the join procedure */ -#define JOIN_CHANNELS ( uint16_t )( LC( 1 ) | LC( 2 ) | LC( 3 ) ) +#define JOIN_CHANNELS (uint16_t)(LC(1) | LC(2) | LC(3)) -#elif defined( USE_BAND_780 ) +#elif defined(USE_BAND_780) /*! * LoRaMac maximum number of channels */ -#define LORA_MAX_NB_CHANNELS 16 +#define LORA_MAX_NB_CHANNELS 16 /*! * Minimal datarate that can be used by the node */ -#define LORAMAC_TX_MIN_DATARATE DR_0 +#define LORAMAC_TX_MIN_DATARATE DR_0 /*! * Minimal datarate that can be used by the node */ -#define LORAMAC_TX_MAX_DATARATE DR_7 +#define LORAMAC_TX_MAX_DATARATE DR_7 /*! * Minimal datarate that can be used by the node */ -#define LORAMAC_RX_MIN_DATARATE DR_0 +#define LORAMAC_RX_MIN_DATARATE DR_0 /*! * Minimal datarate that can be used by the node */ -#define LORAMAC_RX_MAX_DATARATE DR_7 +#define LORAMAC_RX_MAX_DATARATE DR_7 /*! * Default datarate used by the node */ -#define LORAMAC_DEFAULT_DATARATE DR_0 +#define LORAMAC_DEFAULT_DATARATE DR_0 /*! * Minimal Rx1 receive datarate offset */ -#define LORAMAC_MIN_RX1_DR_OFFSET 0 +#define LORAMAC_MIN_RX1_DR_OFFSET 0 /*! * Maximal Rx1 receive datarate offset */ -#define LORAMAC_MAX_RX1_DR_OFFSET 5 +#define LORAMAC_MAX_RX1_DR_OFFSET 5 /*! * Minimal Tx output power that can be used by the node */ -#define LORAMAC_MIN_TX_POWER TX_POWER_M5_DBM +#define LORAMAC_MIN_TX_POWER TX_POWER_M5_DBM /*! * Minimal Tx output power that can be used by the node */ -#define LORAMAC_MAX_TX_POWER TX_POWER_10_DBM +#define LORAMAC_MAX_TX_POWER TX_POWER_10_DBM /*! * Default Tx output power used by the node */ -#define LORAMAC_DEFAULT_TX_POWER TX_POWER_10_DBM +#define LORAMAC_DEFAULT_TX_POWER TX_POWER_10_DBM /*! * LoRaMac TxPower definition */ -#define TX_POWER_10_DBM 0 -#define TX_POWER_07_DBM 1 -#define TX_POWER_04_DBM 2 -#define TX_POWER_01_DBM 3 -#define TX_POWER_M2_DBM 4 -#define TX_POWER_M5_DBM 5 +#define TX_POWER_10_DBM 0 +#define TX_POWER_07_DBM 1 +#define TX_POWER_04_DBM 2 +#define TX_POWER_01_DBM 3 +#define TX_POWER_M2_DBM 4 +#define TX_POWER_M5_DBM 5 /*! * LoRaMac datarates definition */ -#define DR_0 0 // SF12 - BW125 -#define DR_1 1 // SF11 - BW125 -#define DR_2 2 // SF10 - BW125 -#define DR_3 3 // SF9 - BW125 -#define DR_4 4 // SF8 - BW125 -#define DR_5 5 // SF7 - BW125 -#define DR_6 6 // SF7 - BW250 -#define DR_7 7 // FSK +#define DR_0 0 // SF12 - BW125 +#define DR_1 1 // SF11 - BW125 +#define DR_2 2 // SF10 - BW125 +#define DR_3 3 // SF9 - BW125 +#define DR_4 4 // SF8 - BW125 +#define DR_5 5 // SF7 - BW125 +#define DR_6 6 // SF7 - BW250 +#define DR_7 7 // FSK /*! * Second reception window channel definition. */ // Channel = { Frequency [Hz], Datarate } -#define RX_WND_2_CHANNEL { 786000000, DR_0 } +#define RX_WND_2_CHANNEL \ + { 786000000, DR_0 } /*! * LoRaMac maximum number of bands */ -#define LORA_MAX_NB_BANDS 1 +#define LORA_MAX_NB_BANDS 1 // Band = { DutyCycle, TxMaxPower, LastTxDoneTime, TimeOff } -#define BAND0 { 100, TX_POWER_10_DBM, 0, 0 } // 1.0 % +#define BAND0 \ + { 100, TX_POWER_10_DBM, 0, 0 } // 1.0 % /*! * LoRaMac default channels */ // Channel = { Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band } -#define LC1 { 779500000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } -#define LC2 { 779700000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } -#define LC3 { 779900000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 } +#define LC1 \ + { 779500000, {((DR_5 << 4) | DR_0)}, 0 } +#define LC2 \ + { 779700000, {((DR_5 << 4) | DR_0)}, 0 } +#define LC3 \ + { 779900000, {((DR_5 << 4) | DR_0)}, 0 } /*! * LoRaMac duty cycle for the join procedure */ -#define JOIN_DC 1000 +#define JOIN_DC 1000 /*! * LoRaMac channels which are allowed for the join procedure */ -#define JOIN_CHANNELS ( uint16_t )( LC( 1 ) | LC( 2 ) | LC( 3 ) ) +#define JOIN_CHANNELS (uint16_t)(LC(1) | LC(2) | LC(3)) -#elif defined( USE_BAND_868 ) +#elif defined(USE_BAND_868) /*! * LoRaMac maximum number of channels */ -#define LORA_MAX_NB_CHANNELS 16 +#define LORA_MAX_NB_CHANNELS 16 /*! * Minimal datarate that can be used by the node */ -#define LORAMAC_TX_MIN_DATARATE DR_0 +#define LORAMAC_TX_MIN_DATARATE DR_0 /*! * Minimal datarate that can be used by the node */ -#define LORAMAC_TX_MAX_DATARATE DR_7 +#define LORAMAC_TX_MAX_DATARATE DR_7 /*! * Minimal datarate that can be used by the node */ -#define LORAMAC_RX_MIN_DATARATE DR_0 +#define LORAMAC_RX_MIN_DATARATE DR_0 /*! * Minimal datarate that can be used by the node */ -#define LORAMAC_RX_MAX_DATARATE DR_7 +#define LORAMAC_RX_MAX_DATARATE DR_7 /*! * Default datarate used by the node */ -#define LORAMAC_DEFAULT_DATARATE DR_0 +#define LORAMAC_DEFAULT_DATARATE DR_0 /*! * Minimal Rx1 receive datarate offset */ -#define LORAMAC_MIN_RX1_DR_OFFSET 0 +#define LORAMAC_MIN_RX1_DR_OFFSET 0 /*! * Maximal Rx1 receive datarate offset */ -#define LORAMAC_MAX_RX1_DR_OFFSET 5 +#define LORAMAC_MAX_RX1_DR_OFFSET 5 /*! * Minimal Tx output power that can be used by the node */ -#define LORAMAC_MIN_TX_POWER TX_POWER_02_DBM +#define LORAMAC_MIN_TX_POWER TX_POWER_02_DBM /*! * Minimal Tx output power that can be used by the node */ -#define LORAMAC_MAX_TX_POWER TX_POWER_20_DBM +#define LORAMAC_MAX_TX_POWER TX_POWER_20_DBM /*! * Default Tx output power used by the node */ -#define LORAMAC_DEFAULT_TX_POWER TX_POWER_14_DBM +#define LORAMAC_DEFAULT_TX_POWER TX_POWER_14_DBM /*! * LoRaMac TxPower definition */ -#define TX_POWER_20_DBM 0 -#define TX_POWER_14_DBM 1 -#define TX_POWER_11_DBM 2 -#define TX_POWER_08_DBM 3 -#define TX_POWER_05_DBM 4 -#define TX_POWER_02_DBM 5 +#define TX_POWER_20_DBM 0 +#define TX_POWER_14_DBM 1 +#define TX_POWER_11_DBM 2 +#define TX_POWER_08_DBM 3 +#define TX_POWER_05_DBM 4 +#define TX_POWER_02_DBM 5 /*! * LoRaMac datarates definition */ -#define DR_0 0 // SF12 - BW125 -#define DR_1 1 // SF11 - BW125 -#define DR_2 2 // SF10 - BW125 -#define DR_3 3 // SF9 - BW125 -#define DR_4 4 // SF8 - BW125 -#define DR_5 5 // SF7 - BW125 -#define DR_6 6 // SF7 - BW250 -#define DR_7 7 // FSK +#define DR_0 0 // SF12 - BW125 +#define DR_1 1 // SF11 - BW125 +#define DR_2 2 // SF10 - BW125 +#define DR_3 3 // SF9 - BW125 +#define DR_4 4 // SF8 - BW125 +#define DR_5 5 // SF7 - BW125 +#define DR_6 6 // SF7 - BW250 +#define DR_7 7 // FSK /*! * Second reception window channel definition. */ // Channel = { Frequency [Hz], Datarate } -#define RX_WND_2_CHANNEL { 869525000, DR_0 } +#define RX_WND_2_CHANNEL \ + { 869525000, DR_0 } /*! * LoRaMac maximum number of bands */ -#define LORA_MAX_NB_BANDS 5 +#define LORA_MAX_NB_BANDS 5 /*! * LoRaMac EU868 default bands */ -typedef enum -{ - BAND_G1_0, - BAND_G1_1, - BAND_G1_2, - BAND_G1_3, - BAND_G1_4, -}BandId_t; +typedef enum { + BAND_G1_0, + BAND_G1_1, + BAND_G1_2, + BAND_G1_3, + BAND_G1_4, +} BandId_t; // Band = { DutyCycle, TxMaxPower, LastTxDoneTime, TimeOff } -#define BAND0 { 100 , TX_POWER_14_DBM, 0, 0 } // 1.0 % -#define BAND1 { 100 , TX_POWER_14_DBM, 0, 0 } // 1.0 % -#define BAND2 { 1000, TX_POWER_14_DBM, 0, 0 } // 0.1 % -#define BAND3 { 10 , TX_POWER_14_DBM, 0, 0 } // 10.0 % -#define BAND4 { 100 , TX_POWER_14_DBM, 0, 0 } // 1.0 % +#define BAND0 \ + { 100, TX_POWER_14_DBM, 0, 0 } // 1.0 % +#define BAND1 \ + { 100, TX_POWER_14_DBM, 0, 0 } // 1.0 % +#define BAND2 \ + { 1000, TX_POWER_14_DBM, 0, 0 } // 0.1 % +#define BAND3 \ + { 10, TX_POWER_14_DBM, 0, 0 } // 10.0 % +#define BAND4 \ + { 100, TX_POWER_14_DBM, 0, 0 } // 1.0 % /*! * LoRaMac default channels */ // Channel = { Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band } -#define LC1 { 868100000, { ( ( DR_5 << 4 ) | DR_0 ) }, 1 } -#define LC2 { 868300000, { ( ( DR_5 << 4 ) | DR_0 ) }, 1 } -#define LC3 { 868500000, { ( ( DR_5 << 4 ) | DR_0 ) }, 1 } +#define LC1 \ + { 868100000, {((DR_5 << 4) | DR_0)}, 1 } +#define LC2 \ + { 868300000, {((DR_5 << 4) | DR_0)}, 1 } +#define LC3 \ + { 868500000, {((DR_5 << 4) | DR_0)}, 1 } /*! * LoRaMac duty cycle for the join procedure */ -#define JOIN_DC 1000 +#define JOIN_DC 1000 /*! * LoRaMac channels which are allowed for the join procedure */ -#define JOIN_CHANNELS ( uint16_t )( LC( 1 ) | LC( 2 ) | LC( 3 ) ) +#define JOIN_CHANNELS (uint16_t)(LC(1) | LC(2) | LC(3)) -#elif defined( USE_BAND_915 ) || defined( USE_BAND_915_HYBRID ) +#elif defined(USE_BAND_915) || defined(USE_BAND_915_HYBRID) /*! * LoRaMac maximum number of channels */ -#define LORA_MAX_NB_CHANNELS 72 +#define LORA_MAX_NB_CHANNELS 72 /*! * Minimal datarate that can be used by the node */ -#define LORAMAC_TX_MIN_DATARATE DR_0 +#define LORAMAC_TX_MIN_DATARATE DR_0 /*! * Minimal datarate that can be used by the node */ -#define LORAMAC_TX_MAX_DATARATE DR_4 +#define LORAMAC_TX_MAX_DATARATE DR_4 /*! * Minimal datarate that can be used by the node */ -#define LORAMAC_RX_MIN_DATARATE DR_8 +#define LORAMAC_RX_MIN_DATARATE DR_8 /*! * Minimal datarate that can be used by the node */ -#define LORAMAC_RX_MAX_DATARATE DR_13 +#define LORAMAC_RX_MAX_DATARATE DR_13 /*! * Default datarate used by the node */ -#define LORAMAC_DEFAULT_DATARATE DR_0 +#define LORAMAC_DEFAULT_DATARATE DR_0 /*! * Minimal Rx1 receive datarate offset */ -#define LORAMAC_MIN_RX1_DR_OFFSET 0 +#define LORAMAC_MIN_RX1_DR_OFFSET 0 /*! * Maximal Rx1 receive datarate offset */ -#define LORAMAC_MAX_RX1_DR_OFFSET 3 +#define LORAMAC_MAX_RX1_DR_OFFSET 3 /*! * Minimal Tx output power that can be used by the node */ -#define LORAMAC_MIN_TX_POWER TX_POWER_10_DBM +#define LORAMAC_MIN_TX_POWER TX_POWER_2_DBM /*! * Minimal Tx output power that can be used by the node */ -#define LORAMAC_MAX_TX_POWER TX_POWER_30_DBM +#define LORAMAC_MAX_TX_POWER TX_POWER_30_DBM /*! * Default Tx output power used by the node */ -#define LORAMAC_DEFAULT_TX_POWER TX_POWER_30_DBM +#define LORAMAC_DEFAULT_TX_POWER TX_POWER_30_DBM /*! * LoRaMac TxPower definition */ -#define TX_POWER_30_DBM 0 -#define TX_POWER_28_DBM 1 -#define TX_POWER_26_DBM 2 -#define TX_POWER_24_DBM 3 -#define TX_POWER_22_DBM 4 -#define TX_POWER_20_DBM 5 -#define TX_POWER_18_DBM 6 -#define TX_POWER_16_DBM 7 -#define TX_POWER_14_DBM 8 -#define TX_POWER_12_DBM 9 -#define TX_POWER_10_DBM 10 +#define TX_POWER_30_DBM 0 +#define TX_POWER_28_DBM 1 +#define TX_POWER_26_DBM 2 +#define TX_POWER_24_DBM 3 +#define TX_POWER_22_DBM 4 +#define TX_POWER_20_DBM 5 +#define TX_POWER_18_DBM 6 +#define TX_POWER_16_DBM 7 +#define TX_POWER_14_DBM 8 +#define TX_POWER_12_DBM 9 +#define TX_POWER_10_DBM 10 +#define TX_POWER_8_DBM 11 +#define TX_POWER_6_DBM 12 +#define TX_POWER_4_DBM 13 +#define TX_POWER_2_DBM 14 /*! * LoRaMac datarates definition */ -#define DR_0 0 // SF10 - BW125 | -#define DR_1 1 // SF9 - BW125 | -#define DR_2 2 // SF8 - BW125 +-> Up link -#define DR_3 3 // SF7 - BW125 | -#define DR_4 4 // SF8 - BW500 | -#define DR_5 5 // RFU -#define DR_6 6 // RFU -#define DR_7 7 // RFU -#define DR_8 8 // SF12 - BW500 | -#define DR_9 9 // SF11 - BW500 | -#define DR_10 10 // SF10 - BW500 | -#define DR_11 11 // SF9 - BW500 | -#define DR_12 12 // SF8 - BW500 +-> Down link -#define DR_13 13 // SF7 - BW500 | -#define DR_14 14 // RFU | -#define DR_15 15 // RFU | +#define DR_0 0 // SF10 - BW125 | +#define DR_1 1 // SF9 - BW125 | +#define DR_2 2 // SF8 - BW125 +-> Up link +#define DR_3 3 // SF7 - BW125 | +#define DR_4 4 // SF8 - BW500 | +#define DR_5 5 // RFU +#define DR_6 6 // RFU +#define DR_7 7 // RFU +#define DR_8 8 // SF12 - BW500 | +#define DR_9 9 // SF11 - BW500 | +#define DR_10 10 // SF10 - BW500 | +#define DR_11 11 // SF9 - BW500 | +#define DR_12 12 // SF8 - BW500 +-> Down link +#define DR_13 13 // SF7 - BW500 | +#define DR_14 14 // RFU | +#define DR_15 15 // RFU | /*! * Second reception window channel definition. */ // Channel = { Frequency [Hz], Datarate } -#define RX_WND_2_CHANNEL { 923300000, DR_8 } +#define RX_WND_2_CHANNEL \ + { 923300000, DR_8 } /*! * LoRaMac maximum number of bands */ -#define LORA_MAX_NB_BANDS 1 +#define LORA_MAX_NB_BANDS 1 // Band = { DutyCycle, TxMaxPower, LastTxDoneTime, TimeOff } -#define BAND0 { 1, TX_POWER_20_DBM, 0, 0 } // 100.0 % +#define BAND0 \ + { 1, TX_POWER_20_DBM, 0, 0 } // 100.0 % /*! * LoRaMac default channels @@ -507,7 +531,7 @@ * \endcode */ #else - #error "Please define a frequency band in the compiler options." +#error "Please define a frequency band in the compiler options." #endif -#endif // __LORAMAC_BOARD_H__ +#endif // __LORAMAC_BOARD_H__