From 772f4136b384ed82387206533170a054fecf89ba Mon Sep 17 00:00:00 2001 From: Marat Fayzullin Date: Sun, 24 Mar 2024 12:58:17 -0400 Subject: [PATCH] Introduced way to get available profile names in order. --- owrx/connection.py | 3 ++- owrx/sdr.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/owrx/connection.py b/owrx/connection.py index 85271c0e..8868dc22 100644 --- a/owrx/connection.py +++ b/owrx/connection.py @@ -290,7 +290,8 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient): self.setSdr() def _sendProfiles(self, *args): - profiles = [{"id": pid, "name": name} for pid, name in SdrService.getAvailableProfiles().items()] +# profiles = [{"id": pid, "name": name} for pid, name in SdrService.getAvailableProfiles().items()] + profiles = [{"id": pid, "name": name} for pid, name in SdrService.getAvailableProfileNames().items()] self.write_profiles(profiles) def handleTextMessage(self, conn, message): diff --git a/owrx/sdr.py b/owrx/sdr.py index 3169b9b1..147338d0 100644 --- a/owrx/sdr.py +++ b/owrx/sdr.py @@ -272,3 +272,15 @@ class SdrService(object): def stopAllSources(): for source in SdrService.getAllSources().values(): source.stop() + + # This function always returns sources and profiles in the same order + # they are stored in the corresponding property layers, as opposed to + # the AvailableProfiles class. + @staticmethod + def getAvailableProfileNames(): + result = {} + for s_id, source in SdrService.getAllSources().items(): + if source.isEnabled() and not source.isFailed(): + for p_id, profile in source.getProfiles().items(): + result["{}|{}".format(s_id, p_id)] = "{} {}".format(source.getName(), profile["name"]) + return result