The New One That Works

master
dewdude 2 years ago
parent d038732ff4
commit 523a40784e

@ -19,10 +19,7 @@ and off. The entire thing was just permanently set as an every 5-minute
cronjob.
Pi-Star has some sort of GPS stuff built-in to it; but I couldn't figure out
how to make it work. It's also been a few years since I tried to even run it in
it's current state. I plan on making use of it soon; so it will likely see re-
writes. In fact the method of scraping has changed entirely.
how to make it work. This has been updated for the new scraping method.
I also lost the php that handled the activation.
Some of this has been resurrected as **[piscrape - Hotspot Info Display For PHP](https://git.pickmy.org/dewdude/piscrape)**.
@ -32,6 +29,7 @@ The original PiStaprs page is at: https://pickmy.org/?page_id=136
```
07-MAY-2022 - Initial Commit
12-MAY-2022 - update scrape. fix fatal bugs
```
# License

@ -3,27 +3,27 @@
#Jay Moore/NQ4T - https://git.pickmy.org/dewdude/pistaprs
#Licensed under GPL-3.0-or-later
# script activation/webui control
[ ! -s "/tmp/aprs" ] && exit
#[ ! -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
ip=192.168.1.207
port=50000
# Use GPSD? (0 = No, 1 = Yes)
gpsd=1
gpsd=0
# Android "gps tethering" app (or NMEA over IP)?
gpstether=0
gpstether=1
# Is 'GPS Tether' UDP?
gpsudp=0
# APRS-IS user id
user=urcall
user=URCALL
# APRS-IS passcode
password=urpasscode
password=1234
# APRS Object ID/SSID
senduser=urcall-ssid
senduser=CALL-#
# APRS Icon Selection (refer to pdf)
# Standard table
table="/"
@ -33,8 +33,8 @@ table="/"
symbol=">"
# What system are you running? (And if you say YSF then good luck pal.)
# YSF is completely untested.
mode=dstar
#mode=dmr
#mode=dstar
mode=dmr
#mode=ysf
@ -42,34 +42,38 @@ mode=dstar
[ "$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)
[ "$gpstether" -eq 1 ] && [ "$gpsudp" -eq 0 ] && nema=$(timeout 1 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
[ -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
#[ "$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
[ -z "$lon" ] && 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')
[ "$mode" = "dmr" ] && tg=$(curl -s http://192.168.1.10/mmdvmhost/bm_links.php| sed 's/<[^>]\+>/\n/g' | grep '^TG' | sed 's/TG/#/g'| sed 's/(.)//g' | sed ':a;N;$!ba;s/\n/ - /g')
[ -z "$tg" ] && tg="No Talkgroups Found"
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/')
#[ "$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/')
#[ "$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 hello. testing. $ft"
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"
#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
[ "$activate" -eq 1 ] && printf "%s\n" "user $user pass $password" "$data" | ncat rotate.aprs2.net 14580

Loading…
Cancel
Save