STMicroelectronics/STM32CubeWL

Device is not setting the user data rate and tx power, on reset.

Opened this issue · 3 comments

Describe the set-up

The board is NUCLEO-WL55JC1
STM32 CubeIDE v1.15.1
STM32 CubeMx v6.10

Describe the bug (skip if none)

I setted the default data rate (say DR4)and Tx power using he cubeMx in LoraWan_end_node example(although its occuring even in the other LoRaWan examples). On device reboot, on first attempt, device tries to connect with the default data rate DR4. On second attempt it switch to DR0, since its in the join parameters. But, even after the device has been joined, its not using the user setted data rate ie DR4, it continues in the DR0.

How to reproduce the bug (skip if none)

  1. Open the LoRaWan_End_Node_Example.
  2. configure data rate except DR0.
    image
  3. Configure tx power except TX_POWER_0.
  4. Generate the code and see the effects.

Additional context.

In the generated code, the user parameters has been setted in the file lora_app, using the variable LmHandlerParams.
image

When the device do not receive the answer from the gateway, the MLME_JOIN event occurs, in the file LmHandler.c,
image

There are 2 functions called , LmHandlerGetTxDatarate and LmHandlerGetTxPower has been called, to set the data rate and the Tx power for the join parameters.
In the function LmHandlerGetTxDatarate, at line 1000, we are setting the data rate to variable name LmHandlerParams.
LmHandlerParams is copied from the user device LmHandler values, which has to be used.
image.
This alter the user defined values, causing the issue. On commenting the line 1000, resolves the issue.

Is there is any specific reason, that we are setting the LmHandlerParams, over riding the user values? As these function are not in the original LoRaMac Node repo.

This might be the case for the Tx Power also, although I did not tested it.

Hello @ankit-bansal-oxit,

First, thank you for your contribution. Is your problem with the code generation using STM32Cube MX or with our firmware? Because I can't find the function LmHandlerGetTxDatarate. Where did you encounter your issue? Could you please specify your problem? In which files does this function appear, and is it a problem with the generation using MX?

Thanks,

@RJMSTM Thanks for the reply!

My problem is from the firmware side.

The function present in the file LmHandler.c at line 985. Here it isfor the reference
https://github.com/STMicroelectronics/STM32CubeWL/blob/99e6b06c87338a6d78a7454e8b455b119cc29ac8/Middlewares/Third_Party/LoRaWAN/LmHandler/LmHandler.c#L985C24-L985C46

https://github.com/STMicroelectronics/STM32CubeWL/blob/main/Middlewares/Third_Party/LoRaWAN/LmHandler/LmHandler.c

When you compare the MLME_JOIN, event, from the ST proviced LmHandler.c and LmHandler.c from loramac node, this funciton LmHandlerGetTxDatarate is absent in the original stack.

LmHandlerGetTxDatarate( &JoinParams.Datarate );

https://github.com/Lora-net/LoRaMac-node/blob/dcbcfb329b4a343ab007bc19ac43a8dc952b3354/src/apps/LoRaMac/common/LmHandler/LmHandler.c#L828

ST Internal Reference: 193444