Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPS NTP Server

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.

Features

  • 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

Configuration

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)

Building

go build -o gps-ntp-server

Running

With default settings (localhost:2947)

sudo ./gps-ntp-server

Note: Requires root/sudo to bind to NTP port 123.

With custom GPS source

sudo GPS_HOST=192.168.1.100 GPS_PORT=10110 ./gps-ntp-server

With custom HTTP port

sudo HTTP_PORT=8080 ./gps-ntp-server

Note: Port 80 requires root privileges. Use a higher port (e.g., 8080) to run without sudo.

NMEA Requirements

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.

NTP Stratum Levels

  • Stratum 1: GPS is synchronized and providing valid time
  • Stratum 16: GPS is not synchronized or no recent updates (unsynchronized)

About

Go application that emulates a NTP server sourced from GPS

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages