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_HYBRID | 125KHz | 500KHz |
---|---|---|
defined value | channels | channel |
0 | 0 to 7 | 64 |
1 | 8 to 15 | 65 |
2 | 16 to 23 | 66 |
3 | 24 to 31 | 67 |
4 | 32 to 39 | 68 |
5 | 40 to 47 | 69 |
6 | 48 to 55 | 70 |
7 | 56 to 63 | 71 |
undef | 0 to 63 | 64 to 71 |
Diff: lmic.cpp
- Revision:
- 3:519c71d29a06
- Parent:
- 1:d3b7bde3995c
- Child:
- 4:85b2b647cb64
--- a/lmic.cpp Tue Mar 31 13:36:56 2015 +0000 +++ b/lmic.cpp Thu Nov 26 12:46:56 2015 +0000 @@ -689,7 +689,6 @@ LMIC.txend = LMIC.bands[BAND_MILLI].avail + rndDelay(8); } - static ostime_t nextJoinState (void) { u1_t failed = 0; @@ -741,11 +740,12 @@ static u4_t convFreq (xref2u1_t ptr) { u4_t freq = (os_rlsbf4(ptr-1) >> 8) * 100; - if( freq >= US915_FREQ_MIN && freq <= US915_FREQ_MAX ) + if( freq < US915_FREQ_MIN || freq > US915_FREQ_MAX ) freq = 0; return freq; } + bit_t LMIC_setupChannel (u1_t chidx, u4_t freq, u2_t drmap, s1_t band) { if( chidx < 72 || chidx >= 72+MAX_XCHANNELS ) return 0; // channels 0..71 are hardwired @@ -1382,7 +1382,7 @@ u1_t chidx=72; #endif for( ; chidx<8; chidx++, dlen+=3 ) - LMIC_setupChannel(chidx, os_rlsbf4(&LMIC.frame[dlen-1]) >> 8, 0, -1); + LMIC_setupChannel(chidx, convFreq(&LMIC.frame[dlen]), 0, -1); } // already incremented when JOIN REQ got sent off