#!/bin/bash
# console-config/src/lib-scripts/timing-gps.sh
#
#  Copyright: ©2013–2014, Güralp Systems Ltd.
#  Author: Laurence Withers <lwithers@guralp.com>
#  License: GPLv3
#
# NTP synchronised to GPS. This requires one input NMEA port and does not
# support output NMEA ports.
#



direct_gps_setup() {
    serial_select_input
    if [ $? -ne 0 ]
    then
        echo "Configuration not changed."
        exit 1
    fi

    (
        write_ntp_preamble
        cat <<EOF
# SHM managed by gpsd
server 127.127.28.1 minpoll 4 maxpoll 4
fudge 127.127.28.1 refid GPS
EOF
    ) | write_config_file "${NTP_CONFIG}"

    write_timing_config "direct_gps" "true" "false" "true"

    svc timing restart

    serial_clear_xlate
    serial_clear_output

    echo "Configuration updated."
    exit 0
}



# vim: ts=4:sw=4:expandtab:syntax=sh
