IBM LoRa MAC in C (LMiC) mbed library port

Dependents:   lora-temperature LoRaWAN-lmic-app_HS LoRaWAN-lmic-app_huynh

LoRa WAN in C for sx1276 shield

Currently version 1.5


LoRaWAN network configuration for end-device

The following three pieces of information uniquely identifies end-device to network to allow over-the-air activation. These are stored in the end-device prior to join procedure.

AppEUI

Uniquely identifies application provider of end-device.

Least-significant byte first, 8 bytes, use reverse memcpy() to keep same order as shown on lora server.

example C code

static const u1_t APPEUI[8]  = { 0x01, 0x00, 0x01, 0x00, 0x00, 0x0C, 0x25, 0x00 };

This is copied into LMIC by os_getArtEui() callback function in application.

DevEUI

End-device ID, unique to each end-node.

Least-significant byte first, 8 bytes, use reverse memcpy() to keep same order as shown on lora server.

example C code

static const u1_t DEVEUI[8]  = { 0x00, 0x00, 0x00, 0x00, 0x01, 0x0C, 0x25, 0x00 }; 

This is copied into LMIC by os_getDevEui() callback function in application.

AppKey (aka DevKey)

128-bit (16byte) AES key.

example C code

static const u1_t DEVKEY[16] = { 0xe4, 0x72, 0x71, 0xc5, 0xf5, 0x30, 0xa9, 0x9f, 0xcf, 0xc4, 0x0e, 0xab, 0xea, 0xd7, 0x19, 0x42 };

This is copied into LMIC by os_getDevKey() callback function in application.

Using over-the air activation, the end-device (LMIC) performs a join procedure every time it starts for first time, or has lost session context information. When join procedure has successfully completed, the end-device will have a network session key (NwkSKey) and an application session key (AppSKey), which are used for encryption and message integrity check.


US915 configuration with http://us01-iot.semtech.com/

  • log in to server
  • click on Applications
  • find your application and click it
  • go to configure motes
  • to create a mote, you may enter a new DevEUI
    • you may copy-paste the 16byte application key from an already existing mote, if you desire.
CHNL_HYBRID125KHz500KHz
defined valuechannelschannel
00 to 764
18 to 1565
216 to 2366
324 to 3167
432 to 3968
540 to 4769
648 to 5570
756 to 6371
undef0 to 6364 to 71
Revision:
2:974cafbfb159
Parent:
1:d3b7bde3995c
Child:
4:85b2b647cb64
--- a/lmic.h	Tue Mar 31 13:36:56 2015 +0000
+++ b/lmic.h	Wed Nov 25 02:49:45 2015 +0000
@@ -16,8 +16,9 @@
 #define _lmic_h_
 
 // MBED compiler options
-#define CFG_eu868                                   1
-//#define CFG_us915                                   0
+//#define CFG_eu868                                   1
+#define CFG_us915                                   1
+#define CHNL_HYBRID     0       /* US915: 0-7 to select block of 8 channels used */
 
 #define USE_SMTC_RADIO_DRIVER                       1
 
@@ -30,16 +31,16 @@
 
 // LMIC version
 #define LMIC_VERSION_MAJOR 1
-#define LMIC_VERSION_MINOR 4
-#define LMIC_VERSION_BUILD 1426605786
+#define LMIC_VERSION_MINOR 5
+#define LMIC_VERSION_BUILD 1431528305
 
 enum { MAX_FRAME_LEN      =  64 };   //!< Library cap on max frame length
 enum { TXCONF_ATTEMPTS    =   8 };   //!< Transmit attempts for confirmed frames
 enum { MAX_MISSED_BCNS    =  20 };   // threshold for triggering rejoin requests
 enum { MAX_RXSYMS         = 100 };   // stop tracking beacon beyond this
 
-enum { LINK_CHECK_CONT    =   6 ,    // continue with this after reported dead link
-       LINK_CHECK_DEAD    =  12 ,    // after this UP frames and no response from NWK assume link is dead
+enum { LINK_CHECK_CONT    =  12 ,    // continue with this after reported dead link
+       LINK_CHECK_DEAD    =  24 ,    // after this UP frames and no response from NWK assume link is dead
        LINK_CHECK_INIT    = -12 ,    // UP frame count until we inc datarate
        LINK_CHECK_OFF     =-128 };   // link check disabled
 
@@ -157,6 +158,7 @@
     u1_t        rxsyms;
     u1_t        dndr;
     s1_t        txpow;     // dBm
+    s1_t        txpow_limit;    // dBm maximum permitted
 
     osjob_t     osjob;
 
@@ -183,6 +185,8 @@
     u1_t        datarate;     // current data rate
     u1_t        errcr;        // error coding rate (used for TX only)
     u1_t        rejoinCnt;    // adjustment for rejoin datarate
+    u1_t        joinBlock;    // during join attempt: current channel block
+    u1_t        joinBlockChnl;    // during join attempt: current 125KHz channel    
     s2_t        drift;        // last measured drift
     s2_t        lastDriftDiff;
     s2_t        maxDriftDiff;
@@ -268,6 +272,7 @@
 void LMIC_setSession (u4_t netid, devaddr_t devaddr, xref2u1_t nwkKey, xref2u1_t artKey);
 void LMIC_setLinkCheckMode (bit_t enabled);
 
+void LMIC_reverse_memcpy(u1_t *dst, const u1_t *src, size_t len);
 // Special APIs - for development or testing
 // !!!See implementation for caveats!!!