From 9571b0bb38f444f5b52d3b36b9efd2e8e7a331d5 Mon Sep 17 00:00:00 2001 From: Hemna Date: Fri, 16 Dec 2022 12:01:35 -0500 Subject: [PATCH] Fixed position report for webchat beacon With more testing of the webchat beaconing, found a problem with the packet format for the beacon. This patch fixes the packet format of the beacon. Also added a timeout when trying to get the GPS location in the browser, otherwise it could never come back. --- aprsd/cmds/webchat.py | 5 +---- aprsd/web/chat/static/js/gps.js | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/aprsd/cmds/webchat.py b/aprsd/cmds/webchat.py index 85397d2..4bf35f8 100644 --- a/aprsd/cmds/webchat.py +++ b/aprsd/cmds/webchat.py @@ -375,12 +375,9 @@ class SendMessageNamespace(Namespace): # 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" + f":@{time_zulu}z{lat}/{long}l 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" diff --git a/aprsd/web/chat/static/js/gps.js b/aprsd/web/chat/static/js/gps.js index e9520c6..dbe0229 100644 --- a/aprsd/web/chat/static/js/gps.js +++ b/aprsd/web/chat/static/js/gps.js @@ -10,7 +10,14 @@ function init_gps() { function getLocation() { if (navigator.geolocation) { console.log("getCurrentPosition"); - navigator.geolocation.getCurrentPosition(showPosition, showError); + try { + navigator.geolocation.getCurrentPosition( + showPosition, showError, + {timeout:3000}); + } catch(err) { + console.log("Failed to getCurrentPosition"); + console.log(err); + } } else { var msg = "Geolocation is not supported by this browser." console.log(msg); @@ -30,7 +37,7 @@ function showError(error) { msg = "Location information is unavailable." break; case error.TIMEOUT: - msg = "The request to get user location timed out." + msg = "The location fix timed out." break; case error.UNKNOWN_ERROR: msg = "An unknown error occurred." @@ -39,9 +46,11 @@ function showError(error) { console.log(msg); $.toast({ title: 'GPS Error', + class: 'warning', + position: 'middle center', message: msg, - showProgress: 'bottom', - classProgress: 'red' + showProgress: 'top', + classProgress: 'blue', }); } @@ -59,5 +68,6 @@ function showPosition(position) { classProgress: 'red' }); + console.log("Sending GPS msg") socket.emit("gps", msg); }