commit 15efccce8e523654133c7b99f8165420bc9a337b Author: Loren Moore Date: Sat May 7 11:22:37 2022 -0400 Going up! diff --git a/README.md b/README.md new file mode 100644 index 0000000..60fb601 --- /dev/null +++ b/README.md @@ -0,0 +1,54 @@ +# Pi-StAPrS - Script for Pi-Star & APRS + +Gathers GPS and Pi-Star Info to beacon to APRS-IS as location & comment + +## About + +This script was originally written a couple of years ago to do two things: + +``` +gather & parse GPS information for an APRS packet +scrape Pi-Star for Talkgroup/Reflector for APRS comment +blast those to APRS-IS +``` + +The scripts were originally written to run directly on the RPi running Pi-Star; +scraping the information locally and getting GPS from another Pi running +gpsd. A simple PHP interface was hacked together to turn the beacon on +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. + +I also lost the php that handled the activation. + +Some of this has been resurrected as a hotspot information display. I will +update this spot when I get it's repository up. The original page is at: +https://pickmy.org/?page_id=136 + +# History + +``` +07-MAY-2022 - Initial Commit +``` + +# License + + Pi-StAPrS - Script for Pi-Star & APRS + Copyright (C) 2022 Jay Moore - nq4tango@gmail.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . diff --git a/pistaprs.sh b/pistaprs.sh new file mode 100644 index 0000000..b0cf80c --- /dev/null +++ b/pistaprs.sh @@ -0,0 +1,75 @@ +#!/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 \ No newline at end of file