gfroerli / firmware

Firmware for the water temperature sensor project
GNU General Public License v3.0
6 stars 1 forks source link

Rejoin logic / upctr handling #16

Closed dbrgn closed 2 years ago

dbrgn commented 6 years ago
rnestler commented 6 years ago

When waking up from deep sleep, do mac join abp to join without the OTAA process

Do we currently do that?

dbrgn commented 6 years ago

I think we don't actually need to do that, since the power is never cut. So when we wake up in the main loop, the RN2483 still remembers its credentials.

Should we close this?

dbrgn commented 3 years ago

We're switching to ABP.

TODO: Find out how we can persist the counter value! Probably mac save.

dbrgn commented 3 years ago

We can persist the data with mac save. This saves both the ABP keys as well as the counters to EEPROM.

Because the setting of the keys also takes a while, we can employ the following logic:

  1. Read the configured device address (mac get devaddr). By default, this will be 0000000.
  2. Compare the device address to the one from the sensor configuration. a. If they do not match, carry on with 3 b. If they match, jump to 4
  3. Set up keys with mac set devaddr <x>, mac set appskey <x>, mac set nwkskey <x> and mac set upctr 0
  4. Join with mac join abp
  5. Send data
  6. Before going to sleep, send mac save to persist all data
dbrgn commented 2 years ago

Before we close #16, the restoring of the counter values should be verified. But for that, we first need to implement standby.

dbrgn commented 2 years ago

It seems to work nicely! See commit https://github.com/gfroerli/firmware/pull/111/commits/481b84f7b88b3d81a52a10b2e730f1ea9f04a84b.