Error: Programming LoPy from Arduino IDE

Hello,

i am trying to send data from my LoPy4 via ttn using the Arduino IDE with lmic.
Sending data works fine with the LoPy firmware, but in the firmware lightsleep is not included therefore I have to use the Arduino IDE.

I followed the tutorial: https://www.thethingsnetwork.org/labs/story/program-your-lopy-from-the-arduino-ide-using-lmic

but when adding .mosi .miso and .sck to the lmic_pins i get the following error message:

ttn-otaa:85:1: error: ‘const lmic_pinmap {aka const Arduino_LMIC::HalPinmap_t}’ has no non-static data member named ‘mosi’
};
^
Multiple libraries were found for “lmic.h”
Used: /home/daniel/Arduino/libraries/MCCI_LoRaWAN_LMIC_library
Multiple libraries were found for “SPI.h”
Used: /home/daniel/.arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/SPI
exit status 1
‘const lmic_pinmap {aka const Arduino_LMIC::HalPinmap_t}’ has no non-static data member named ‘mosi’

Has someone an idea, what i could try? Thanks in advance.

That class does not support specifying the SPI pins because on most Arduino platforms the assignment of the primary SPI pins is assumed. In contrast there is no standard for the DIO pins used to generate interrupts off radio state changes, so those do get specified.

If you need to do something unique you will likely have to find the code that would use this information and change it there. Ideally you would change the class definition to be able to pass it through but many might chose to just fix it in the location where used.

It’s not really clear how well the combination of LMiC, Arduino, and ESP32 works right now at achieving the very precise timing requirements of LoRaWAN. You may want to consider looking at the native (ESP-IDF) port of LMiC to the ESP32 rather than one with all the complications of Arduino and the somewhat odd way it provides timing information stuck as an intermediary in between the code and the hardware.

I finally resolved the issue.

For me it only works with this lmic Library:

The following libraries did not work for me:
GitHub - mcci-catena/arduino-lmic: LoraWAN-MAC-in-C library, adapted to run under the Arduino environment
GitHub - jpmeijers/arduino-lmic: LoraWAN-MAC-in-C library, adapted to run under the Arduino environment

Then for the Lopy 4 the lmic_pins had to be changed like this:

const lmic_pinmap lmic_pins = {
.nss = 18,
.rxtx = LMIC_UNUSED_PIN,
.rst = LMIC_UNUSED_PIN,
.dio = {23,23,23},
};

in …/libraries/arduino-lmic-master/src/hal/hal.cpp the spi_init had to be changed to include the right SPI pins:

static void hal_spi_init () {
SPI.begin(5,19,27,18);
}