A Go application that provides an NTP (Network Time Protocol) server synchronized to GPS time from NMEA messages received via a TCP network socket.
This application is not intended to provide highly accurate time, instead it is intended to provide a rough time source for isolated or embedded environments.
- NTP server implementation (emulates Stratum 1 when GPS synchronized)
- Connects to GPS source via TCP network socket
- Parses NMEA sentences (GPRMC/GNRMC for time, GPGGA for position, GPGSV for satellites, GPGSA for fix data)
- Automatic reconnection on connection loss
- HTTP REST API with status dashboard and JSON endpoints
The application is configured using environment variables:
GPS_HOST: The hostname or IP address of the GPS TCP source (default:localhost)GPS_PORT: The TCP port of the GPS source (default:2947)HTTP_PORT: The HTTP server port (default:80)
go build -o gps-ntp-serversudo ./gps-ntp-serverNote: Requires root/sudo to bind to NTP port 123.
sudo GPS_HOST=192.168.1.100 GPS_PORT=10110 ./gps-ntp-serversudo HTTP_PORT=8080 ./gps-ntp-serverNote: Port 80 requires root privileges. Use a higher port (e.g., 8080) to run without sudo.
The GPS source must provide NMEA sentences over TCP. The server processes:
$GPRMC/$GNRMC- GPS/GNSS Recommended Minimum sentence (time, date, position, speed, course)$GPGGA/$GNGGA- GPS/GNSS Fix Data (position, fix quality, satellites, altitude)$GPGSV/$GNGSV- GPS/GNSS Satellites in View (satellite details: PRN, elevation, azimuth, SNR)$GPGSA/$GNGSA- GPS/GNSS DOP and Active Satellites (which satellites are used in solution)
These sentences provide comprehensive GPS information including time, position, and detailed satellite tracking.
- Stratum 1: GPS is synchronized and providing valid time
- Stratum 16: GPS is not synchronized or no recent updates (unsynchronized)