From 8fa17960379fa689b2dc618160a4697975c6d997 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sat, 20 Mar 2021 23:30:09 +0100 Subject: [PATCH] re-start connection sdr if no sdr was available before --- owrx/connection.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/owrx/connection.py b/owrx/connection.py index 827269c..c90e41b 100644 --- a/owrx/connection.py +++ b/owrx/connection.py @@ -162,7 +162,7 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient): self.write_modes(modes) self._sendProfiles() - SdrService.getActiveSources().wire(self._sendProfiles) + SdrService.getActiveSources().wire(self._onSdrDeviceChanges) CpuUsageThread.getSharedInstance().add_client(self) @@ -239,7 +239,13 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient): def getClientClass(self) -> SdrClientClass: return SdrClientClass.USER - def _sendProfiles(self, *args): + def _onSdrDeviceChanges(self, changes): + self._sendProfiles() + # restart the client if an sdr has become available + if self.sdr is None and any(s is not PropertyDeleted for s in changes.values()): + self.setSdr() + + def _sendProfiles(self): profiles = [ {"name": s.getName() + " " + p["name"], "id": sid + "|" + pid} for (sid, s) in SdrService.getActiveSources().items() @@ -302,13 +308,14 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient): if self.sdr is not None: self.sdr.removeClient(self) + self.sdr = next + if next is None: # exit condition: no sdrs available logger.warning("no more SDR devices available") self.handleNoSdrsAvailable() return - self.sdr = next self.sdr.addClient(self) def handleSdrAvailable(self):