diff --git a/aprsd/clients/kiss.py b/aprsd/clients/kiss.py
index f3d85f3..79db9b7 100644
--- a/aprsd/clients/kiss.py
+++ b/aprsd/clients/kiss.py
@@ -91,21 +91,29 @@ class KISS3Client:
# payload
# )).encode('US-ASCII'),
# payload = str(msg).encode('US-ASCII')
+ payload = None
+ path = ["WIDE1-1", "WIDE2-1"]
if isinstance(msg, messaging.AckMessage):
msg_payload = f"ack{msg.id}"
+ elif isinstance(msg, messaging.RawMessage):
+ payload = msg.message.encode("US-ASCII")
+ path = ["WIDE2-1"]
else:
msg_payload = f"{msg.message}{{{str(msg.id)}"
- payload = (
- ":{:<9}:{}".format(
- msg.tocall,
- msg_payload,
- )
- ).encode("US-ASCII")
+
+ if not payload:
+ payload = (
+ ":{:<9}:{}".format(
+ msg.tocall,
+ msg_payload,
+ )
+ ).encode("US-ASCII")
+
LOG.debug(f"Send '{payload}' TO KISS")
frame = Frame.ui(
destination=msg.tocall,
source=msg.fromcall,
- path=["WIDE1-1", "WIDE2-1"],
+ path=path,
info=payload,
)
self.kiss.write(frame)
diff --git a/aprsd/cmds/webchat.py b/aprsd/cmds/webchat.py
index 15f94fc..1dbacd8 100644
--- a/aprsd/cmds/webchat.py
+++ b/aprsd/cmds/webchat.py
@@ -9,6 +9,7 @@ import threading
import time
import aprslib
+from aprslib import util as aprslib_util
import click
import flask
from flask import request
@@ -433,6 +434,32 @@ class SendMessageNamespace(Namespace):
msg.send()
# self._msg_queues["tx"].put(msg)
+ def on_gps(self, data):
+ LOG.debug(f"WS on_GPS: {data}")
+ lat = aprslib_util.latitude_to_ddm(data["latitude"])
+ long = aprslib_util.longitude_to_ddm(data["longitude"])
+ LOG.debug(f"Lat DDM {lat}")
+ LOG.debug(f"Long DDM {long}")
+
+ local_datetime = datetime.datetime.now()
+ utc_offset_timedelta = datetime.datetime.utcnow() - local_datetime
+ result_utc_datetime = local_datetime + utc_offset_timedelta
+ time_zulu = result_utc_datetime.strftime("%d%H%M")
+
+ # now construct a beacon to send over the client connection
+ txt = (
+ f"{self._config['aprs']['login']}>APZ100,WIDE2-1"
+ f":!{lat}{long}#PHG7260 APRSD WebChat Beacon"
+ )
+
+ txt = f"@{time_zulu}z{lat}1{long}$APRSD WebChat Beacon"
+
+ LOG.debug(f"Sending {txt}")
+ beacon_msg = messaging.RawMessage(txt)
+ beacon_msg.fromcall = self._config["aprs"]["login"]
+ beacon_msg.tocall = "APDW16"
+ beacon_msg.send_direct()
+
def handle_message(self, data):
LOG.debug(f"WS Data {data}")
diff --git a/aprsd/web/chat/static/js/send-message.js b/aprsd/web/chat/static/js/send-message.js
index d6b20c4..a03dad8 100644
--- a/aprsd/web/chat/static/js/send-message.js
+++ b/aprsd/web/chat/static/js/send-message.js
@@ -1,11 +1,11 @@
var cleared = false;
var callsign_list = {};
var message_list = {};
+const socket = io("/sendmsg");
function size_dict(d){c=0; for (i in d) ++c; return c}
function init_chat() {
- const socket = io("/sendmsg");
socket.on('connect', function () {
console.log("Connected to socketio");
});
@@ -44,6 +44,54 @@ function init_chat() {
socket.emit("send", msg);
$('#message').val('');
});
+
+ $("#send_beacon").click(function() {
+ console.log("Send a beacon!")
+ getLocation();
+ });
+}
+
+function getLocation() {
+ if (navigator.geolocation) {
+ console.log("getCurrentPosition");
+ navigator.geolocation.getCurrentPosition(showPosition, showError);
+ } else {
+ var msg = "Geolocation is not supported by this browser."
+ console.log(msg);
+ alert(msg)
+ }
+}
+
+function showError(error) {
+ console.log("showError");
+ console.log(error);
+ var msg = "";
+ switch(error.code) {
+ case error.PERMISSION_DENIED:
+ msg = "User denied the request for Geolocation."
+ break;
+ case error.POSITION_UNAVAILABLE:
+ msg = "Location information is unavailable."
+ break;
+ case error.TIMEOUT:
+ msg = "The request to get user location timed out."
+ break;
+ case error.UNKNOWN_ERROR:
+ msg = "An unknown error occurred."
+ break;
+ }
+ console.log(msg);
+ alert(msg);
+}
+
+function showPosition(position) {
+ console.log("showPosition Called");
+ msg = {
+ 'latitude': position.coords.latitude,
+ 'longitude': position.coords.longitude
+ }
+ console.log(msg);
+ socket.emit("gps", msg);
}
diff --git a/aprsd/web/chat/templates/index.html b/aprsd/web/chat/templates/index.html
index 7f731bd..c90f51a 100644
--- a/aprsd/web/chat/templates/index.html
+++ b/aprsd/web/chat/templates/index.html
@@ -63,6 +63,7 @@
+
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 04b358b..5b8f9fe 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -16,7 +16,7 @@ ENV LANG=C.UTF-8
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update
-RUN apt install -y git build-essential rustc cargo
+RUN apt install -y git build-essential
RUN apt install -y libffi-dev python3-dev libssl-dev libxml2-dev libxslt-dev
RUN apt install -y python3 python3-pip python3-dev python3-lxml