Beacon your hotspot(s) to APRS with linked refelectors/TGs in comment.

Post your tips and tricks here
SP2ONG
Posts: 32
Joined: Fri Aug 10, 2018 5:05 am

Re: Beacon your hotspot(s) to APRS with linked refelectors/TGs in comment.

Post by SP2ONG » Mon May 06, 2019 7:43 pm

GPS Share sends GPS data in NMEA format. I use GPGGA because it contains, among other things, altitude. In GPRMC there is minimal GPS information without altitude. The first line from GPS Share is GPGGA

GPGA format:
http://aprs.gids.nl/nmea/#gga

GPRMC format
http://aprs.gids.nl/nmea/#rmc

NQ4T
Posts: 25
Joined: Mon Aug 06, 2018 11:48 pm

Re: Beacon your hotspot(s) to APRS with linked refelectors/TGs in comment.

Post by NQ4T » Tue May 07, 2019 2:28 pm

So I did some work on this since I last posted. The script keeps morphing in to what I hope is better.

So I also used GPGGA..at least at first since it made the most sense. However as I began studying the APRS protocol I kept figuring out how I switched to using GPRMC to gather speed and heading information which isn't sent in GPGGA. Then I got the idea for altitude...so I actually filter out a GPGGA and GPRMC to extract location, speed, heading, and altitude since Im already getting a ton of data.

As far as the firewall... haven't had that issue with port 2947. The non gpsd method I havent been able to reliability test as my phone disables GPS when it's idle. But I have had issues with GPS Tether on Android just not working on occasion. The other thing I had to do with that is wildcard the sentences. GPS Tether and the other GPS tethering app change GPGGA to GNGGA for some odd reason.

I cant remember if this was the last version I came up with last night...I made some changes and am at work right now so I don't have access to it.

Code: Select all

#!/bin/bash
# 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 NEMA 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//g' | sed ':a;N;$!ba;s/\n/ /g' | sed 's/TG/#/g')
comment="Brandmeister TGs: $tg"
[ -z "$tg" ] && comment="Brandmeister TGs: None"
# 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

SP2ONG
Posts: 32
Joined: Fri Aug 10, 2018 5:05 am

Re: Beacon your hotspot(s) to APRS with linked refelectors/TGs in comment.

Post by SP2ONG » Wed May 08, 2019 10:12 am

I was just working on a script that sent the received coordinates from Share GPS application to APRS and MMDVMHost.

After many times monitoring UDP port 7834 it is look like MMDVMHost not working with MobileGPS despite the [MobileGPS] option enabled, because not send request data to MobileGPS , when YSFGateway which send request to MobileGPS if in configuration we setup MobileGPS and APRS enable but when we disable APRS YSFGateway don't send request to MbileGPS.

It will be nice to use coordinates form Mobile GPS or other application (for example Android "Share GPS" to update coordinates in MMDVMHost and send to Brandmeister

NQ4T
Posts: 25
Joined: Mon Aug 06, 2018 11:48 pm

Re: Beacon your hotspot(s) to APRS with linked refelectors/TGs in comment.

Post by NQ4T » Wed May 08, 2019 1:11 pm

Well...good luck with that.

Due to some personal interaction with someone elsewhere...I have lost all desire to continue developing the script and therefore have basically abandoned the project.

This thread will remain the only "public release".

Good day.

SP2ONG
Posts: 32
Joined: Fri Aug 10, 2018 5:05 am

Re: Beacon your hotspot(s) to APRS with linked refelectors/TGs in comment.

Post by SP2ONG » Fri May 10, 2019 1:16 pm

I have made a small script in python which sends to aprs.fi own text and it is possible to send as message status of the list of used TG BMs

Code: Select all

#!/usr/bin/python
#
# Install the necessary libraries
# rpi-rw
# sudo apt-get update
# sudo apt-get install python-pip
# sudo pip install aprslib
#
# - SP2ONG 2019 -
#
import socket
import os
import aprslib
import time
import datetime
import json
from urllib2 import Request, urlopen, URLError

# Define message APRS
msg="Pi-Star Hotspot DMR "

# Define SSID for APRS callsign
ssid=10

# Set 1 if you want to send status APRS message with your list of TG BM
tglist=1

# Get TG BM
err=""
if tglist == 1:
 slot1=int(os.popen("sed '/Slot1=/!d; s/Slot1=//' /etc/mmdvmhost").read())
 dmrid=str(os.popen("sed '/Id=/!d; s/Id=//' /etc/mmdvmhost").read())
 url = 'https://api.brandmeister.network/v1.0/repeater/?action=PROFILE&q='+dmrid
 req = Request(url)
 try:
  data = json.load(urlopen(req))
 except URLError as e:
  err=e.reason   
 if not err:
  tgbm=""
  for i in data["staticSubscriptions"]:
    if slot1 == 1 and i["slot"] == 0:
     tg="#"+str(i["talkgroup"])+" "
     tgbm=tgbm+tg
    if i["slot"] == 1 or i["slot"] == 2:
     tg="#"+str(i["talkgroup"])+" "
     tgbm=tgbm+tg

# Get call, lat, lon, alt from MMDVMHost configuration
call=str(os.popen("sed '/Callsign=/!d; /Callsign/s/Callsign=//' /etc/mmdvmhost").read())
aprscall=call.strip()+"-"+str(ssid)
lat=aprslib.util.latitude_to_ddm(float(os.popen("sed '/Latitude=/!d; s/Latitude=//' /etc/mmdvmhost").read()))
lon=aprslib.util.longitude_to_ddm(float(os.popen("sed '/Longitude=/!d; s/Longitude=//' /etc/mmdvmhost").read()))
alt=aprslib.util.comment_altitude(float(os.popen("sed '/Height=/!d; s/Height=//' /etc/mmdvmhost").read()))

# Connect to APRS server
AIS = aprslib.IS("DMR-WW", passwd="26031", port=14580)
AIS.connect()
# Set timestamp
time = datetime.datetime.utcnow()
timestamp=time.strftime("%d%H%M")
# APRS frame
info=aprscall+">APRS,TCPIP*:@"+timestamp+"z"+lat+"D"+lon+"&"+alt+msg
# Send to aprs.fi info 
AIS.sendall(info)
# Send TG BM as status APRS
if tglist == 1 and not err:
 status=aprscall+">APRS,TCPIP*:>My TG BM: "+tgbm
 AIS.sendall(status)

Post Reply