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

Post your tips and tricks here
NQ4T
Posts: 46
Joined: Mon Aug 06, 2018 11:48 pm

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

Post by NQ4T » Sat May 04, 2019 10:02 pm

M1DNS wrote:
Sat May 04, 2019 1:48 pm
Mobile GPS. I don't think it's the branch that pistar is currently running but I'm sure it will be on the next update. Which is prob. going to make the klx solution the used preference over gpsd.

Andrew M1DNS, (Mod)
I do not have USB GPS dongles to plug in to my hotspots; so I source the data from a Pi based NTP server with a GPS hat. It's actually running gpsd. In fact all I need from the "client" side is gpspipe, which is provided by gpsd-clients which currently calls gpsd as a dependency; but you can apt-get purge gpsd and still keep gpspipe.

So...when I started the preference for using gpsd was already determined by the fact my RPi NTPD server already had it running; and it was a convenient "no-cost" solution to getting gps data over to the hotspots. The other factor was you can get gpsd data out of android mildly easy...you can root your system and get to it or you can install an app that will create a "second" gpsd on a valid port and just relay. Maybe someone will make a MobileGPS application for android that can supply the data; but Android already has gpsd internally so it would require either mobilegps allowing something besides serial input or serial port emulation.
SP2ONG wrote:
Sat May 04, 2019 2:18 pm
Hi NQ4T

The nice idea put information about own TG in APRS message. I have add to my script to generate a list of TG base on your bm_links2.php and send information about TG as the status aprs message.


73 Waldek SP2ONG
The modified bm_links2.php basically just outputs the dynamic and static talkgroup fields instead of the entire table. They come out in columns of 3, so stripping line-breaks helps. "None" is also added if either the dynamic or static TGs are empty. My entire project spawned as a way of keeping a list of connected TG's updated and reasonably accessible.

M1DNS
Posts: 836
Joined: Thu Apr 05, 2018 5:30 am

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

Post by M1DNS » Sun May 05, 2019 6:48 am


NQ4T wrote:
M1DNS wrote:
Sat May 04, 2019 1:48 pm
Mobile GPS. I don't think it's the branch that pistar is currently running but I'm sure it will be on the next update. Which is prob. going to make the klx solution the used preference over gpsd.

Andrew M1DNS, (Mod)
I do not have USB GPS dongles to plug in to my hotspots; so I source the data from a Pi based NTP server with a GPS hat. It's actually running gpsd. In fact all I need from the "client" side is gpspipe, which is provided by gpsd-clients which currently calls gpsd as a dependency; but you can apt-get purge gpsd and still keep gpspipe.

So...when I started the preference for using gpsd was already determined by the fact my RPi NTPD server already had it running; and it was a convenient "no-cost" solution to getting gps data over to the hotspots. The other factor was you can get gpsd data out of android mildly easy...you can root your system and get to it or you can install an app that will create a "second" gpsd on a valid port and just relay. Maybe someone will make a MobileGPS application for android that can supply the data; but Android already has gpsd internally so it would require either mobilegps allowing something besides serial input or serial port emulation.
You might be misreading what my last message was indicating...
The newer vers of MMDVM has written in support for mobile GPS.
Yes you need a usb GPS puck but it will work natively with the differing gateways and forward to APRS servers. So no dependencies reguired of external code and no android rooting or dependency etc.

I'm not 'knocking' what ur doing, ur use case is fitting in the way you are using itImage, and it showing TG status is a good addition.



Andrew M1DNS, (Mod)

Andrew M1DNS.
Pi-star Admin Team.

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

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

Post by SP2ONG » Sun May 05, 2019 7:33 am

Another interesting solution may be to use GPS data from a mobile phone that sends via UDP to Pi-Star. On Pi-star we can download data using netcat (nc) and then via scripts send data to APRS.

https://play.google.com/store/apps/deta ... eGPS&hl=en

I tried to use this but it looks like you need to add a rule to the firewall so you can receive data from GPS on the UDP port

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

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

Post by NQ4T » Sun May 05, 2019 3:20 pm

M1DNS wrote:
Sun May 05, 2019 6:48 am

You might be misreading what my last message was indicating...
The newer vers of MMDVM has written in support for mobile GPS.
Yes you need a usb GPS puck but it will work natively with the differing gateways and forward to APRS servers. So no dependencies reguired of external code and no android rooting or dependency etc.

I'm not 'knocking' what ur doing, ur use case is fitting in the way you are using itImage, and it showing TG status is a good addition.
It still to me had the tone of "we're going to do this so you can stop what you're doing and adopt our method regardless if it works for you". At the same time, I realize you guys don't develop mmdvm directly.

When I dug through the code for what I could understand...I almost just don't see the point. I mean mobileGPS basically looks like it's scanning the GPGGA and GMRMC sentences and updating based on distance. It seems like re-inventing the wheel. That's not to mention the modules only seem to beacon every 20 minutes and don't show reflector/TG status. I looked heavily in to using what was already in Pi-Star...I didn't want to reinvent the wheel either; but the wheel already there wasn't up to the task.

That being said, it'd be possible to fake out mobilegps by having something like gpscat feed data to a virtual serial port.

My mention of Android was just the fact it is possible to use it's GPS data since it's GPSD output. It's possible to have that data routed using an app "outside the phone". If we already have that capability and it wind up not being too difficult, then why not use something that would let users leverage it?

The current native implantation wouldn't work for my purposes; I built something largely for me that meets my needs and requirements. I'm sharing it on the off-chance someone else has similar requirements. It's entirely possible I don't need to use gpspipe, there's likely a way I can have something else pull GPSD data from my source. It's entirely possible I could compile a gpspipe executable and include it in the package. These are things I haven't gotten around to yet.

Plus adding outside stuff is just another case of why Pi-Star powered hotspots are "a little bit better" than the others; we have a whole underlying standard operating system we can get at and do stuff like this. Could you do this on an OpenSpot(2)? Probably not.

But when you get down to it...my script only requires a $GPRMC (as of last night) sentence to operate. It literally doesn't care how it gets it.
SP2ONG wrote:
Sun May 05, 2019 7:33 am
Another interesting solution may be to use GPS data from a mobile phone that sends via UDP to Pi-Star. On Pi-star we can download data using netcat (nc) and then via scripts send data to APRS.

https://play.google.com/store/apps/deta ... eGPS&hl=en

I tried to use this but it looks like you need to add a rule to the firewall so you can receive data from GPS on the UDP port
I tested this on my ntp server, which is good because the GPS dongle lost GPS sync overnight and it might be a while before it gets it back, so the alternative GPS source will let me keep tweaking my script: (192.168.1.183 is the ip of my android device)

Code: Select all

[email protected]:~/scripttest $ ncat 192.168.1.183 50000
$GPGSV,3,2,10,23,64,264,22,26,41,049,18,27,49,149,26,31,15,098,13*7A
$GPGSV,3,3,10,03,08,219,,21,04,066,*7E
$GLGSV,3,1,10,78,16,066,19,79,53,016,23,69,38,226,16,88,25,045,20*69
$GLGSV,3,2,10,81,34,101,20,70,34,303,,82,12,150,,80,35,295,*64
$GLGSV,3,3,10,71,01,341,,68,06,187,*63
$GAGSV,1,1,0,*74
$PQGSV,1,1,0,*73
$PQGSV,1,1,0,*73
$GNGSA,A,3,09,16,23,26,27,,,,,,,,1.3,0.9,0.9,1*3D
$GNGSA,A,2,69,81,88,,,,,,,,,,1.3,0.9,0.9,2*37
$GNVTG,,T,,M,0.0,N,0.0,K,A*3D
$GNRMC,144011.00,A,3843.655284,N,07725.965287,W,0.0,,050519,7.9,W,A*06
Right now I just have to figure out how to get ncat to stop after so many lines. It was also 12 lines before I got the sentence I wanted. The sentences are also renamed GNGGA and GNRMC. But this does pose a problem. For starters, ncat isn't installed on the hotspots; which is an outside source "we shouldn't need". You also can't make ncat gracefully exit after so many lines; the GNRMC happens every twelve lines.

Sadly that app's gpsd doesn't seem to work. The phone indicates a connection; but I don't ever get any data out of it.

Code: Select all

[email protected]:~/scripttest $ gpspipe -r 192.168.1.183:2947
{"class":"VERSION","protocolMajor":3.0,"protocolMinor":11.0,"release":"3","rev":"3.16"}
I didn't have to do any special firewall stuff to get the ncat output from the thing. I don't think you need to root for this one...that was something I did years ago on an old phone to get raw access to the underlying gpsd to forward it to a phone with broken gps. (This was back when sharing gps over bluetooth amounted to brute-forcing data in to 'fake location')

The problem I have with running a script to just write location information is that it won't be as current as when the packet was sent, it could be as far off as how ever that information is updated. When you're flying down the highway at 70/75 miles/hour...a minute or two old location data can amount to more than a mile. But I would like to get something working using the phone as a source in the long run since most people have smartphones.

Now on to new stuff:

Script was redone last night to add speed and heading information. A change to $GPRMC sentences as source was involved.

Code: Select all

#!/bin/bash
# script activation/webui control
[ ! -s "/tmp/aprs" ] && exit

#       Script Configuration

# APRS-IS user id
user=USER
# APRS-IS passcode
password=URPASS
# APRS Object ID/SSID
senduser=CALL-SSID
# APRS Icon Selection (refer to pdf)
# Standard table
#table="/"
# Alternate Table
table="\\"
# Symbol
symbol=">"

# Poll GPSD
gpsd=$(gpspipe -n 9 -r | sed -n '/$GPRMC/{p;q}')
# GPS Lock Check
gpss=$(printf "$gpsd" | cut -d ',' -f3)
test "$gpss" = "V" && exit
# GPS Coordinate Set
lat=$(printf "$gpsd" | awk -F, '$1 == "$GPRMC" {printf "%07.2f%c", $4, $5;}')
lon=$(printf "$gpsd" | awk -F, '$1 == "$GPRMC" {printf "%08.2f%c", $6, $7;}')
# Set heading & speed
spd=$(printf "$gpsd" | awk -F, '$1 == "$GPRMC" {printf "%03.0f%c%03.0f", $9, "/", $8}')
#gps="$lat$table$lon$symbol$spd"
# DMR - Scrape for TGs and set comment.
#tg=$(curl -s http://pi-star/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"
# DSTAR - Scrape for reflector and set comment (should work for YSF too)
dstar=$(curl -s http://pi-dstar/mmdvmhost/repeaterinfo.php | egrep "Linked|linked" | sed 's/<[^>]\+>//g' | sed 's/L/l/')
comment="DStar $dstar"
# I have not tested if it actually works for YSF.
#comment="YSF $dstar"
# parse packet
data="$senduser>APRS,TCPIP*:!$lat$table$lon$symbol$spd $comment"
# Send data to the terminal for testing
printf "%s\n" "user $user pass $password" "$data"
#DO NOT ENABLE UNTILL YOU'RE SURE IT WORKS!!!!!!!
#printf "%s\n" "user $user pass $password" "$data" | ncat rotate.aprs2.net 14580
The main change is that all your configuration can be done without modifying the script itself; so changing your icon table and symbol doesn't require hacking the script. I also updated the script to indicate we don't have APRS messaging...working more like a generic tracker. Coordinates are now rounded (somewhat) and properly padded. Speed and heading information is also rounded and padded with 0s to match the protocol. I also believe the YSF Reflector information can be scraped the same way the DStar information is; though if you're using YSF2DMR bridge on BM it may be better to just use the DMR code instead.

At some point it'll stop raining and my NTP server will regain it's GPS or I'll figure out how to get ncat to poll my phone and exit after so many lines.

M1DNS
Posts: 836
Joined: Thu Apr 05, 2018 5:30 am

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

Post by M1DNS » Sun May 05, 2019 3:58 pm


NQ4T wrote:
M1DNS wrote:
Sun May 05, 2019 6:48 am

You might be misreading what my last message was indicating...
The newer vers of MMDVM has written in support for mobile GPS.
Yes you need a usb GPS puck but it will work natively with the differing gateways and forward to APRS servers. So no dependencies reguired of external code and no android rooting or dependency etc.

I'm not 'knocking' what ur doing, ur use case is fitting in the way you are using itImage, and it showing TG status is a good addition.
It still to me had the tone of "we're going to do this so you can stop what you're doing and adopt our method regardless.

Really. Wtf. That's the reason why I replied to clarify that's NOT the way I'm intending my reply to say.

Simple fact is the new 'klx MMDVM host has support for mobile GPS, using USB GPS dongles and that release will eventually find its way into pi-star, as pistar uses 'klx MMDVM.

The idea was to instill a hint you might want to look at working with the way that version works, a heads up in following its use case that pushes the info out through the various gateways. and so having a project that might not be scuppered when "we" move onto that release. Integration of 3rd party projects built on top of pistar isn't something we will hold pistar back on, but please do continue just ensure you don't throw Ur teddy from the pram, as others have before you. Image should changes made in pistar effect ur particular project.



Andrew M1DNS, (Mod)







Andrew M1DNS.
Pi-star Admin Team.

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

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

Post by SP2ONG » Sun May 05, 2019 4:15 pm

Hi,

I have written a small script in python to receive GPS data from Android application "GPS Share" and send 2 APRS packet one with position and second with the status of TG
For me works on my Pi-star with your bm_links2.php script. I have setup GPS Share to send information about coordinates every 10 minutes. The script is waiting for data via UDP, if receive gps data send aprs packets.

Code: Select all

#!/usr/bin/python
#
# Receive GPS data from mobile phone and application "GPS Share" via UDP
# You need installl pip and aprslib
# Run following commands:
# rpi-rw
# sudo apt-get install python-pip
# sudo pip install aprslib
#
# - SP2ONG 2019 -
#
import socket
import os
import aprslib
import time
import datetime

# Define APRS callsign withh SSID
mycall="N0CALL-10"

# Define message APRS
msg="Hotspot DMR"

# Get TG BM list
cmd="curl -s http://127.0.0.1/mmdvmhost/bm_links2.php | sed 's/<[^>]\\+>//g' | sed 's/None//g' | sed ':a;N;$!ba;s/\\n/ /g'|sed 's/TG/#/g'"

# Get Ip adress on "wlan0" or change to "eth0"
UDP_IP=os.popen('ip addr show wlan0').read().split("inet ")[1].split("/")[0]

# UDP port for GPS data
# Put in Pi-star file /root/ipv4.fw following lines:
# iptables -A OUTPUT -p udp --dport 30000 -j ACCEPT
# iptables -A INPUT -p udp --dport 30000 -j ACCEPT
#
UDP_PORT = 30000

def altm(altm):
        alt = str(int(round(altm * 3.2808)))
        if len(alt) == 1:
         alt = "/A=00000"+alt;
        elif len(alt) == 2:
         alt = "/A=0000"+alt;
        elif len(alt) == 3:
         alt = "/A=000"+alt;
        elif len(alt) == 4:
         alt = "/A=00"+alt
        elif len(alt) == 5:
         alt = "/A=0"+alt
	return alt

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind((UDP_IP, UDP_PORT))

while True: 
    line, addr = sock.recvfrom(1024)
    line = line.split(',')
#    Data = (float(line[2]), line[3], float(line[4]), line[5], float(line[9]))
#    print "received message:", Data 
    lat=str(round(float(line[2]),2))[0:7]
    lon=str(line[4])[0:8]
    alt=altm(float(line[9]))
    r=os.popen(cmd).read()
    AIS = aprslib.IS("DMR-WW", passwd="26031", port=14580)
    AIS.connect()
    time = datetime.datetime.utcnow()
    timestamp=time.strftime("%d%H%M")
    info=mycall+">APRS,TCPIP*:@"+timestamp+"z"+lat+line[3]+"D"+lon+line[5]+"&"+alt+msg
    AIS.sendall(info)
    status=mycall+">APRS,TCPIP*:>My TG BM: "+r
    AIS.sendall(status)

Last edited by SP2ONG on Mon May 06, 2019 7:27 pm, edited 4 times in total.

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

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

Post by NQ4T » Sun May 05, 2019 5:34 pm

M1DNS wrote:
Sun May 05, 2019 3:58 pm

Really. Wtf. That's the reason why I replied to clarify that's NOT the way I'm intending my reply to say.

Simple fact is the new 'klx MMDVM host has support for mobile GPS, using USB GPS dongles and that release will eventually find its way into pi-star, as pistar uses 'klx MMDVM.

The idea was to instill a hint you might want to look at working with the way that version works, a heads up in following its use case that pushes the info out through the various gateways. and so having a project that might not be scuppered when "we" move onto that release. Integration of 3rd party projects built on top of pistar isn't something we will hold pistar back on, but please do continue just ensure you don't throw Ur teddy from the pram, as others have before you. Image should changes made in pistar effect ur particular project.




Andrew M1DNS, (Mod)
The problem is I had already mentioned I looked at "what Pi-Star and MMDVM" already had supported. If you missed that or it wasn't very clear..I'm sorry. But I feel as if I clearly stated I had already examined that path and found it wasn't suitable for my goals; so I got defensive of what I was trying to do. Again..if I didn't make it clear that I had examined the native/existing options; I'm sorry. Rest assured the first few hours of work was looking at what was already built in.

My mention of GPSD is *only* because it happens to be set as a dependency for gpsd-clients in apt...which is the package that supplies gpspipe; and gpspipe doesn't even depend on gpsd since it is literally just a client application. I could probably compile an executable on a pi without having to install anything. I designed the script to really only rely on the Pi-Star dashboard to grab TG & reflector information. It doesn't even need to run on the hotspots. I can run the entire script on an external device and just poll the dashboard for linking information.

I mean ultimately we'll have to wait and see. If the modules start pulling from the mobileGPS and beaconing like normal...that's not going to accomplish what I designed this script to do. If there are major changes to how the mmdvm dongles beacon to APRS-IS, I will gladly investigate them. If by some reason things don't want to work after an update...then I'll just move things over to an non Pi-Star RPi and have things beacon that way. But given that I had fewer issues installing the packages on v4....I don't know how the script would "stop working". If it does...ok..I'll just move the stuff over to the RPi-NTP and run from there. It accomplishes the same goal.
SP2ONG wrote:
Sun May 05, 2019 4:15 pm
I have written a small script in python to receive GPS data from Android application "GPS Share" and send 2 APRS packet one with position and second with the status of TG
For me works on my Pi-star with your bm_links2.php script. I have setup GPS Share to send information about coordinates every 10 minutes. The script is waiting for data via UDP, if receive gps data send aprs packets.
I will try to brush up on my Python and see if I can figure out exactly how it works and what it's doing. I'm at a disadvantage at the only programming languages I ever really learned was Applesoft BASIC and enough 6802/08 assembly to hack on some pinball machines.



M1DNS
Posts: 836
Joined: Thu Apr 05, 2018 5:30 am

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

Post by M1DNS » Sun May 05, 2019 6:16 pm

As said I'm ( and I don't think any of us) are opposed to users creating bolt ons to their projects, it's Ur hardware after all, as long as there's a realisation there might be a time where what ur making particular use of, might change and that could effect ur bolt on.

Andrew M1DNS, (Mod)



Andrew M1DNS.
Pi-star Admin Team.

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

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

Post by NQ4T » Mon May 06, 2019 5:05 pm

SP2ONG wrote:
Sun May 05, 2019 4:15 pm
I have written a small script in python
Ok...quite interesting. I think I understand what most of it is doing. I probably could have written this in python afterall.

Anyway..I came up with this for keeping with my current convention:

Code: Select all

timeout 3 netcat 192.168.1.183 10110 |  sed -n '/$G.RMC/{p;q}'
This just gets netcat ouput from GPS Tether (or GPS Share if configured for UDP) for 3 seconds and has sed spit out the RMC sentence. I have to use wildcards as GPS Tether changes this from $GPRMC to $GNRMC when GPS is locked...and I seem to recall GPS Share also changed that. That will let me dump the proper field in to rest of my script.

I do like how yours is doing altitude. I'll have to look in to doing that next.

SP2ONG
Posts: 39
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 6:57 pm

Hi,

In order for my script to work on Pi-star it is necessary to create a file
/root/ivp4.fw

iptables -A OUTPUT -p udp --dport 9000 -j ACCEPT
iptables -A INPUT -p udp --dport 9000 -j ACCEPT

where 9000 is udp port for comunnication GPS Share and Pi-star
Last edited by SP2ONG on Mon May 06, 2019 7:43 pm, edited 1 time in total.

Post Reply