RAK11300 Save values to EEPROM

The first code you showed is taken from the WisBlock-API, which right now works on RAK4631 and RAK11300 is still under testing.
The timer part of WisBlock API is not yet adapted for RAK11300.

I do not have an example to change the send frequency over downlink commands. But it is quite simple to implement it in the RX callback function. You just have to parse the downlink payload, read the new timer value and apply it.

For saving the timer interval, I hoped the example code I pointed you to would help.
Basically, it uses the last sector of the RAk11300 flash to store parameters.
The code I mean can be found here RAK11300-AT-Command-Firmware/flash.cpp at main · RAKWireless/RAK11300-AT-Command-Firmware · GitHub

and one more question
what max value for LORAWAN_APP_INTERVAL?
we want to set the interval to 2 hours or more,
but when we set 7 200 000 - there are no packets after 2 hours(

I have to run a test for that. Didn’t try 2 hours between two packets yet.

ok, thank you
wait for result

:face_vomiting:

MBed timer seems to be messed up.
Setting the timer to two hours, I get nothing as well.

That is a problem somewhere in the RP2040 BSP (we just use that, we do not maintain it) and it is not the first time I have problems with it.

That needs some more digging and investigating.

1 Like

60 minutes works :thinking:
image

yes, yes, 1 hour - works ok
Perhaps the reason is in the type of the variable (long, int, long int…)?

The time is defined as an uint32_t
That means
4294967295 milliseconds
4294967 seconds
7157 minutes
119 hours

I think there is a bug in the MBed timers that cause an overflow.
Problem is that I cannot debug the BSP, we just take the Arduino-MBed for RP2040 and put our device in it. We don’t maintain the BSP.

there is error:

4294967 seconds = 71582 minutes = 1193hours

and what about this? here are microseconds
that mean max 4294967295 microseconds~ 71.58 min,

I will try to set 70min and then 72 min to check

yes, the reason in timer var size
so, 71 min - all ok

when I set LORAWAN_APP_INTERVAL to 72 min - packets start to be sent every 25 seconds:
4 294,967 seconds - 72 * 60 = - 25.033 seconds

and when I set the LORAWAN_APP_INTERVAL to 73 minutes - the packets are sent after every 1min 25 seconds:
4 294,967 seconds - 72 * 60 = - 85.033 seconds

so timer max is uint32_t 4294967295 microseconds

Looks like I need a new calculator, but you are right.

The attach function is defined as void attach(Callback<void()> func, std::chrono::microseconds t);

But in mbed_chrono.h I found

 * Standard std::chrono::microseconds is signed 64-bit. For some purposes

so it is limited actually to 32bit (negative times make not really sense).
And the whole mbed stuff is pre-compiled, so no option to fix it.

so it can’t be fixed?
and the maximum sending frequency can be only 71 minutes for PAK11300?
is it through the BSP for RP2040?

does other WisBlock Cores have the same issue?

I cannot fix it, the guys who maintain the Arduino-MBed BSP should be able to fix it.

Every WisBlock Core has different MCU, which means different BSP.
I didn’t test on the RAK11200 (ESP32 BSP), But I had the RAK4631 set to 6 hours (soil moisture sensor) and it worked.

It is bad news :frowning_face:
is it possible to create a ticket on Arduino-MBed BSP team?

Hi, @beegee

We have a need to save the new setting after a reboot.

Here, we add it, let’s say here.

But how (what method) to use it in my program to save (update) this value in FLASH?

Welcome back @mykhalych90

Depends on the code that you used as a base, but usually I have a function called save_settings() that writes this structure into the flash.

Yes, but how to how to pass my variable value to g_lorawan_settings?

For example, I have var relay_1 (it will it will change by downling command), and I need firstly add it to the g_lorawan_settings struct? and then apply by save_settings()? right? or I’m wrong?))

you can use

// Set the value
g_lorawan_settings.relay_1 = 0;
save_settings();

// Read the value
if (g_lorawan_settings.relay_1 == 1)
{
   // Do something
}

to set the value and then save it to the flash or the read the value.

Hello beegee, I am using rak4631 to send data to the gateway through lora. I have a little doubt about Lora transmission interval. The default is #define LORAWAN_APP_INTERVAL 20000. But I want to know what is the minimum value that can be set?

Please don’t hijack existing threads. This is a new question and should be in a new thread.