Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
LoRAWAN-lib is a port of the GitHub LoRaMac-node develop branch 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:
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
Diff: LoRaMac.h
- Revision:
- 1:4820e04b066c
- Parent:
- 0:66f12acb8acb
- Child:
- 2:76f59096e3a7
--- a/LoRaMac.h Thu Jun 02 07:58:35 2016 +0000
+++ b/LoRaMac.h Tue Jul 05 15:12:50 2016 +0000
@@ -47,37 +47,37 @@
#define __LORAMAC_H__
// Includes board dependent definitions such as channels frequencies
-#include "LoRaMac-board.h"
+#include "LoRaMac-definitions.h"
/*!
- * Beacon interval in ms
+ * Beacon interval in us
*/
-#define BEACON_INTERVAL 128000
+#define BEACON_INTERVAL 128000000
/*!
- * Class A&B receive delay 1 in ms
+ * Class A&B receive delay 1 in us
*/
-#define RECEIVE_DELAY1 1000
+#define RECEIVE_DELAY1 1000000
/*!
- * Class A&B receive delay 2 in ms
+ * Class A&B receive delay 2 in us
*/
-#define RECEIVE_DELAY2 2000
+#define RECEIVE_DELAY2 2000000
/*!
- * Join accept receive delay 1 in ms
+ * Join accept receive delay 1 in us
*/
-#define JOIN_ACCEPT_DELAY1 5000
+#define JOIN_ACCEPT_DELAY1 5000000
/*!
- * Join accept receive delay 2 in ms
+ * Join accept receive delay 2 in us
*/
-#define JOIN_ACCEPT_DELAY2 6000
+#define JOIN_ACCEPT_DELAY2 6000000
/*!
- * Class A&B maximum receive window delay in ms
+ * Class A&B maximum receive window delay in us
*/
-#define MAX_RX_WINDOW 3000
+#define MAX_RX_WINDOW 3000000
/*!
* Maximum allowed gap for the FCNT field
@@ -99,19 +99,19 @@
* receiving an acknowledge.
* AckTimeout = \ref ACK_TIMEOUT + Random( -\ref ACK_TIMEOUT_RND, \ref ACK_TIMEOUT_RND )
*/
-#define ACK_TIMEOUT 2000
+#define ACK_TIMEOUT 2000000
/*!
* Random number of seconds after the start of the second reception window without
* receiving an acknowledge
* AckTimeout = \ref ACK_TIMEOUT + Random( -\ref ACK_TIMEOUT_RND, \ref ACK_TIMEOUT_RND )
*/
-#define ACK_TIMEOUT_RND 1000
+#define ACK_TIMEOUT_RND 1000000
/*!
- * Check the Mac layer state every MAC_STATE_CHECK_TIMEOUT in ms
+ * Check the Mac layer state every MAC_STATE_CHECK_TIMEOUT in us
*/
-#define MAC_STATE_CHECK_TIMEOUT 1000
+#define MAC_STATE_CHECK_TIMEOUT 1000000
/*!
* Maximum number of times the MAC layer tries to get an acknowledge.
@@ -149,11 +149,6 @@
*/
#define LORA_MAC_PUBLIC_SYNCWORD 0x34
- /*!
- * LoRaMac internal state
- */
-//uint32_t LoRaMacState;
-
/*!
* LoRaWAN devices classes definition
*/
@@ -274,6 +269,57 @@
}Rx2ChannelParams_t;
/*!
+ * Global MAC layer parameters
+ */
+typedef struct sLoRaMacParams
+{
+ /*!
+ * Channels TX power
+ */
+ int8_t ChannelsTxPower;
+ /*!
+ * Channels data rate
+ */
+ int8_t ChannelsDatarate;
+ /*!
+ * LoRaMac maximum time a reception window stays open
+ */
+ uint32_t MaxRxWindow;
+ /*!
+ * Receive delay 1
+ */
+ uint32_t ReceiveDelay1;
+ /*!
+ * Receive delay 2
+ */
+ uint32_t ReceiveDelay2;
+ /*!
+ * Join accept delay 1
+ */
+ uint32_t JoinAcceptDelay1;
+ /*!
+ * Join accept delay 1
+ */
+ uint32_t JoinAcceptDelay2;
+ /*!
+ * Number of uplink messages repetitions [1:15] (unconfirmed messages only)
+ */
+ uint8_t ChannelsNbRep;
+ /*!
+ * Datarate offset between uplink and downlink on first window
+ */
+ uint8_t Rx1DrOffset;
+ /*!
+ * LoRaMAC 2nd reception window settings
+ */
+ Rx2ChannelParams_t Rx2Channel;
+ /*!
+ * Mask indicating which channels are enabled
+ */
+ uint16_t ChannelsMask[6];
+}LoRaMacParams_t;
+
+/*!
* LoRaMAC multicast channel parameter
*/
typedef struct sMulticastParams
@@ -1098,31 +1144,31 @@
*/
MIB_CHANNELS_NB_REP,
/*!
- * Maximum receive window duration in [ms]
+ * Maximum receive window duration in [us]
*
* LoRaWAN Specification V1.0.1, chapter 3.3.3
*/
MIB_MAX_RX_WINDOW_DURATION,
/*!
- * Receive delay 1 in [ms]
+ * Receive delay 1 in [us]
*
* LoRaWAN Specification V1.0.1, chapter 7
*/
MIB_RECEIVE_DELAY_1,
/*!
- * Receive delay 2 in [ms]
+ * Receive delay 2 in [us]
*
* LoRaWAN Specification V1.0.1, chapter 7
*/
MIB_RECEIVE_DELAY_2,
/*!
- * Join accept delay 1 in [ms]
+ * Join accept delay 1 in [us]
*
* LoRaWAN Specification V1.0.1, chapter 7
*/
MIB_JOIN_ACCEPT_DELAY_1,
/*!
- * Join accept delay 2 in [ms]
+ * Join accept delay 2 in [us]
*
* LoRaWAN Specification V1.0.1, chapter 7
*/