aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2023-08-19 10:56:33 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2023-08-19 10:56:33 +0200
commit3048414f34d53ff8bc5eb9fe226a09898685020a (patch)
tree2a47bb434f474f388f589008cc8863d6cd8f1b5c
parent9e6de5e983af7285a32267f69d590dccf354af35 (diff)
downloadlora-aprs-hb9egm-3048414f34d53ff8bc5eb9fe226a09898685020a.tar.gz
lora-aprs-hb9egm-3048414f34d53ff8bc5eb9fe226a09898685020a.tar.bz2
lora-aprs-hb9egm-3048414f34d53ff8bc5eb9fe226a09898685020a.zip
igate: send messages and uncompressed reports to APRS-IS
-rwxr-xr-xpython/igate.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/python/igate.py b/python/igate.py
index 7c2e131..0637e42 100755
--- a/python/igate.py
+++ b/python/igate.py
@@ -39,7 +39,7 @@ REPORTING_DISTANCE = "10"
def decode_encoded_position_report(packet):
"""Returns a string with decoded latitude and longitude, or raises ValueError"""
- ix = packet.index(b":!/")
+ ix = packet.index(b":!")
gps_packet = packet[ix+3:]
encoded_latitude = gps_packet[:4]
encoded_longitude = gps_packet[4:8]
@@ -59,10 +59,8 @@ def send_frame_to_aprs_is(frame):
aprsauth = f"user {CALLSIGN} pass {PASSCODE} vers HB9EGM_lorapy 1.0 filter t/m/{CALLSIGN}/{REPORTING_DISTANCE}\n";
data = aprsauth.encode() + frame
- print(data)
-
r = requests.post(f"http://{APRS_IS_SERVER}:{APRS_IS_PORT}/", data=data, headers=headers)
- print(f"{r.status_code} {r.content.decode()}")
+ #print(f"{r.status_code} {r.content.decode()}")
r.raise_for_status()
@@ -115,8 +113,16 @@ try:
print("{}: {}".format(datetime.datetime.now(), packet))
#print(" {}".format(" ".join(hex(x) for x in packet)))
- if b":!/" in packet:
- print(decode_encoded_position_report(packet))
+ if b":!" in packet:
+ try:
+ print(decode_encoded_position_report(packet))
+ except Exception as e:
+ print(f"Failed to decode packet: {e}")
+
+ # :! are compressed position reports
+ # :> are messages
+ # := are uncompressed position reports
+ if any(pattern in packet for pattern in [b":!", b":>", b":="]):
try:
# Prefix igate path
path, _, message = packet[3:].partition(b":")