You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
3.1 KiB
Bash
75 lines
3.1 KiB
Bash
3 years ago
|
#!/bin/bash
|
||
|
#pistaprs - v??
|
||
|
#Jay Moore/NQ4T - https://git.pickmy.org/dewdude/pistaprs
|
||
|
#Licensed under GPL-3.0-or-later
|
||
|
# script activation/webui control
|
||
|
[ ! -s "/tmp/aprs" ] && exit
|
||
|
|
||
|
# Script Configuration
|
||
|
|
||
|
# Make sure you're really tested the script before you activate!!!!!
|
||
|
activate=0
|
||
|
#GPS server IP/Port
|
||
|
ip=hostnameorip
|
||
|
port=port
|
||
|
# Use GPSD? (0 = No, 1 = Yes)
|
||
|
gpsd=1
|
||
|
# Android "gps tethering" app (or NMEA over IP)?
|
||
|
gpstether=0
|
||
|
# Is 'GPS Tether' UDP?
|
||
|
gpsudp=0
|
||
|
# APRS-IS user id
|
||
|
user=urcall
|
||
|
# APRS-IS passcode
|
||
|
password=urpasscode
|
||
|
# APRS Object ID/SSID
|
||
|
senduser=urcall-ssid
|
||
|
# APRS Icon Selection (refer to pdf)
|
||
|
# Standard table
|
||
|
table="/"
|
||
|
# Alternate Table - this MUST be double backslash or it won't work
|
||
|
#table="\\"
|
||
|
# Symbol - If your symbol is a backslash, you must double backslash.
|
||
|
symbol=">"
|
||
|
# What system are you running? (And if you say YSF then good luck pal.)
|
||
|
# YSF is completely untested.
|
||
|
mode=dstar
|
||
|
#mode=dmr
|
||
|
#mode=ysf
|
||
|
|
||
|
|
||
|
# Why the hell did I have to add more GPS support?
|
||
|
[ "$gpsd" = "$gpstether" ] && echo "Invalid GPS Configuration" && exit
|
||
|
[ "$gpsd" -eq 1 ] && nema=$(gpspipe -n 9 -r "$ip:$port")
|
||
|
[ "$gpstether" -eq 1 ] && [ "$gpsudp" -eq 1 ] && nema=$(timeout 3 ncat -u $ip $port)
|
||
|
[ "$gpstether" -eq 1 ] && [ "$gpsudp" -eq 0 ] && nema=$(timeout 3 ncat $ip $port)
|
||
|
# New filtering method for altitude and non-standard sentence names.
|
||
|
rmc=$(printf "$nema" | sed -n '/$G.RMC/{p;q}')
|
||
|
[ -z "$rmc" ] | echo "Better luck next time. (Or modify script for more gpspipe data.)" && exit
|
||
|
gga=$(printf "$nema" | sed -n '/$G.GGA/{p;q}')
|
||
|
# GPS Lock Check
|
||
|
gpss=$(printf "$rmc" | cut -d ',' -f3)
|
||
|
[ "$gpss" = "V" ] && exit
|
||
|
# GPS Coordinate Set
|
||
|
lat=$(printf "$rmc" | awk -F, '{printf "%07.2f%c", $4, $5;}')
|
||
|
[ -z "$lat" ] && echo "Latitude error?" && exit
|
||
|
lon=$(printf "$rmc" | awk -F, '{printf "%08.2f%c", $6, $7;}')
|
||
|
[ -z "$long" ] && echo "Longitude error?" && exit
|
||
|
# Set heading & speed
|
||
|
hsp=$(printf "$rmc" | awk -F, '{printf "%03.0f%c%03.0f", $9, "/", $8}')
|
||
|
# Altitude (aka literally the only reason we pull a $gpgga)
|
||
|
altm=$(echo "$gga" | cut -d ',' -f10)
|
||
|
ft=$(echo "/A=$(echo "$altm*3.280839895" | bc | xargs printf "%06.0f")")
|
||
|
# DMR - Scrape for TGs and set comment.
|
||
|
[ "$mode" = "dmr" ] && tg=$(curl -s http://127.0.0.1/pistaprs/bmscrape.php| sed 's/<[^>]\+>//g' | sed 's/None//' | sed ':a;N;$!ba;s/\n/ /g' | sed 's/TG/#/g')
|
||
|
comment="Brandmeister TGs: $tg"
|
||
|
# DSTAR - Scrape for reflector and set comment.
|
||
|
[ "$mode" = "dstar" ] && comment="DStar "$(curl -s http://127.0.0.1/mmdvmhost/repeaterinfo.php | egrep "Linked|linked" | sed 's/<[^>]\+>//g' | sed 's/L/l/')
|
||
|
# Dear god why the hell are you using an entirely untested mode?
|
||
|
[ "$mode" = "ysf" ] && comment="YSF "$(curl -s http://127.0.0.1/mmdvmhost/repeaterinfo.php | egrep "Linked|linked" | sed 's/<[^>]\+>//g' | sed 's/L/l/')
|
||
|
# Here's how we hand-craft an APRS packet. (Who needs a client anyway?)
|
||
|
data="$senduser>APRS,TCPIP*:!$lat$table$lon$symbol$hsp $comment $ft"
|
||
|
# Send data to the terminal for testing
|
||
|
[ "$activate" -eq 0 ] && printf "%s\n" "user $user pass $password" "$data"
|
||
|
# Make sure output is sane before actually commiting to server.
|
||
|
[ "$activate" -eq 1 ] && printf "%s\n" "user $user pass $password" "$data" | ncat rotate.aprs2.net 14580
|