end node on synchronous star LoRa network.

Dependencies:   SX127x sx12xx_hal TSL2561

radio chip selection

Radio chip driver is not included, allowing choice of radio device.
If you're using SX1272 or SX1276, then import sx127x driver into your program.
if you're using SX1261 or SX1262, then import sx126x driver into your program.
if you're using SX1280, then import sx1280 driver into your program.
If you're using NAmote72 or Murata discovery, then you must import only sx127x driver.

This project for use with LoRaWAN_singlechannel_gateway project.

Alternately gateway running on raspberry pi can be used as gateway.

LoRaWAN on single radio channel

Network description is at gateway project page. Synchronous star network.

Hardware Support

This project supports SX1276 and SX1272, sx126x kit, sx126x shield, and sx128x 2.4GHz. The ST board B-L072Z-LRWAN1 is also supported (TypeABZ module). When B-L072Z-LRWAN1 target is selected, TARGET_DISCO_L072CZ_LRWAN1 is defined by tools, allowing correct radio driver configuration for this platform. Alternately, any mbed board that can use LoRa radio shield board should work, but NUCLEO boards are tested.

End-node Unique ID

DevEUI is created from CPU serial number. AppEUI and AppKey are declared as software constants.

End-node Configuration

Data rate definition LORAMAC_DEFAULT_DATARATE configured in LoRaMac-definitions.h. See gateway project page for configuration of gateway.
LoRaWAN addressing is configured in Comissioning.h; only OTA mode is functional.
Header file board/lora_config.h, selects application layer options (i.e. sensors) to be compiled in.

Serial Interface

Serial port operates at 115200bps.
Application layer single_us915_main.cpp User button triggers uplink (i.e. blue button on nucleo board), or jumper enables continuously sends repeated uplink packets. The MAC layer holds each uplink request until the allocated timeslot.

commandargumentsdescription
?-print available commands
. (period)-print status (DevEUI, DevAddr, etc)
ullength integerset payload length of test uplink packets

sensor demo

Selected grove sensors may be plugged into SX1272 shield.
To enable, edit lora_config.h to define SENSORS.

Sensor connections on SX1272MB2xAS:

D8 D9: buttonRX TX: (unused)A3 A4: Rotary Angle Sensor
D6 D7: RGB LEDSCL SDA: digital light sensorA1 A2: Rotary Angle Sensor

Digital input pin, state reported via uplink: PC8
Digital output pin, controlled via downlink: PC6
PWM out: PB_10

Jumper enables auto-repeated transmit: PC10 and PC12 on NUCLEO board, located on end of morpho headers nearby JP4.

Revision:
29:ad409c68c0a6
Parent:
25:fed9d5b77183
Child:
30:1c35c4f56e50
--- a/mac/LoRaMac.h	Mon Aug 28 13:13:56 2017 -0700
+++ b/mac/LoRaMac.h	Fri Dec 07 17:57:41 2018 -0800
@@ -22,11 +22,7 @@
  *
  * \endcode
  *
- * \author    Miguel Luis ( Semtech )
- *
- * \author    Gregory Cristian ( Semtech )
- *
- * \author    Daniel Jäckle ( STACKFORCE )
+ * \author    ( Semtech )
  *
  * \defgroup  LORAMAC LoRa MAC layer implementation
  *            This module specifies the API implementation of the LoRaMAC layer.
@@ -34,14 +30,6 @@
  *            layer and the supported features.
  * \{
  *
- * \example   classA/LoRaMote/main.c
- *            LoRaWAN class A application example for the LoRaMote.
- *
- * \example   classB/LoRaMote/main.c
- *            LoRaWAN class B application example for the LoRaMote.
- *
- * \example   classC/LoRaMote/main.c
- *            LoRaWAN class C application example for the LoRaMote.
  */
 #ifndef __LORAMAC_H__
 #define __LORAMAC_H__
@@ -52,14 +40,13 @@
 /*!
  * Beacon interval in ms
  */
-#define BEACON_INTERVAL_us                   128000000        /*16000000*/
-#define PPM_100_BEACON_INTERVAL              (BEACON_INTERVAL_us / 10000)
+#define BEACON_INTERVAL_us                   128000000        /*16000000*/      /*8000000*/
+#define PPM_BEACON_INTERVAL              (BEACON_INTERVAL_us / 5000)   /* timer crystal max error accomidation */
 
 /*!
- * Class A&B receive delay 1 in ms
+ * Class A&B receive delay 1 in us
  */
-#define RECEIVE_DELAY_us              /*1000000 */ 100000
-
+#define RECEIVE_DELAY_us                              100000
 
 #define JOIN_ACCEPT_DELAY_us                          100000
 
@@ -268,7 +255,7 @@
      * [-SystemMaxRxError : +SystemMaxRxError]
      * Default: +/-10 ms
      */
-    uint32_t SystemMaxRxError;
+    uint32_t SystemMaxRxError_ms;
     /*!
      * Minimum required number of symbols to detect an Rx frame
      * Default: 6 symbols
@@ -607,29 +594,37 @@
         /*!
          * MCPS-Req pending
          */
-        uint8_t McpsReq         : 1;
+        uint16_t McpsReq         : 1; // 0
         /*!
          * MCPS-Ind pending
          */
-        uint8_t McpsInd         : 1;
+        uint16_t McpsInd         : 1; // 1
         /*!
          * MCPS-Ind pending. Skip indication to the application layer
          */
-        uint8_t McpsIndSkip     : 1;
+        uint16_t McpsIndSkip     : 1; // 2
         /*!
          * MLME-Req pending
          */
-        uint8_t MlmeReq         : 1;
+        uint16_t MlmeReq         : 1; // 3
         /*!
          * MAC cycle done
          */
-        uint8_t MacDone         : 1;
+        uint16_t MacDone         : 1; // 4
         /*!
          * MLME-Ind pending
          */
-        uint8_t MlmeInd         : 1;
+        uint16_t MlmeInd         : 1; // 5
+
+        uint16_t uplink_pending  : 1; // 6
 
-        uint8_t uplink_pending  : 1;
+        uint16_t IsLoRaMacNetworkJoined : 1; // 7
+        uint16_t join_send              : 1; // 8
+        uint16_t send                   : 1; // 9
+        uint16_t expecting_beacon       : 1; // 10
+        uint16_t reJoin                 : 1; // 11
+        uint16_t NodeAckRequested       : 1; // 12
+        uint16_t SrvAckRequested        : 1; // 13
     }Bits;
 }LoRaMacFlags_t;
 
@@ -829,9 +824,8 @@
     //uint8_t NbRetries;
     /*!
      * The transmission time on air of the frame
-     */
-    //TimerTime_t TxTimeOnAir;
-    uint32_t TxTimeOnAir;
+     *
+    uint32_t TxTimeOnAir;*/
     /*!
      * The uplink counter value related to the frame
      */
@@ -1048,9 +1042,8 @@
     LoRaMacEventInfoStatus_t Status;
     /*!
      * The transmission time on air of the frame
-     */
-    //TimerTime_t TxTimeOnAir;
-    uint32_t TxTimeOnAir;
+     *
+    uint32_t TxTimeOnAir;*/
     /*!
      * Demodulation margin. Contains the link margin [dB] of the last
      * successfully received LinkCheckReq
@@ -1131,7 +1124,7 @@
      *
      * LoRaWAN Specification V1.0.1
      */
-    MIB_DEVICE_CLASS,
+    //MIB_DEVICE_CLASS,
     /*!
      * LoRaWAN Network joined attribute
      *
@@ -1378,41 +1371,6 @@
      */
     bool EnablePublicNetwork;
     /*!
-     * Enable or disable repeater support
-     *
-     * Related MIB type: \ref MIB_REPEATER_SUPPORT
-     */
-    //bool EnableRepeaterSupport;
-    /*!
-     * LoRaWAN Channel
-     *
-     * Related MIB type: \ref MIB_CHANNELS
-     */
-    //ChannelParams_t* ChannelList;
-     /*!
-     * Channel for the receive window 2
-     *
-     * Related MIB type: \ref MIB_RX2_CHANNEL
-     */
-     /*!
-     * Channel for the receive window 2
-     *
-     * Related MIB type: \ref MIB_RX2_DEFAULT_CHANNEL
-     */
-    //Rx2ChannelParams_t Rx2DefaultChannel;
-    /*!
-     * Channel mask
-     *
-     * Related MIB type: \ref MIB_CHANNELS_MASK
-     */
-    //uint16_t* ChannelsMask;
-    /*!
-     * Default channel mask
-     *
-     * Related MIB type: \ref MIB_CHANNELS_DEFAULT_MASK
-     */
-    //uint16_t* ChannelsDefaultMask;
-    /*!
      * Number of frame repetitions
      *
      * Related MIB type: \ref MIB_CHANNELS_NB_REP
@@ -1433,13 +1391,13 @@
      *
      * Related MIB type: \ref MIB_CHANNELS_DEFAULT_DATARATE
      */
-    int8_t ChannelsDefaultDatarate;
+    //int8_t ChannelsDefaultDatarate;
     /*!
      * Channels data rate
      *
      * Related MIB type: \ref MIB_CHANNELS_DATARATE
      */
-    int8_t ChannelsDatarate;
+    //int8_t ChannelsDatarate;
     /*!
      * Channels TX power
      *
@@ -1475,7 +1433,7 @@
      *
      * Related MIB type: \ref MIB_SYSTEM_MAX_RX_ERROR
      */
-    uint32_t SystemMaxRxError;
+    uint32_t SystemMaxRxError_ms;
     /*!
      * Minimum required number of symbols to detect an Rx frame
      *