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: hal.h
- Revision:
- 0:62d1edcc13d1
- Child:
- 1:d3b7bde3995c
diff -r 000000000000 -r 62d1edcc13d1 hal.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hal.h Thu Jan 22 12:50:49 2015 +0000 @@ -0,0 +1,115 @@ +/******************************************************************************* + * Copyright (c) 2014 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Zurich Research Lab - initial API, implementation and documentation + *******************************************************************************/ + +#ifndef _hal_hpp_ +#define _hal_hpp_ + +/* + * initialize hardware (IO, SPI, TIMER, IRQ). + */ +void hal_init (void); + +/* + * drive radio NSS pin (0=low, 1=high). + */ +void hal_pin_nss (u1_t val); + +/* + * drive radio RX/TX pins (0=rx, 1=tx). + */ +void hal_pin_rxtx (u1_t val); + +/* + * control radio RST pin (0=low, 1=high, 2=floating) + */ +void hal_pin_rst (u1_t val); + +/* + * perform 8-bit SPI transaction with radio. + * - write given byte 'outval' + * - read byte and return value + */ +u1_t hal_spi (u1_t outval); + +/* + * disable all CPU interrupts. + * - might be invoked nested + * - will be followed by matching call to hal_enableIRQs() + */ +void hal_disableIRQs (void); + +/* + * enable CPU interrupts. + */ +void hal_enableIRQs (void); + +/* + * put system and CPU in low-power mode, sleep until interrupt. + */ +void hal_sleep (void); + +/* + * return 32-bit system time in ticks. + */ +u4_t hal_ticks (void); + +/* + * busy-wait until specified timestamp (in ticks) is reached. + */ +void hal_waitUntil (u4_t time); + +/* + * check and rewind timer for target time. + * - return 1 if target time is close + * - otherwise rewind timer for target time or full period and return 0 + */ +u1_t hal_checkTimer (u4_t targettime); + +/* + * perform fatal failure action. + * - called by assertions + * - action could be HALT or reboot + */ +void hal_failed (void); + +////////////////////////////////////////////////////////////////////// +#ifdef CFG_DEBUG +void debug_init (void); +void debug_led (u1_t val); +void debug_char (u1_t c); +void debug_hex (u1_t b); +void debug_buf (const u1_t* buf, u2_t len); +void debug_uint (u4_t v); +void debug_str (const u1_t* str); +void debug_event (int ev); +void debug_val (const u1_t* label, u4_t val); +#define DEBUG_INIT() debug_init() +#define DEBUG_LED(v) debug_led(v) +#define DEBUG_CHAR(c) debug_char(c) +#define DEBUG_HEX(b) debug_hex(b) +#define DEBUG_BUF(b,l) debug_buf(b,l) +#define DEBUG_UINT(v) debug_uint(v) +#define DEBUG_STR(s) debug_str(s) +#define DEBUG_EVENT(e) debug_event(e) +#define DEBUG_VAL(l,v) debug_val(l, v) +#else // CFG_DEBUG +#define DEBUG_INIT() +#define DEBUG_LED(v) +#define DEBUG_CHAR(c) +#define DEBUG_HEX(b) +#define DEBUG_BUF(b,l) +#define DEBUG_UINT(v) +#define DEBUG_STR(s) +#define DEBUG_EVENT(e) +#define DEBUG_VAL(l,v) +#endif // CFG_DEBUG + +#endif // _hal_hpp_