Making changes to sleep_time and saving to memory

Hi everyone, I have a sketch for a pressure transducer (4-20ma), which is working fine. I’m trying to modify two things.

  1. I would like to have the first x number of tx_intervals to be at a certain period, and then when a counter reaches a number, it swaps to what I would usually have it set to. This is to allow say the first 10 uplinks to be at 5 minute intervals for diagnostics, calibration etc…rather than getting one every 2 hours or similar. I have this successfully working for a weather station, but I assume because the PT goes to sleep, I can’t get it to work…
  2. I would like this tx_interval to be saved to memory, so that when I make a change (say by downlink), it keeps the setting when power cycled.

Here are a couple of screenshots, happy to provide the entire sketch if required. Thanks in advance.
image


Hi Andy,

(1)
You could start with a shorter frequency and when your counter reaches the end do

	TimerStop(&g_appTimer);
	TimerSetValue(&g_appTimer, your_new_time);
	TimerStart(&g_appTimer);

(2)
You might have a look here how to read and save values from/to the flash memory.
flash-nrf52.cpp

(3) You could have a look into the WisBlock-API
It has an AT command interface to change settings and save them into flash.
It has a command AT+SENDFREQ= to change the send frequency manually and reuse the changed value in the future.
It should be possible as well to change the send frequency on runtime with it’s API calls
Basically, after debug phase is finished the commands would be

api_timer_restart(new_time);
g_lorawan_settings.send_repeat_time = new_time;
api_set_credentials();

Thanks @beegee, getting “g_appTimer’ was not declared in this scope”, any ideas?
Currently have it in the sendLoRaFrame(void)…is that the correct position?

Ah, sorry, that was from different example.

Looking on your code it should be

taskWakeupTimer.stop();
taskWakeupTimer.setPeriod(new_time);
taskWakeupTimer.start();