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 |
TARGET_MOTE_L152RC/debug.cpp@0:f2716e543d97, 2015-06-02 (annotated)
- Committer:
- dudmuck
- Date:
- Tue Jun 02 19:04:29 2015 +0000
- Revision:
- 0:f2716e543d97
- Child:
- 9:83ae7f34e88c
lmic-v1.5 for MOTE_L152RC
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dudmuck | 0:f2716e543d97 | 1 | //#include "oslmic.h" |
dudmuck | 0:f2716e543d97 | 2 | #include "lmic.h" |
dudmuck | 0:f2716e543d97 | 3 | #include "debug.h" |
dudmuck | 0:f2716e543d97 | 4 | #include "mbed.h" |
dudmuck | 0:f2716e543d97 | 5 | |
dudmuck | 0:f2716e543d97 | 6 | Serial pc(USBTX, USBRX); |
dudmuck | 0:f2716e543d97 | 7 | |
dudmuck | 0:f2716e543d97 | 8 | static DigitalOut red_led(PB_1); |
dudmuck | 0:f2716e543d97 | 9 | #define LED_ON 0 |
dudmuck | 0:f2716e543d97 | 10 | #define LED_OFF 1 |
dudmuck | 0:f2716e543d97 | 11 | |
dudmuck | 0:f2716e543d97 | 12 | void debug_init() |
dudmuck | 0:f2716e543d97 | 13 | { |
dudmuck | 0:f2716e543d97 | 14 | pc.baud(115200); |
dudmuck | 0:f2716e543d97 | 15 | |
dudmuck | 0:f2716e543d97 | 16 | // print banner |
dudmuck | 0:f2716e543d97 | 17 | debug_str("\r\n============== DEBUG STARTED ==============\r\n"); |
dudmuck | 0:f2716e543d97 | 18 | |
dudmuck | 0:f2716e543d97 | 19 | red_led = LED_OFF; |
dudmuck | 0:f2716e543d97 | 20 | } |
dudmuck | 0:f2716e543d97 | 21 | |
dudmuck | 0:f2716e543d97 | 22 | void debug_str (const char* str) |
dudmuck | 0:f2716e543d97 | 23 | { |
dudmuck | 0:f2716e543d97 | 24 | debug("%s", str); |
dudmuck | 0:f2716e543d97 | 25 | } |
dudmuck | 0:f2716e543d97 | 26 | |
dudmuck | 0:f2716e543d97 | 27 | void debug_event (int ev) |
dudmuck | 0:f2716e543d97 | 28 | { |
dudmuck | 0:f2716e543d97 | 29 | static const u1_t* evnames[] = { |
dudmuck | 0:f2716e543d97 | 30 | [EV_SCAN_TIMEOUT] = "SCAN_TIMEOUT", |
dudmuck | 0:f2716e543d97 | 31 | [EV_BEACON_FOUND] = "BEACON_FOUND", |
dudmuck | 0:f2716e543d97 | 32 | [EV_BEACON_MISSED] = "BEACON_MISSED", |
dudmuck | 0:f2716e543d97 | 33 | [EV_BEACON_TRACKED] = "BEACON_TRACKED", |
dudmuck | 0:f2716e543d97 | 34 | [EV_JOINING] = "JOINING", |
dudmuck | 0:f2716e543d97 | 35 | [EV_JOINED] = "JOINED", |
dudmuck | 0:f2716e543d97 | 36 | [EV_RFU1] = "RFU1", |
dudmuck | 0:f2716e543d97 | 37 | [EV_JOIN_FAILED] = "JOIN_FAILED", |
dudmuck | 0:f2716e543d97 | 38 | [EV_REJOIN_FAILED] = "REJOIN_FAILED", |
dudmuck | 0:f2716e543d97 | 39 | [EV_TXCOMPLETE] = "TXCOMPLETE", |
dudmuck | 0:f2716e543d97 | 40 | [EV_LOST_TSYNC] = "LOST_TSYNC", |
dudmuck | 0:f2716e543d97 | 41 | [EV_RESET] = "RESET", |
dudmuck | 0:f2716e543d97 | 42 | [EV_RXCOMPLETE] = "RXCOMPLETE", |
dudmuck | 0:f2716e543d97 | 43 | [EV_LINK_DEAD] = "LINK_DEAD", |
dudmuck | 0:f2716e543d97 | 44 | [EV_LINK_ALIVE] = "LINK_ALIVE", |
dudmuck | 0:f2716e543d97 | 45 | }; |
dudmuck | 0:f2716e543d97 | 46 | |
dudmuck | 0:f2716e543d97 | 47 | debug("%s\r\n", evnames[ev]); |
dudmuck | 0:f2716e543d97 | 48 | } |
dudmuck | 0:f2716e543d97 | 49 | |
dudmuck | 0:f2716e543d97 | 50 | void debug_val (const char* label, u4_t val) |
dudmuck | 0:f2716e543d97 | 51 | { |
dudmuck | 0:f2716e543d97 | 52 | debug("%s%d\r\n", label, val); |
dudmuck | 0:f2716e543d97 | 53 | } |
dudmuck | 0:f2716e543d97 | 54 | |
dudmuck | 0:f2716e543d97 | 55 | void debug_buf(const u1_t* buf, u2_t len) |
dudmuck | 0:f2716e543d97 | 56 | { |
dudmuck | 0:f2716e543d97 | 57 | while (len--) { |
dudmuck | 0:f2716e543d97 | 58 | debug("%02x ", *buf++); |
dudmuck | 0:f2716e543d97 | 59 | } |
dudmuck | 0:f2716e543d97 | 60 | debug("\r\n"); |
dudmuck | 0:f2716e543d97 | 61 | } |
dudmuck | 0:f2716e543d97 | 62 | |
dudmuck | 0:f2716e543d97 | 63 | void debug_led(unsigned char on) |
dudmuck | 0:f2716e543d97 | 64 | { |
dudmuck | 0:f2716e543d97 | 65 | if (on) |
dudmuck | 0:f2716e543d97 | 66 | red_led = LED_ON; |
dudmuck | 0:f2716e543d97 | 67 | else |
dudmuck | 0:f2716e543d97 | 68 | red_led = LED_OFF; |
dudmuck | 0:f2716e543d97 | 69 | } |
dudmuck | 0:f2716e543d97 | 70 | |
dudmuck | 0:f2716e543d97 | 71 | void debug_done() |
dudmuck | 0:f2716e543d97 | 72 | { |
dudmuck | 0:f2716e543d97 | 73 | /* block until last bit sent out debug UART */ |
dudmuck | 0:f2716e543d97 | 74 | while (!(USART2->SR & UART_FLAG_TC)) |
dudmuck | 0:f2716e543d97 | 75 | __NOP(); |
dudmuck | 0:f2716e543d97 | 76 | } |