send messages to frontend, spots to pskreporter

This commit is contained in:
Jakob Ketterl 2020-04-14 21:10:35 +02:00
parent bcb8a2315c
commit 2de0cbc6c0
3 changed files with 30 additions and 8 deletions

View File

@ -13,6 +13,7 @@ from owrx.locator import Locator
from owrx.property import PropertyStack
from multiprocessing import Queue
from queue import Full
from js8py import Js8Frame
import json
import threading
@ -333,6 +334,15 @@ class OpenWebRxReceiverClient(Client):
def write_backoff_message(self, reason):
self.send({"type": "backoff", "reason": reason})
def write_js8_message(self, frame: Js8Frame, freq: int):
self.send({"type": "js8_message", "value": {
"msg": str(frame),
"timestamp": frame.timestamp,
"db": frame.db,
"dt": frame.dt,
"freq": freq + frame.freq,
}})
class MapConnection(Client):
def __init__(self, conn):

View File

@ -2,7 +2,9 @@ from .wsjt import WsjtChopper
from .parser import Parser
import re
from js8py import Js8
from js8py.frames import Js8FrameDirected, Js8FrameData, Js8FrameDataCompressed
from js8py.frames import Js8FrameHeartbeat
from owrx.map import Map, LocatorLocation
from owrx.pskreporter import PskReporter
import logging
@ -36,12 +38,22 @@ class Js8Parser(Parser):
logger.debug(msg)
frame = Js8().parse_message(msg)
if frame is None:
logger.warning("message could not be parsed")
elif isinstance(frame, Js8FrameDirected):
logger.debug("directed frame from: {0} to: {1}".format(frame.callsign_from, frame.callsign_to))
elif isinstance(frame, Js8FrameData) or isinstance(frame, Js8FrameDataCompressed):
logger.debug("message frame: {0}".format(frame.message))
self.handler.write_js8_message(frame, self.dial_freq)
logger.debug(frame)
if isinstance(frame, Js8FrameHeartbeat):
Map.getSharedInstance().updateLocation(
frame.callsign, LocatorLocation(frame.grid), "JS8", self.band
)
PskReporter.getSharedInstance().spot({
"callsign": frame.callsign,
"mode": "JS8",
"locator": frame.grid,
"freq": self.dial_freq + frame.freq,
"db": frame.db,
"timestamp": frame.timestamp,
"msg": str(frame)
})
except Exception:
logger.exception("error while parsing js8 message")

View File

@ -30,7 +30,7 @@ class PskReporter(object):
sharedInstance = None
creationLock = threading.Lock()
interval = 300
supportedModes = ["FT8", "FT4", "JT9", "JT65"]
supportedModes = ["FT8", "FT4", "JT9", "JT65", "JS8"]
@staticmethod
def getSharedInstance():