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
Committer:
mluis
Date:
Thu Nov 26 17:17:08 2015 +0000
Revision:
4:85b2b647cb64
Parent:
1:d3b7bde3995c
Merged branches

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mluis 0:62d1edcc13d1 1 /*******************************************************************************
mluis 1:d3b7bde3995c 2 * Copyright (c) 2014-2015 IBM Corporation.
mluis 0:62d1edcc13d1 3 * All rights reserved. This program and the accompanying materials
mluis 0:62d1edcc13d1 4 * are made available under the terms of the Eclipse Public License v1.0
mluis 0:62d1edcc13d1 5 * which accompanies this distribution, and is available at
mluis 0:62d1edcc13d1 6 * http://www.eclipse.org/legal/epl-v10.html
mluis 0:62d1edcc13d1 7 *
mluis 0:62d1edcc13d1 8 * Contributors:
mluis 0:62d1edcc13d1 9 * IBM Zurich Research Lab - initial API, implementation and documentation
mluis 0:62d1edcc13d1 10 *******************************************************************************/
mluis 0:62d1edcc13d1 11
mluis 0:62d1edcc13d1 12 #ifndef _hal_hpp_
mluis 0:62d1edcc13d1 13 #define _hal_hpp_
mluis 0:62d1edcc13d1 14
mluis 0:62d1edcc13d1 15 /*
mluis 0:62d1edcc13d1 16 * initialize hardware (IO, SPI, TIMER, IRQ).
mluis 0:62d1edcc13d1 17 */
mluis 0:62d1edcc13d1 18 void hal_init (void);
mluis 0:62d1edcc13d1 19
mluis 0:62d1edcc13d1 20 /*
mluis 0:62d1edcc13d1 21 * drive radio NSS pin (0=low, 1=high).
mluis 0:62d1edcc13d1 22 */
mluis 0:62d1edcc13d1 23 void hal_pin_nss (u1_t val);
mluis 0:62d1edcc13d1 24
mluis 0:62d1edcc13d1 25 /*
mluis 0:62d1edcc13d1 26 * drive radio RX/TX pins (0=rx, 1=tx).
mluis 0:62d1edcc13d1 27 */
mluis 0:62d1edcc13d1 28 void hal_pin_rxtx (u1_t val);
mluis 0:62d1edcc13d1 29
mluis 0:62d1edcc13d1 30 /*
mluis 0:62d1edcc13d1 31 * control radio RST pin (0=low, 1=high, 2=floating)
mluis 0:62d1edcc13d1 32 */
mluis 0:62d1edcc13d1 33 void hal_pin_rst (u1_t val);
mluis 0:62d1edcc13d1 34
mluis 0:62d1edcc13d1 35 /*
mluis 0:62d1edcc13d1 36 * perform 8-bit SPI transaction with radio.
mluis 0:62d1edcc13d1 37 * - write given byte 'outval'
mluis 0:62d1edcc13d1 38 * - read byte and return value
mluis 0:62d1edcc13d1 39 */
mluis 0:62d1edcc13d1 40 u1_t hal_spi (u1_t outval);
mluis 0:62d1edcc13d1 41
mluis 0:62d1edcc13d1 42 /*
mluis 0:62d1edcc13d1 43 * disable all CPU interrupts.
mluis 0:62d1edcc13d1 44 * - might be invoked nested
mluis 0:62d1edcc13d1 45 * - will be followed by matching call to hal_enableIRQs()
mluis 0:62d1edcc13d1 46 */
mluis 0:62d1edcc13d1 47 void hal_disableIRQs (void);
mluis 0:62d1edcc13d1 48
mluis 0:62d1edcc13d1 49 /*
mluis 0:62d1edcc13d1 50 * enable CPU interrupts.
mluis 0:62d1edcc13d1 51 */
mluis 0:62d1edcc13d1 52 void hal_enableIRQs (void);
mluis 0:62d1edcc13d1 53
mluis 0:62d1edcc13d1 54 /*
mluis 0:62d1edcc13d1 55 * put system and CPU in low-power mode, sleep until interrupt.
mluis 0:62d1edcc13d1 56 */
mluis 0:62d1edcc13d1 57 void hal_sleep (void);
mluis 0:62d1edcc13d1 58
mluis 0:62d1edcc13d1 59 /*
mluis 0:62d1edcc13d1 60 * return 32-bit system time in ticks.
mluis 0:62d1edcc13d1 61 */
mluis 0:62d1edcc13d1 62 u4_t hal_ticks (void);
mluis 0:62d1edcc13d1 63
mluis 0:62d1edcc13d1 64 /*
mluis 0:62d1edcc13d1 65 * busy-wait until specified timestamp (in ticks) is reached.
mluis 0:62d1edcc13d1 66 */
mluis 0:62d1edcc13d1 67 void hal_waitUntil (u4_t time);
mluis 0:62d1edcc13d1 68
mluis 0:62d1edcc13d1 69 /*
mluis 0:62d1edcc13d1 70 * check and rewind timer for target time.
mluis 0:62d1edcc13d1 71 * - return 1 if target time is close
mluis 0:62d1edcc13d1 72 * - otherwise rewind timer for target time or full period and return 0
mluis 0:62d1edcc13d1 73 */
mluis 0:62d1edcc13d1 74 u1_t hal_checkTimer (u4_t targettime);
mluis 0:62d1edcc13d1 75
mluis 0:62d1edcc13d1 76 /*
mluis 0:62d1edcc13d1 77 * perform fatal failure action.
mluis 0:62d1edcc13d1 78 * - called by assertions
mluis 0:62d1edcc13d1 79 * - action could be HALT or reboot
mluis 0:62d1edcc13d1 80 */
mluis 0:62d1edcc13d1 81 void hal_failed (void);
mluis 0:62d1edcc13d1 82
mluis 0:62d1edcc13d1 83 #endif // _hal_hpp_