diff options
-rwxr-xr-x | python/igate.py | 18 |
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":") |