kopia lustrzana https://github.com/sm3ulc/hab-wspr
new config style & maidenhead
rodzic
1b2532eec3
commit
1179350e88
|
@ -0,0 +1,19 @@
|
|||
[main]
|
||||
push_habhub = True
|
||||
habhub_callsign = "SM4ULC"
|
||||
|
||||
push_aprs = True
|
||||
aprsCallsign = "SM4ULC"
|
||||
aprsUser = 'SM3ULC' # Replace with your own callsign. This should NOT have any SSID's on it (i.e. -9)
|
||||
aprsPass = '24505' # APRS-IS passcode for your callsign.
|
||||
|
||||
# balloons = [[ "BSS22","SA6BSS",14,11]]
|
||||
|
||||
balloons = [[ "BSS22","SA6BSS",14,11],
|
||||
["U3B-25","VE3KCL", 14, 4],
|
||||
["U3B-27","VA3UAL", 14, 4],
|
||||
["ICT3","YO3ICT",14, 15],
|
||||
["STELLA24","DL6OWT",14, 8],
|
||||
["STELLA20","DL6OW",14, 10],
|
||||
["BZ1","PE2BZ",14, 9],
|
||||
["U3S33","N2NXZ",14,5]]
|
|
@ -0,0 +1,78 @@
|
|||
# From ttps://github.com/scivision/maidenhead
|
||||
|
||||
"""## mlocs - Maidenhead
|
||||
toMaiden([lat, lon], level) returns a char (len = lvl*2)
|
||||
toLoc(mloc) takes any string and returns topleft [lat,lon] within mloc
|
||||
|
||||
Beyond 8 characters is not defined for Maidenhead.
|
||||
"""
|
||||
|
||||
def toLoc(maiden):
|
||||
"""
|
||||
input: maidenhead locator of length 2 to 8
|
||||
output: [lat,lon]
|
||||
"""
|
||||
assert isinstance(maiden, str), 'Maidenhead is a string'
|
||||
maiden = maiden.strip().upper()
|
||||
|
||||
N = len(maiden)
|
||||
assert 8>=N>=2 and N%2==0,'Maidenhead locator requires 2-8 characters, even number of characters'
|
||||
|
||||
O = ord('A')
|
||||
lon = -180
|
||||
lat = -90
|
||||
#%% first pair
|
||||
lon += (ord(maiden[0])-O)*20
|
||||
lat += (ord(maiden[1])-O)*10
|
||||
#%% second pair
|
||||
if N>=4:
|
||||
lon += int(maiden[2])*2
|
||||
lat += int(maiden[3])*1
|
||||
if N==4:
|
||||
lon += 1
|
||||
lat += 0.5
|
||||
#%%
|
||||
if N>=6:
|
||||
lon += (ord(maiden[4])-O) * 5./60
|
||||
lat += (ord(maiden[5])-O) * 2.5/60
|
||||
if N==6:
|
||||
lon += 2.5/60
|
||||
lat += 1.25/60
|
||||
#%%
|
||||
if N>=8:
|
||||
lon += int(maiden[6]) * 5./600 + 2.5/600
|
||||
lat += int(maiden[7]) * 2.5/600 + 1.25/600
|
||||
|
||||
return lat,lon
|
||||
|
||||
def toMaiden(position, precision=3):
|
||||
"""Returns a maidenloc for specified lat-lon tuple at specified level.
|
||||
"""
|
||||
assert len(position)==2,'lat lon required'
|
||||
lat = float(position[0])
|
||||
lon = float(position[1])
|
||||
|
||||
A = ord('A')
|
||||
a = divmod(lon+180, 20)
|
||||
b = divmod(lat+90, 10)
|
||||
astring = chr(A+int(a[0])) + chr(A+int(b[0]))
|
||||
lon = a[1] / 2.
|
||||
lat = b[1]
|
||||
i = 1
|
||||
while i < precision:
|
||||
i += 1
|
||||
a = divmod(lon,1)
|
||||
b = divmod(lat,1)
|
||||
if not (i%2):
|
||||
astring += str(int(a[0])) + str(int(b[0]))
|
||||
lon = 24 * a[1]
|
||||
lat = 24 * b[1]
|
||||
else:
|
||||
astring += chr(A+int(a[0])) + chr(A+int(b[0]))
|
||||
lon = 10 * a[1]
|
||||
lat = 10 * b[1]
|
||||
|
||||
if len(astring)>=6:
|
||||
astring = astring[:4] + astring[4:6].lower() + astring[6:]
|
||||
|
||||
return astring
|
11
telemetry.py
11
telemetry.py
|
@ -16,10 +16,8 @@ import sqlite3
|
|||
import sys
|
||||
import time
|
||||
|
||||
|
||||
# https://github.com/scivision/maidenhead
|
||||
import maidenhead
|
||||
from maidenhead import toLoc
|
||||
# from maidenhead import toLo
|
||||
|
||||
from balloon import *
|
||||
from sonde_to_aprs import *
|
||||
|
@ -27,11 +25,14 @@ from sonde_to_aprs import *
|
|||
# Power to decimal conversion table
|
||||
pow2dec = {0:0,3:1,7:2,10:3,13:4,17:5,20:6,23:7,27:8,30:9,33:10,37:11,40:12,43:13,47:14,50:15,53:16,57:17,60:18}
|
||||
|
||||
habhub_callsign = "MYCALL"
|
||||
# habhub_callsign = "SM4ULC"
|
||||
balloons = config['main']['habhub_callsign']
|
||||
|
||||
# push_habhub = False
|
||||
# push_aprs = False
|
||||
|
||||
|
||||
|
||||
def trim(spots):
|
||||
# Clean out old spots
|
||||
if len(spots) > 0:
|
||||
|
@ -604,7 +605,7 @@ def process_telemetry(spots, balloons, habhub_callsign, push_habhub, push_aprs):
|
|||
# print(seqnr)
|
||||
|
||||
# telemetry = [ spot_pos_time, spot_pos_call, lat, lon, loc, alt, temp, batt, speed, gps, sats ]
|
||||
telestr = "%s,%d,%s,%.5f,%.5f,%d,%d,%.2f,%d,%d,%d" % (
|
||||
telestr = "%s,%d,%s,%.5f,%.5f,%d,%d,%.2f,%.2f,%d,%d" % (
|
||||
balloon_name, seqnr, telemetry['time'].strftime('%H:%M'), telemetry['lat'], telemetry['lon'],
|
||||
telemetry['alt'], telemetry['speed'], telemetry['temp'], telemetry['batt'], telemetry['gps'], telemetry['sats'])
|
||||
|
||||
|
|
27
webscrape.py
27
webscrape.py
|
@ -2,6 +2,7 @@
|
|||
|
||||
# port urllib3
|
||||
|
||||
import configparser
|
||||
import datetime
|
||||
import re
|
||||
import requests
|
||||
|
@ -14,9 +15,17 @@ import time
|
|||
from balloon import *
|
||||
from telemetry import *
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read('balloon.ini')
|
||||
|
||||
push_habhub = config['main']['push_habhub']
|
||||
|
||||
push_aprs = config['main']['push_aprs']
|
||||
balloons = config['main']['balloons']
|
||||
|
||||
|
||||
def getspots (nrspots):
|
||||
# print("Fetching...")
|
||||
# wiki = "http://wsprnet.org/olddb?mode=html&band=all&limit=" + str(nrspots) + "&findcall=&findreporter=&sort=date"
|
||||
wiki = "http://wsprnet.org/olddb?mode=html&band=all&limit=" + str(nrspots) + "&findcall=&findreporter=&sort=spotnum"
|
||||
try:
|
||||
page = requests.get(wiki)
|
||||
|
@ -94,8 +103,6 @@ def balloonfilter(spots,balloons):
|
|||
for b in balloons:
|
||||
calls.append(b[1])
|
||||
|
||||
# print("calls:", calls)
|
||||
|
||||
for row in spots:
|
||||
for c in calls:
|
||||
if row[1] == c:
|
||||
|
@ -142,19 +149,11 @@ def deduplicate(spotlist):
|
|||
return spotlist
|
||||
|
||||
|
||||
# Name, Call, Freq (MHz (int)), channel
|
||||
|
||||
balloons = [[ "BAL-1","VY1XYZ",14,11]]
|
||||
|
||||
|
||||
spots = []
|
||||
|
||||
# Read active balloons from db
|
||||
# balloons = readballoonsdb()
|
||||
|
||||
|
||||
push_habhub = True
|
||||
push_aprs = True
|
||||
|
||||
# Spots to pull from wsprnet
|
||||
nrspots_pull= 2000
|
||||
spotcache = []
|
||||
|
@ -166,15 +165,11 @@ spotcache = balloonfilter(spotcache ,balloons)
|
|||
print("Fspots2",len(spotcache))
|
||||
|
||||
spots = spotcache
|
||||
|
||||
|
||||
|
||||
cache_max = 10000
|
||||
new_max = 0
|
||||
only_balloon=False
|
||||
sleeptime = 60
|
||||
|
||||
|
||||
print("Entering pollingloop.")
|
||||
while 1==1:
|
||||
tnow = datetime.datetime.now()
|
||||
|
|
Ładowanie…
Reference in New Issue