-
Notifications
You must be signed in to change notification settings - Fork 90
Add manual and automatic NTP time sync options in Clock menu #519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Refactor RTC menu option in settings and UI pages. - Update NTP client implementation for improved synchronization. - Modify related files: settings.c, settings.h, page_clock.c, page_wifi.c, ntp_client.c, ntp_client.h.
|
This is looking pretty good. NTP will be a nice feature :-) Regardless of the servers we pre-fill the user may need to provide specific NTP servers... hdzero-goggle/src/util/ntp_client.c Line 64 in a3fba72
hdzero-goggle/src/util/ntp_client.c Line 74 in a3fba72
Can you remove these two hard coded NTP server lists and replace it with a single user editable NTP server string of comma separated URL/IP and pre-fill the default NTP server string with URLs that remain more neutral. ? |
|
I agree that one ntp server is typically fine but think two should be pre-filled so a user can see how to add alternates when needed. I also recognize a lot of work went into this. However, the more I think about it I realize this should be simplified into just a user interface for ntpd, date and TZ that are already included with the OS. |
|
Some notes about existing time tools in goggle OS: root@tina:~# echo $TZ root@tina:~# find /usr/share/zoneinfo/ # TZ Note: a current zone list contains 522 zones totaling ~2.1M of space. root@tina:~# ntpd --help Usage: ntpd [-dnqNwl -I IFACE] [-S PROG] [-p PEER]... NTP client/server root@tina:~# ntpd -d -w -p 192.168.2.217 # ntpd note: my tests environment does not have an ntp server. ntpd -w will just query and not set time. I figure the app could manually trigger ntpd but it would be more stable if the app configured ntpd to run at the OS level and make the app UI read the current server list & time zones, only pre-polulating values when the user enables ntp and ntpd was not previously configured. root@tina:~# date --help Usage: date [OPTIONS] [+FMT] [TIME] Display time (using +FMT), or set time Recognized TIME formats: root@tina:~# date root@tina:~# date +"%Y-%m-%d %H:%M:%S" # date Note: The best readily available way to get, set, convert, and find a difference in date-time values. |
|
I have had to manipulate / justify time in many ways over the years. The more I did so the more problems I saw even within popular tools and widely accepted practice. In the end the two most reliable and flexible tool sets to manage time ended up being databases and basic linux tools. I have even utilized linux tools for windows many, many times. Sorry, This is just a hobby product, but wanted to share pain from the past to prevent other pain in the future. |
|
@mauriciobridge I really like the GUI and thoughtfulness of this PR integrating ntp into the app/WiFi state. If you have interest in collaborating please reach out via #open-source or DM on discord. Below are my current notes for allowing app to manage ntp and timezones on the OS. primary app gui function: app time service management: OS support: potential OS level changes: |
|
Hi @pitts-mo ! Thanks for the detailed feedback, I really appreciate it! I really like your suggestion of using the existing system methods (/etc/ntp.conf, /etc/TZ, ntpd). That would definitely be more robust and follow proper Linux conventions. I also agree users should be able to edit their preferred NTP servers. That said, I was initially thinking that since HDZero Goggles are a specialized FPV device, maybe a simpler plug-and-play approach would be more appropriate for typical users. But you've got me thinking... there's probably a good middle ground here that leverages the system tools without overcomplicating things. |


This update adds new options in the Clock menu to set the time from the Internet using NTP servers.
✅ New features:
Sync from Internet: A new button in the Clock menu that lets you update the date and time using an NTP server.
Time Zone: You can now choose your UTC offset (from UTC−12:00 to UTC+14:00).
Auto Sync: If enabled, the goggles will sync the time automatically when connected to Wi-Fi in client mode.
Settings are saved: The time zone and auto sync settings are saved and loaded correctly.
💻 UI changes:
Added dropdown to select UTC time zone.
New buttons: “Sync from Internet” and “Auto Sync”.
Shows messages when sync is successful or failed.
“Sync from Internet” button is disabled if Wi-Fi is not connected.
⚙️ Technical changes:
Added new file: ntp_client.c to handle NTP sync.
Added file: wifi_status.c to check if Wi-Fi is connected.
Modified page_clock.c, settings.c, page_wifi.c, and others.
🔍 Notes:
If sync fails, the user will see a red message.
If sync works, the clock is updated and saved.
Works only when Wi-Fi is in client mode and connected.
Let me know if something needs to be changed.
Thanks for reviewing!