diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index 240374b..020f3c1 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -1158,6 +1158,7 @@ debug_ws_data_received=0; debug_ws_time_start = 0; max_clients_num=0; client_num = 0; +var currentprofile; var COMPRESS_FFT_PAD_N=10; //should be the same as in csdr.c @@ -1210,6 +1211,9 @@ function on_ws_recv(evt) } } waterfall_clear(); + + currentprofile = config.profile_id; + $('#openwebrx-sdr-profiles-listbox').val(currentprofile); break; case "secondary_config": window.secondary_fft_size = json.value.secondary_fft_size; @@ -1241,6 +1245,9 @@ function on_ws_recv(evt) listbox.innerHTML = json.value.map(function(profile){ return '"; }).join(""); + if (currentprofile) { + $('#openwebrx-sdr-profiles-listbox').val(currentprofile); + } break; case "features": for (var feature in json.value) { diff --git a/owrx/connection.py b/owrx/connection.py index f7f8dc5..cea86ce 100644 --- a/owrx/connection.py +++ b/owrx/connection.py @@ -164,6 +164,8 @@ class OpenWebRxReceiverClient(Client): config = dict((key, configProps[key]) for key in OpenWebRxReceiverClient.config_keys) # TODO mathematical properties? hmmmm config["start_offset_freq"] = configProps["start_freq"] - configProps["center_freq"] + # TODO this is a hack that only works because setting the profile always causes plenty of config change + config["profile_id"] = self.sdr.getId() + "|" + self.sdr.getProfileId() self.write_config(config) cf = configProps["center_freq"] diff --git a/owrx/source.py b/owrx/source.py index 428955c..4b7fe5c 100644 --- a/owrx/source.py +++ b/owrx/source.py @@ -89,7 +89,7 @@ class SdrService(object): props = SdrService.sdrProps[id] className = "".join(x for x in props["type"].title() if x.isalnum()) + "Source" cls = getattr(sys.modules[__name__], className) - SdrService.sources[id] = cls(props, SdrService.getNextPort()) + SdrService.sources[id] = cls(id, props, SdrService.getNextPort()) return SdrService.sources @@ -98,8 +98,10 @@ class SdrSourceException(Exception): class SdrSource(object): - def __init__(self, props, port): + def __init__(self, id, props, port): + self.id = id self.props = props + self.profile_id = None self.activateProfile() self.rtlProps = self.props.collect( "samp_rate", "nmux_memory", "center_freq", "ppm", "rf_gain", "lna_gain", "rf_amp", "antenna", "if_gain" @@ -131,7 +133,10 @@ class SdrSource(object): profiles = self.props["profiles"] if profile_id is None: profile_id = list(profiles.keys())[0] + if profile_id == self.profile_id: + return; logger.debug("activating profile {0}".format(profile_id)) + self.profile_id = profile_id profile = profiles[profile_id] for (key, value) in profile.items(): # skip the name, that would overwrite the source name. @@ -139,6 +144,12 @@ class SdrSource(object): continue self.props[key] = value + def getId(self): + return self.id + + def getProfileId(self): + return self.profile_id + def getProfiles(self): return self.props["profiles"] @@ -291,7 +302,7 @@ class Resampler(SdrSource): props["samp_rate"] = if_samp_rate self.sdr = sdr - super().__init__(props, port) + super().__init__(None, props, port) def start(self): self.modificationLock.acquire()