#!/bin/bash
# time stamp this shit yo
nowdate=$(date "+%d-%m-%y")
nowtime=$(date "+%H:%M:%S")
# stole this idea of using gpspipe, grep and awk from here: http://thomasloughlin.com/gpspipe-gps-client/
gpsdata=$(gpspipe -w -n 10 | grep -m 1 lon)
lat=$(echo "$gpsdata" | jsawk ‘return this.lat’)
lon=$(echo "$gpsdata" | jsawk ‘return this.lon’)
gpsspeed=$(echo "$gpsdata" | jsawk ‘return this.speed’)
# runs my modified the speedtest-cli python script and uses tr instead of grep to remove some line feeds and change it to a comma to suit the csv
speed=$(python /home/pi/speed.py –simple –server 3252 | tr ‘n’ ‘,’)
# writes the values to a csv file – the $speed value returns like 5.01,0.03, (note the trailing comma) which is why there’s no comma between $speed and $lat
echo "$nowdate,$nowtime,$speed$lat,$lon,$gpsspeed" >> /home/pi/vha_speedlog.csv
# sends info to the Pushover service, which then sends a push notification to my iPad with the results of the speedtest
curl -s
-F "token=sekrit"
-F "user=sekrit"
-F "message=down,up speedtest result : $speed"
https://api.pushover.net/1/messages.json
exit 0