allow to work through soapyRemote driver

This commit is contained in:
Alexander Sholohov 2023-10-31 21:10:35 +07:00
parent 79c199d905
commit 08c5c97dcb

View file

@ -1,7 +1,9 @@
from owrx.source.soapy import SoapyConnectorSource, SoapyConnectorDeviceDescription from owrx.source.soapy import SoapyConnectorSource, SoapyConnectorDeviceDescription
from owrx.form.input import Input, CheckboxInput, NumberInput from owrx.form.input import Input, CheckboxInput, NumberInput
from owrx.form.input.device import RemoteInput from owrx.form.input.device import RemoteInput, TextInput
from owrx.form.input.validator import RangeValidator from owrx.form.input.validator import RangeValidator
from owrx.form.input.converter import OptionalConverter
from owrx.form.input.validator import RequiredValidator
from typing import List from typing import List
@ -9,6 +11,17 @@ AFEDRI_DEVICE_KEYS = ["rx_mode", "map_ch0"]
AFEDRI_PROFILE_KEYS = ["r820t_lna_agc", "r820t_mixer_agc"] AFEDRI_PROFILE_KEYS = ["r820t_lna_agc", "r820t_mixer_agc"]
class AfedriAddressPortInput(TextInput):
def __init__(self):
super().__init__(
"afedri_adress_port",
"Afedri IP and Port",
infotext="Afedri IP and port to connect to. Format = IP:Port",
converter=OptionalConverter(),
validator=RequiredValidator(),
)
class AfedriSource(SoapyConnectorSource): class AfedriSource(SoapyConnectorSource):
def getSoapySettingsMappings(self): def getSoapySettingsMappings(self):
mappings = super().getSoapySettingsMappings() mappings = super().getSoapySettingsMappings()
@ -16,16 +29,20 @@ class AfedriSource(SoapyConnectorSource):
return mappings return mappings
def getEventNames(self): def getEventNames(self):
return super().getEventNames() + ["remote"] + AFEDRI_DEVICE_KEYS return super().getEventNames() + ["remote", "afedri_adress_port"] + AFEDRI_DEVICE_KEYS
def getDriver(self): def getDriver(self):
return "afedri" return "afedri"
def buildSoapyDeviceParameters(self, parsed, values): def buildSoapyDeviceParameters(self, parsed, values):
params = super().buildSoapyDeviceParameters(parsed, values) params = super().buildSoapyDeviceParameters(parsed, values)
params = [v for v in params if not "remote" in params]
remote = values["remote"] # replace driver with sopayRemote
address, port = remote.split(":") if "remote" in values:
params = [v for v in params if "driver" not in v] # remove present driver
params += [{"driver": "remote", "remote:driver": self.getDriver(), "remote": values["remote"]}]
address, port = values["afedri_adress_port"].split(":")
params += [{"address": address, "port": port}] params += [{"address": address, "port": port}]
can_be_set_at_start = AFEDRI_DEVICE_KEYS can_be_set_at_start = AFEDRI_DEVICE_KEYS
@ -51,6 +68,7 @@ class AfedriDeviceDescription(SoapyConnectorDeviceDescription):
def getInputs(self) -> List[Input]: def getInputs(self) -> List[Input]:
return super().getInputs() + [ return super().getInputs() + [
RemoteInput(), RemoteInput(),
AfedriAddressPortInput(),
CheckboxInput( CheckboxInput(
"r820t_lna_agc", "r820t_lna_agc",
"Enable R820T LNA AGC", "Enable R820T LNA AGC",
@ -75,10 +93,10 @@ class AfedriDeviceDescription(SoapyConnectorDeviceDescription):
] ]
def getDeviceMandatoryKeys(self): def getDeviceMandatoryKeys(self):
return super().getDeviceMandatoryKeys() + ["remote"] return super().getDeviceMandatoryKeys() + ["afedri_adress_port"]
def getDeviceOptionalKeys(self): def getDeviceOptionalKeys(self):
return super().getDeviceOptionalKeys() + AFEDRI_DEVICE_KEYS return super().getDeviceOptionalKeys() + ["remote"] + AFEDRI_DEVICE_KEYS
def getProfileOptionalKeys(self): def getProfileOptionalKeys(self):
return super().getProfileOptionalKeys() + AFEDRI_PROFILE_KEYS return super().getProfileOptionalKeys() + AFEDRI_PROFILE_KEYS