diff --git a/owrx/connection.py b/owrx/connection.py index da6365d1..ab0cabb8 100644 --- a/owrx/connection.py +++ b/owrx/connection.py @@ -142,6 +142,11 @@ class OpenWebRxReceiverClient(Client): def setSdr(self, id=None): next = SdrService.getSource(id) + + if next is None: + self.handleSdrFailure("sdr device failed") + return + if next == self.sdr: return @@ -180,6 +185,9 @@ class OpenWebRxReceiverClient(Client): self.sdr.addSpectrumClient(self) + def handleSdrFailure(self, message): + self.write_sdr_error(message) + def startDsp(self): if self.dsp is None: self.dsp = DspManager(self, self.sdr) diff --git a/owrx/source.py b/owrx/source.py index 80e125c6..2d576ce1 100644 --- a/owrx/source.py +++ b/owrx/source.py @@ -76,10 +76,14 @@ class SdrService(object): def getSource(id=None): SdrService.loadProps() sources = SdrService.getSources() + if not sources: + return None if id is None: # TODO: configure default sdr in config? right now it will pick the first one off the list. id = list(sources.keys())[0] + if not id in sources: + return None return sources[id] @staticmethod @@ -654,7 +658,7 @@ class DspManager(csdr.output): def onSdrFailed(self): logger.debug("received onSdrFailed, shutting down DspSource") self.dsp.stop() - self.handler.write_sdr_error("sdr failed") + self.handler.handleSdrFailure("sdr device failed") class CpuUsageThread(threading.Thread):