DevNonce has already been used

Happy New Year All!

I swapped a battery out on one of my TTGO LORA boards today and now I get the message in the subject line.

I don’t seem to be able to clear it.

This is turning into a real problem as the unit is in a remote location and not easy to reach.

Does anyone know what this message means and how to clear it?

Thanks in advance.

TTN console → The Application for the TTGO → Select the TTGO end device → General Settings → Network Layer-> Reset session and MAC State.

Try that

Hello John,

Thanks for the help but it has not cleared the error.

Have you had success with this solution previously?

Yes once or twice, failing that cold restart the node.

Dev nonce re-use is technically illegal. You’re as responsible for storing that, as you are for storing the frame count in an ABP session - OTA doesn’t erase the problem of needing to store stuff, it just moves it.

Illicitt re-use tends to happen with LoRaWAN stacks that aren’t connected to an actual random number generator and instead start at a predictable dev nonce, then count linearly forward from there.

Hopefully it will eventually hit an unused value, but the reality is that this is buggy node software that violates the LoRaWAN spec.

There is a Troubleshooting section in the documentation that may help with this.

So I had to shut down the sensor for an hour or so and then restart it. This cleared the problem but its not ideal as I do not need to be waiting around an hour every time a battery needs changing. Apart from the obvious idea of having the unit run on an alternate power source while the battery is being swapped out, does anyone have any ideas how to make this less painful?

We’d need to know what LoRaWAN library you are using - it shouldn’t occur with OTAA on MCCI LMIC 4.1 using LW v1.0.3 on the console. Or at least it doesn’t for me and my recent testing has provoked several joins without issue.

In the design of LoRaWAN, nodes are required to maintain state through that. They’re just not supposed to be cold restarted.

People think that OTAA eliminates this need, but in reality it only moves it - instead of remembering the session details, now you have to remember the used dev nonces.

As a hack on the requirement, stacks will try starting with a random dev nonce, and then counting linearly forward from there with each attempt. This classically fails if a given port to hardware doesn’t have an actual random number generator implementation, since it will always start at the same “random” number like 0 (hey, as Randal Monroe points out, a constant could have been chosen by a fair dice roll!) and then count forward - meaning each join takes at least one more attempt than the last one.

Complying with the spec is better than banging ones head against the wall until non-compliance finally reaches a working nonce…

And sleeping a TTGO ESP32 board is an art that most people end up actually effectively turning off the device as it only preserves very selected parts of RAM so you have to consciously aka explicitly save and then recall between ‘sleeps’.