collect dial frequencies and send to client

This commit is contained in:
Jakob Ketterl 2019-07-19 23:55:52 +02:00
parent 6e08a428d6
commit abd5cf0795
2 changed files with 18 additions and 1 deletions

View File

@ -18,7 +18,7 @@ class Band(object):
if not self.inBand(f): if not self.inBand(f):
logger.warning("Frequency for {mode} on {band} is not within band limits: {frequency}".format(mode = mode, frequency = f, band = self.name)) logger.warning("Frequency for {mode} on {band} is not within band limits: {frequency}".format(mode = mode, frequency = f, band = self.name))
else: else:
self.frequencies.append([{"mode": mode, "frequency": f}]) self.frequencies.append({"mode": mode, "frequency": f})
def inBand(self, freq): def inBand(self, freq):
return self.lower_bound <= freq <= self.upper_bound return self.lower_bound <= freq <= self.upper_bound
@ -26,6 +26,10 @@ class Band(object):
def getName(self): def getName(self):
return self.name return self.name
def getDialFrequencies(self, range):
(low, hi) = range
return [e for e in self.frequencies if low <= e["frequency"] <= hi]
class Bandplan(object): class Bandplan(object):
sharedInstance = None sharedInstance = None
@ -43,3 +47,6 @@ class Bandplan(object):
def findBand(self, freq): def findBand(self, freq):
return next(band for band in self.bands if band.inBand(freq)) return next(band for band in self.bands if band.inBand(freq))
def collectDialFrequencis(self, range):
return [e for b in self.bands for e in b.getDialFrequencies(range)]

View File

@ -2,6 +2,7 @@ from owrx.config import PropertyManager
from owrx.source import DspManager, CpuUsageThread, SdrService, ClientRegistry from owrx.source import DspManager, CpuUsageThread, SdrService, ClientRegistry
from owrx.feature import FeatureDetector from owrx.feature import FeatureDetector
from owrx.version import openwebrx_version from owrx.version import openwebrx_version
from owrx.bands import Bandplan
import json import json
from owrx.map import Map from owrx.map import Map
@ -83,6 +84,12 @@ class OpenWebRxReceiverClient(Client):
config["start_offset_freq"] = configProps["start_freq"] - configProps["center_freq"] config["start_offset_freq"] = configProps["start_freq"] - configProps["center_freq"]
self.write_config(config) self.write_config(config)
cf = configProps["center_freq"]
srh = configProps["samp_rate"] / 2
frequencyRange = (cf - srh, cf + srh)
self.write_dial_frequendies(Bandplan.getSharedInstance().collectDialFrequencis(frequencyRange))
self.configSub = configProps.wire(sendConfig) self.configSub = configProps.wire(sendConfig)
sendConfig(None, None) sendConfig(None, None)
@ -162,6 +169,9 @@ class OpenWebRxReceiverClient(Client):
def write_wsjt_message(self, message): def write_wsjt_message(self, message):
self.protected_send({"type": "wsjt_message", "value": message}) self.protected_send({"type": "wsjt_message", "value": message})
def write_dial_frequendies(self, frequencies):
self.protected_send({"type": "dial_frequencies", "value": frequencies})
class MapConnection(Client): class MapConnection(Client):
def __init__(self, conn): def __init__(self, conn):