Change the fcnt in my device

My device shutdowns every time it sends a message and thus the frame counters are not the same in ttn and device (I have unchecked the frame counters count in ttn but sometimes it does the check anyway…), could I possibly change the fcnt from the device to a different number?
I am using an stm32l0xx series chip.

No/yes/depends…

It depends on the software stack you use. However the controller can very energy efficient (if programmed the right way) so why do you shut it down?

In that case you have the RTC backup registers, that you could use for something like the frame count (and as a validity check its complement), and also the EEPROM that you could use for less frequently changed things like OTAA sessions and their join nonces. Remember that OTAA isn’t a license to forget either, as a re-used join nonce is silently ignored. And an OTAA join is far too costly an operation to re-do for every transmission.

I am using this https://os.mbed.com/docs/mbed-os/v5.15/apis/lorawan.html

I don’t really shut it down it goes to standby for long periods of time and thus is more efficient.

I am using ABP to avoid the re-join process…

If it goes to standby you should not need to rejoin and set counters. However in your first message you say you shutdown the device…

Back to the original question: have you check the API documentation to see if there is a way to set the counters?

1 Like

Given that rejoining for every transmission is all of absurd, unsustainable, and unacceptable, that’s a sound choice.

But it still doesn’t let you escape the fact that LoRaWAN does not support nodes which lack persistent state

If you choose the ABP route, you must preserve the frame counter in both uplink and downlink directions, and realistically speaking generally preserve the ADR state (ie, spreading factor and trends of failure pointing towards increasing it), also you need to preserve enough frequency information to keep your selections reasonably distributed.

I couldn’t find anything in the API documentation to change the fcnt, the counter is always zero image

thus i have unchecked the frame counters checks in the ttn which is not recommendedimage

This is why you should suspend the processor and not shut it down.

Or if you must lose RAM contents, dig into the source code and add hooks to restore state. But not just the uplink frame count - you need the downlink frame count and ADR state, too.

2 Likes

Then you have answered your own question. The library currently does not provide a way to set it. If you want to set it you will need to add the functionality yourself. Keep in mind you need to safe multiple values as @cslorabox mentioned.
Better solution is to use a low power standby mode of the controller.

1 Like