#!/bin/false
# For GW6 and GWM devices

initGPSVar() {
    GPSENABLED=no
    PORT=CNone
    . '/etc/telem-gps.conf'
}

isGPSttyEnabled() {
    if [ -f '/etc/telem-gps.conf' ]; then
        (
            initGPSVar
            # test
            [ "${GPSENABLED}" = "yes" ] && [ "${PORT}" = "C1" ]
        )
        return
    fi
    false
}

getPPSdev() {
    # Usually pps0 is pps, but imx6dl has ptp0 as pps0
    # so we need to use ppsfind
    local PPS_NAME="$(ppsfind pps | cut -d: -f1)"
    echo "/dev/${PPS_NAME:-pps0}"
}

getGPStty() {
    # GW6 and GWM have only C1 for GPS (excluding legacy)
    local HW_XML='/usr/local/etc/telem/hw-run.xml'
    ls $(grep index=\"1\" "${HW_XML}" | sed 's/^.*name=\"\([^ ]*\)\".*/\1/') | grep tty
}
