LMIC for MOTE_L152RC
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 LMIC_reverse_memcpy() for AppEUI to keep same byte order as that 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 LMIC_reverse_memcpy() for DevEUI to keep same byte order as that 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.
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.
Information
DevEUI is entered in reverse order into C-code from that shown on server (unique device ID).
AppEUI is entered in reverse order into C-code from that shown on server.
AppEUI is equivalent to "Application"
transmit power limits
FCC Part 15 rules permit one watt of transmit power when more than 50 channels are used. When received by a 64-channel gateway, the maximum power may be used.
However, if end-device is sending to a 8-channel gateway (single SX1301), the maximum transmit power permitted is +20dBm.
To configure LMIC for use with 8-channel gateway, CHNL_HYBRID
should be defined in in config.h, and should be undefined for use with 64-channel gateway.
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: radio.cpp
- Revision:
- 8:0faa1bb768b5
- Parent:
- 4:1a9a62cf220f
- Child:
- 9:83ae7f34e88c
--- a/radio.cpp Mon Sep 21 17:59:42 2015 +0000 +++ b/radio.cpp Wed Oct 21 01:03:34 2015 +0000 @@ -399,7 +399,33 @@ DigitalOut pd2(PD_2); // power amplifier voltage control pin +/* pd2=0 pd2=1 +op pab rfo rfo +0 4.6 18.5 27.0 +1 5.6 21.1 28.1 +2 6.7 23.3 29.1 +3 7.7 25.3 30.1 +4 8.8 26.2 30.7 +5 9.8 27.3 31.2 +6 10.7 28.1 31.6 +7 11.7 28.6 32.2 +8 12.8 29.2 32.4 +9 13.7 29.9 32.9 +10 14.7 30.5 33.1 +11 15.6 30.8 33.4 +12 16.4 30.9 33.6 +13 17.1 31.0 33.7 +14 17.8 31.1 33.7 +15 18.4 31.1 33.7 +*/ +// txpow: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 +static const u1_t boost_table[20] = { 0, 0, 0, 0, 0, 1, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15 }; + +// txpow: 20 21 22 23 24 25 26 27 28 29 30 +static const u1_t rfo_table[11] = { 1, 1, 1, 2, 2, 3, 4, 5, 6, 8, 9 }; + static void configPower () { + printf("txpow:%d ", LMIC.txpow); #ifdef CFG_sx1276_radio // no boost used for now s1_t pw = (s1_t)LMIC.txpow; @@ -413,30 +439,17 @@ writeReg(RegPaDac, readReg(RegPaDac)|0x4); #elif defined(CFG_sx1272_radio) - // set PA config (2-17 dBm using PA_BOOST) - s1_t pw = (s1_t)LMIC.txpow; - /*if(pw > 17) { - pw = 17; - } else if(pw < 2) { - pw = 2; - }*/ + /* NA-mote TX power config: */ - if (pw > 23) { - // use RFO with external amplifier + if (LMIC.txpow > 19) { PaSelect = 0x00; // use RFO - writeReg(RegPaConfig, (u1_t)(PaSelect|(pw-25))); - if (pw > 26) - pd2 = 1; - else - pd2 = 0; + writeReg(RegPaConfig, PaSelect | rfo_table[LMIC.txpow-20]); + pd2 = 0; } else { - // use PA_BOOST direct to antenna PaSelect = 0x80; // use PA_BOOST - if (pw > 17) - pw = 17; - writeReg(RegPaConfig, (u1_t)(PaSelect|(pw-2))); + writeReg(RegPaConfig, PaSelect | boost_table[LMIC.txpow]); } - + //printf("PaConfig:%02x\r\n", readReg(RegPaConfig)); #else #error Missing CFG_sx1272_radio/CFG_sx1276_radio