allow underlying mode to be specified in bandplan

This commit is contained in:
Jakob Ketterl
2023-02-28 15:30:31 +01:00
parent cb5b2e64af
commit a54a5fd560
3 changed files with 44 additions and 20 deletions

View File

@@ -123,13 +123,11 @@ class ServiceHandler(SdrSourceEventClient):
def updateServices(self):
def addService(dial, source):
mode = dial["mode"]
frequency = dial["frequency"]
try:
service = self.setupService(mode, frequency, source)
service = self.setupService(dial, source)
self.services.append(service)
except Exception:
logger.exception("Error setting up service %s on frequency %d", mode, frequency)
logger.exception("Error setting up service {mode} on frequency {frequency}".format(**dial))
with self.lock:
logger.debug("re-scheduling services due to sdr changes")
@@ -247,23 +245,26 @@ class ServiceHandler(SdrSourceEventClient):
return None
return best["groups"]
def setupService(self, mode, frequency, source):
logger.debug("setting up service {0} on frequency {1}".format(mode, frequency))
def setupService(self, dial, source):
logger.debug("setting up service {mode} on frequency {frequency}".format(**dial))
modeObject = Modes.findByModulation(mode)
modeObject = Modes.findByModulation(dial["mode"])
if not isinstance(modeObject, DigitalMode):
logger.warning("mode is not a digimode: %s", mode)
logger.warning("mode is not a digimode: %s", dial["mode"])
return None
if "underlying" in dial:
modeObject = modeObject.for_underlying(dial["underlying"])
demod = self._getDemodulator(modeObject.get_modulation())
secondaryDemod = self._getSecondaryDemodulator(modeObject.modulation)
center_freq = source.getProps()["center_freq"]
sampleRate = source.getProps()["samp_rate"]
bandpass = modeObject.get_bandpass()
if isinstance(secondaryDemod, DialFrequencyReceiver):
secondaryDemod.setDialFrequency(frequency)
secondaryDemod.setDialFrequency(dial["frequency"])
chain = ServiceDemodulatorChain(demod, secondaryDemod, sampleRate, frequency - center_freq)
chain = ServiceDemodulatorChain(demod, secondaryDemod, sampleRate, dial["frequency"] - center_freq)
chain.setBandPass(bandpass.low_cut, bandpass.high_cut)
chain.setReader(source.getBuffer().getReader())