lnlp / LMIC-node

LMIC-node | One example to rule them all. LMIC-node is an example LoRaWAN application for a node that can be used with The Things Network. It demonstrates how to send uplink messages, how to receive downlink messages, how to implement a downlink command and it provides useful status information. With LMIC-node it is easy to get a working node quickly up and running. LMIC-node supports many popular (LoRa) development boards out of the box. It uses the Arduino framework, the LMIC LoRaWAN library and PlatformIO.
MIT License
223 stars 102 forks source link

Definition: _LMIC_CONFIG_PRECONDITIONS_H_ #36

Closed CK1-CK closed 2 years ago

CK1-CK commented 2 years ago

Hi

where is the definition to "_LMIC_CONFIG_PRECONDITIONSH"? I don't know where to define the _LMIC_CONFIG_PRECONDITIONSH

The project compiles everytime with the deprecated lmic lib. Unfortunately the deprecated lib doesn't work with TTN Stack v3.

https://github.com/lnlp/LMIC-node/blob/fabdde20276baedb91526cf8943e7ad3f076b69d/src/LMIC-node.h#L64

best regards CK1

lnlp commented 2 years ago

Hi,

At first I misread your question. I have updated my answer below.

where is the definition to "LMIC_CONFIG_PRECONDITIONS_H"?

The code already more or less explains this:

// Determine which LMIC library is used
#ifdef _LMIC_CONFIG_PRECONDITIONS_H_   
    #define MCCI_LMIC
#else
    #define CLASSIC_LMIC
#32 

If defined the MCCI LMIC library is used. It is defined within the MCCI LMIC library. Above is a simple test to check if MCCI LMIC is used or not.

I don't know where to define the LMIC_CONFIG_PRECONDITIONS_H

This is not something that you need to or should define yourself.

The project compiles everytime with the deprecated lmic lib.

Apparently you have selected one of the boards with 8-bit AVR microcontroller. Can you confirm this? Which boardid have you selected in platformio.ini? The documentation clearly describes which LMIC library is used for which board and shows examples of how this is implemented.

Unfortunately the deprecated lib doesn't work with TTN Stack v3.

Classic LMIC is not (fully) LoRaWAN compliant and e.g. does not properly handle MAC commands. Not everything works but at least some of the basics like sending a message works. Due to these limitations in LMIC-node use of ABP has been disabled for Classic LMIC but OTAA should work. 8-bit AVR based boards and Classic LMIC were already supported by LMIC-node when we only had TTN V2 and V3 was not yet available and Classic LMIC was not yet deprecated. 8-bit AVR boards are still supported by LMIC-node - although only for Classic LMIC - to provide new users with older 8-bit AVR boards at least with something that works. These 8-bit AVR MCU's are however not preferred for new LoRaWAN developments (due to their limited amount of memory) and neither is the deprecated Classic LMIC library.

CK1-CK commented 2 years ago

Hi,

thanks for answering.

I use the following hardware (because of the current consumption):

I just want to monitor a door switch by interrupt PIN (3) and if the pin changes a message should be sent to TTN.

Apparently you have selected one of the boards with 8-bit AVR microcontroller. Can you confirm this?

yes i can confirm

Which boardid have you selected in platformio.ini?

pro8mhzatmega328 (Arduino Pro Mini 3.3V 8Mhz)

These 8-bit AVR MCU's are however not preferred for new LoRaWAN developments (due to their limited amount of memory) and neither is the deprecated Classic LMIC library.

-.- :(

I thought i can switch to the "new" MCCI Lib with "#Define _LMIC_CONFIG_PRECONDITIONSH " but than a lot of code errors occur.

// Determine which LMIC library is used
#ifdef _LMIC_CONFIG_PRECONDITIONS_H_   
    #define MCCI_LMIC
#else
    #define CLASSIC_LMIC

In principle, I don't care if I use an outdated lib. I hope that I can just get a connection with TTN and send the one byte.

Currently the join process fails and no payload will be sent. (see screenshot TTN Console) image At the moment i don't know is it a failure in the arduino code or a wrong config in ttn

image

lnlp commented 2 years ago

Apparently you have selected one of the boards with 8-bit AVR microcontroller. Can you confirm this?

yes i can confirm

Which boardid have you selected in platformio.ini?

pro8mhzatmega328 (Arduino Pro Mini 3.3V 8Mhz)

These 8-bit AVR MCU's are however not preferred for new LoRaWAN developments (due to their limited amount of memory) and neither is the deprecated Classic LMIC library.

If you read the (LMIC-node) documentation (you should!) you will see that the 8-bit AVR boards have too little memory for LMIC-node in combination with a recent MCCI LMIC library version.

You can still use an 8-bit AVR with MCCI LMIC but you will not have much memory left for more advanced programs. Try the ttn-otaa.ino example included with the MCCI LMIC library together with the MCCI LMIC library. It will also work on 8-bit AVR but is quite a bit more complicated to get it to work than LMIC-node and you will have to avoid any pitfalls yourself.

For LoRaWAN version and regional parameters I usually use version v1.0.3. I don't remember what the exact differences between v1.0.2 and v1.0.3 are but v1.0.3 usually works for me.

For more support check The Things Network forum where more people will be able to help.