A way for better timestamps without RTC

the “net-pos” plugin saves no timestamps atm. (better no timestamp than a wrong one)

example: {"location": {"lat": 51.36755, "lng": 11.9571}, "accuracy": 207.5067112}

i work on a map plugin and want to show handshakes on map in a defined period of time.
for this i need good timestamps of the handshakes.

problem:

  • raspi has no battery buffered clock. on boot its set time to last-file-change of “/var/lib/systemd/timesync/clock”
  • the cron makes every minute a “touch /var/lib/systemd/timesync/clock”
    • so: raspi always starts with time from last shutdown and syncs time, if internet is available (or gps/* time sync)

a solution

works only if time is synced later on a boot (without reboot!)

  • we store on every boot the timestamp+uptime. if timestamp/uptime is different over 60s from saved boot values, we know: time was synced
  • now we can fix times from before sync time by calculating an offset
  • store (on saved handshakes for example) timestamp if synced or if not synced: {“ts”: 1571775435, “boot_uuid”: “a1f0…e3d”, “uptime”: 1234}
  • sync time from other already synced pwnagotchi

how it works:

  • on-boot.sh needs to be called in /etc/rc.local
  • you get a timestamp or dict for usage with:
    raspi_synced_time = RaspiSyncedTime()
    timestamp = raspi_synced_time.getTime()
  • you can calculate time from a dict, if possible
    raspi_synced_time.getTime(old_time)

the repo: https://github.com/xenDE/pwnagotchi-plugin-timesync

i’m not sure, if this is a good/best way for this and if this is still needed.

it helps, if you need to boot your Pwnagotchi on the way an can bring it online later, without reboot.

for bring good time after boot, we have already 2 solutions, so problem is no longer priority for me:

  • install a RTC
  • go online with pwnagotchi with bt-tether

what do you think? needs this problem a solution?

mmm about this: if this is a requirement, isn’t it the same of connecting it to internet once just to have it synced and then keeping it on without internet?

no. my class can correct times from before internet-sync.
thats it for (only for that is the class)