20171208

Fork of LoRaWAN-lib by Semtech

Revision:
7:c16969e0f70f
Parent:
4:37c12dbc8dc7
Child:
8:26002607de9c
diff -r d7a34ded7c87 -r c16969e0f70f LoRaMac.h
--- a/LoRaMac.h	Wed May 18 11:19:24 2016 +0000
+++ b/LoRaMac.h	Tue Jul 05 13:24:54 2016 +0000
@@ -47,7 +47,7 @@
 #define __LORAMAC_H__
 
 // Includes board dependent definitions such as channels frequencies
-#include "LoRaMac-board.h"
+#include "LoRaMac-definitions.h"
 
 /*!
  * Beacon interval in us
@@ -149,11 +149,6 @@
  */
 #define LORA_MAC_PUBLIC_SYNCWORD                    0x34
 
- /*!
- * LoRaMac internal state
- */
-//uint32_t LoRaMacState;
-
 /*!
  * LoRaWAN devices classes definition
  */
@@ -162,19 +157,19 @@
     /*!
      * LoRaWAN device class A
      *
-     * LoRaWAN Specification V1.0, chapter 3ff
+     * LoRaWAN Specification V1.0.1, chapter 3ff
      */
     CLASS_A,
     /*!
      * LoRaWAN device class B
      *
-     * LoRaWAN Specification V1.0, chapter 8ff
+     * LoRaWAN Specification V1.0.1, chapter 8ff
      */
     CLASS_B,
     /*!
      * LoRaWAN device class C
      *
-     * LoRaWAN Specification V1.0, chapter 17ff
+     * LoRaWAN Specification V1.0.1, chapter 17ff
      */
     CLASS_C,
 }DeviceClass_t;
@@ -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
@@ -303,7 +349,7 @@
 /*!
  * LoRaMAC frame types
  *
- * LoRaWAN Specification V1.0, chapter 4.2.1, table 1
+ * LoRaWAN Specification V1.0.1, chapter 4.2.1, table 1
  */
 typedef enum eLoRaMacFrameType
 {
@@ -344,7 +390,7 @@
 /*!
  * LoRaMAC mote MAC commands
  *
- * LoRaWAN Specification V1.0, chapter 5, table 4
+ * LoRaWAN Specification V1.0.1, chapter 5, table 4
  */
 typedef enum eLoRaMacMoteCmd
 {
@@ -381,7 +427,7 @@
 /*!
  * LoRaMAC server MAC commands
  *
- * LoRaWAN Specification V1.0, chapter 5, table 4
+ * LoRaWAN Specification V1.0.1 chapter 5, table 4
  */
 typedef enum eLoRaMacSrvCmd
 {
@@ -441,7 +487,7 @@
 /*!
  * LoRaMAC header field definition (MHDR field)
  *
- * LoRaWAN Specification V1.0, chapter 4.2
+ * LoRaWAN Specification V1.0.1, chapter 4.2
  */
 typedef union uLoRaMacHeader
 {
@@ -472,7 +518,7 @@
 /*!
  * LoRaMAC frame control field definition (FCtrl)
  *
- * LoRaWAN Specification V1.0, chapter 4.3.1
+ * LoRaWAN Specification V1.0.1, chapter 4.3.1
  */
 typedef union uLoRaMacFrameCtrl
 {
@@ -642,7 +688,7 @@
      * Frame port field. Must be set if the payload is not empty. Use the
      * application specific frame port values: [1...223]
      *
-     * LoRaWAN Specification V1.0, chapter 4.3.2
+     * LoRaWAN Specification V1.0.1, chapter 4.3.2
      */
     uint8_t fPort;
     /*!
@@ -668,7 +714,7 @@
      * Frame port field. Must be set if the payload is not empty. Use the
      * application specific frame port values: [1...223]
      *
-     * LoRaWAN Specification V1.0, chapter 4.3.2
+     * LoRaWAN Specification V1.0.1, chapter 4.3.2
      */
     uint8_t fPort;
     /*!
@@ -686,7 +732,7 @@
     /*!
      * Number of trials to transmit the frame, if the LoRaMAC layer did not
      * receive an acknowledgment. The MAC performs a datarate adaptation,
-     * according to the LoRaWAN Specification V1.0, chapter 18.4, according
+     * according to the LoRaWAN Specification V1.0.1, chapter 19.4, according
      * to the following table:
      *
      * Transmission nb | Data Rate
@@ -883,13 +929,13 @@
     /*!
      * Initiates the Over-the-Air activation
      *
-     * LoRaWAN Specification V1.0, chapter 6.2
+     * LoRaWAN Specification V1.0.1, chapter 6.2
      */
     MLME_JOIN,
     /*!
      * LinkCheckReq - Connectivity validation
      *
-     * LoRaWAN Specification V1.0, chapter 5, table 4
+     * LoRaWAN Specification V1.0.1, chapter 5, table 4
      */
     MLME_LINK_CHECK,
 }Mlme_t;
@@ -902,19 +948,19 @@
     /*!
      * Globally unique end-device identifier
      *
-     * LoRaWAN Specification V1.0, chapter 6.2.1
+     * LoRaWAN Specification V1.0.1, chapter 6.2.1
      */
     uint8_t *DevEui;
     /*!
      * Application identifier
      *
-     * LoRaWAN Specification V1.0, chapter 6.1.2
+     * LoRaWAN Specification V1.0.1, chapter 6.1.2
      */
     uint8_t *AppEui;
     /*!
      * AES-128 application key
      *
-     * LoRaWAN Specification V1.0, chapter 6.2.2
+     * LoRaWAN Specification V1.0.1, chapter 6.2.2
      */
     uint8_t *AppKey;
 }MlmeReqJoin_t;
@@ -1014,19 +1060,19 @@
     /*!
      * LoRaWAN device class
      *
-     * LoRaWAN Specification V1.0
+     * LoRaWAN Specification V1.0.1
      */
     MIB_DEVICE_CLASS,
     /*!
      * LoRaWAN Network joined attribute
      *
-     * LoRaWAN Specification V1.0
+     * LoRaWAN Specification V1.0.1
      */
     MIB_NETWORK_JOINED,
     /*!
      * Adaptive data rate
      *
-     * LoRaWAN Specification V1.0, chapter 4.3.1.1
+     * LoRaWAN Specification V1.0.1, chapter 4.3.1.1
      *
      * [true: ADR enabled, false: ADR disabled]
      */
@@ -1034,31 +1080,31 @@
     /*!
      * Network identifier
      *
-     * LoRaWAN Specification V1.0, chapter 6.2.5
+     * LoRaWAN Specification V1.0.1, chapter 6.1.1
      */
     MIB_NET_ID,
     /*!
      * End-device address
      *
-     * LoRaWAN Specification V1.0, chapter 6.1.2
+     * LoRaWAN Specification V1.0.1, chapter 6.1.1
      */
     MIB_DEV_ADDR,
     /*!
      * Network session key
      *
-     * LoRaWAN Specification V1.0, chapter 6.1.3
+     * LoRaWAN Specification V1.0.1, chapter 6.1.3
      */
     MIB_NWK_SKEY,
     /*!
      * Application session key
      *
-     * LoRaWAN Specification V1.0, chapter 6.1.4
+     * LoRaWAN Specification V1.0.1, chapter 6.1.4
      */
     MIB_APP_SKEY,
     /*!
      * Set the network type to public or private
      *
-     * LoRaWAN Specification V1.0, chapter 7
+     * LoRaWAN Specification V1.0.1, chapter 7
      *
      * [true: public network, false: private network]
      */
@@ -1066,7 +1112,7 @@
     /*!
      * Support the operation with repeaters
      *
-     * LoRaWAN Specification V1.0, chapter 7
+     * LoRaWAN Specification V1.0.1, chapter 7
      *
      * [true: repeater support enabled, false: repeater support disabled]
      */
@@ -1076,61 +1122,61 @@
      * pointer which references the first entry of the channel list. The
      * list is of size LORA_MAX_NB_CHANNELS
      *
-     * LoRaWAN Specification V1.0, chapter 7
+     * LoRaWAN Specification V1.0.1, chapter 7
      */
     MIB_CHANNELS,
     /*!
      * Set receive window 2 channel
      *
-     * LoRaWAN Specification V1.0, chapter 3.3.2
+     * LoRaWAN Specification V1.0.1, chapter 3.3.2
      */
     MIB_RX2_CHANNEL,
     /*!
      * LoRaWAN channels mask
      *
-     * LoRaWAN Specification V1.0, chapter 5.2
+     * LoRaWAN Specification V1.0.1, chapter 7
      */
     MIB_CHANNELS_MASK,
     /*!
      * Set the number of repetitions on a channel
      *
-     * LoRaWAN Specification V1.0, chapter 5.2
+     * LoRaWAN Specification V1.0.1, chapter 5.2
      */
     MIB_CHANNELS_NB_REP,
     /*!
      * Maximum receive window duration in [us]
      *
-     * LoRaWAN Specification V1.0, chapter 3.3.3
+     * LoRaWAN Specification V1.0.1, chapter 3.3.3
      */
     MIB_MAX_RX_WINDOW_DURATION,
     /*!
      * Receive delay 1 in [us]
      *
-     * LoRaWAN Specification V1.0, chapter 6
+     * LoRaWAN Specification V1.0.1, chapter 7
      */
     MIB_RECEIVE_DELAY_1,
     /*!
      * Receive delay 2 in [us]
      *
-     * LoRaWAN Specification V1.0, chapter 6
+     * LoRaWAN Specification V1.0.1, chapter 7
      */
     MIB_RECEIVE_DELAY_2,
     /*!
      * Join accept delay 1 in [us]
      *
-     * LoRaWAN Specification V1.0, chapter 6
+     * LoRaWAN Specification V1.0.1, chapter 7
      */
     MIB_JOIN_ACCEPT_DELAY_1,
     /*!
      * Join accept delay 2 in [us]
      *
-     * LoRaWAN Specification V1.0, chapter 6
+     * LoRaWAN Specification V1.0.1, chapter 7
      */
     MIB_JOIN_ACCEPT_DELAY_2,
     /*!
      * Default Data rate of a channel
      *
-     * LoRaWAN Specification V1.0, chapter 7
+     * LoRaWAN Specification V1.0.1, chapter 7
      *
      * EU868 - [DR_0, DR_1, DR_2, DR_3, DR_4, DR_5, DR_6, DR_7]
      *
@@ -1140,7 +1186,7 @@
     /*!
      * Data rate of a channel
      *
-     * LoRaWAN Specification V1.0, chapter 7
+     * LoRaWAN Specification V1.0.1, chapter 7
      *
      * EU868 - [DR_0, DR_1, DR_2, DR_3, DR_4, DR_5, DR_6, DR_7]
      *
@@ -1150,7 +1196,7 @@
     /*!
      * Transmission power of a channel
      *
-     * LoRaWAN Specification V1.0, chapter 7
+     * LoRaWAN Specification V1.0.1, chapter 7
      *
      * EU868 - [TX_POWER_20_DBM, TX_POWER_14_DBM, TX_POWER_11_DBM,
      *          TX_POWER_08_DBM, TX_POWER_05_DBM, TX_POWER_02_DBM]
@@ -1164,13 +1210,13 @@
     /*!
      * LoRaWAN Up-link counter
      *
-     * LoRaWAN Specification V1.0, chapter 4.3.1.5
+     * LoRaWAN Specification V1.0.1, chapter 4.3.1.5
      */
     MIB_UPLINK_COUNTER,
     /*!
      * LoRaWAN Down-link counter
      *
-     * LoRaWAN Specification V1.0, chapter 4.3.1.5
+     * LoRaWAN Specification V1.0.1, chapter 4.3.1.5
      */
     MIB_DOWNLINK_COUNTER,
     /*!