aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2023-07-24 14:16:33 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2023-07-24 14:16:33 +0200
commitfb795285ca99d2c7d66a0771b4859e1fa5967da1 (patch)
treeca508a3f2e0ad7227b3642aa9aa45dd834bbc20f /python
parent4d169139e964884e30cc6b24153a783964cf2eb8 (diff)
downloadlora-aprs-hb9egm-fb795285ca99d2c7d66a0771b4859e1fa5967da1.tar.gz
lora-aprs-hb9egm-fb795285ca99d2c7d66a0771b4859e1fa5967da1.tar.bz2
lora-aprs-hb9egm-fb795285ca99d2c7d66a0771b4859e1fa5967da1.zip
Add decode_gps.py experiment
Diffstat (limited to 'python')
-rwxr-xr-xpython/experiments/decode_gps.py23
-rwxr-xr-xpython/igate.py5
2 files changed, 27 insertions, 1 deletions
diff --git a/python/experiments/decode_gps.py b/python/experiments/decode_gps.py
new file mode 100755
index 0000000..da7904a
--- /dev/null
+++ b/python/experiments/decode_gps.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+import struct
+from math import pow
+
+EXAMPLE_MSG = b"<\xff\x01HB9EGM-7>APLRT1,WIDE1-1:!/7%=6P\')8[I#Q"
+
+def decodeEncodedGPS(packet):
+ """Returns a string with decoded latitude and longitude, or raises ValueError"""
+ ix = packet.index(b":!/")
+ gps_packet = packet[ix+3:]
+ encoded_latitude = gps_packet[:4]
+ encoded_longitude = gps_packet[4:8]
+
+ (y1, y2, y3, y4) = struct.unpack("<bbbb", encoded_latitude)
+
+ decodedLatitude = 90.0 - ((((y1-33) * pow(91,3)) + ((y2-33) * pow(91,2)) + ((y3-33) * 91) + y4-33) / 380926.0);
+
+ (x1, x2, x3, x4) = struct.unpack("<bbbb", encoded_longitude)
+
+ decodedLongitude = -180.0 + ((((x1-33) * pow(91,3)) + ((x2-33) * pow(91,2)) + ((x3-33) * 91) + x4-33) / 190463.0);
+ return f"{decodedLatitude}N / {decodedLongitude}E"
+
+print(decodeEncodedGPS(EXAMPLE_MSG))
diff --git a/python/igate.py b/python/igate.py
index 91edbcc..7c2e131 100755
--- a/python/igate.py
+++ b/python/igate.py
@@ -26,6 +26,9 @@ APRS_IS_SERVER = "france.aprs2.net"
APRS_IS_PORT = 8080
CALLSIGN = "HB9EGM-10"
+# See https://github.com/aprsorg/aprs-deviceid/blob/main/ALLOCATING.md
+APRS_DEVICEID = "APZEGM"
+
# 46°23.07' N 6°13.28'
LATITUDE = "4623.07N"
LONGITUDE = "00613.28E"
@@ -132,7 +135,7 @@ try:
if last_beacon_time + 1800 < now:
last_beacon_time = now
- packet = f"{CALLSIGN}>APLRG1,qAC:={LATITUDE}L{LONGITUDE}&{COMMENT}"
+ packet = f"{CALLSIGN}>{APRS_DEVICEID},qAC:={LATITUDE}L{LONGITUDE}&{COMMENT}"
try:
send_frame_to_aprs_is(packet.encode())
except Exception as ex: