Created
September 18, 2018 17:40
-
-
Save wgaylord/c4a37a528ec5a6276972f81e70e66877 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
So last year I wrote my own APRS tracker using Pythonista. | |
APRS stands for Automatic Packet Reporting System | |
Using a python library for it and pythonistas access to location and the internet I was able to write my own software to report into the system using my Call Sign and display my location of aprs.fi | |
The following is my code which I never really tided up at all. | |
``` | |
import aprslib | |
import location | |
import livejson | |
import time | |
from math import sin, cos, sqrt, atan2, radians | |
last = None | |
count = 0 | |
location.start_updates() | |
aprs = aprslib.IS('CALLSIGN',aprslib.passcode('CALLSIGN')) | |
aprs.connect() | |
packet = aprslib.packets.PositionReport() | |
packet.fromcall='CALLSIGN' #Insert your hamradio call sign | |
packet.tocall='WIDE1' | |
packet.comment=' ' | |
packet.symbol='>' | |
def dist(locA,locB): | |
lat1 = radians(locA['latitude']) | |
lon1 = radians(locA['longitude']) | |
lat2 = radians(locB['latitude']) | |
lon2 = radians(locB['longitude']) | |
dlon = lon2 - lon1 | |
dlat = lat2 - lat1 | |
a = sin(dlat / 2.0)**2.0 + cos(lat1) * cos(lat2) * sin(dlon / 2.0)**2.0 | |
c = 2.0 * atan2(sqrt(a), sqrt(1.0 - a)) | |
return 6373.0 * c * 0.621371 | |
def sendLoc(aprs,loc): | |
packet.timestamp=loc['timestamp'] | |
packet.latitude=loc['latitude'] | |
packet.longitude=loc['longitude'] | |
aprs.sendall(packet) | |
print 'Location Updated!' | |
def course(last,loc): | |
old = last['course'] | |
new = loc['course'] | |
if old <0: | |
return False | |
if new < 0: | |
return False | |
delta = abs(new-old) | |
if delta <= 180: | |
delta = delta | |
else: | |
delta= 360-delta | |
if delta > 60: | |
print 'Course Changed!',new,old,delta | |
return True | |
loc = location.get_location() | |
sendLoc(aprs,loc) | |
last=loc | |
while True: | |
loc = location.get_location() | |
if (dist(last,loc) > 0.25 and count >= 4) or dist(last,loc) > 1 or count >24 or course(last,loc): | |
count = 0 | |
last=loc | |
try: | |
sendLoc(aprs,loc) | |
except: | |
aprs.connect() | |
sendLoc(aprs,loc) | |
else: | |
print count | |
count +=1 | |
time.sleep(10)``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment