From 65443eb0ba373f7987531772f562e2191eaf031d Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sat, 27 Mar 2021 23:40:10 +0100 Subject: [PATCH] improve event handling --- owrx/connection.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/owrx/connection.py b/owrx/connection.py index a06e538..a3c542f 100644 --- a/owrx/connection.py +++ b/owrx/connection.py @@ -194,18 +194,23 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient): def sendBookmarks(*args): cf = configProps["center_freq"] srh = configProps["samp_rate"] / 2 - frequencyRange = (cf - srh, cf + srh) - self.write_dial_frequencies(Bandplan.getSharedInstance().collectDialFrequencies(frequencyRange)) - bookmarks = [b.__dict__() for b in Bookmarks.getSharedInstance().getBookmarks(frequencyRange)] + dial_frequencies = [] + bookmarks = [] + if "center_freq" in configProps and "samp_rate" in configProps: + frequencyRange = (cf - srh, cf + srh) + dial_frequencies = Bandplan.getSharedInstance().collectDialFrequencies(frequencyRange) + bookmarks = [b.__dict__() for b in Bookmarks.getSharedInstance().getBookmarks(frequencyRange)] + self.write_dial_frequencies(dial_frequencies) self.write_bookmarks(bookmarks) def updateBookmarkSubscription(*args): if self.bookmarkSub is not None: self.bookmarkSub.cancel() - cf = configProps["center_freq"] - srh = configProps["samp_rate"] / 2 - frequencyRange = (cf - srh, cf + srh) - self.bookmarkSub = Bookmarks.getSharedInstance().subscribe(frequencyRange, sendBookmarks) + if "center_freq" in configProps and "samp_rate" in configProps: + cf = configProps["center_freq"] + srh = configProps["samp_rate"] / 2 + frequencyRange = (cf - srh, cf + srh) + self.bookmarkSub = Bookmarks.getSharedInstance().subscribe(frequencyRange, sendBookmarks) sendBookmarks() self.configSubs.append(configProps.wire(sendConfig)) @@ -344,6 +349,7 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient): self.configSubs.pop().cancel() if self.bookmarkSub is not None: self.bookmarkSub.cancel() + self.bookmarkSub = None super().close() def stopDsp(self):