Code Monkey home page Code Monkey logo

arduino-lmic's Introduction

⚠️ This repository is no longer maintained. The recommended alternative is the MCCI version of LMIC, which is based on this one, but has seen much improvements over the years, has much better documentation and is mostly a drop-in replacement. If you need support for the SX126x, you can consider Lacuna's port of BasicMAC, which is based on a parallel development based on the original LMIC. Only when you have very tight constraints on RAM or flash should this version still be considered.

See this post for more details and background.

Arduino-LMIC library

This repository contains the IBM LMIC (LoraMAC-in-C) library, slightly modified to run in the Arduino environment, allowing using the SX1272, SX1276 tranceivers and compatible modules (such as some HopeRF RFM9x modules).

This library mostly exposes the functions defined by LMIC, it makes no attempt to wrap them in a higher level API that is more in the Arduino style. To find out how to use the library itself, see the examples, or see the PDF file in the doc subdirectory.

This library requires Arduino IDE version 1.6.6 or above, since it requires C99 mode to be enabled by default.

Installing

To install this library:

  • install it using the Arduino Library manager ("Sketch" -> "Include Library" -> "Manage Libraries..."), or
  • download a zipfile from github using the "Download ZIP" button and install it using the IDE ("Sketch" -> "Include Library" -> "Add .ZIP Library..."
  • clone this git repository into your sketchbook/libraries folder.

For more info, see https://www.arduino.cc/en/Guide/Libraries

Features

The LMIC library provides a fairly complete LoRaWAN Class A and Class B implementation, supporting the EU-868 and US-915 bands. Only a limited number of features was tested using this port on Arduino hardware, so be careful when using any of the untested features.

What certainly works:

  • Sending packets uplink, taking into account duty cycling.
  • Encryption and message integrity checking.
  • Receiving downlink packets in the RX2 window.
  • Custom frequencies and datarate settings.
  • Over-the-air activation (OTAA / joining).

What has not been tested:

  • Receiving downlink packets in the RX1 window.
  • Receiving and processing MAC commands.
  • Class B operation.

If you try one of these untested features and it works, be sure to let us know (creating a github issue is probably the best way for that).

Configuration

A number of features can be configured or disabled by editing the config.h file in the library folder. Unfortunately the Arduino environment does not offer any way to do this (compile-time) configuration from the sketch, so be careful to recheck your configuration when you switch between sketches or update the library.

At the very least, you should set the right type of transceiver (SX1272 vs SX1276) in config.h, most other values should be fine at their defaults.

Supported hardware

This library is intended to be used with plain LoRa transceivers, connecting to them using SPI. In particular, the SX1272 and SX1276 families are supported (which should include SX1273, SX1277, SX1278 and SX1279 which only differ in the available frequencies, bandwidths and spreading factors). It has been tested with both SX1272 and SX1276 chips, using the Semtech SX1272 evaluation board and the HopeRF RFM92 and RFM95 boards (which supposedly contain an SX1272 and SX1276 chip respectively).

This library contains a full LoRaWAN stack and is intended to drive these Transceivers directly. It is not intended to be used with full-stack devices like the Microchip RN2483 and the Embit LR1272E. These contain a transceiver and microcontroller that implements the LoRaWAN stack and exposes a high-level serial interface instead of the low-level SPI transceiver interface.

This library is intended to be used inside the Arduino environment. It should be architecture-independent, so it should run on "normal" AVR arduinos, but also on the ARM-based ones, and some success has been seen running on the ESP8266 board as well. It was tested on the Arduino Uno, Pinoccio Scout, Teensy LC and 3.x, ESP8266, Arduino 101.

This library an be quite heavy, especially if the fairly small ATmega 328p (such as in the Arduino Uno) is used. In the default configuration, the available 32K flash space is nearly filled up (this includes some debug output overhead, though). By disabling some features in config.h (like beacon tracking and ping slots, which are not typically needed), some space can be freed up. Some work is underway to replace the AES encryption implementation, which should free up another 8K or so of flash in the future, making this library feasible to run on a 328p microcontroller.

Connections

To make this library work, your Arduino (or whatever Arduino-compatible board you are using) should be connected to the transceiver. The exact connections are a bit dependent on the transceiver board and Arduino used, so this section tries to explain what each connection is for and in what cases it is (not) required.

Note that the SX1272 module runs at 3.3V and likely does not like 5V on its pins (though the datasheet is not say anything about this, and my transceiver did not obviously break after accidentally using 5V I/O for a few hours). To be safe, make sure to use a level shifter, or an Arduino running at 3.3V. The Semtech evaluation board has 100 ohm resistors in series with all data lines that might prevent damage, but I would not count on that.

Power

The SX127x transceivers need a supply voltage between 1.8V and 3.9V. Using a 3.3V supply is typical. Some modules have a single power pin (like the HopeRF modules, labeled 3.3V) but others expose multiple power pins for different parts (like the Semtech evaluation board that has VDD_RF, VDD_ANA and VDD_FEM), which can all be connected together. Any GND pins need to be connected to the Arduino GND pin(s).

SPI

The primary way of communicating with the transceiver is through SPI (Serial Peripheral Interface). This uses four pins: MOSI, MISO, SCK and SS. The former three need to be directly connected: so MOSI to MOSI, MISO to MISO, SCK to SCK. Where these pins are located on your Arduino varies, see for example the "Connections" section of the Arduino SPI documentation.

The SS (slave select) connection is a bit more flexible. On the SPI slave side (the transceiver), this must be connect to the pin (typically) labeled NSS. On the SPI master (Arduino) side, this pin can connect to any I/O pin. Most Arduinos also have a pin labeled "SS", but this is only relevant when the Arduino works as an SPI slave, which is not the case here. Whatever pin you pick, you need to tell the library what pin you used through the pin mapping (see below).

DIO pins

The DIO (digitial I/O) pins on the transceiver board can be configured for various functions. The LMIC library uses them to get instant status information from the transceiver. For example, when a LoRa transmission starts, the DIO0 pin is configured as a TxDone output. When the transmission is complete, the DIO0 pin is made high by the transceiver, which can be detected by the LMIC library.

The LMIC library needs only access to DIO0, DIO1 and DIO2, the other DIOx pins can be left disconnected. On the Arduino side, they can connect to any I/O pin, since the current implementation does not use interrupts or other special hardware features (though this might be added in the feature, see also the "Timing" section).

In LoRa mode the DIO pins are used as follows:

  • DIO0: TxDone and RxDone
  • DIO1: RxTimeout

In FSK mode they are used as follows::

  • DIO0: PayloadReady and PacketSent
  • DIO2: TimeOut

Both modes need only 2 pins, but the tranceiver does not allow mapping them in such a way that all needed interrupts map to the same 2 pins. So, if both LoRa and FSK modes are used, all three pins must be connected.

The pins used on the Arduino side should be configured in the pin mapping in your sketch (see below).

Reset

The transceiver has a reset pin that can be used to explicitely reset it. The LMIC library uses this to ensure the chip is in a consistent state at startup. In practice, this pin can be left disconnected, since the transceiver will already be in a sane state on power-on, but connecting it might prevent problems in some cases.

On the Arduino side, any I/O pin can be used. The pin number used must be configured in the pin mapping (see below).

RXTX

The transceiver contains two separate antenna connections: One for RX and one for TX. A typical transceiver board contains an antenna switch chip, that allows switching a single antenna between these RX and TX connections. Such a antenna switcher can typically be told what position it should be through an input pin, often labeled RXTX.

The easiest way to control the antenna switch is to use the RXTX pin on the SX127x transceiver. This pin is automatically set high during TX and low during RX. For example, the HopeRF boards seem to have this connection in place, so they do not expose any RXTX pins and the pin can be marked as unused in the pin mapping.

Some boards do expose the antenna switcher pin, and sometimes also the SX127x RXTX pin. For example, the SX1272 evaluation board calls the former FEM_CTX and the latter RXTX. Again, simply connecting these together with a jumper wire is the easiest solution.

Alternatively, or if the SX127x RXTX pin is not available, LMIC can be configured to control the antenna switch. Connect the antenna switch control pin (e.g. FEM_CTX on the Semtech evaluation board) to any I/O pin on the Arduino side, and configure the pin used in the pin map (see below). It is not entirely clear why would not want the transceiver to control the antenna directly, though.

Pin mapping

As described above, most connections can use arbitrary I/O pins on the Arduino side. To tell the LMIC library about these, a pin mapping struct is used in the sketch file.

For example, this could look like this:

lmic_pinmap lmic_pins = {
    .nss = 6,
    .rxtx = LMIC_UNUSED_PIN,
    .rst = 5,
    .dio = {2, 3, 4},
};

The names refer to the pins on the transceiver side, the numbers refer to the Arduino pin numbers (to use the analog pins, use constants like A0). For the DIO pins, the three numbers refer to DIO0, DIO1 and DIO2 respectively. Any pins that are not needed should be specified as LMIC_UNUSED_PIN. The nss and dio0 pin is required, the others can potentially left out (depending on the environments and requirements, see the notes above for when a pin can or cannot be left out).

The name of this struct must always be lmic_pins, which is a special name recognized by the library.

LoRa Nexus by Ideetron

This board uses the following pin mapping:

const lmic_pinmap lmic_pins = {
    .nss = 10,
    .rxtx = LMIC_UNUSED_PIN,
    .rst = LMIC_UNUSED_PIN, // hardwired to AtMega RESET
    .dio = {4, 5, 7},
};

Examples

This library currently provides three examples:

  • ttn-abp.ino shows a basic transmission of a "Hello, world!" message using the LoRaWAN protocol. It contains some frequency settings and encryption keys intended for use with The Things Network, but these also correspond to the default settings of most gateways, so it should work with other networks and gateways as well. This example uses activation-by-personalization (ABP, preconfiguring a device address and encryption keys), and does not employ over-the-air activation.

    Reception of packets (in response to transmission, using the RX1 and RX2 receive windows is also supported).

  • ttn-otaa.ino also sends a "Hello, world!" message, but uses over the air activation (OTAA) to first join a network to establish a session and security keys. This was tested with The Things Network, but should also work (perhaps with some changes) for other networks.

  • raw.ino shows how to access the radio on a somewhat low level, and allows to send raw (non-LoRaWAN) packets between nodes directly. This is useful to verify basic connectivity, and when no gateway is available, but this example also bypasses duty cycle checks, so be careful when changing the settings.

Timing

Unfortunately, the SX127x tranceivers do not support accurate timekeeping themselves (there is a sequencer that is almost sufficient for timing the RX1 and RX2 downlink windows, but that is only available in FSK mode, not in LoRa mode). This means that the microcontroller is responsible for keeping track of time. In particular, it should note when a packet finished transmitting, so it can open up the RX1 and RX2 receive windows at a fixed time after the end of transmission.

This timing uses the Arduino micros() timer, which has a granularity of 4μs and is based on the primary microcontroller clock. For timing events, the tranceiver uses its DIOx pins as interrupt outputs. In the current implementation, these pins are not handled by an actual interrupt handler, but they are just polled once every LMIC loop, resulting in a bit inaccuracy in the timestamping. Also, running scheduled jobs (such as opening up the receive windows) is done using a polling approach, which might also result in further delays.

Fortunately, LoRa is a fairly slow protocol and the timing of the receive windows is not super critical. To synchronize transmitter and receiver, a preamble is first transmitted. Using LoRaWAN, this preamble consists of 8 symbols, of which the receiver needs to see 4 symbols to lock on. The current implementation tries to enable the receiver for 5 symbol times at 1.5 symbol after the start of the receive window, meaning that a inacurracy of plus or minus 2.5 symbol times should be acceptable.

At the fastest LoRa setting supported by the tranceiver (SF5BW500) a single preamble symbol takes 64μs, so the receive window timing should be accurate within 160μs (for LoRaWAN this is SF7BW250, needing accuracy within 1280μs). This is certainly within a crystal's accuracy, but using the internal oscillator is probably not feasible (which is 1% - 10% accurate, depending on calibration). This accuracy should also be feasible with the polling approach used, provided that the LMIC loop is run often enough.

It would be good to properly review this code at some point, since it seems that in some places some offsets and corrections are applied that might not be appropriate for the Arduino environment. So if reception is not working, the timing is something to have a closer look at.

The LMIC library was intended to connect the DIO pins to interrupt lines and run code inside the interrupt handler. However, doing this opens up an entire can of worms with regard to doing SPI transfers inside interrupt routines (some of which is solved by the Arduino beginTransaction() API, but possibly not everything). One simpler alternative could be to use an interrupt handler to just store a timestamp, and then do the actual handling in the main loop (this requires modifications of the library to pass a timestamp to the LMIC radio_irq_handler() function).

An even more accurate solution could be to use a dedicated timer with an input capture unit, that can store the timestamp of a change on the DIO0 pin (the only one that is timing-critical) entirely in hardware. Unfortunately, timer0, as used by Arduino's millis() and micros() functions does not seem to have an input capture unit, meaning a separate timer is needed for this.

If the main microcontroller does not have a crystal, but uses the internal oscillator, the clock output of the transceiver (on DIO5) could be usable to drive this timer instead of the main microcontroller clock, to ensure the receive window timing is sufficiently accurate. Ideally, this would use timer2, which supports asynchronous mode (e.g. running while the microcontroller is sleeping), but that timer does not have an input capture unit. Timer1 has one, but it seems it will stop running once the microcontroller sleeps. Running the microcontroller in idle mode with a slower clock might be feasible, though. Instead of using the main crystal oscillator of the transceiver, it could be possible to use the transceiver's internal RC oscillator (which is calibrated against the transceiver crystal), or to calibrate the microcontroller internal RC oscillator using the transceiver's clkout. However, that datasheet is a bit vague on the RC oscillator's accuracy and how to use it exactly (some registers seem to be FSK-mode only), so this needs some experiments.

The code can currently compensate for an inaccurate clock, by calling the LMIC_setClockError() function somewhere during setup. You can pass a clock error percentage, e.g. to correct for 1% clock error:

LMIC_setClockError(MAX_CLOCK_ERROR * 1 / 100);

Problems with downlink and OTAA

Uplink will often work right away, but sometimes downlink (and thus also OTAA) will not work directly. In practice, this is often due to inaccuracies in the receive window timing (see the previous section for details). If you run into problems with OTAA or downlink, it is a good idea to relax the RX mode timings to see if that helps by adding this to your setup somewhere:

LMIC_setClockError(MAX_CLOCK_ERROR * 10 / 100);

This function is intended to compensate for clock inaccuracy (up to ±10% in this example), but that also works to compensate for inaccuracies due to software delays. The downside of this compensation is a longer receive window, which means a higher battery drain. So if this helps, you might want to try to lower the percentage (i.e. lower the 10 in the above call), often 1% works well already.

Downlink datarate

Note that the datarate used for downlink packets in the RX2 window defaults to SF12BW125 according to the specification, but some networks use different values (iot.semtech.com and The Things Network both use SF9BW). When using personalized activate (ABP), it is your responsibility to set the right settings, e.g. by adding this to your sketch (after calling LMIC_setSession). ttn-abp.ino already does this.

 LMIC.dn2Dr = DR_SF9;

When using OTAA, the network communicates the RX2 settings in the join accept message, but the LMIC library does not currently process these settings. Until that is solved (see issue #20), you should manually set the RX2 rate, after joining (see the handling of EV_JOINED in the ttn-otaa.ino for an example.

License

Most source files in this repository are made available under the Eclipse Public License v1.0. The examples which use a more liberal license. Some of the AES code is available under the LGPL. Refer to each individual source file for more details.

arduino-lmic's People

Contributors

belovictor avatar frankleonrose avatar matthijskooijman avatar oliv4945 avatar per1234 avatar robertoostenveld avatar tftelkamp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arduino-lmic's Issues

Dragino shield V1.3 : Pin mapping

for the documentation
// Pin mapping for Dragino Board Version 1.3 (open J_DIO5)
const lmic_pinmap lmic_pins = {
.nss = 10,
.rxtx = LMIC_UNUSED_PIN,
.rst = 9,
.dio = {2, 6, 7}, // Specify pin numbers for DIO0, 1, 2
// connected to D2, D6, D7
};
not tested with LoRa/GPS shield!

AdaFruit LoRa Feather M0 - ARM related Issue?

I'm trying to get the AdaFruit M0 LoRa feather working with LoRaWAN with OTAA. While compiling the example I get this error. It seems to be ARM Cortex M0 related, but I haven't found a solution yet. Any ideas?

Product : https://www.adafruit.com/product/3178

[ ARDUINO ERROR LOG]
Build options changed, rebuilding all
C:\Users\Jort-Signa\Documents\Arduino\libraries\IBM_LMIC_framework\src\hal\hal.cpp: In function 'void hal_printf_init()':

C:\Users\Jort-Signa\Documents\Arduino\libraries\IBM_LMIC_framework\src\hal\hal.cpp:223:54: error: '_FDEV_SETUP_WRITE' was not declared in this scope

 fdev_setup_stream (&uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE);

                                                  ^

C:\Users\Jort-Signa\Documents\Arduino\libraries\IBM_LMIC_framework\src\hal\hal.cpp:223:71: error: 'fdev_setup_stream' was not declared in this scope

 fdev_setup_stream (&uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE);

                                                                   ^

exit status 1
Error compiling for board Adafruit Feather M0 (Native USB Port).
[/ARDUINO ERROR LOG]

Expose the radio.c functions in the LMIC API?

What do you think about exposing the constants and functions defined in radio.c as part of the LMIC API, even just a via a radio.h would do?

I'd like to be able to use the radio.c functions in my own code, for example, like in @tftelkamp's gateway but it would be much nicer not to have to duplicate all the LMIC radio.c and hal code.

Get it connected rfm95 (Sx1276)

If you want to connect the rfm95 (Sx1276) to lib.

In the library open the file: 'lmic/config.h'

Change the following comments:
//#define CFG_eu868 1

define CFG_us915 1

//#define CFG_sx1272_radio 1

define CFG_sx1276_radio 1

We can't set it in the Arduino .ino file, so you have to change it in the code.

DIO1 or DIO2 must be used

const lmic_pinmap lmic_pins = {
.nss = 4,
.rxtx = LMIC_UNUSED_PIN,
.rst = LMIC_UNUSED_PIN,
.dio = {2, LMIC_UNUSED_PIN, LMIC_UNUSED_PIN},
};

won't work on Moteino Mega LORA: Sketch keeps rebooting with printing "Starting" endless.
If one of DIO1 or DIO2 gets a pin assigned (doesn't matter if connected or not) sketch gets in queued state after multiple lines with "Starting" but won't get to EV_TXCOMPLETE.
Will test tomorrow if there is a difference if the pins are connected -older "testing" works fine with all pins connected and defined

EV_TXCOMPLETE slow to occur

I've been looking at a battery powered node using an ESP8266 and RFM95W hoping to get quite long battery life sleeping most of the time, however it turns out that it takes quite a long time for the node to do a send and get the TX_COMPLETE event back, 6 - 10 seconds, so even when using deepSleep for the rest of the time that 10 seconds of up time would drain the batteries quite quickly.

That seems odd, it shouldn't take so long should it? Poking around in the LMIC code and the SX1276 datasheet it sounded like after a send DIO0 going high would indicate the send is complete so I've tried using that to trigger when to put the ESP8266 in deepSleep, and that seems to work, DIO0 goes high about 130 milliseconds after the send and putting the ESP8266 to sleep then the gateway still seems to get the transmission ok.

I wonder is this a bug in the LMIC code that its not doing the EV_TXCOMPLETE sooner, or perhaps is the SX1276 carrying on finishing the send after i put the ESP to sleep after 130milliseconds and the SX1276 stays awake? Any ideas?

I've put this code i have for this ESP8266/RFM95W node here.

(I've previously asked about this over here)

Wrong DIO function mapping

In this block of code, DIO mapping for LoRa mode is defined. In particular MAP_DIO2_LORA_NOP (which should represent ----11--, or 0x0C) is defined as 0xC0, which equals 11------.

This sets the DIO0 mapping to 11 instead, corresponding to it being unused according to the SX1272 datasheet in table 17. This value is written into the DIO mapping register in this OR statement. As a result, when receiving in LoRa mode, a check on DIO0 does not signal when a receiving event has occurred.

I have not yet had the chance to test the effect of this change, when I do and it fixes any issues I had with receiving, I will make a pull request. In the mean time, I am posting this here to hear other people's opinions (I might be overlooking something, eg. other modules than SX1272).

I am aware this would be an error at the IBM side, but I'm making a GH issue here first, as this HAL makes use of the pin.

TX power issues

Currently, the library allows setting the TX power using LMIC_setDrTxpow(). This sets the LMIC.adrTxPow field, but this field is never actually used anywhere.

The actual tx power to use is kept in LMIC.txpow and is currently defined per-band for 868 and hardcoded for 900 (see updateTx() for both).

However, the actual writing of the registers in configPower() seems inconsistent. The comments say that PA_BOOST is used for SX1272 and RFO for SX1276, but then for both the PaSelect bit (0x80) is set in RegPaConfig to select PA_BOOST. However, the corresponding value in RegPaDac, which should be 0x7 for PA_BOOST is set to 0x4 (for RFO), or left at the default of 0x4. Correction: RegPaDac should be set to 0x7 only for +20dBm operation (which requires additional care), with RegPaDac PA_BOOST is limited to +17dBm.

Then, the cropping of the txpow value for 1276 seems wrong, if txpow is 16, it effectively becomes 0 instead of 15 (due to the & 0xf masking). The lower limit is set to 2, but if PA_BOOST is indeed not used, this should be 0.

Finally, the txpower -> register setting calculation is wrong, assuming no PA_BOOST is used. The datasheet says:

Pmax=10.8+0.6*MaxPower [dBm]
Pout=Pmax-(15-OutputPower) if PaSelect = 0 (RFO pins)

If MaxPower == 7, then Pmax = 15 and Pout = OutputPower (just like with SX1272, which does not have MaxPower). The calculation seems to assume this, but it sets MaxPower to 0.

However, since PaSelect is actually set (using PA_BOOST), the real calculation should be txpow-2 (as for 1272). Effectively, I believe this means that for the 0.1% and 1% bands, LMIC on a 17276 currently transmits at 16dBm instead of the intended 14dBm.

1272 uno and error radio.c:659

I use module sx1272 on uno and i get failure

Starting
FAILURE
/home/cyryl/Arduino/libraries/arduino-lmic-1.5.0-arduino-1/src/lmic/radio.c:659

Receiving downlink packets in RX1 windows seems to work

In German Digimondo LoRaWAN network i can see that acknowledgement packets are successfully received in RX1 windows with this LMIC stack:

{
"tmst": 3872703516,
"time_on_air": 144384,
"size": 12,
"rx_window": "rx1",
"rfch": 0,
"powe": 14,
"modu": "LORA",
"ipol": true,
"gw_mac": "0000024B08060246",
"freq": 867.1,
"datr": "SF9BW125",
"data": "YCiEqRcgsQOCfKao",
"codr": "4/5"
}

SPI clock issue on ATmega328

Hi,

Hi tried your library with an RFM95 chip and the "raw" exemple, and it works with an ATMega1280 but not 328... I hooked up an oscilloscope and spotted that there is only 3 clock cycles !
I saw on TheThinkNetwork that you tried it on ATMega328, did you already run into this issue ?

Thanks !

Autoconvert EUIs to little-endian

The LMIC library expects EUIs for OTAA to be in the little-endian format that is used in LoRa transmissions. Currently, the examples just specify the EUIs as byte arrays, requiring the programmer to manually "reverse" the bytes to get a little endian number. Ideally, you would just specify a uint64_t for the EUI and let the compiler/code figure things out.

Using a uint64_t means that the data will be stored in architecture-specific order, so handling it needs to be different between little and big endian systems. Unfortunately the libc standard endianness conversion functions aren't available on AVR, so we should probably add a specific one just for EUIs / uint64_t.

Ideally, the conversion would happen at compiletime through a macro, so at runtime the bytes can just be copied directly from PROGMEM using memcpy_P as now (manually copying and inverting seems to result in bigger code).

RE:arduino-lmic

hie there I am trying to build a Lora node to node communication using two mini arduinos and twoFM LORA TRANSCEIVER MODULE, PRE SET TO 868MHZ which has an SX1272 Chip, im having sme errors on my arduino, its not compiling instead im getting these errors...
\ Build options changed, rebuilding all
C:\Users\x00097124\Documents\Arduino\libraries\arduino-lmic-master\src\hal\hal.cpp: In function 'u4_t hal_ticks()':
C:\Users\x00097124\Documents\Arduino\libraries\arduino-lmic-master\src\hal\hal.cpp:154:115: error: 'static_assert' was not declared in this scope
static_assert(US_PER_OSTICK_EXPONENT > 0 && US_PER_OSTICK_EXPONENT < 8, "Invalid US_PER_OSTICK_EXPONENT value");
^
Error compiling. //
what could be my problem, please help...

Arduino Mega Cant Send Data To TTN Server!

Hi,

I am using Arduino Mega + Adafruit RFM95 (SX1276). The code is working, but I do not know how to send data to The Things Network server, and view them.

This is the console output:
issuelora

I really need your help in how to do TTN server configuration.

Thanks in advance.

Arduino error for SX1276 module

Startting Failure

C:\Users\XXX\Desktop\Sketch\libraries\arduino-lmic-master\src\lmic\radio.c 689

I have tried with 1.6.10, 1.6.11 and latest version of arduino.

radio.c code which i am using

/*******************************************************************************

  • Copyright (c) 2014-2015 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
    *******************************************************************************/

#include "lmic.h"

// ----------------------------------------
// Registers Mapping
#define RegFifo 0x00 // common
#define RegOpMode 0x01 // common
#define FSKRegBitrateMsb 0x02
#define FSKRegBitrateLsb 0x03
#define FSKRegFdevMsb 0x04
#define FSKRegFdevLsb 0x05
#define RegFrfMsb 0x06 // common
#define RegFrfMid 0x07 // common
#define RegFrfLsb 0x08 // common
#define RegPaConfig 0x09 // common
#define RegPaRamp 0x0A // common
#define RegOcp 0x0B // common
#define RegLna 0x0C // common
#define FSKRegRxConfig 0x0D
#define LORARegFifoAddrPtr 0x0D
#define FSKRegRssiConfig 0x0E
#define LORARegFifoTxBaseAddr 0x0E
#define FSKRegRssiCollision 0x0F
#define LORARegFifoRxBaseAddr 0x0F
#define FSKRegRssiThresh 0x10
#define LORARegFifoRxCurrentAddr 0x10
#define FSKRegRssiValue 0x11
#define LORARegIrqFlagsMask 0x11
#define FSKRegRxBw 0x12
#define LORARegIrqFlags 0x12
#define FSKRegAfcBw 0x13
#define LORARegRxNbBytes 0x13
#define FSKRegOokPeak 0x14
#define LORARegRxHeaderCntValueMsb 0x14
#define FSKRegOokFix 0x15
#define LORARegRxHeaderCntValueLsb 0x15
#define FSKRegOokAvg 0x16
#define LORARegRxPacketCntValueMsb 0x16
#define LORARegRxpacketCntValueLsb 0x17
#define LORARegModemStat 0x18
#define LORARegPktSnrValue 0x19
#define FSKRegAfcFei 0x1A
#define LORARegPktRssiValue 0x1A
#define FSKRegAfcMsb 0x1B
#define LORARegRssiValue 0x1B
#define FSKRegAfcLsb 0x1C
#define LORARegHopChannel 0x1C
#define FSKRegFeiMsb 0x1D
#define LORARegModemConfig1 0x1D
#define FSKRegFeiLsb 0x1E
#define LORARegModemConfig2 0x1E
#define FSKRegPreambleDetect 0x1F
#define LORARegSymbTimeoutLsb 0x1F
#define FSKRegRxTimeout1 0x20
#define LORARegPreambleMsb 0x20
#define FSKRegRxTimeout2 0x21
#define LORARegPreambleLsb 0x21
#define FSKRegRxTimeout3 0x22
#define LORARegPayloadLength 0x22
#define FSKRegRxDelay 0x23
#define LORARegPayloadMaxLength 0x23
#define FSKRegOsc 0x24
#define LORARegHopPeriod 0x24
#define FSKRegPreambleMsb 0x25
#define LORARegFifoRxByteAddr 0x25
#define LORARegModemConfig3 0x26
#define FSKRegPreambleLsb 0x26
#define FSKRegSyncConfig 0x27
#define LORARegFeiMsb 0x28
#define FSKRegSyncValue1 0x28
#define LORAFeiMib 0x29
#define FSKRegSyncValue2 0x29
#define LORARegFeiLsb 0x2A
#define FSKRegSyncValue3 0x2A
#define FSKRegSyncValue4 0x2B
#define LORARegRssiWideband 0x2C
#define FSKRegSyncValue5 0x2C
#define FSKRegSyncValue6 0x2D
#define FSKRegSyncValue7 0x2E
#define FSKRegSyncValue8 0x2F
#define FSKRegPacketConfig1 0x30
#define FSKRegPacketConfig2 0x31
#define LORARegDetectOptimize 0x31
#define FSKRegPayloadLength 0x32
#define FSKRegNodeAdrs 0x33
#define LORARegInvertIQ 0x33
#define FSKRegBroadcastAdrs 0x34
#define FSKRegFifoThresh 0x35
#define FSKRegSeqConfig1 0x36
#define FSKRegSeqConfig2 0x37
#define LORARegDetectionThreshold 0x37
#define FSKRegTimerResol 0x38
#define FSKRegTimer1Coef 0x39
#define LORARegSyncWord 0x39
#define FSKRegTimer2Coef 0x3A
#define FSKRegImageCal 0x3B
#define FSKRegTemp 0x3C
#define FSKRegLowBat 0x3D
#define FSKRegIrqFlags1 0x3E
#define FSKRegIrqFlags2 0x3F
#define RegDioMapping1 0x40 // common
#define RegDioMapping2 0x41 // common
#define RegVersion 0x42 // common
// #define RegAgcRef 0x43 // common
// #define RegAgcThresh1 0x44 // common
// #define RegAgcThresh2 0x45 // common
// #define RegAgcThresh3 0x46 // common
// #define RegPllHop 0x4B // common
// #define RegTcxo 0x58 // common
#define RegPaDac 0x5A // common
// #define RegPll 0x5C // common
// #define RegPllLowPn 0x5E // common
// #define RegFormerTemp 0x6C // common
// #define RegBitRateFrac 0x70 // common

// ----------------------------------------
// spread factors and mode for RegModemConfig2
#define SX1272_MC2_FSK 0x00
#define SX1272_MC2_SF7 0x70
#define SX1272_MC2_SF8 0x80
#define SX1272_MC2_SF9 0x90
#define SX1272_MC2_SF10 0xA0
#define SX1272_MC2_SF11 0xB0
#define SX1272_MC2_SF12 0xC0
// bandwidth for RegModemConfig1
#define SX1272_MC1_BW_125 0x00
#define SX1272_MC1_BW_250 0x40
#define SX1272_MC1_BW_500 0x80
// coding rate for RegModemConfig1
#define SX1272_MC1_CR_4_5 0x08
#define SX1272_MC1_CR_4_6 0x10
#define SX1272_MC1_CR_4_7 0x18
#define SX1272_MC1_CR_4_8 0x20
#define SX1272_MC1_IMPLICIT_HEADER_MODE_ON 0x04 // required for receive
#define SX1272_MC1_RX_PAYLOAD_CRCON 0x02
#define SX1272_MC1_LOW_DATA_RATE_OPTIMIZE 0x01 // mandated for SF11 and SF12
// transmit power configuration for RegPaConfig
#define SX1272_PAC_PA_SELECT_PA_BOOST 0x80
#define SX1272_PAC_PA_SELECT_RFIO_PIN 0x00

// sx1276 RegModemConfig1
#define SX1276_MC1_BW_125 0x70
#define SX1276_MC1_BW_250 0x80
#define SX1276_MC1_BW_500 0x90
#define SX1276_MC1_CR_4_5 0x02
#define SX1276_MC1_CR_4_6 0x04
#define SX1276_MC1_CR_4_7 0x06
#define SX1276_MC1_CR_4_8 0x08

#define SX1276_MC1_IMPLICIT_HEADER_MODE_ON 0x01

// sx1276 RegModemConfig2
#define SX1276_MC2_RX_PAYLOAD_CRCON 0x04

// sx1276 RegModemConfig3
#define SX1276_MC3_LOW_DATA_RATE_OPTIMIZE 0x08
#define SX1276_MC3_AGCAUTO 0x04

// preamble for lora networks (nibbles swapped)
#define LORA_MAC_PREAMBLE 0x34

#define RXLORA_RXMODE_RSSI_REG_MODEM_CONFIG1 0x0A
#ifdef CFG_sx1276_radio
#define RXLORA_RXMODE_RSSI_REG_MODEM_CONFIG2 0x70
#elif CFG_sx1272_radio
#define RXLORA_RXMODE_RSSI_REG_MODEM_CONFIG2 0x74
#endif

// ----------------------------------------
// Constants for radio registers
#define OPMODE_LORA 0x80
#define OPMODE_MASK 0x07
#define OPMODE_SLEEP 0x00
#define OPMODE_STANDBY 0x01
#define OPMODE_FSTX 0x02
#define OPMODE_TX 0x03
#define OPMODE_FSRX 0x04
#define OPMODE_RX 0x05
#define OPMODE_RX_SINGLE 0x06
#define OPMODE_CAD 0x07

// ----------------------------------------
// Bits masking the corresponding IRQs from the radio
#define IRQ_LORA_RXTOUT_MASK 0x80
#define IRQ_LORA_RXDONE_MASK 0x40
#define IRQ_LORA_CRCERR_MASK 0x20
#define IRQ_LORA_HEADER_MASK 0x10
#define IRQ_LORA_TXDONE_MASK 0x08
#define IRQ_LORA_CDDONE_MASK 0x04
#define IRQ_LORA_FHSSCH_MASK 0x02
#define IRQ_LORA_CDDETD_MASK 0x01

#define IRQ_FSK1_MODEREADY_MASK 0x80
#define IRQ_FSK1_RXREADY_MASK 0x40
#define IRQ_FSK1_TXREADY_MASK 0x20
#define IRQ_FSK1_PLLLOCK_MASK 0x10
#define IRQ_FSK1_RSSI_MASK 0x08
#define IRQ_FSK1_TIMEOUT_MASK 0x04
#define IRQ_FSK1_PREAMBLEDETECT_MASK 0x02
#define IRQ_FSK1_SYNCADDRESSMATCH_MASK 0x01
#define IRQ_FSK2_FIFOFULL_MASK 0x80
#define IRQ_FSK2_FIFOEMPTY_MASK 0x40
#define IRQ_FSK2_FIFOLEVEL_MASK 0x20
#define IRQ_FSK2_FIFOOVERRUN_MASK 0x10
#define IRQ_FSK2_PACKETSENT_MASK 0x08
#define IRQ_FSK2_PAYLOADREADY_MASK 0x04
#define IRQ_FSK2_CRCOK_MASK 0x02
#define IRQ_FSK2_LOWBAT_MASK 0x01

// ----------------------------------------
// DIO function mappings D0D1D2D3
#define MAP_DIO0_LORA_RXDONE 0x00 // 00------
#define MAP_DIO0_LORA_TXDONE 0x40 // 01------
#define MAP_DIO1_LORA_RXTOUT 0x00 // --00----
#define MAP_DIO1_LORA_NOP 0x30 // --11----
#define MAP_DIO2_LORA_NOP 0xC0 // ----11--

#define MAP_DIO0_FSK_READY 0x00 // 00------ (packet sent / payload ready)
#define MAP_DIO1_FSK_NOP 0x30 // --11----
#define MAP_DIO2_FSK_TXNOP 0x04 // ----01--
#define MAP_DIO2_FSK_TIMEOUT 0x08 // ----10--

// FSK IMAGECAL defines
#define RF_IMAGECAL_AUTOIMAGECAL_MASK 0x7F
#define RF_IMAGECAL_AUTOIMAGECAL_ON 0x80
#define RF_IMAGECAL_AUTOIMAGECAL_OFF 0x00 // Default

#define RF_IMAGECAL_IMAGECAL_MASK 0xBF
#define RF_IMAGECAL_IMAGECAL_START 0x40

#define RF_IMAGECAL_IMAGECAL_RUNNING 0x20
#define RF_IMAGECAL_IMAGECAL_DONE 0x00 // Default

// RADIO STATE
// (initialized by radio_init(), used by radio_rand1())
static u1_t randbuf[16];

#ifdef CFG_sx1276_radio
#define LNA_RX_GAIN (0x20|0x1)
#elif CFG_sx1272_radio
#define LNA_RX_GAIN (0x20|0x03)
#else
#error Missing CFG_sx1272_radio/CFG_sx1276_radio
#endif

static void writeReg (u1_t addr, u1_t data ) {
hal_pin_nss(0);
hal_spi(addr | 0x80);
hal_spi(data);
hal_pin_nss(1);
}

static u1_t readReg (u1_t addr) {
hal_pin_nss(0);
hal_spi(addr & 0x7F);
u1_t val = hal_spi(0x00);
hal_pin_nss(1);
return val;
}

static void writeBuf (u1_t addr, xref2u1_t buf, u1_t len) {
hal_pin_nss(0);
hal_spi(addr | 0x80);
for (u1_t i=0; i<len; i++) {
hal_spi(buf[i]);
}
hal_pin_nss(1);
}

static void readBuf (u1_t addr, xref2u1_t buf, u1_t len) {
hal_pin_nss(0);
hal_spi(addr & 0x7F);
for (u1_t i=0; i<len; i++) {
buf[i] = hal_spi(0x00);
}
hal_pin_nss(1);
}

static void opmode (u1_t mode) {
writeReg(RegOpMode, (readReg(RegOpMode) & ~OPMODE_MASK) | mode);
}

static void opmodeLora() {
u1_t u = OPMODE_LORA;
#ifdef CFG_sx1276_radio
u |= 0x8; // TBD: sx1276 high freq
#endif
writeReg(RegOpMode, u);
}

static void opmodeFSK() {
u1_t u = 0;
#ifdef CFG_sx1276_radio
u |= 0x8; // TBD: sx1276 high freq
#endif
writeReg(RegOpMode, u);
}

// configure LoRa modem (cfg1, cfg2)
static void configLoraModem () {
sf_t sf = getSf(LMIC.rps);

#ifdef CFG_sx1276_radio
u1_t mc1 = 0, mc2 = 0, mc3 = 0;

    switch (getBw(LMIC.rps)) {
    case BW125: mc1 |= SX1276_MC1_BW_125; break;
    case BW250: mc1 |= SX1276_MC1_BW_250; break;
    case BW500: mc1 |= SX1276_MC1_BW_500; break;
    default:
        ASSERT(0);
    }
    switch( getCr(LMIC.rps) ) {
    case CR_4_5: mc1 |= SX1276_MC1_CR_4_5; break;
    case CR_4_6: mc1 |= SX1276_MC1_CR_4_6; break;
    case CR_4_7: mc1 |= SX1276_MC1_CR_4_7; break;
    case CR_4_8: mc1 |= SX1276_MC1_CR_4_8; break;
    default:
        ASSERT(0);
    }

    if (getIh(LMIC.rps)) {
        mc1 |= SX1276_MC1_IMPLICIT_HEADER_MODE_ON;
        writeReg(LORARegPayloadLength, getIh(LMIC.rps)); // required length
    }
    // set ModemConfig1
    writeReg(LORARegModemConfig1, mc1);

    mc2 = (SX1272_MC2_SF7 + ((sf-1)<<4));
    if (getNocrc(LMIC.rps) == 0) {
        mc2 |= SX1276_MC2_RX_PAYLOAD_CRCON;
    }
    writeReg(LORARegModemConfig2, mc2);

    mc3 = SX1276_MC3_AGCAUTO;
    if ((sf == SF11 || sf == SF12) && getBw(LMIC.rps) == BW125) {
        mc3 |= SX1276_MC3_LOW_DATA_RATE_OPTIMIZE;
    }
    writeReg(LORARegModemConfig3, mc3);

#elif CFG_sx1272_radio
u1_t mc1 = (getBw(LMIC.rps)<<6);

    switch( getCr(LMIC.rps) ) {
    case CR_4_5: mc1 |= SX1272_MC1_CR_4_5; break;
    case CR_4_6: mc1 |= SX1272_MC1_CR_4_6; break;
    case CR_4_7: mc1 |= SX1272_MC1_CR_4_7; break;
    case CR_4_8: mc1 |= SX1272_MC1_CR_4_8; break;
    }

    if ((sf == SF11 || sf == SF12) && getBw(LMIC.rps) == BW125) {
        mc1 |= SX1272_MC1_LOW_DATA_RATE_OPTIMIZE;
    }

    if (getNocrc(LMIC.rps) == 0) {
        mc1 |= SX1272_MC1_RX_PAYLOAD_CRCON;
    }

    if (getIh(LMIC.rps)) {
        mc1 |= SX1272_MC1_IMPLICIT_HEADER_MODE_ON;
        writeReg(LORARegPayloadLength, getIh(LMIC.rps)); // required length
    }
    // set ModemConfig1
    writeReg(LORARegModemConfig1, mc1);

    // set ModemConfig2 (sf, AgcAutoOn=1 SymbTimeoutHi=00)
    writeReg(LORARegModemConfig2, (SX1272_MC2_SF7 + ((sf-1)<<4)) | 0x04);

#else
#error Missing CFG_sx1272_radio/CFG_sx1276_radio
#endif /* CFG_sx1272_radio */
}

static void configChannel () {
// set frequency: FQ = (FRF * 32 Mhz) / (2 ^ 19)
uint64_t frf = ((uint64_t)LMIC.freq << 19) / 32000000;
writeReg(RegFrfMsb, (u1_t)(frf>>16));
writeReg(RegFrfMid, (u1_t)(frf>> 8));
writeReg(RegFrfLsb, (u1_t)(frf>> 0));
}

static void configPower () {
#ifdef CFG_sx1276_radio
// no boost used for now
s1_t pw = (s1_t)LMIC.txpow;
if(pw >= 17) {
pw = 15;
} else if(pw < 2) {
pw = 2;
}
// check board type for BOOST pin
writeReg(RegPaConfig, (u1_t)(0x80|(pw&0xf)));
writeReg(RegPaDac, readReg(RegPaDac)|0x4);

#elif 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;
}
writeReg(RegPaConfig, (u1_t)(0x80|(pw-2)));
#else
#error Missing CFG_sx1272_radio/CFG_sx1276_radio
#endif /* CFG_sx1272_radio */
}

static void txfsk () {
// select FSK modem (from sleep mode)
writeReg(RegOpMode, 0x10); // FSK, BT=0.5
ASSERT(readReg(RegOpMode) == 0x10);
// enter standby mode (required for FIFO loading))
opmode(OPMODE_STANDBY);
// set bitrate
writeReg(FSKRegBitrateMsb, 0x02); // 50kbps
writeReg(FSKRegBitrateLsb, 0x80);
// set frequency deviation
writeReg(FSKRegFdevMsb, 0x01); // +/- 25kHz
writeReg(FSKRegFdevLsb, 0x99);
// frame and packet handler settings
writeReg(FSKRegPreambleMsb, 0x00);
writeReg(FSKRegPreambleLsb, 0x05);
writeReg(FSKRegSyncConfig, 0x12);
writeReg(FSKRegPacketConfig1, 0xD0);
writeReg(FSKRegPacketConfig2, 0x40);
writeReg(FSKRegSyncValue1, 0xC1);
writeReg(FSKRegSyncValue2, 0x94);
writeReg(FSKRegSyncValue3, 0xC1);
// configure frequency
configChannel();
// configure output power
configPower();

// set the IRQ mapping DIO0=PacketSent DIO1=NOP DIO2=NOP
writeReg(RegDioMapping1, MAP_DIO0_FSK_READY|MAP_DIO1_FSK_NOP|MAP_DIO2_FSK_TXNOP);

// initialize the payload size and address pointers
writeReg(FSKRegPayloadLength, LMIC.dataLen+1); // (insert length byte into payload))

// download length byte and buffer to the radio FIFO
writeReg(RegFifo, LMIC.dataLen);
writeBuf(RegFifo, LMIC.frame, LMIC.dataLen);

// enable antenna switch for TX
hal_pin_rxtx(1);

// now we actually start the transmission
opmode(OPMODE_TX);

}

static void txlora () {
// select LoRa modem (from sleep mode)
//writeReg(RegOpMode, OPMODE_LORA);
opmodeLora();
ASSERT((readReg(RegOpMode) & OPMODE_LORA) != 0);

// enter standby mode (required for FIFO loading))
opmode(OPMODE_STANDBY);
// configure LoRa modem (cfg1, cfg2)
configLoraModem();
// configure frequency
configChannel();
// configure output power
writeReg(RegPaRamp, (readReg(RegPaRamp) & 0xF0) | 0x08); // set PA ramp-up time 50 uSec
configPower();
// set sync word
writeReg(LORARegSyncWord, LORA_MAC_PREAMBLE);

// set the IRQ mapping DIO0=TxDone DIO1=NOP DIO2=NOP
writeReg(RegDioMapping1, MAP_DIO0_LORA_TXDONE|MAP_DIO1_LORA_NOP|MAP_DIO2_LORA_NOP);
// clear all radio IRQ flags
writeReg(LORARegIrqFlags, 0xFF);
// mask all IRQs but TxDone
writeReg(LORARegIrqFlagsMask, ~IRQ_LORA_TXDONE_MASK);

// initialize the payload size and address pointers
writeReg(LORARegFifoTxBaseAddr, 0x00);
writeReg(LORARegFifoAddrPtr, 0x00);
writeReg(LORARegPayloadLength, LMIC.dataLen);

// download buffer to the radio FIFO
writeBuf(RegFifo, LMIC.frame, LMIC.dataLen);

// enable antenna switch for TX
hal_pin_rxtx(1);

// now we actually start the transmission
opmode(OPMODE_TX);

#if LMIC_DEBUG_LEVEL > 0
u1_t sf = getSf(LMIC.rps) + 6; // 1 == SF7
u1_t bw = getBw(LMIC.rps);
u1_t cr = getCr(LMIC.rps);
printf("%lu: TXMODE, freq=%lu, len=%d, SF=%d, BW=%d, CR=4/%d, IH=%d\n",
os_getTime(), LMIC.freq, LMIC.dataLen, sf,
bw == BW125 ? 125 : (bw == BW250 ? 250 : 500),
cr == CR_4_5 ? 5 : (cr == CR_4_6 ? 6 : (cr == CR_4_7 ? 7 : 8)),
getIh(LMIC.rps)
);
#endif
}

// start transmitter (buf=LMIC.frame, len=LMIC.dataLen)
static void starttx () {
ASSERT( (readReg(RegOpMode) & OPMODE_MASK) == OPMODE_SLEEP );
if(getSf(LMIC.rps) == FSK) { // FSK modem
txfsk();
} else { // LoRa modem
txlora();
}
// the radio will go back to STANDBY mode as soon as the TX is finished
// the corresponding IRQ will inform us about completion.
}

enum { RXMODE_SINGLE, RXMODE_SCAN, RXMODE_RSSI };

static CONST_TABLE(u1_t, rxlorairqmask)[] = {
[RXMODE_SINGLE] = IRQ_LORA_RXDONE_MASK|IRQ_LORA_RXTOUT_MASK,
[RXMODE_SCAN] = IRQ_LORA_RXDONE_MASK,
[RXMODE_RSSI] = 0x00,
};

// start LoRa receiver (time=LMIC.rxtime, timeout=LMIC.rxsyms, result=LMIC.frame[LMIC.dataLen])
static void rxlora (u1_t rxmode) {
// select LoRa modem (from sleep mode)
opmodeLora();
ASSERT((readReg(RegOpMode) & OPMODE_LORA) != 0);
// enter standby mode (warm up))
opmode(OPMODE_STANDBY);
// don't use MAC settings at startup
if(rxmode == RXMODE_RSSI) { // use fixed settings for rssi scan
writeReg(LORARegModemConfig1, RXLORA_RXMODE_RSSI_REG_MODEM_CONFIG1);
writeReg(LORARegModemConfig2, RXLORA_RXMODE_RSSI_REG_MODEM_CONFIG2);
} else { // single or continuous rx mode
// configure LoRa modem (cfg1, cfg2)
configLoraModem();
// configure frequency
configChannel();
}
// set LNA gain
writeReg(RegLna, LNA_RX_GAIN);
// set max payload size
writeReg(LORARegPayloadMaxLength, 64);
#if !defined(DISABLE_INVERT_IQ_ON_RX)
// use inverted I/Q signal (prevent mote-to-mote communication)
writeReg(LORARegInvertIQ, readReg(LORARegInvertIQ)|(1<<6));
#endif
// set symbol timeout (for single rx)
writeReg(LORARegSymbTimeoutLsb, LMIC.rxsyms);
// set sync word
writeReg(LORARegSyncWord, LORA_MAC_PREAMBLE);

// configure DIO mapping DIO0=RxDone DIO1=RxTout DIO2=NOP
writeReg(RegDioMapping1, MAP_DIO0_LORA_RXDONE|MAP_DIO1_LORA_RXTOUT|MAP_DIO2_LORA_NOP);
// clear all radio IRQ flags
writeReg(LORARegIrqFlags, 0xFF);
// enable required radio IRQs
writeReg(LORARegIrqFlagsMask, ~TABLE_GET_U1(rxlorairqmask, rxmode));

// enable antenna switch for RX
hal_pin_rxtx(0);

// now instruct the radio to receive
if (rxmode == RXMODE_SINGLE) { // single rx
    hal_waitUntil(LMIC.rxtime); // busy wait until exact rx time
    opmode(OPMODE_RX_SINGLE);
} else { // continous rx (scan or rssi)
    opmode(OPMODE_RX);
}

#if LMIC_DEBUG_LEVEL > 0
if (rxmode == RXMODE_RSSI) {
printf("RXMODE_RSSI\n");
} else {
u1_t sf = getSf(LMIC.rps) + 6; // 1 == SF7
u1_t bw = getBw(LMIC.rps);
u1_t cr = getCr(LMIC.rps);
printf("%lu: %s, freq=%lu, SF=%d, BW=%d, CR=4/%d, IH=%d\n",
os_getTime(),
rxmode == RXMODE_SINGLE ? "RXMODE_SINGLE" : (rxmode == RXMODE_SCAN ? "RXMODE_SCAN" : "UNKNOWN_RX"),
LMIC.freq, sf,
bw == BW125 ? 125 : (bw == BW250 ? 250 : 500),
cr == CR_4_5 ? 5 : (cr == CR_4_6 ? 6 : (cr == CR_4_7 ? 7 : 8)),
getIh(LMIC.rps)
);
}
#endif
}

static void rxfsk (u1_t rxmode) {
// only single rx (no continuous scanning, no noise sampling)
ASSERT( rxmode == RXMODE_SINGLE );
// select FSK modem (from sleep mode)
//writeReg(RegOpMode, 0x00); // (not LoRa)
opmodeFSK();
ASSERT((readReg(RegOpMode) & OPMODE_LORA) == 0);
// enter standby mode (warm up))
opmode(OPMODE_STANDBY);
// configure frequency
configChannel();
// set LNA gain
//writeReg(RegLna, 0x20|0x03); // max gain, boost enable
writeReg(RegLna, LNA_RX_GAIN);
// configure receiver
writeReg(FSKRegRxConfig, 0x1E); // AFC auto, AGC, trigger on preamble?!?
// set receiver bandwidth
writeReg(FSKRegRxBw, 0x0B); // 50kHz SSb
// set AFC bandwidth
writeReg(FSKRegAfcBw, 0x12); // 83.3kHz SSB
// set preamble detection
writeReg(FSKRegPreambleDetect, 0xAA); // enable, 2 bytes, 10 chip errors
// set sync config
writeReg(FSKRegSyncConfig, 0x12); // no auto restart, preamble 0xAA, enable, fill FIFO, 3 bytes sync
// set packet config
writeReg(FSKRegPacketConfig1, 0xD8); // var-length, whitening, crc, no auto-clear, no adr filter
writeReg(FSKRegPacketConfig2, 0x40); // packet mode
// set sync value
writeReg(FSKRegSyncValue1, 0xC1);
writeReg(FSKRegSyncValue2, 0x94);
writeReg(FSKRegSyncValue3, 0xC1);
// set preamble timeout
writeReg(FSKRegRxTimeout2, 0xFF);//(LMIC.rxsyms+1)/2);
// set bitrate
writeReg(FSKRegBitrateMsb, 0x02); // 50kbps
writeReg(FSKRegBitrateLsb, 0x80);
// set frequency deviation
writeReg(FSKRegFdevMsb, 0x01); // +/- 25kHz
writeReg(FSKRegFdevLsb, 0x99);

// configure DIO mapping DIO0=PayloadReady DIO1=NOP DIO2=TimeOut
writeReg(RegDioMapping1, MAP_DIO0_FSK_READY|MAP_DIO1_FSK_NOP|MAP_DIO2_FSK_TIMEOUT);

// enable antenna switch for RX
hal_pin_rxtx(0);

// now instruct the radio to receive
hal_waitUntil(LMIC.rxtime); // busy wait until exact rx time
opmode(OPMODE_RX); // no single rx mode available in FSK

}

static void startrx (u1_t rxmode) {
ASSERT( (readReg(RegOpMode) & OPMODE_MASK) == OPMODE_SLEEP );
if(getSf(LMIC.rps) == FSK) { // FSK modem
rxfsk(rxmode);
} else { // LoRa modem
rxlora(rxmode);
}
// the radio will go back to STANDBY mode as soon as the RX is finished
// or timed out, and the corresponding IRQ will inform us about completion.
}

// get random seed from wideband noise rssi
void radio_init () {
hal_disableIRQs();

// manually reset radio

#ifdef CFG_sx1276_radio
hal_pin_rst(0); // drive RST pin low
#else
hal_pin_rst(1); // drive RST pin high
#endif
hal_waitUntil(os_getTime()+ms2osticks(1)); // wait >100us
hal_pin_rst(2); // configure RST pin floating!
hal_waitUntil(os_getTime()+ms2osticks(5)); // wait 5ms

opmode(OPMODE_SLEEP);

// some sanity checks, e.g., read version number
u1_t v = readReg(RegVersion);

#ifdef CFG_sx1276_radio
ASSERT(v == 0x12 );
#elif CFG_sx1272_radio
ASSERT(v == 0x22);
#else
#error Missing CFG_sx1272_radio/CFG_sx1276_radio
#endif
// seed 15-byte randomness via noise rssi
rxlora(RXMODE_RSSI);
while( (readReg(RegOpMode) & OPMODE_MASK) != OPMODE_RX ); // continuous rx
for(int i=1; i<16; i++) {
for(int j=0; j<8; j++) {
u1_t b; // wait for two non-identical subsequent least-significant bits
while( (b = readReg(LORARegRssiWideband) & 0x01) == (readReg(LORARegRssiWideband) & 0x01) );
randbuf[i] = (randbuf[i] << 1) | b;
}
}
randbuf[0] = 16; // set initial index

#ifdef CFG_sx1276mb1_board
// chain calibration
writeReg(RegPaConfig, 0);

// Launch Rx chain calibration for LF band
writeReg(FSKRegImageCal, (readReg(FSKRegImageCal) & RF_IMAGECAL_IMAGECAL_MASK)|RF_IMAGECAL_IMAGECAL_START);
while((readReg(FSKRegImageCal)&RF_IMAGECAL_IMAGECAL_RUNNING) == RF_IMAGECAL_IMAGECAL_RUNNING){ ; }

// Sets a Frequency in HF band
u4_t frf = 868000000;
writeReg(RegFrfMsb, (u1_t)(frf>>16));
writeReg(RegFrfMid, (u1_t)(frf>> 8));
writeReg(RegFrfLsb, (u1_t)(frf>> 0));

// Launch Rx chain calibration for HF band
writeReg(FSKRegImageCal, (readReg(FSKRegImageCal) & RF_IMAGECAL_IMAGECAL_MASK)|RF_IMAGECAL_IMAGECAL_START);
while((readReg(FSKRegImageCal) & RF_IMAGECAL_IMAGECAL_RUNNING) == RF_IMAGECAL_IMAGECAL_RUNNING) { ; }

#endif /* CFG_sx1276mb1_board */

opmode(OPMODE_SLEEP);

hal_enableIRQs();

}

// return next random byte derived from seed buffer
// (buf[0] holds index of next byte to be returned)
u1_t radio_rand1 () {
u1_t i = randbuf[0];
ASSERT( i != 0 );
if( i==16 ) {
os_aes(AES_ENC, randbuf, 16); // encrypt seed with any key
i = 0;
}
u1_t v = randbuf[i++];
randbuf[0] = i;
return v;
}

u1_t radio_rssi () {
hal_disableIRQs();
u1_t r = readReg(LORARegRssiValue);
hal_enableIRQs();
return r;
}

static CONST_TABLE(u2_t, LORA_RXDONE_FIXUP)[] = {
[FSK] = us2osticks(0), // ( 0 ticks)
[SF7] = us2osticks(0), // ( 0 ticks)
[SF8] = us2osticks(1648), // ( 54 ticks)
[SF9] = us2osticks(3265), // ( 107 ticks)
[SF10] = us2osticks(7049), // ( 231 ticks)
[SF11] = us2osticks(13641), // ( 447 ticks)
[SF12] = us2osticks(31189), // (1022 ticks)
};

// called by hal ext IRQ handler
// (radio goes to stanby mode after tx/rx operations)
void radio_irq_handler (u1_t dio) {
ostime_t now = os_getTime();
if( (readReg(RegOpMode) & OPMODE_LORA) != 0) { // LORA modem
u1_t flags = readReg(LORARegIrqFlags);
if( flags & IRQ_LORA_TXDONE_MASK ) {
// save exact tx time
LMIC.txend = now - us2osticks(43); // TXDONE FIXUP
} else if( flags & IRQ_LORA_RXDONE_MASK ) {
// save exact rx time
if(getBw(LMIC.rps) == BW125) {
now -= TABLE_GET_U2(LORA_RXDONE_FIXUP, getSf(LMIC.rps));
}
LMIC.rxtime = now;
// read the PDU and inform the MAC that we received something
LMIC.dataLen = (readReg(LORARegModemConfig1) & SX1272_MC1_IMPLICIT_HEADER_MODE_ON) ?
readReg(LORARegPayloadLength) : readReg(LORARegRxNbBytes);
// set FIFO read address pointer
writeReg(LORARegFifoAddrPtr, readReg(LORARegFifoRxCurrentAddr));
// now read the FIFO
readBuf(RegFifo, LMIC.frame, LMIC.dataLen);
// read rx quality parameters
LMIC.snr = readReg(LORARegPktSnrValue); // SNR [dB] * 4
LMIC.rssi = readReg(LORARegPktRssiValue) - 125 + 64; // RSSI [dBm] (-196...+63)
} else if( flags & IRQ_LORA_RXTOUT_MASK ) {
// indicate timeout
LMIC.dataLen = 0;
}
// mask all radio IRQs
writeReg(LORARegIrqFlagsMask, 0xFF);
// clear radio IRQ flags
writeReg(LORARegIrqFlags, 0xFF);
} else { // FSK modem
u1_t flags1 = readReg(FSKRegIrqFlags1);
u1_t flags2 = readReg(FSKRegIrqFlags2);
if( flags2 & IRQ_FSK2_PACKETSENT_MASK ) {
// save exact tx time
LMIC.txend = now;
} else if( flags2 & IRQ_FSK2_PAYLOADREADY_MASK ) {
// save exact rx time
LMIC.rxtime = now;
// read the PDU and inform the MAC that we received something
LMIC.dataLen = readReg(FSKRegPayloadLength);
// now read the FIFO
readBuf(RegFifo, LMIC.frame, LMIC.dataLen);
// read rx quality parameters
LMIC.snr = 0; // determine snr
LMIC.rssi = 0; // determine rssi
} else if( flags1 & IRQ_FSK1_TIMEOUT_MASK ) {
// indicate timeout
LMIC.dataLen = 0;
} else {
ASSERT(0);
}
}
// go from stanby to sleep
opmode(OPMODE_SLEEP);
// run os job (use preset func ptr)
os_setCallback(&LMIC.osjob, LMIC.osjob.func);
}

void os_radio (u1_t mode) {
hal_disableIRQs();
switch (mode) {
case RADIO_RST:
// put radio to sleep
opmode(OPMODE_SLEEP);
break;

  case RADIO_TX:
    // transmit frame now
    starttx(); // buf=LMIC.frame, len=LMIC.dataLen
    break;

  case RADIO_RX:
    // receive frame now (exactly at rxtime)
    startrx(RXMODE_SINGLE); // buf=LMIC.frame, time=LMIC.rxtime, timeout=LMIC.rxsyms
    break;

  case RADIO_RXON:
    // start scanning for beacon now
    startrx(RXMODE_SCAN); // buf=LMIC.frame
    break;
}
hal_enableIRQs();

}

config.h file which i am using
#ifndef lmic_config_h
#define lmic_config_h

// In the original LMIC code, these config values were defined on the
// gcc commandline. Since Arduino does not allow easily modifying the
// compiler commandline, use this file instead.

#define CFG_eu868 1
//#define CFG_us915 1
// This is the SX1272/SX1273 radio, which is also used on the HopeRF
// RFM92 boards.
//#define CFG_sx1272_radio 1
// This is the SX1276/SX1277/SX1278/SX1279 radio, which is also used on
// the HopeRF RFM95 boards.
#define CFG_sx1276_radio 1

// 16 μs per tick
// LMIC requires ticks to be 15.5μs - 100 μs long
#define US_PER_OSTICK_EXPONENT 4
#define US_PER_OSTICK (1 << US_PER_OSTICK_EXPONENT)
#define OSTICKS_PER_SEC (1000000 / US_PER_OSTICK)

// Set this to 1 to enable some basic debug output (using printf) about
// RF settings used during transmission and reception. Set to 2 to
// enable more verbose output. Make sure that printf is actually
// configured (e.g. on AVR it is not by default), otherwise using it can
// cause crashing.
#define LMIC_DEBUG_LEVEL 0

// Enable this to allow using printf() to print to the given serial port
// (or any other Print object). This can be easy for debugging. The
// current implementation only works on AVR, though.
//#define LMIC_PRINTF_TO Serial

// Any runtime assertion failures are printed to this serial port (or
// any other Print object). If this is unset, any failures just silently
// halt execution.
#define LMIC_FAILURE_TO Serial

// Uncomment this to disable all code related to joining
//#define DISABLE_JOIN
// Uncomment this to disable all code related to ping
//#define DISABLE_PING
// Uncomment this to disable all code related to beacon tracking.
// Requires ping to be disabled too
//#define DISABLE_BEACONS

// Uncomment these to disable the corresponding MAC commands.
// Class A
//#define DISABLE_MCMD_DCAP_REQ // duty cycle cap
//#define DISABLE_MCMD_DN2P_SET // 2nd DN window param
//#define DISABLE_MCMD_SNCH_REQ // set new channel
// Class B
//#define DISABLE_MCMD_PING_SET // set ping freq, automatically disabled by DISABLE_PING
//#define DISABLE_MCMD_BCNI_ANS // next beacon start, automatical disabled by DISABLE_BEACON

// In LoRaWAN, a gateway applies I/Q inversion on TX, and nodes do the
// same on RX. This ensures that gateways can talk to nodes and vice
// versa, but gateways will not hear other gateways and nodes will not
// hear other nodes. By uncommenting this macro, this inversion is
// disabled and this node can hear other nodes. If two nodes both have
// this macro set, they can talk to each other (but they can no longer
// hear gateways). This should probably only be used when debugging
// and/or when talking to the radio directly (e.g. like in the "raw"
// example).
//#define DISABLE_INVERT_IQ_ON_RX

// This allows choosing between multiple included AES implementations.
// Make sure exactly one of these is uncommented.
//
// This selects the original AES implementation included LMIC. This
// implementation is optimized for speed on 32-bit processors using
// fairly big lookup tables, but it takes up big amounts of flash on the
// AVR architecture.
// #define USE_ORIGINAL_AES
//
// This selects the AES implementation written by Ideetroon for their
// own LoRaWAN library. It also uses lookup tables, but smaller
// byte-oriented ones, making it use a lot less flash space (but it is
// also about twice as slow as the original).
#define USE_IDEETRON_AES

#endif // lmic_config_h

About some of the problems for LMiC on Arduino board

I've read that you write Arduino-LMiC library and porting it. So,have some questions for you.

This is my hardware. (Arduino UNO, LoRa module: SX1272, Multiprotocol Radio Shield for Arduino)
link:
https://www.cooking-hacks.com/documentation/tutorials/extreme-range-lora-sx1272-module-shield-arduino-raspberry-pi-intel-galileo/

qq 20161011225826

Can I do these works? And how

Sending packets uplink, taking into account duty cycling.
Encryption and message integrity checking.
Receiving downlink packets in the RX2 window.
Custom frequencies and datarate settings.
Over-the-air activation (OTAA / joining)

That's PHY layer or MAC layer ?

I hope to get your suggestions because I'm going to talk about this aspect of these problem with my professor in next week.

Thank you for read

regard.

DISABLE_MCMD_DCAP_REQ cause oidx not to be incremented

I'm not sure this is a tested path. But when DISABLE_MCMD_DCAP_REQ was added, the code oidx += 2; was moved from the second line of the case to just before the continue. But it is still inside the #if. The other modifications have the adjustment of oidx outside the #if so that the parsing continues, even if the capability is not implemented. I think this should be checked.

D0/D1/D2 pull-up, pull-down or left floating?

I'm currently using the same PCB for both RFM69 and RFM9x Lora chips.

In the case of the RFM69 the D0 pin is the interrupt line, and therefore is connected to a pull-up resistor.
The other two pins, D1 and D2 are left floating (no pull-up/down).

In order to use the RFM9x chip and the arduino-lmic library, should I change the pull-up on D0 and add pull-downs on D1/D2, or will it work the way it is now?

Easy way to restart arduino on `FAILURE`?

How can I make sure my arduino restarts after the library encountered a FAILURE condition? I know of the asm volatile (" jmp 0");, but how can I integrate it into the library?

Problems with Arduino (Moteino) Mega

I have a simple "hello world" sketch which works fine on an Uno. When I use this on a Mega, the OTAA joins are never responded to (they are received and authored (a new device address is allocated in the 'backend' (which is the TTN network).

Could you help me diagnose this issue? I have tried including

LMIC_setClockError(MAX_CLOCK_ERROR * 1 / 100);

After the LMIC_reset() but this doesn't assist - I own the gateway which is within 10 feet and other nodes are authorising correctly.

Arduino uno & Libelium shield & sx1272 with LMIC lib. assert failure

The goal what I want is OTAA(over the air activation) communication with Arduino(or raspberry pi 3) - Gateway(raspberry pi 3 or arduino) - TTN(the thing network).

Ready to execute code..
1. Arduino Uno R3, computer-arduino serial cable
2. Arduino shield, sx1272 chip
3. LMIC library Version 1.5
4. Upload library to Arduino(IDE V1.6.11) sketch library.
5. Not modify pin map struct in raw.ino
6. Circuit image
7. Pin mapping

 const lmic_pinmap lmic_pins = {
     .nss = 6,
     .rxtx = LMIC_UNUSED_PIN,
     .rst = 5,
     .dio = {2, 3, 4},
 };

At first, i want to phy level communication(raw.ino in lmic library)test with just one arduino. So i modify some files like below

config.h

//#define CFG_eu868 1
//#define CFG_sx1276_radio 1
#define CFG_us915 1
#define CFG_sx1272_radio 1
#define DISABLE_INVERT_IQ_ON_RX

hal/hal.cpp

static const SPISettings settings(10E6, MSBFIRST, SPI_MODE0)
// static const SPISettings settings(1E6, MSBFIRST, SPI_MODE0)
// static const SPISettings settings(4E6, MSBFIRST, SPI_MODE0)

Question 1. I tried all the comments, but i get the following error. how can i fix error ?
Starting
FAILURE
C:\Users\Jaeho Shin\Documents\Arduino\libraries\arduino-lmic-master\src \lmic\radio.c:702

Question 2. is this link correct gateway source code ?

lmic is not sending enough NewChannelAns ?

Hi,

I worked with an operator to validate the stack on their network and we might have spotted an issue I want to discuss with you before sending a PR : when the operator is sending several NewChannelReq in one downstream message, it expects several NewChannelAns in the following upstream message.

I am not sure of the interpretation of the LoraWAN spec 1.0 (page 28, L8), which is

The end-device acknowledges the reception of a NewChannelReq by sending back a NewChannelAns command.

Currently, the stack only answers one NewChannelAns for each frame, regardless the number of NewChannelReq inside.
Does somebody else thinks that if the stack receives X NewChannelReq in one dowlink frame, it should send X NewChannelAns in the next uplink frame ? If so, I will do a PR on the code I wrote.

ttn_abp.ino sample code always use channel 0?

Since the new release, it seems that LIMC does not change channel on each send, Before this new update when I was using ttn_apb.ino example, the send was occurring from channel 0 to 8, today it's always channel 0.

I compiled sample code changing my keys and DIO mapping, I'm on a SAMD21 Arduino Zero with RFM95
Here are my logs, and all seems consistent, packet are sent, received by gateway and sent to TTN, no problem except that the frequency is always the same

Serial Monitor
image

* nodejs monitoring TTN entries*
image

TTN Dashboard
image

Did I missed something?

Working on RX1 instead RX2

I have one node with an arduino uno and RFM95, and it's working in RX1 instead of RX2 as the example of arduino says, and i have another node but it has a RN2903, it use RX2, when i try to join by OTA on RX2 i cant connect both at the same time

Arduino lmic problem to run sample code.

Best @matthijskooijman

Sorry for posting my previous issue on the wrong spot!

But we have the sx1272 and when I debug the running code the value of v is 255. I thought this is a really weird value to get back. If the SPI connection isn't set up properly, how do i fix that of what can the problem be?

Greetings Po4life

Arduino/Genduino 101

working with the sx1276 based rfm95 chip I have no issue using the UNO but when working with the Arudino 101 I get the following error:

Starting
FAILURE 
/Users/rob/Documents/Arduino/libraries/arduino-lmic/src/lmic/radio.c:708
VAL: 0x09
EXP: 0x12

It is mentioned in the readme that the 101 has been tested. Were there any changes necessary to make this work?

Sending raw packets

I don't have a gateway set up, and was testing functionality between two nodes using the raw.ino example. I can send a simple ping/pong packet back and fourth, but the range consists of about 10 meters.

I noticed in the documentation it says "shows how to access the radio on a somewhat low level, and allows to send raw (non-LoRaWAN) packets between nodes directly. This is useful to verify basic connectivity, and when no gateway is available, but this example also bypasses duty cycle checks, so be careful when changing the settings."

Would the duty cycle check being bypassed cause the range to be this short?

Tested @ 920MHz using txpow 27 and datarate DR_SF12.

Erroneous information regarding SX127x power connections

Power

"The SX127x transceivers need a supply voltage between 1.8V and 3.9V. Using a 3.3V supply is typical. The SX127x chips have various supply lines (VR_ANA, VR_DIG and VR_PA), all of which need the same supply voltage. Some modules (like the Semtech evaluation board) expose these pins separately, just connect them all together to a 3.3V source."

Note: The VR_ANA and VR_DIG are external bypass points for regulated supplies internal to the chip at a 1.5V potential and should NOT be connected to 3.3V as this could damage the chip. The VR_PA is the output from an internal programmable supply that is used to set the TX power level. It also should not be connected to 3.3V because doing so could also damage the chip and prevent proper power level settings.

Downlink not working on Luigino (Arduino) ATMEGA328p 8Mhz

hi,
i' m using your LMIC library on my node which is a Luigino equipped with Atmega328p 8Mhz 3.3v and a RFM95W (SX1276) : i can send to my gateway the message and look at it in the TTN payload log but when i try a downlink in the gateway's log i can see the downlink has been sent but there's no hope to see it as received in the node's logs...
what should i tune/modify to get it working ?
eventually what should i check into the gateway to understand if the downlink has really been delivered to the node ?
i read in the issues that with Arduino's boards there are different problems regarding clock/SPI sync or settings...

thank you for your time.

Ken

please note that i tried another node equipped with the RN2483 and i can get the downlink from the TTN without any problem .

EV_JOINED doesn't fire.. little help?

So... I have this library running on an OTAA sketch. It's running on an Uno R3. It's configured for CFG_us915.

Everything compiles and works nicely... or so it seems. From the network server I can see that the unit does a join request and that it's accepted, but the EV_JOINED event never fires.

I put in some print statements to give an idea of what is going on. Any input would be greatly appreciated.

Setup printf
Init...
RXMODE_RSSI
Reset...
Start send and join...
238: engineUpdate, opmode=0x8
Packet queued
Event
790: EV_JOINING
971: engineUpdate, opmode=0xc
Get ARTEUI 
Get DEVEUi 
Get DEVKEY 
2017: TXMODE, freq=902300000, len=23, SF=7, BW=125, CR=4/5, IH=0
315897: RXMODE_SINGLE, freq=923300000, SF=7, BW=500, CR=4/5, IH=0
Get DEVKEY 
Get DEVKEY 
377557: RXMODE_SINGLE, freq=923300000, SF=12, BW=500, CR=4/5, IH=0
387245: engineUpdate, opmode=0xc
405393: engineUpdate, opmode=0xc
Get ARTEUI 
Get DEVEUi 
Get DEVKEY 
405786: TXMODE, freq=903000000, len=23, SF=8, BW=500, CR=4/5, IH=0
717579: RXMODE_SINGLE, freq=923300000, SF=7, BW=500, CR=4/5, IH=0
Get DEVKEY 
Get DEVKEY 
779238: RXMODE_SINGLE, freq=923300000, SF=12, BW=500, CR=4/5, IH=0
788927: engineUpdate, opmode=0xc
829634: engineUpdate, opmode=0xc
Get ARTEUI 
Get DEVEUi 
Get DEVKEY 
830027: TXMODE, freq=902300000, len=23, SF=8, BW=125, CR=4/5, IH=0
Setup printf
Init...
RXMODE_RSSI
Reset...
Start send and join...
238: engineUpdate, opmode=0x8
Packet queued
Event
790: EV_JOINING
971: engineUpdate, opmode=0xc
Get ARTEUI 
Get DEVEUi 
Get DEVKEY 
2017: TXMODE, freq=902300000, len=23, SF=7, BW=125, CR=4/5, IH=0
315897: RXMODE_SINGLE, freq=923300000, SF=7, BW=500, CR=4/5, IH=0
Get DEVKEY 
Get DEVKEY 
377557: RXMODE_SINGLE, freq=923300000, SF=12, BW=500, CR=4/5, IH=0
387245: engineUpdate, opmode=0xc
405393: engineUpdate, opmode=0xc
Get ARTEUI 
Get DEVEUi 
Get DEVKEY 
405786: TXMODE, freq=903000000, len=23, SF=8, BW=500, CR=4/5, IH=0
717579: RXMODE_SINGLE, freq=923300000, SF=7, BW=500, CR=4/5, IH=0
Get DEVKEY 
Get DEVKEY 
779238: RXMODE_SINGLE, freq=923300000, SF=12, BW=500, CR=4/5, IH=0
788927: engineUpdate, opmode=0xc
829634: engineUpdate, opmode=0xc
Get ARTEUI 
Get DEVEUi 
Get DEVKEY 
830027: TXMODE, freq=902300000, len=23, SF=8, BW=125, CR=4/5, IH=0

Where the received data is stored?

Hello.

I have been debugging my ATSAMD21G18 & SX1272 setup for quite a while now. I'm using OTAA-example as a reference and I have my own gateway & Amazon AWS setup up and running. Motem joins to my private network flawlessly and also transmits data to the cloud just fine. I also get almost always a response from the cloud to the motem after TXCOMPLETE event.

However, in the OTAA-example received data is not displayed, since it's not implemented. Correct my if I'm doing this wrong:

In switch-case statement under EV_TXCOMPLETE, I just added this line:

Serial.write(LMIC.frame, LMIC.dataLen);

In console I just get character ´ printed. As hex LMIC.frame[0] contains 0x60 and LMIC.frame[1] 0x03. LMIC.dataLen is correct, I'm expecting 2 bytes of data.

Console output is always the same, even though the response sent from the cloud is different.

Any ideas what I'm doing wrong? Is there some other rxbuffer?

register value definition(MAP_DIO2_LORA_NOP) error?

MAP_DIO2_LORA_NOP value error?

radio.c line 229

 #define MAP_DIO2_LORA_NOP      0xC0  // ----11--

should be

 #define MAP_DIO2_LORA_NOP      0x0C  // ----11--

haven't test on sx1276???

radio.c line 777

// read the PDU and inform the MAC that we received something
            LMIC.dataLen = (readReg(LORARegModemConfig1) & SX1272_MC1_IMPLICIT_HEADER_MODE_ON) ?
                readReg(LORARegPayloadLength) : readReg(LORARegRxNbBytes);

should be

#ifdef CFG_sx1272_radio 
            LMIC.dataLen = (readReg(LORARegModemConfig1) & SX1272_MC1_IMPLICIT_HEADER_MODE_ON) ? 
                readReg(LORARegPayloadLength) : readReg(LORARegRxNbBytes); 
#else 
            LMIC.dataLen = (readReg(LORARegModemConfig1) & SX1276_MC1_IMPLICIT_HEADER_MODE_ON) ? 
                            readReg(LORARegPayloadLength) : readReg(LORARegRxNbBytes); 
#endif 

First message lost after (2) reset

Hello,

I am using this library with my NodeMCU (ESP8266) and the RFM95W.

Everything works fine if I send messages periodically. The problems comes when I reset twice.

Example:

  • I send periodically and I reset => No problem, the first message is sent
  • I reset again => The first message is lost (I can see the counter in TTN)

Once I receive a new message again, the cycle repeats.

I am using the sub band 1 in the US (through select sub band). Can anyone give me some hint about what I am doing wrong?

Thanks!

hal_waitUntil() not working ?

Hi,

I am playing with the library, able to transmit (alleluia :-) ) but not to receive.
After digging into the library I think that the function hal_waitUntil() is not working due to delayMicroseconds().

It is a bit weird and I really don't understand, unless you changed the timer0 frequency ? But I did not see it in your code...

First, the code from your repository with some prints:

void hal_waitUntil (u4_t time) {
    s4_t delta = delta_time(time);
    // From delayMicroseconds docs: Currently, the largest value that
    // will produce an accurate delay is 16383.
    while (delta > (16000 / US_PER_OSTICK)) {
        delay(16);
        delta -= (16000 / US_PER_OSTICK);
    }
    if (delta > 0) {
LMIC_PRINTF_TO.println(hal_ticks());
        delayMicroseconds(delta * US_PER_OSTICK);
LMIC_PRINTF_TO.println(hal_ticks());
LMIC_PRINTF_TO.print("delta: ");
LMIC_PRINTF_TO.println(delta);
LMIC_PRINTF_TO.print("RX: ");
LMIC_PRINTF_TO.println(time);
    }
}

Outputs:
3256043
3256088
delta: 86
RX : 3256129
-> real wait : 45 ticks, need 41 more

Now if I try to manually add fancy delays

void hal_waitUntil (u4_t time) {
    s4_t delta = delta_time(time);
    // From delayMicroseconds docs: Currently, the largest value that
    // will produce an accurate delay is 16383.
    while (delta > (16000 / US_PER_OSTICK)) {
        delay(16);
        delta -= (16000 / US_PER_OSTICK);
    }
    if (delta > 0) {
LMIC_PRINTF_TO.println(hal_ticks());
        delayMicroseconds(delta * US_PER_OSTICK);
        delayMicroseconds(41*16);
        delayMicroseconds(41*16);
        delayMicroseconds(41*16);
LMIC_PRINTF_TO.println(hal_ticks());
LMIC_PRINTF_TO.print("delta: ");
LMIC_PRINTF_TO.println(delta);
LMIC_PRINTF_TO.print("RX: ");
LMIC_PRINTF_TO.println(time);
    }
}

It outputs
1197911
1197950
delta: 85
RX: 1197996
-> real wait : 39 ticks !!

delayMicroseconds() does not block interrupts since Arduino 018, so the hal_time() should be valid. Does I missed something obvious ?

"Space Time Continuum" Problems With hal_ticks()?

Hi,

Please forgive the facetious issue subject title - hopefully the reason for its naming will become apparent... :)

Long-story-short: hal_ticks() (in hal.cpp) can return a time in the past which (I currently believe) is causing my nodes to stall when left for long enough.

Observations: Calls to os_getTime() go negative when they get big enough and then at some point (I think!) are causing a stall in the HAL after "Packet queued" is printed on the Serial port. For example, I see the following in my Serial Monitor:

2145760172: EV_TXCOMPLETE (includes waiting for RX windows)
Packet queued
[Nxt Tick]
-2147000220: EV_TXCOMPLETE (includes waiting for RX windows)
Packet queued
[More Ticks...]
-992562099: EV_TXCOMPLETE (includes waiting for RX windows)
Packet queued
[Infinite stall after "Packet queued" is printed. Only a Microcontroller reset will resolve.]

Digging into the code...

It looks like the problem could be when subsequent calls to hal_ticks() straddle a "time travel" because the delta_time() function (in hal.cpp, line 161) checks for a relative time in the past (i.e. job deadline - current hal_ticks() time) and although hal_ticks() returns a u4_t, it is often set to an s4_t in various other placed in the code - I haven't checked for consistency everywhere.

I appreciate that the timing overflow issue has to be dealt with, since we can't just keep counting higher forever. But I don't understand the code well enough to be sure that when the overflow happens, current jobs and pending jobs all behave appropriately given the delicate spacing between transmissions.

My current attempt at a fix (read: dodgy hack!) is to check the proposed deadline time before setting it through the os_setTimedCallback whilst preserving the TX_INTERVAL, etc. and make sure that no "negative" times are set in the job queue.

What do you think?

Any help or advice would be much appreciated.

Thanks,

Andy

How can i modify raw.ino ??

I successfully porting raw.ino in Arudino UNO.

Is original raw.ino transmit code, right ?

Then, how do i modify raw.ino to receiving node ?

OTAA does not work on 8MHz ?

Does anyone tested OTAA on 8 MHz ATMega328 ?
It works well on my 16 MHz Arduino shield, but I do not receive any message on my 8 MHz boards during join process, whatever is the SF. I checked the timings which seems to be OK, and the gateway log shows that joinAccept is answered.

I am a bit lost because in APB the downlink works well on RX1 and RX2 :-(

MAC Command Link_Adr_Req successful

I am using an Ideetron Nexus with this LMIC Stack in German Digimondo LoRaWAN with SF7BW125. After i while i found the Nexus transmitting with SF8BW125 and was surprised. After some analysis i found that it obviously has beend switched by network MAC commands - that means, MAC commands work with this LMIC stack!

This is what i see on Digimondo side:

{
"port": 0,
"pending": false,
"mtype": "unconfirmed_data_down",
"mic_pass": true,
"major": 0,
"mac_cmds": [
{
"type": "link_adr_req",
"tx_power": 0,
"number_of_transmissions": 1,
"data_rate": 3,
"channel_mask_ctrl": 6,
"channel_mask": 65535
}
],
"fopts_len": 5,
"fcnt": 229,
"dir": "down",
"dev_addr_hex": "17a98428",
"adrackreq": false,
"adr": false,
"ack": false
}

DLsettings and RxDelay in join accept not processed

The current LMIC version is not processing the mentioned fields from the join accept message. Since both iot.semtech.com and TTN use these fields to change the RX2 datarate, this means that RX2 will not work without manually changing the RX2 settings in the JOINED event handler.

The library should be modified to process these settings. The channel list is already processed (though I'm not sure if either network sends it?).

ping / LMIC_setPingable

Hi,

i'm sending messages down to the node, and it works fine: when the node sends a message, the EV_TXCOMPLETE event reports the downlink message after sending something.

Now I've read about LMIC_setPingable(x) that sends a ping every 2^x seconds. I've put the call right before the main os_runloop(); .This should then trigger a EV_RXCOMPLETE event, with the downlink message. However, I didn't manage to get that running.

What am I missing? Do i need to send the ping manually somehow?

Thanks! Lukas

OTAA with SX1272MB2xAS on Uno

Hi there,

I am trying to configure an Uno with SX1272MB2xAS board but I can only go as far as

Starting
Packet queued
183: EV_JOINING

The set seems to work fine with ABP.

I have tried the clock compensation trick but still no luck

// Let LMIC compensate for +/- 1% clock error
LMIC_setClockError(MAX_CLOCK_ERROR * 1 / 100);

Any suggestions?
:-)

Should line 762 in lmic.cpp be right-shifting by 4, not dividing by 4?

Hi,

Thanks for all your great work on getting this library ported - much appreciated!

Whilst trying to disable some channels in the US (915 MHz) spectrum using the disableChannel function (at Line 760 - not 684), I noticed that line 762 has the channel to be disabled dividing by 4:

LMIC.channelMap[channel/4] &= ~(1<<(channel&0xF));

whereas in the _nextTx function (at Line 817 - US variant) in the 125kHz section, I noticed that it determines whether next channel to transmit on is free by right-shifting by 4:

if( (LMIC.channelMap[(chnl >> 4)] & (1<<(chnl & 0xF))) != 0 ) {

I figure right-shifting is correct, since the channel map for the US (915 MHz) spectrum appears to be split up into 4x 16 channel segments (- 32-bits wide mind you!) for the 125 kHz-wide channels, with a 5th segment only 16 bits wide for the 500 kHz-wide channels.

Honestly, I'm not sure why there needs to be 4x 16 channel segments using 32-bit wide addressing. Surely only 1x is necessary plus a bit extra for the extended channels?

But perhaps I'm missing something...
(...wouldn't be the first time!)

Does all that make sense? Please let me know if I've misunderstood the code.

Thanks again for all your hard work!

Andy

Fix to avoid unable to compile mjs branch with AES

@matthijskooijman
I'm tried to compile new mjs branch (for ESP8266) but it does not work. I listed there the problems and the fix I've done

  • 1st point

using USE_ORIGINAL_AES in config.h fire multiple undefined reference.

S:\Skydrive\devt\Arduino\hardware\esp8266com\esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc" -g  -Os -nostdlib -Wl,--no-check-sections -u call_user_start -u _printf_float -u _scanf_float -Wl,-static "-LS:\Skydrive\devt\Arduino\hardware\esp8266com\esp8266/tools/sdk/lib" "-LS:\Skydrive\devt\Arduino\hardware\esp8266com\esp8266/tools/sdk/ld" "-LS:\Skydrive\devt\Arduino\hardware\esp8266com\esp8266/tools/sdk/libc/xtensa-lx106-elf/lib" "-Teagle.flash.4m1m.ld" -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,register_chipv6_phy  -o "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp/ttn-abp.ino.elf" -Wl,--start-group "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\sketch\ttn-abp.ino.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\aes\lmic.c.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\aes\other.c.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\aes\ideetron\AES-128_V10.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\hal\hal.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\lmic\lmic.c.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\lmic\oslmic.c.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\lmic\radio.c.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\SPI\SPI.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\ESP8266WiFi\ESP8266WiFi.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\ESP8266WiFi\ESP8266WiFiAP.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\ESP8266WiFi\ESP8266WiFiGeneric.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\ESP8266WiFi\ESP8266WiFiMulti.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\ESP8266WiFi\ESP8266WiFiSTA.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\ESP8266WiFi\ESP8266WiFiScan.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\ESP8266WiFi\WiFiClient.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\ESP8266WiFi\WiFiClientSecure.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\ESP8266WiFi\WiFiServer.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\ESP8266WiFi\WiFiUdp.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp/arduino.ar" -lhal -lphy -lpp -lnet80211 -llwip_gcc -lwpa -lcrypto -lmain -lwps -laxtls -lsmartconfig -lmesh -lwpa2 -lstdc++ -lm -lc -lgcc -Wl,--end-group  "-LC:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp"
C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\lmic\lmic.c.o: In function `convFreq':
S:\Skydrive\devt\Arduino\libraries\arduino-lmic\src\lmic/lmic.c:85: undefined reference to `AESAUX'
C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\lmic\lmic.c.o:(.text.aes_cipher$part$3+0x4): undefined reference to `AESAUX'
C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\lmic\lmic.c.o:(.text.aes_cipher$part$3+0x8): undefined reference to `AESAUX'
C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\lmic\lmic.c.o:(.text.aes_cipher$part$3+0xc): undefined reference to `AESKEY'
C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\lmic\lmic.c.o:(.text.aes_cipher$part$3+0x10): undefined reference to `os_aes'
C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\lmic\lmic.c.o: In function `aes_cipher':
S:\Skydrive\devt\Arduino\libraries\arduino-lmic\src\lmic/lmic.c:85: undefined reference to `os_aes'
C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\lmic\lmic.c.o: In function `rxschedInit':
S:\Skydrive\devt\Arduino\libraries\arduino-lmic\src\lmic/lmic.c:85: undefined reference to `os_aes'
C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\lmic\lmic.c.o: In function `decodeFrame':
S:\Skydrive\devt\Arduino\libraries\arduino-lmic\src\lmic/lmic.c:85: undefined reference to `os_aes'
C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\lmic\lmic.c.o: In function `engineUpdate':
S:\Skydrive\devt\Arduino\libraries\arduino-lmic\src\lmic/lmic.c:85: undefined reference to `os_aes'
C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\lmic\lmic.c.o:S:\Skydrive\devt\Arduino\libraries\arduino-lmic\src\lmic/lmic.c:85: more undefined references to `os_aes' follow

collect2.exe: error: ld returned 1 exit status

Using library arduino-lmic at version 1.5.0+arduino-1 in folder: S:\Skydrive\devt\Arduino\libraries\arduino-lmic 
Using library SPI at version 1.0 in folder: S:\Skydrive\devt\Arduino\hardware\esp8266com\esp8266\libraries\SPI 
Using library ESP8266WiFi at version 1.0 in folder: S:\Skydrive\devt\Arduino\hardware\esp8266com\esp8266\libraries\ESP8266WiFi 
exit status 1
Error compiling for board WeMos D1 R2 & mini.

Fix is in the file src/aes/limc.c, change at the beginning, the test #if defined after the include for the compiler knows the USE_ORIGINAL_AES and also change the #include file name (set te relative) because it was not found so

#if defined(USE_ORIGINAL_AES)
#include "oslmic.h"

becomes

#include "../lmic/oslmic.h"
#if defined(USE_ORIGINAL_AES)
  • Second point

Using USE_IDEETRON_AES in config.h fire a linker error with double definition of aes_encrypt only on ESP8266 but this is because SDK already contain aes_encrypt() function in libcrypto.a.

S:\Skydrive\devt\Arduino\hardware\esp8266com\esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc" -g  -Os -nostdlib -Wl,--no-check-sections -u call_user_start -u _printf_float -u _scanf_float -Wl,-static "-LS:\Skydrive\devt\Arduino\hardware\esp8266com\esp8266/tools/sdk/lib" "-LS:\Skydrive\devt\Arduino\hardware\esp8266com\esp8266/tools/sdk/ld" "-LS:\Skydrive\devt\Arduino\hardware\esp8266com\esp8266/tools/sdk/libc/xtensa-lx106-elf/lib" "-Teagle.flash.4m1m.ld" -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,register_chipv6_phy  -o "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp/ttn-abp.ino.elf" -Wl,--start-group "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\sketch\ttn-abp.ino.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\aes\lmic.c.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\aes\other.c.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\aes\ideetron\AES-128_V10.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\hal\hal.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\lmic\lmic.c.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\lmic\oslmic.c.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\lmic\radio.c.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\SPI\SPI.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\ESP8266WiFi\ESP8266WiFi.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\ESP8266WiFi\ESP8266WiFiAP.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\ESP8266WiFi\ESP8266WiFiGeneric.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\ESP8266WiFi\ESP8266WiFiMulti.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\ESP8266WiFi\ESP8266WiFiSTA.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\ESP8266WiFi\ESP8266WiFiScan.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\ESP8266WiFi\WiFiClient.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\ESP8266WiFi\WiFiClientSecure.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\ESP8266WiFi\WiFiServer.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\ESP8266WiFi\WiFiUdp.cpp.o" "C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp/arduino.ar" -lhal -lphy -lpp -lnet80211 -llwip_gcc -lwpa -lcrypto -lmain -lwps -laxtls -lsmartconfig -lmesh -lwpa2 -lstdc++ -lm -lc -lgcc -Wl,--end-group  "-LC:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp"
S:\Skydrive\devt\Arduino\hardware\esp8266com\esp8266/tools/sdk/lib\libcrypto.a(aes-internal-enc.o): In function `aes_encrypt':
(.irom0.text+0x490): multiple definition of `aes_encrypt'
C:\Users\CHARLE~1\AppData\Local\Temp\build20a4a2935c21ce58917d68130563504a.tmp\libraries\arduino-lmic\aes\ideetron\AES-128_V10.cpp.o:S:\Skydrive\devt\Arduino\libraries\arduino-lmic\src\aes\ideetron/AES-128_V10.cpp:92: first defined here

collect2.exe: error: ld returned 1 exit status

Using library arduino-lmic at version 1.5.0+arduino-1 in folder: S:\Skydrive\devt\Arduino\libraries\arduino-lmic 
Using library SPI at version 1.0 in folder: S:\Skydrive\devt\Arduino\hardware\esp8266com\esp8266\libraries\SPI 
Using library ESP8266WiFi at version 1.0 in folder: S:\Skydrive\devt\Arduino\hardware\esp8266com\esp8266\libraries\ESP8266WiFi 
exit status 1
Error compiling for board WeMos D1 R2 & mini.

Workaround was (may be better solution) to rename all aes_encrypt() to limc_aes_encrypt() to avoid target error due to existing function.

Error on Linkit ONE

Hi
I using Lora Shield and LinkIt ONE, When I compile with the following error :

Arduino: 1.6.8 (Windows 7), Board: "LinkIt ONE"

Warning: platform.txt from core 'MediaTek ARM7 EJ-S (32-bits) Boards' contains deprecated recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} "{build.path}/{archive_file}" "{object_file}", automatically converted to recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} "{archive_file_path}" "{object_file}". Consider upgrading this core.
C:\Users\R@MiN\Documents\Arduino\libraries\arduino-lmic\src\hal\hal.cpp:77:14: error: 'SPISettings' does not name a type

 static const SPISettings settings(10E6, MSBFIRST, SPI_MODE0);

              ^

C:\Users\R@MiN\Documents\Arduino\libraries\arduino-lmic\src\hal\hal.cpp: In function 'void hal_pin_nss(u1_t)':

C:\Users\R@MiN\Documents\Arduino\libraries\arduino-lmic\src\hal\hal.cpp:85:13: error: 'class SPIClass' has no member named 'beginTransaction'

         SPI.beginTransaction(settings);

             ^

C:\Users\R@MiN\Documents\Arduino\libraries\arduino-lmic\src\hal\hal.cpp:85:30: error: 'settings' was not declared in this scope

         SPI.beginTransaction(settings);

                              ^

C:\Users\R@MiN\Documents\Arduino\libraries\arduino-lmic\src\hal\hal.cpp:87:13: error: 'class SPIClass' has no member named 'endTransaction'

         SPI.endTransaction();

             ^

C:\Users\R@MiN\Documents\Arduino\libraries\arduino-lmic\src\hal\hal.cpp: In function 'u4_t hal_ticks()':

C:\Users\R@MiN\Documents\Arduino\libraries\arduino-lmic\src\hal\hal.cpp:154:115: error: 'static_assert' was not declared in this scope

     static_assert(US_PER_OSTICK_EXPONENT > 0 && US_PER_OSTICK_EXPONENT < 8, "Invalid US_PER_OSTICK_EXPONENT value");

                                                                                                                   ^

exit status 1
Error compiling for board LinkIt ONE.

What's the solution ?
Note : I found this PR to be relevant (But it did not work.):
#27

SD card breakout

Has anyone got this library working with an SD card breakout or shield? It seems as soon as I connect the SD card breakout to 50,51,52,53 with 53 as CS the Lora (CS on 10) doesn't seem to properly initialize any more. Setting the CS of the SD card to high doesn't seem to help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.