add parsing of DPMR data
This commit is contained in:
parent
f3d1084b60
commit
ba97f76737
@ -180,6 +180,7 @@ DStarMetaPanel.prototype.update = function(data) {
|
|||||||
this.setDeparture(data['departure']);
|
this.setDeparture(data['departure']);
|
||||||
this.setDestination(data['destination']);
|
this.setDestination(data['destination']);
|
||||||
this.setMessage(data['message']);
|
this.setMessage(data['message']);
|
||||||
|
this.setLocation(data['lat'], data['lon'], data['ourcall']);
|
||||||
} else {
|
} else {
|
||||||
this.clear();
|
this.clear();
|
||||||
}
|
}
|
||||||
@ -188,7 +189,7 @@ DStarMetaPanel.prototype.update = function(data) {
|
|||||||
DStarMetaPanel.prototype.setOurCall = function(ourcall) {
|
DStarMetaPanel.prototype.setOurCall = function(ourcall) {
|
||||||
if (this.ourcall === ourcall) return;
|
if (this.ourcall === ourcall) return;
|
||||||
this.ourcall = ourcall;
|
this.ourcall = ourcall;
|
||||||
this.el.find('.openwebrx-dstar-ourcall').text(ourcall || '');
|
this.el.find('.openwebrx-dstar-ourcall .callsign').text(ourcall || '');
|
||||||
};
|
};
|
||||||
|
|
||||||
DStarMetaPanel.prototype.setYourCall = function(yourcall) {
|
DStarMetaPanel.prototype.setYourCall = function(yourcall) {
|
||||||
@ -222,6 +223,18 @@ DStarMetaPanel.prototype.clear = function() {
|
|||||||
this.setDeparture();
|
this.setDeparture();
|
||||||
this.setDestination();
|
this.setDestination();
|
||||||
this.setMessage();
|
this.setMessage();
|
||||||
|
this.setLocation();
|
||||||
|
};
|
||||||
|
|
||||||
|
DStarMetaPanel.prototype.setLocation = function(lat, lon, callsign) {
|
||||||
|
var hasLocation = lat && lon && callsign && callsign != '';
|
||||||
|
if (hasLocation === this.hasLocation && this.callsign === callsign) return;
|
||||||
|
this.hasLocation = hasLocation; this.callsign = callsign;
|
||||||
|
var html = '';
|
||||||
|
if (hasLocation) {
|
||||||
|
html = '<a class="openwebrx-maps-pin" href="map?callsign=' + encodeURIComponent(callsign) + '" target="_blank"><svg viewBox="0 0 20 35"><use xlink:href="static/gfx/svg-defs.svg#maps-pin"></use></svg></a>';
|
||||||
|
}
|
||||||
|
this.el.find('.openwebrx-dstar-source .location').html(html);
|
||||||
};
|
};
|
||||||
|
|
||||||
MetaPanel.types = {
|
MetaPanel.types = {
|
||||||
|
47
owrx/meta.py
47
owrx/meta.py
@ -6,10 +6,21 @@ import logging
|
|||||||
import threading
|
import threading
|
||||||
from owrx.map import Map, LatLngLocation
|
from owrx.map import Map, LatLngLocation
|
||||||
from owrx.parser import Parser
|
from owrx.parser import Parser
|
||||||
|
from owrx.aprs import AprsParser, AprsLocation
|
||||||
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class Enricher(ABC):
|
||||||
|
def __init__(self, parser):
|
||||||
|
self.parser = parser
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def enrich(self, meta):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class DmrCache(object):
|
class DmrCache(object):
|
||||||
sharedInstance = None
|
sharedInstance = None
|
||||||
|
|
||||||
@ -38,8 +49,9 @@ class DmrCache(object):
|
|||||||
return self.cache[key]["data"]
|
return self.cache[key]["data"]
|
||||||
|
|
||||||
|
|
||||||
class DmrMetaEnricher(object):
|
class DmrMetaEnricher(Enricher):
|
||||||
def __init__(self):
|
def __init__(self, parser):
|
||||||
|
super().__init__(parser)
|
||||||
self.threads = {}
|
self.threads = {}
|
||||||
|
|
||||||
def downloadRadioIdData(self, id):
|
def downloadRadioIdData(self, id):
|
||||||
@ -71,10 +83,7 @@ class DmrMetaEnricher(object):
|
|||||||
return meta
|
return meta
|
||||||
|
|
||||||
|
|
||||||
class YsfMetaEnricher(object):
|
class YsfMetaEnricher(Enricher):
|
||||||
def __init__(self, parser):
|
|
||||||
self.parser = parser
|
|
||||||
|
|
||||||
def enrich(self, meta):
|
def enrich(self, meta):
|
||||||
for key in ["source", "up", "down", "target"]:
|
for key in ["source", "up", "down", "target"]:
|
||||||
if key in meta:
|
if key in meta:
|
||||||
@ -89,10 +98,34 @@ class YsfMetaEnricher(object):
|
|||||||
return meta
|
return meta
|
||||||
|
|
||||||
|
|
||||||
|
class DStarEnricher(Enricher):
|
||||||
|
def enrich(self, meta):
|
||||||
|
if "dpmr" in meta:
|
||||||
|
# we can send the DPMR stuff through our APRS parser to extract the information
|
||||||
|
# TODO: only thrid-party parsing accepts this format right now
|
||||||
|
# TODO: we also need to pass a handler, which is not needed
|
||||||
|
parser = AprsParser(None)
|
||||||
|
dprsData = parser.parseThirdpartyAprsData(meta["dpmr"])
|
||||||
|
logger.debug("decoded APRS data: %s", dprsData)
|
||||||
|
if "data" in dprsData:
|
||||||
|
data = dprsData["data"]
|
||||||
|
if "lat" in data and "lon" in data:
|
||||||
|
# TODO: we could actually get the symbols from the parsed APRS data and show that
|
||||||
|
meta["lat"] = data["lat"]
|
||||||
|
meta["lon"] = data["lon"]
|
||||||
|
|
||||||
|
if "ourcall" in meta:
|
||||||
|
# send location info to map as well
|
||||||
|
loc = AprsLocation(data)
|
||||||
|
Map.getSharedInstance().updateLocation(meta["ourcall"], loc, "APRS", self.parser.getBand())
|
||||||
|
|
||||||
|
return meta
|
||||||
|
|
||||||
|
|
||||||
class MetaParser(Parser):
|
class MetaParser(Parser):
|
||||||
def __init__(self, handler):
|
def __init__(self, handler):
|
||||||
super().__init__(handler)
|
super().__init__(handler)
|
||||||
self.enrichers = {"DMR": DmrMetaEnricher(), "YSF": YsfMetaEnricher(self)}
|
self.enrichers = {"DMR": DmrMetaEnricher(self), "YSF": YsfMetaEnricher(self), "DSTAR": DStarEnricher(self)}
|
||||||
|
|
||||||
def parse(self, meta):
|
def parse(self, meta):
|
||||||
fields = meta.split(";")
|
fields = meta.split(";")
|
||||||
|
Loading…
Reference in New Issue
Block a user