Git Product home page Git Product logo

stm32lorawan's Introduction

STM32LoRaWAN library

This library provides support for LoRaWAN communication using the STM32WL55 microcontroller (with embedded LoRa radio) inside the Arduino develop environment (together with the stm32duino core with version 2.4.0 or later).

This library offers an API that is highly similar to the API offered by the Arduino MKRWAN library (including undocumented methods) so any sketches written for either library should usually work on the other too (but note below for some caveats).

Documentation

Overview and reference documentation is embedded in the source code and can be viewed online on Github.

To generate the documentation yourself, simply run the doxygen command (no options needed) in the root of this repository. This will produce HTML documentation in the api-docs subdirectory.

Running checks

This repository is set up to run some checks in github workflows automatically. You can also run them locally as follows.

For codespell spell checking, just run the command without options, it will tell you about any spelling errors in the code.

codespell

For astyle, you need to pass a few options. This will automatically fix style errors, so this is probably best done after staging all changes, so you can easily see what was changed. Add --dry-run to only see which files need to be changed (does not display the changes made, though).

astyle --project=.astylerc --recursive '*.c' '*.h' '*.ino'

(you can also set ARTISTIC_STYLE_PROJECT_OPTIONS=.astylerc in your environment and omit --project option)

License

This library is based on LoRaMac-node developed by semtech, with extensive modifications and additions made by STMicroelectronics.

All code included in this library is licensed under the Revised BSD license, the full license text can be found in the LICENSE file and in individual source files as well.

stm32lorawan's People

Contributors

fpistm avatar frastm avatar matthijskooijman avatar miceuz avatar tcpipchip 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stm32lorawan's Issues

unknown type name 'SUBGHZ_HandleTypeDef'

Hi,
I was trying to compile on version 2.3 of the Generic STM32WL series board "Generic WLE5CCUx" and I got this error:

STM32LoRaWAN.cpp:1113:3: error: 'vcore_debug' was not declared in this scope; did you mean 'core_debug'?

I fix the error changing "vcore_debug" to "core_debug". I created a fork with this fixed #4 . But now when that was fixed appears new errors:

STM32LoRaWAN-main\src\BSP\subghz.h:50:8: error: unknown type name 'SUBGHZ_HandleTypeDef'
50 | extern SUBGHZ_HandleTypeDef hsubghz;

STM32LoRaWAN-main\src\BSP\subghz.c:43:1: error: unknown type name 'SUBGHZ_HandleTypeDef'; did you mean 'UART_HandleTypeDef'?
43 | SUBGHZ_HandleTypeDef hsubghz;

rtc init

Hi team
Did you already got this problem ?
Error: C:\Users\Usuario\Documents\Arduino\libraries\STM32LoRaWAN-main\src\BSP\rt
c.c (56)

/** Initialize RTC Only
*/
hrtc.Instance = RTC;
hrtc.Init.AsynchPrediv = RTC_PREDIV_A;
hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE;
hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
hrtc.Init.OutPutPullUp = RTC_OUTPUT_PULLUP_NONE;
hrtc.Init.BinMode = RTC_BINARY_ONLY;
if (HAL_RTC_Init(&hrtc) != HAL_OK)
{
Error_Handler();
}

Class C Support?

Is it possible to get Class C support?

STM32CUBEIDE has Class C support, hoping we can get it to work with Arduino IDE as well.

SimpleAsync Example does not receive packets from the Helium Network

Describe the bug
When running a Lora-e5 module (STM32WL55) with Arduino example SimpleAsync.ino packets are not received from the Helium network. However if a packet is queued before a join, when the device joins the packet is received, but only once.

To Reproduce

Compile, flash SimpleAsync.ino to e5-mini, setup config variables.

Queue packet to be sent on LNS
Reset device.
Device joins.
Packet received

Queue packet to be sent on LNS
Device transmits data to LNS
No packet received

Expected behavior
Queue packet to be sent on LNS
Reset device.
Device joins.
Packet received

Queue packet to be sent on LNS
Device transmits data to LNS
Packet received

Screenshots
Screenshot from 2024-04-09 09-30-55

Screenshot from 2024-04-09 09-31-37

Screenshot from 2024-04-09 09-32-26

Screenshot from 2024-04-09 09-32-36

Desktop (please complete the following information):

  • OS: Linux
  • Arduino IDE version: 2.3.2
  • Library version: 0.2.0
  • Upload method: SWD

Hardware (please complete the following information):

  • Board Name: Lora-E5 Dev board
  • Extra hardware used if any: ST Link

Additional context

I have tried setting

modem.setRX2DR(DR_0);
modem.setRX2Freq(869525000);

Also setting in the queued message

FPort

But still not working.

LowPower.deepSleep not working after modem.begin

  • I am running the latest version of this repository (dependencies too)
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been created

Expected Behavior

After setting modem.begin(EU868) and LowPower.deepSleep() it goes sleep, and the chip will not wake up.

Current Behavior

After setting modem.begin(EU868) and LowPower.deepSleep() it goes sleep, but after around 900ms it wakes up.

If modem.begin(EU868) isn't used then it works as intended, and the chip will not wake up.

Minimal example

#include <Arduino.h>
#include <STM32LoRaWAN.h>
#include <STM32RTC.h>
#include "STM32LowPower.h"

STM32RTC& rtc = STM32RTC::getInstance();
STM32LoRaWAN modem;

void setup() {
    Serial.begin(115200);
    modem.begin(EU868);
    LowPower.begin();
    LowPower.deepSleep();
}

void loop() {
    Serial.begin(115200);
    Serial.println("wakes up");
    delay(1000);
    LowPower.deepSleep();
}

Power Profiler screenshot with modem.begin()
image

Power Profiler screenshot without modem.begin()
image

Details (what I tried)

I tried to look on

bool STM32LoRaWAN::begin(_lora_band band)
{
if (instance != nullptr)
return failure("Only one STM32LoRaWAN instance can be used");
instance = this;
/*
* Init RTC as an object :
* use the MIX mode = free running BCD calendar + binary mode for
* the sub-second counter RTC_SSR on 32 bit
*/
_rtc.setClockSource(STM32RTC::LSE_CLOCK);
_rtc.setBinaryMode(STM32RTC::MODE_MIX);
_rtc.begin(true, STM32RTC::HOUR_24);
/* Attach the callback function before enabling Interrupt */
_rtc.attachInterrupt(UTIL_TIMER_IRQ_MAP_PROCESS, STM32RTC::ALARM_B);
_rtc.attachSecondsInterrupt(TIMER_IF_SSRUCallback);
/* The subsecond alarm B is set during the StartTimerEvent */
UTIL_TIMER_Init(_rtc.getHandle());
and tried in my main code to:

rtc.detachInterrupt, rtc.detachSecondsInterrupt, rtc.disableAlarm (both A ,B), but none of it worked.

Only when I after modem.begin() called rtc.end() and then rtc.begin() it stops waking up, but after joining the network (which was successfull), modem.send() didn't send any message (propably some problem with RTC settings that should have been set in modem.begin() and was cleared after rtc.end())

Context

I'm using supported LORA-E5 chip (STM32WLE5JC) on custom PCB

platformio.ini:

[env:lora_e5_mini]
platform = ststm32
board = lora_e5_mini
framework = arduino
lib_deps = 
    https://github.com/stm32duino/STM32LoRaWAN.git#0.2.0
    https://github.com/stm32duino/STM32RTC.git#1.4.0
    https://github.com/stm32duino/STM32LowPower.git#5ae219c
monitor_speed = 115200
monitor_filters = time
upload_protocol = stlink
debug_tool = stlink

No random number

I use this library for a "Seeed Lora-E5 mini" board. I had to make some changes for the 3 pins for the RF switches. I also had to fix the definition of "LORAWAN_TX_CONFIG", which should be "RBI_COF_RFO_HP" for this board.

The module works well: the OTAA JOIN was successful and several packets were sent.

After a reset, a new JOIN was not possible. The TTN error was “DevNonce has already been used”.

I found out that the devnonce was always "0000", so not very random. The problem is the function "SUBGRF_GetRandom()" in radio_driver.c. This function always returns a 32-bit zero value.

Deadlock on joinOTAA

I'm testing the Basic example on a LORA-E5/Wio-E5 module - using core Generic WLE5JCIx. Core logs are enable.

At startup I see "Start" printed on the serial port, but the the sketch locks up after that. By adding more prints I see it is stopping on joinOTAA.

My guess is that the rf switch defines are not correct for the E5 module. I'm trying to debug that, which brings me to the second issue, which is that the library is not printing any debug logs, even though I have core logs enabled.

image

image

CW mode support?

Is there a possibility to enter into continuous wave mode for testing purposes?

LoRa send and receive without joining the Things Network

Hi!

I am working on a LoRa based device using the Wio-E5-mini, and I am very interested in using this module for my sensor. Yet, I do find the joinOTAA using the things network a bit too much so to say for the desired functionality of my sensor. Hence, I was wondering if it was possible to just transmit signals via the antenna without going to the things network. I was thinking something along the line of

LoRaModem modem;


void setup(void)
{

    if (!modem.begin(EU868)){
        Serial.println(F("Failed to start module"));
        while(1){}
    }
    Serial.print(F("Version: "));
   Serial.print(modem.version());

    }
}

void loop(void)
{
    String msg= "This is a good message!";
    modem.beginPacket();
    modem.print(msg);
    int err = modem.endPacket(true);
}

This might be a dumb question so to say, but it was not immediately clear for me when reading the documentation. If I overlooked something, I would be grateful for a pointer in the right direction. My question still remains, is this kind of communication supported with this module, and if so, could I get a pointer as to how this is performed? And if it is not supported, would it be possible to request this to be supported in a future edition?

PlatformIO project is not compiling

Hello! I am trying to use this module to operate the LoRa device in the board "Wio E5 Mini" from Seeed studio. When including this library, however, I get several error messages relating to undeclared functions, variables and datatypes. This made me think I perhaps forgot to install some dependency, but I can't seem to figure out which dependency this would be or if the problem lies somewhere else.

The error messages I get are listed below, and I will post my code (platformio.ini and main.cpp) in an answer to this issue.

Compiling .pio\build\nucleo_wl55jc\lib114\STM32duinoLoRaWAN\STM32CubeWL\LoRaWAN\Crypto\lorawan_aes.c.o
.pio\libdeps\nucleo_wl55jc\STM32duinoLoRaWAN\src\BSP\mw_log.cpp: In function 'void MW_LOG(MwLogTimestamp_t, MwLogLevel_t, const char*, ...)':
.pio\libdeps\nucleo_wl55jc\STM32duinoLoRaWAN\src\BSP\mw_log.cpp:45:5: error: 'vcore_debug' was not declared in this scope; did you mean 'core_debug'?
  45 |     vcore_debug(fmt, ap);
     |     ^~~~~~~~~~~
     |     core_debug
Compiling .pio\build\nucleo_wl55jc\lib114\STM32duinoLoRaWAN\STM32CubeWL\LoRaWAN\Crypto\soft-se.c.o
*** [.pio\build\nucleo_wl55jc\lib114\STM32duinoLoRaWAN\BSP\mw_log.cpp.o] Error 1
In file included from .pio\libdeps\nucleo_wl55jc\STM32duinoLoRaWAN\src\BSP\subghz.c:41:
.pio\libdeps\nucleo_wl55jc\STM32duinoLoRaWAN\src\BSP\subghz.h:50:8: error: unknown type name 'SUBGHZ_HandleTypeDef'
  50 | extern SUBGHZ_HandleTypeDef hsubghz;
     |        ^~~~~~~~~~~~~~~~~~~~
.pio\libdeps\nucleo_wl55jc\STM32duinoLoRaWAN\src\BSP\subghz.c:43:1: error: unknown type name 'SUBGHZ_HandleTypeDef'; did you mean 'UART_HandleTypeDef'?
  43 | SUBGHZ_HandleTypeDef hsubghz;
     | ^~~~~~~~~~~~~~~~~~~~
     | UART_HandleTypeDef
.pio\libdeps\nucleo_wl55jc\STM32duinoLoRaWAN\src\BSP\subghz.c: In function 'MX_SUBGHZ_Init':
.pio\libdeps\nucleo_wl55jc\STM32duinoLoRaWAN\src\BSP\subghz.c:47:10: error: request for member 'Init' in something not a structure or union
  47 |   hsubghz.Init.BaudratePrescaler = SUBGHZSPI_BAUDRATEPRESCALER_4;
     |          ^
.pio\libdeps\nucleo_wl55jc\STM32duinoLoRaWAN\src\BSP\subghz.c:47:36: error: 'SUBGHZSPI_BAUDRATEPRESCALER_4' undeclared (first use in this function); did you mean 'SPI_BAUDRATEPRESCALER_4'?
  47 |   hsubghz.Init.BaudratePrescaler = SUBGHZSPI_BAUDRATEPRESCALER_4;
     |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     |                                    SPI_BAUDRATEPRESCALER_4
.pio\libdeps\nucleo_wl55jc\STM32duinoLoRaWAN\src\BSP\subghz.c:47:36: note: each undeclared identifier is reported only once for each function it appears in
.pio\libdeps\nucleo_wl55jc\STM32duinoLoRaWAN\src\BSP\subghz.c:48:7: warning: implicit declaration of function 'HAL_SUBGHZ_Init'; did you mean 'MX_SUBGHZ_Init'? [-Wimplicit-function-declaration]
  48 |   if (HAL_SUBGHZ_Init(&hsubghz) != HAL_OK) {
     |       ^~~~~~~~~~~~~~~
     |       MX_SUBGHZ_Init
.pio\libdeps\nucleo_wl55jc\STM32duinoLoRaWAN\src\BSP\subghz.c: At top level:
.pio\libdeps\nucleo_wl55jc\STM32duinoLoRaWAN\src\BSP\subghz.c:54:25: error: unknown type name 'SUBGHZ_HandleTypeDef'; did you mean 'UART_HandleTypeDef'?
  54 | void HAL_SUBGHZ_MspInit(SUBGHZ_HandleTypeDef *subghzHandle)
     |                         ^~~~~~~~~~~~~~~~~~~~
     |                         UART_HandleTypeDef
.pio\libdeps\nucleo_wl55jc\STM32duinoLoRaWAN\src\BSP\subghz.c:65:27: error: unknown type name 'SUBGHZ_HandleTypeDef'; did you mean 'UART_HandleTypeDef'?
  65 | void HAL_SUBGHZ_MspDeInit(SUBGHZ_HandleTypeDef *subghzHandle)
     |                           ^~~~~~~~~~~~~~~~~~~~
     |                           UART_HandleTypeDef
.pio\libdeps\nucleo_wl55jc\STM32duinoLoRaWAN\src\BSP\subghz.c: In function 'SUBGHZ_Radio_IRQHandler':
.pio\libdeps\nucleo_wl55jc\STM32duinoLoRaWAN\src\BSP\subghz.c:78:3: warning: implicit declaration of function 'HAL_SUBGHZ_IRQHandler'; did you mean 'HAL_UART_IRQHandler'? [-Wimplicit-function-declaration]
  78 |   HAL_SUBGHZ_IRQHandler(&hsubghz);
     |   ^~~~~~~~~~~~~~~~~~~~~
     |   HAL_UART_IRQHandler
*** [.pio\build\nucleo_wl55jc\lib114\STM32duinoLoRaWAN\BSP\subghz.c.o] Error 1

Missing header file error

When trying to compile any example of STM32duinoLoRaWAN library (basic, SendAndReceive, asyncs) for my RAK3172 module I get the error:

Arduino\libraries\STM32duinoLoRaWAN\src\BSP\mw_log.cpp:39:10: fatal error: core_debug.h: No such file or directory

I've been looking for that header file but it's not existing in my files. Am I missing any additional stm32 core library?

RX1 window Timer event never reached

Describe the bug
endPacket() is never finished after 4:40h of properly working. I've tested 3 times and it blocked at same time (4:40h).
2 times with 10min sending period between (both times it blocked at counter 29) and once tested with 5min sending period (same time period passed, but now it blocked on counter 57).
I did debugging by adding multiple print logs in header files.

Sending is done successfuly, message arrives on gateway - and than it stops, like it is in infinite loop.
RX1 window should be opened, but it seems that this part is never done.
After LoRaMacProcess() function is done once (for sending), function OnRxWindow1TimerEvent() should be called - but it is never called.

I'm using RAK3172 module, EU868 region.
I'm using STM32 Low Power library to send device in DeepSleep, and I'm using RTC Alarm timed wakeup.
Even if it is stuck between TX and RX windows, this alarms work properly (I can see alarm triggers later).
I tried to disable DeepSleep and alarms, and use delay instead, but result is the same.

Transmitted payload has 6 bytes.

  • OS: Windows
  • Arduino IDE version: 2.2.1
  • STM32 core version: 2.7.1
  • Library version: 0.2.0
  • Upload method: Serial
  • Board Name: RAK3172 (without TXCO)

To Reproduce
Set device to send messages every 10min and wait for 29th message. Or set with 5min time period and wait for 57th message.
That last message will be transmitted, endPacket() function will not be finished.

Expected behavior
This is part of logs how it should looks like when it works correctly (note that 2nd section is missing later):

LoRaMacProcess 1
LoRaMacHandleIrqEvents 1
LoRaMacHandleIrqEvents 2
ProcessRadioTxDone
...
TIMER_IF_StartTimer Start timer: time=4154841, alarm=4156109
GetTimerTicks 1
GetTimerTicks 2: -4154845, 4154844
TIMER_IF_GetTimerElapsedTime: 6
TIMER_IF_GetTime
GetTimerTicks 1
GetTimerTicks 2: -4154847, 4154846
TIMER_IF_BkUp_Read_MSBticks
LoRaMacProcess 2
LoRaMacProcess 3
LoRaMacProcess 13
LoRaMacProcess 14

TIMER_IF_SetTimerContext
GetTimerTicks 1
GetTimerTicks 2: -4156110, 4156109
OnRxWindow1TimerEvent
RxWindowSetup 1
RxWindowSetup 2
RxWindowSetup 3
GetTimerTicks 1
GetTimerTicks 2: -4156114, 4156113
TIMER_IF_GetTimerElapsedTime: 4
GetTimerTicks 1
GetTimerTicks 2: -4156116, 4156115
TIMER_IF_GetTimerElapsedTime: 6
GetTimerTicks 1
GetTimerTicks 2: -4156118, 4156117
TIMER_IF_GetTimerElapsedTime: 8
GetTimerTicks 1
GetTimerTicks 2: -4156120, 4156119
TIMER_IF_StartTimer Start timer: time=4156119, alarm=4156371
OnRadioRxTimeout
OnMacProcessNotify
... [logs continue]

This is log when it stopped:

LoRaMacProcess 1
LoRaMacHandleIrqEvents 1
LoRaMacHandleIrqEvents 2
ProcessRadioTxDone
...
TIMER_IF_StartTimer Start timer: time=4308483, alarm=4309750
GetTimerTicks 1
GetTimerTicks 2: -4308487, 4308486
TIMER_IF_GetTimerElapsedTime: 6
TIMER_IF_GetTime
GetTimerTicks 1
GetTimerTicks 2: -4308489, 4308488
TIMER_IF_BkUp_Read_MSBticks
LoRaMacProcess 2
LoRaMacProcess 3
LoRaMacProcess 13
LoRaMacProcess 14
[logs stopped]

Has anyone had the same problem, or do you have idea about possible solution?

Thanks!

Example request: FreeRTOS+Low Power+LoRaWAN

My ideal setup would be an STM32 running FreeRTOS, going into Low Power mode in its idle task, periodically sending LoRa packets from a FreeRTOS task.

Basically I would need to combine these three libraries:

Currently this is not possible. The first hurdle to overcome is issue #9. After that one would need to combine LowPower with FreeRTOS. I also imagine one would need to replace the LoRaWAN internal scheduler with FreeRTOS.

Assync OTA

Hi,

the basic.ino works cool, always JOIN to network...

But the simpleAsync.ino always fail to join.

Did you tested?

I am using on STM32WL55JC

Overwrite default values to match other antenna configuration

Hi,

to use the lib with the ELV-BM-TRX1 module, some default values have to be changed to match the hardware/antenna configuration.
Please add a preprocessor directive to overwrite the defines with own values or is there a other solution to use custom values?

in radio_conf.h
#define XTAL_DEFAULT_CAP_VALUE ( 0x20UL )

replace with
#ifndef XTAL_DEFAULT_CAP_VALUE
#define XTAL_DEFAULT_CAP_VALUE ( 0x20UL )
#endif /* XTAL_DEFAULT_CAP_VALUE */

if RegionEU868.h
#define EU868_TX_MAX_DATARATE DR_7
#define EU868_RX_MAX_DATARATE DR_7
#define EU868_DEFAULT_ANTENNA_GAIN 2.15f

replace with
#ifndef EU868_TX_MAX_DATARATE
#define EU868_TX_MAX_DATARATE DR_7
#endif /* EU868_TX_MAX_DATARATE */

#ifndef EU868_RX_MAX_DATARATE
#define EU868_RX_MAX_DATARATE DR_7
#endif /* EU868_RX_MAX_DATARATE*/

#ifndef EU868_DEFAULT_ANTENNA_GAIN
#define EU868_DEFAULT_ANTENNA_GAIN 2.15f
#endif /* EU868_DEFAULT_ANTENNA_GAIN */

Maybe for other hardware more values have to be changeable, but for the ELV-BM-TRX1 module only these values are important.

JoinABP assync

Hi,
modem.joinABPAsync() is not yet implemented, right ?

RAK3172T TXCO configuration Issue

I’m happy that the STM32LoRaWAN library V0.2.0 was released a couple of days ago.

I tried the new library with my RAK3172 evaluation board and everything worked as expected. On the evaluation board a RAK3172E module is installed and I did a full chip erase before I flashed my own file based on the basic example.

In parallel I have 25 nodes with a RAK3172T module installed. The RAK3172T module has an TXCO installed for a lower operation temperature and need a special configuration. I was not able to get the same program running on the RAK3172T module. The device will not connect to TTN.

I used Board “LoRa Boards” and the Board Part Number “RAK3172 Module”. STM32LoRaWAN library V0.2.0 and STM32RTC library 1.4 on Arduino 2.2.1.

I guess we need a new device for the RAK3172T module.

Generic Node Support

I’m extremely happy about the release of the STM32LoRaWAN library. By default the STM32LoRaWAN library supports the STM32 Nucleo board with STM32WL55JC MCU.

I would appreciate if the STM32LoRaWAN library could support the Generic Node (https://www.genericnode.com/, https://github.com/TheThingsIndustries/generic-node-se) as well.

The pinout differences are:
RF_CTRL1 NUCLEO - PC4 —> Generic Node - PA0
RF_CTRL2 NUCLEO - PC5 —> Generic Node - PA1
RF_CTRL3 NUCLEO - PC3 —> Generic Node - PB8

Would be great if you could add the Generic Node support.

bug - not join when parameter is String

The bug

do you why JOIN always fail to

String setAppEuiString;
String setAppKeyString;
String setDevEuiString;

  setAppEuiString="0000000000000099";
  setAppKeyString="FF9F138B40180AA45D6846E0A0146954";
  setDevEuiString="XX80E115051XX80A";
  modem.setAppEui(setAppEuiString); //@
  modem.setAppKey(setAppKeyString); //#
  modem.setDevEui(setDevEuiString); //$

and always work to

  modem.setAppEui("0000000000000099"); //@
  modem.setAppKey("FF9F138B40180AA45D6846E0A0146954"); //#
  modem.setDevEui("0080E115051FD80A"); //$

looks that is a problem here

bool setAppEui(String value) { return setDevEui(value.c_str()); }

Should be

bool setAppEui(String value) { return setAppEui(value.c_str()); }

on STM32LoRaWAN.h

After changed its working now, i can JOIN

LoRaWAN with low power and RTC

Hi,
I was trying to use your example of sending data via lorawan and the library "STM32LowPower.h" and I get an error that two functions have multiple definitions.

.: ../../../..\libraries\STM32duino_RTC\rtc.c.o: in function `HAL_RTC_AlarmAEventCallback':
rtc.c:(.text.HAL_RTC_AlarmAEventCallback+0x0): multiple definition of `HAL_RTC_AlarmAEventCallback'; ..\..\..\.\libraries\STM32duino_RTC\rtc.c.o: in function `RTC_Alarm_IRQHandler':
rtc.c:(.text.RTC_Alarm_IRQHandler+0x0): multiple definition of `RTC_Alarm_IRQHandler'; 
..\..\..\.\libraries\STM32LoRaWAN-main\BSP\rtc.c.o:rtc.c:(.text.RTC_Alarm_IRQHandler+0x0): first defined here
collect2.exe: error: ld returned 1 exit status

Is crashing with another library that has the low power that is "STM32RTC.h" it is because they have the same functions.
How can I fix this crash?

RAK3172 "WLE5CCU6"

Hi,
I managed to run your library with rak3172
For this I modified these parts:

In STM32LoRaWAN-main\src\BSP\radio_board_if.c

// Is a TCXO present on the board?
#if !defined(LORAWAN_BOARD_HAS_TCXO)
  #define LORAWAN_BOARD_HAS_TCXO 0U
#endif

  #if !defined(LORAWAN_RFSWITCH_PINS)
  #define LORAWAN_RFSWITCH_PINS PB8,PC13
  #define LORAWAN_RFSWITCH_PIN_COUNT 2
  #define LORAWAN_RFSWITCH_OFF_VALUES LOW,LOW
  #define LORAWAN_RFSWITCH_RX_VALUES HIGH,LOW
  #define LORAWAN_RFSWITCH_RFO_LP_VALUES LOW,HIGH
  #define LORAWAN_RFSWITCH_RFO_HP_VALUES LOW,HIGH

In STM32LoRaWAN-main\src\BSP\rtc.c

 hrtc.Instance = RTC;
  hrtc.Init.AsynchPrediv = 127;
  hrtc.Init.SynchPrediv = 255;
  hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
  hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE;
  hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
  hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
  hrtc.Init.OutPutPullUp = RTC_OUTPUT_PULLUP_NONE;
  hrtc.Init.BinMode = RTC_BINARY_ONLY;

How could I add this to your library without having to modify it, which is what I had to do?

Also I tested your library as you had it in the beginning for the NUCLEO-WLE55JC1 board and everything worked correctly, I also tested it with the US915 and it still worked fine.

stm32cubewl\utilities\timer\stm32_timer.h:60:10: fatal error: rtc.h: No such file or directory 60 | #include "rtc.h" | ^~~~~~~ compilation terminated. exit status 1 Compilation error: exit status 1

code

/**
 * This is a more complex asynchronous sketch that shows how the
 * asynchronous code could be used in a sketch that uses a scheduler of
 * some sort to decide what code to run when.
 *
 * This sketch defines its own very, very simple scheduler that is not
 * suggested to be used directly, but just serves to show how a sketch
 * that uses some scheduling mechanism can be used with the
 * asynchronous STM32LoRaWAN API and the MaintainNeeded callback.
 *
 * The behavior of the sketch is simple, it just blinks a LED
 * (asynchronously) and at the same time joins the network and transmit
 * a packet periodically.
 *
 * Revised BSD License - https://spdx.org/licenses/BSD-3-Clause.html
 */
#include <STM32LoRaWAN.h>

STM32LoRaWAN modem;

/*********************************************************************
 * This part of the sketch defines a very simple scheduler and defines
 * two tasks that handle the actual work.
 *********************************************************************/
struct Task {
  unsigned long time; /* When to run, 0 == never */
  void (*callback)();
};

enum Tasks {
  BLINK_TASK,
  LORA_WORK_TASK,
  LORA_MAINTAIN_TASK,
  NUM_TASKS,
};

void do_blink();
void do_lora_maintain();
void do_lora_work();
void maintain_needed_callback();

Task tasks[NUM_TASKS] = {
  [BLINK_TASK] = {0, do_blink},
  [LORA_WORK_TASK] = {0, do_lora_work},
  [LORA_MAINTAIN_TASK] = {0, do_lora_maintain},
};


void run_scheduler()
{
  // Super-simple scheduler that just checks all tasks and runs
  // any that are due.
  for (size_t i = 0; i < NUM_TASKS; ++i) {
    if (tasks[i].time != 0 && (int)(millis() - tasks[i].time) >= 0) {
      tasks[i].time = 0;
      tasks[i].callback();
    }
  }
}

/*********************************************************************
 * This part of the sketch defines the blink task, which just toggles
 * a LED whenever it is called.
 * And this is the entry points of the sketch.
 *********************************************************************/
static const unsigned long BLINK_TASK_TIME = 1000; /* ms */

void do_blink()
{
  digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
  tasks[BLINK_TASK].time = millis() + BLINK_TASK_TIME;
}

/*********************************************************************
 * This part of the sketch defines the lora work task, which initiates
 * new work and the lora_done() function that processes the results.
 *********************************************************************/

static const unsigned long TX_INTERVAL = 60000; /* ms */
static const unsigned long RETRY_JOIN_INTERVAL = 5000; /* ms */

enum LoraState {
  IDLE,
  JOINING,
  TRANSMITTING,
};
LoraState lora_state;

void start_join()
{
  // Configure join method by (un)commenting the right method
  // call, and fill in credentials in that method call.
  modem.setAppEui("0000000000000000");
  modem.setAppKey("00000000000000000000000000000000");
  modem.setDevEui("0000000000000000");
  modem.joinOTAAAsync();
  //modem.setDevAddr("00000000");
  //modem.setNwkSKey("00000000000000000000000000000000");
  //modem.setAppSKey("00000000000000000000000000000000");
  //modem.joinABP();

  lora_state = JOINING;
}

void send_packet()
{
  uint8_t payload[] = {0xde, 0xad, 0xbe, 0xef};
  modem.setPort(10);
  modem.beginPacket();
  modem.write(payload, sizeof(payload));
  if (modem.endPacketAsync() == sizeof(payload)) {
    Serial.println("Queued packet");
  } else {
    Serial.println("Failed to queue packet");
  }
  lora_state = TRANSMITTING;
}

void process_rx()
{
  if (modem.available()) {
    Serial.print("Received packet on port ");
    Serial.print(modem.getDownlinkPort());
    Serial.print(":");
    while (modem.available()) {
      uint8_t b = modem.read();
      Serial.print(" ");
      Serial.print(b >> 4, HEX);
      Serial.print(b & 0xF, HEX);
    }
    Serial.println();
  }
}

void do_lora_work()
{
  // Time to start new work
  if (!modem.connected()) {
    start_join();
  } else {
    send_packet();
  }
}

void lora_done()
{
  // If, after calling maintain() the library is no longer
  // busy, then the asynchronous operation has completed,
  // so check its results.
  if (lora_state == TRANSMITTING) {
    Serial.println("Sent packet");
    // Done transmitting
    process_rx();
    lora_state = IDLE;
    // Schedule transmission of next packet
    tasks[LORA_WORK_TASK].time = millis() + TX_INTERVAL;
  } else if (lora_state == JOINING) {
    if (modem.connected()) {
      Serial.println("Joined");
      send_packet();
    } else {
      Serial.println("Join failed");
      lora_state = IDLE;
      tasks[LORA_WORK_TASK].time = millis() + RETRY_JOIN_INTERVAL;
    }
  }
}

/*********************************************************************
 * This part of the sketch defines the lora maintain task, which calls
 * maintain() to let the lora library do any background work that it
 * needs to do. It is called whenever request by the callback.
 *********************************************************************/

void do_lora_maintain()
{
  modem.maintain();

  // If, after calling maintain() the library is no longer
  // busy, then the asynchronous operation has completed,
  // so check its results.
  if (!modem.busy()) {
    lora_done();
  }
}

void maintain_needed_callback()
{
  // This is called from interrupt context, so this must *not*
  // call maintain() directly and return as fast as possible.
  // So just schedule the maintain task to run ASAP.
  tasks[LORA_MAINTAIN_TASK].time = millis();
}

/*********************************************************************
 * And this is the entry points of the sketch.
 *********************************************************************/

void setup()
{
  Serial.begin(115200);
  Serial.println("Start");
  modem.begin(EU868);
  modem.setMaintainNeededCallback(maintain_needed_callback);

  pinMode(LED_BUILTIN, OUTPUT);

  do_blink();
  do_lora_work();
}

void loop()
{
  run_scheduler();

}

⚠ When reporting any issue, please try to provide all relevant information to help on its resolution.

Describe the bug
stm32cubewl\utilities\timer\stm32_timer.h:60:10: fatal error: rtc.h: No such file or directory
60 | #include "rtc.h"
| ^~~~~~~
compilation terminated.

exit status 1

Compilation error: exit status 1

To Reproduce
Arduino IDE 2.2.1

Hardware ():

  • Board Name: [e.g. Wio E5 mini (LoRa e5 mini)]
  • Hardware Revision: [e.g. Rev Y]

LoRaWAN Issue on RAK3172

Trying to run the LoRaWAN Basic example on my RAK3172 with STM32LoRaWAN library v0.1.1. Similar to #24 I get the Message:

Start
Error\Arduino\libraries\STM32LoRaWAN\src\BSP\rtc.c (56)

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.