Added device-specific option to disable profile changes without a key.

This commit is contained in:
Marat Fayzullin 2023-06-04 12:23:28 -04:00
parent d02727a147
commit c174cef20e
3 changed files with 7 additions and 5 deletions

View File

@ -305,6 +305,8 @@ class OpenWebRxReceiverClient(OpenWebRxClient, SdrSourceEventClient):
self.setSdr(profile[0])
if not self.sdr.isLocked() or magic == "" or key == magic:
self.sdr.activateProfile(profile[1])
else:
self.sdr.activateProfile(self.sdr.getProfileId(), force=True)
elif message["type"] == "setfrequency":
# If the magic key is set in the settings, only allow
# changes if it matches the received key

View File

@ -406,7 +406,7 @@ class PropertyCarousel(PropertyDelegator):
self.switch()
del self.layers[key]
def switch(self, key=None):
def switch(self, key=None, force=False):
before = self.pm
self.subscription.cancel()
self.pm = self._getDefaultLayer() if key is None else self.layers[key]
@ -416,6 +416,6 @@ class PropertyCarousel(PropertyDelegator):
if key not in self:
changes[key] = PropertyDeleted
else:
if key not in before or before[key] != self[key]:
if key not in before or before[key] != self[key] or force:
changes[key] = self[key]
self._fireCallbacks(changes)

View File

@ -239,10 +239,10 @@ class SdrSource(ABC):
def getCommand(self):
return [self.getCommandMapper().map(self.getCommandValues())]
def activateProfile(self, profile_id):
def activateProfile(self, profile_id, force=False):
logger.debug("activating profile {0} for {1}".format(profile_id, self.getId()))
try:
self.profileCarousel.switch(profile_id)
self.profileCarousel.switch(profile_id, force=force)
self.setCenterFreq(self.profileCarousel["center_freq"])
except KeyError:
logger.warning("invalid profile %s for sdr %s. ignoring", profile_id, self.getId())
@ -574,7 +574,7 @@ class SdrDeviceDescription(object):
),
CheckboxInput(
"key_locked",
"Protect access to this device with a magic key",
"Require magic key to switch profiles on this device",
),
GainInput("rf_gain", "Device gain", self.hasAgc()),
NumberInput(