Skip to content

Instantly share code, notes, and snippets.

@taiko19xx
Created June 8, 2017 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taiko19xx/fbdd4cb854ebad0ed9d7df3274cf1cd7 to your computer and use it in GitHub Desktop.
Save taiko19xx/fbdd4cb854ebad0ed9d7df3274cf1cd7 to your computer and use it in GitHub Desktop.
#!/bin/bash
WAIT=10
NEXT=0
SESSION=`curl -s https://~/start | jq -r .session_id`
LAST=0
gpspipe -w | jq --unbuffered -c '. | if .class == "TPV" then {lat,lon,time} else empty end' | while read -r f; do
CURRENT=`date +%s`
TARGET=$(( LAST + WAIT ))
if [ $CURRENT -ge $TARGET ]; then
JSON=`echo $f | jq --arg SESSION $SESSION '.+{"session_id": $SESSION}'`
curl -s "Accept: application/json" -H "Content-type: application/json" -X POST -d "$JSON" https://~/post
LAST="$CURRENT"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment