server side: send only changed config keys

This commit is contained in:
Jakob Ketterl 2020-12-30 17:17:14 +01:00
parent abb0813948
commit 29703d10b2

View File

@ -248,7 +248,6 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient):
self.sdr.addClient(self)
def handleSdrAvailable(self):
# send initial config
self.getDsp().setProperties(self.connectionProperties)
stack = PropertyStack()
@ -256,14 +255,19 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient):
stack.addLayer(1, Config.get())
configProps = stack.filter(*OpenWebRxReceiverClient.config_keys)
def sendConfig(key, value):
def sendConfig(changes=None):
if changes is None:
config = configProps.__dict__()
# TODO mathematical properties? hmmmm
else:
config = changes
if changes is None or "start_freq" in changes or "center_freq" in changes:
config["start_offset_freq"] = configProps["start_freq"] - configProps["center_freq"]
# TODO this is a hack to support multiple sdrs
if changes is None or "profile_id" in changes:
config["sdr_id"] = self.sdr.getId()
self.write_config(config)
# TODO make a separate subscription for this
if changes is None or "center_freq" in changes or "samp_rate" in changes:
cf = configProps["center_freq"]
srh = configProps["samp_rate"] / 2
frequencyRange = (cf - srh, cf + srh)
@ -272,7 +276,9 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient):
self.write_bookmarks(bookmarks)
self.configSub = configProps.wire(sendConfig)
sendConfig(None, None)
# send initial config
sendConfig()
self.__sendProfiles()
self.sdr.addSpectrumClient(self)