LoRaWAN MAC layer implementation

Dependents:   LoRaWAN-demo-72_tjm LoRaWAN-demo-72_jlc LoRaWAN-demo-elmo frdm_LoRa_Connect_Woodstream_Demo_tjm ... more

LoRAWAN-lib is a port of the GitHub LoRaMac-node LoRaWAN MAC layer implementation.

This library depends on the SX1276Lib or SX1272Lib radio drivers depending on the used mbed component shield.

This library depends also on some cryptographic helper functions as well as helper functions for the timers management. These can be found on the example projects under the system directory.

The example projects are:

  1. LoRaWAN-demo-72
  2. LoRaWAN-demo-76
  3. LoRaWAN-demo-NAMote72

The LoRaWAN specification specifies different ISM bands operating parameters. These are all implemented under the LoRaMac-board.h file.

In order to select which band to use, please change line 24 of board.h file provided on the examples projects as follows:


EU868

board.h

#define USE_BAND_868


US915

board.h

#define USE_BAND_915


US915 - Hybrid

board.h

#define USE_BAND_915_HYBRID


CN780

board.h

#define USE_BAND_780


EU433

board.h

#define USE_BAND_433
Revision:
4:37c12dbc8dc7
Parent:
3:b9d87593a8ae
--- a/LoRaMac-board.h	Mon Mar 14 09:09:54 2016 +0000
+++ b/LoRaMac-board.h	Fri May 13 14:51:50 2016 +0000
@@ -33,12 +33,22 @@
 /*!
  * Minimal datarate that can be used by the node
  */
-#define LORAMAC_MIN_DATARATE                        DR_0
+#define LORAMAC_TX_MIN_DATARATE                     DR_0
 
 /*!
  * Minimal datarate that can be used by the node
  */
-#define LORAMAC_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
+
+/*!
+ * Minimal datarate that can be used by the node
+ */
+#define LORAMAC_RX_MAX_DATARATE                     DR_7
 
 /*!
  * Default datarate used by the node
@@ -111,9 +121,19 @@
  */
 // Channel = { Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
 #define LC1                { 433175000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 }
-#define LC2                { 433375000, { ( ( DR_7 << 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
+
+/*!
+ * LoRaMac channels which are allowed for the join procedure
+ */
+#define JOIN_CHANNELS      ( uint16_t )( LC( 1 ) | LC( 2 ) | LC( 3 ) )
+
 #elif defined( USE_BAND_780 )
 
 /*!
@@ -124,12 +144,22 @@
 /*!
  * Minimal datarate that can be used by the node
  */
-#define LORAMAC_MIN_DATARATE                        DR_0
+#define LORAMAC_TX_MIN_DATARATE                     DR_0
 
 /*!
  * Minimal datarate that can be used by the node
  */
-#define LORAMAC_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
+
+/*!
+ * Minimal datarate that can be used by the node
+ */
+#define LORAMAC_RX_MAX_DATARATE                     DR_7
 
 /*!
  * Default datarate used by the node
@@ -202,9 +232,19 @@
  */
 // Channel = { Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
 #define LC1                { 779500000, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 }
-#define LC2                { 779700000, { ( ( DR_7 << 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
+
+/*!
+ * LoRaMac channels which are allowed for the join procedure
+ */
+#define JOIN_CHANNELS      ( uint16_t )( LC( 1 ) | LC( 2 ) | LC( 3 ) )
+
 #elif defined( USE_BAND_868 )
 
 /*!
@@ -215,12 +255,22 @@
 /*!
  * Minimal datarate that can be used by the node
  */
-#define LORAMAC_MIN_DATARATE                        DR_0
+#define LORAMAC_TX_MIN_DATARATE                     DR_0
 
 /*!
  * Minimal datarate that can be used by the node
  */
-#define LORAMAC_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
+
+/*!
+ * Minimal datarate that can be used by the node
+ */
+#define LORAMAC_RX_MAX_DATARATE                     DR_7
 
 /*!
  * Default datarate used by the node
@@ -309,9 +359,19 @@
  */
 // Channel = { Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band }
 #define LC1                { 868100000, { ( ( DR_5 << 4 ) | DR_0 ) }, 1 }
-#define LC2                { 868300000, { ( ( DR_6 << 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
+
+/*!
+ * LoRaMac channels which are allowed for the join procedure
+ */
+#define JOIN_CHANNELS      ( uint16_t )( LC( 1 ) | LC( 2 ) | LC( 3 ) )
+
 #elif defined( USE_BAND_915 ) || defined( USE_BAND_915_HYBRID )
 
 /*!
@@ -322,12 +382,22 @@
 /*!
  * Minimal datarate that can be used by the node
  */
-#define LORAMAC_MIN_DATARATE                        DR_0
+#define LORAMAC_TX_MIN_DATARATE                     DR_0
 
 /*!
  * Minimal datarate that can be used by the node
  */
-#define LORAMAC_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
+
+/*!
+ * Minimal datarate that can be used by the node
+ */
+#define LORAMAC_RX_MAX_DATARATE                     DR_13
 
 /*!
  * Default datarate used by the node