You are here

Setting location from gpsd workaround

1 post / 0 new
kf6iiu
Setting location from gpsd workaround
Since the ""Use local or network GPS to set location" setting" and gpsd don't seem to be working, at least if the gpsd in on another host and not a locally attached GPS, you can still easily set your lat/long using this script. The gpsd has to be running on a host (laptop, pi, etc) on an IP address accessible to the AREDN node (most likely on the WAN). You don't need gpsd installed on the AREDN node. You only need to rerun it when your location changes.

And to think, I gavw away my 1990's vintage "Awk In A Nutshell" book a few months ago thinking I'd never need it again!

Chmod the script to 755, it echoes the uci commands you need to set the lat and long on the AREDN node. This script has only been tested on a TPLink CPE550. The command line argument is the IP address of the host where gpsd is running:
HOST=$1
TMPFILE=/tmp/latlon.$$
nc $HOST 2947 << EOFFF > $TMPFILE
?WATCH={"enable":true,"json":false};
?POLL;
EOFFF

awk '{
    if (match($0, /"lon":([0-9.-]+)/))
        print "uci set aredn.@location[0].lon=" substr($0, RSTART+6, RLENGTH-6)
}' <$TMPFILE

awk '{
    if (match($0, /"lat":([0-9.-]+)/))
        print "uci set aredn.@location[0].lat=" substr($0, RSTART+6, RLENGTH-6)
}' <$TMPFILE

echo uci commit

rm -f $TMPFILE

Usage (copypasta these commands into the shell):

# ./latlong 10.21.75.107
uci set aredn.@location[0].lon=-122.094271667
uci set aredn.@location[0].lat=37.911353333
uci commit





 

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer