arha / flipper-dcf77

DCF77 emulator off the 125khz LFRFID antenna on Flipper Zero
GNU General Public License v3.0
64 stars 5 forks source link

Add NTP source for broadcast signal #1

Closed MCM-Mike closed 1 year ago

MCM-Mike commented 1 year ago

It would be beneficial to add a NTP Server [1] from where the time is sourced before sending it. This ensures an accurate clock for clocks which have no signal or bad signals.

[1] https://gist.github.com/mutin-sa/eea1c396b1e610a2da1e5550d94b0453

arha commented 1 year ago

I'm not really sure how much this is worth the effort since you can sync flipper to your NTP synced clock simply by plugging it in qflipper.

I don't want to disprove you or dismiss your idea, by which I mean a pull request is always welcome :)

But... my philosophy with FZ dev centers around abusing the internal hardware in lieu of external one. If I were to use an ESP32 for flipper-dcf77, my incentive for using flipper when I need a DCF77 signal drops down to zero: I can recreate the timeclock signal in ESP32 and have a(nother) dedicated tool for DCF77 - and not need flipper at all. But even better -I will also not need to fumble around looking for that one flipper board that has that one specific firmware flashed that can talk to this specific version of the app to give it NTP time - every time I need the DCF signal (which is not often).

Furthermore, NTP servers go down all the time - hardware manufacturers hardcode their devices to run a NTP sync at a fixed time on a fixed server - say 06:00 - and, ironically, the better the accuracy, the bigger the wave of requests the server experiences. The usual approach thus far has been to kill NTP DNS entries completely, since the manufacturers don't care. I feel like hardcoding NTP servers which eventually won't work is a bad idea - so now there's the problem of updating the list of NTP servers on flipper itself.

For me, running NTP sync on my machine and plugging FZ in qflipper before sending a DCF signal simply can't beat the whole trouble with an external board. I also play a bit with my boards, and they rarely have the same firmware. Of course, I can dedicate a board just for flipper-dcf77 + NTP, but then, we're back to square one... I can just generate DCF77 on the board itself, no flipper needed.

However... what is absolutely doable and is probably more beneficial to the whole flipper apps ecosystem is to pull a NTP sync whenever FZ is connected to a wifi board and has internet access. Or - since NTP already exists and syncs the board's RTC on esp8266 and esp32 firmwares (like tasmota, marauder or micropython variants) - simply standardizing a call between flipper and these boards to query their time and last sync.

Alas, FZ's RTC has an accuracy of about 15s/30days IIRC, which is also what an cheapo brand-name DCF watch, beyond their marketing nonsense is rated for (1s/a is with radioclock sync)