2021-02-20 17:09:24 +00:00
|
|
|
from owrx.source.connector import ConnectorSource, ConnectorDeviceDescription
|
|
|
|
from owrx.command import Option
|
2021-05-11 15:21:52 +00:00
|
|
|
from owrx.form.error import ValidationError
|
2021-05-11 00:35:49 +00:00
|
|
|
from owrx.form.input import Input, NumberInput, TextInput
|
2021-05-11 15:21:52 +00:00
|
|
|
from owrx.form.input.validator import RangeValidator
|
2021-05-11 00:35:49 +00:00
|
|
|
from typing import List
|
2020-11-02 12:11:54 +00:00
|
|
|
|
|
|
|
# In order to use an HPSDR radio, you must install hpsdrconnector from https://github.com/jancona/hpsdrconnector
|
|
|
|
# These are the command line options available:
|
|
|
|
# --frequency uint
|
|
|
|
# Tune to specified frequency in Hz (default 7100000)
|
|
|
|
# --gain uint
|
|
|
|
# LNA gain between 0 (-12dB) and 60 (48dB) (default 20)
|
|
|
|
# --radio string
|
|
|
|
# IP address of radio (default use first radio discovered)
|
|
|
|
# --samplerate uint
|
|
|
|
# Use the specified samplerate: one of 48000, 96000, 192000, 384000 (default 96000)
|
2020-11-10 00:19:34 +00:00
|
|
|
# --debug
|
|
|
|
# Emit debug log messages on stdout
|
2020-11-02 12:11:54 +00:00
|
|
|
#
|
|
|
|
# If you omit `remote` from config_webrx.py, hpsdrconnector will use the HPSDR discovery protocol
|
|
|
|
# to find radios on your local network and will connect to the first radio it discovered.
|
|
|
|
|
2021-01-20 16:01:46 +00:00
|
|
|
|
2020-11-10 00:19:34 +00:00
|
|
|
class HpsdrSource(ConnectorSource):
|
2020-11-02 12:11:54 +00:00
|
|
|
def getCommandMapper(self):
|
2020-11-10 00:19:34 +00:00
|
|
|
return (
|
|
|
|
super()
|
|
|
|
.getCommandMapper()
|
|
|
|
.setBase("hpsdrconnector")
|
|
|
|
.setMappings(
|
2021-01-20 16:01:46 +00:00
|
|
|
{
|
|
|
|
"tuner_freq": Option("--frequency"),
|
|
|
|
"samp_rate": Option("--samplerate"),
|
|
|
|
"remote": Option("--radio"),
|
|
|
|
"rf_gain": Option("--gain"),
|
|
|
|
}
|
|
|
|
)
|
2020-11-02 12:11:54 +00:00
|
|
|
)
|
2021-02-20 17:09:24 +00:00
|
|
|
|
2021-05-11 00:35:49 +00:00
|
|
|
class RemoteInput(TextInput):
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__(
|
|
|
|
"remote", "Remote IP", infotext="Remote IP address to connect to."
|
|
|
|
)
|
2021-02-20 17:09:24 +00:00
|
|
|
|
|
|
|
class HpsdrDeviceDescription(ConnectorDeviceDescription):
|
2021-04-17 15:42:08 +00:00
|
|
|
def getName(self):
|
|
|
|
return "HPSDR devices (Hermes / Hermes Lite 2 / Red Pitaya)"
|
2021-05-11 00:35:49 +00:00
|
|
|
|
|
|
|
def getInputs(self) -> List[Input]:
|
2021-05-11 15:21:52 +00:00
|
|
|
return super().getInputs() + [
|
|
|
|
RemoteInput(),
|
|
|
|
NumberInput("rf_gain", "LNA Gain", "LNA gain between 0 (-12dB) and 60 (48dB)", validator=RangeValidator(0, 60)),
|
2021-05-11 00:35:49 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
def getDeviceOptionalKeys(self):
|
|
|
|
return list(filter(lambda x : x not in ["rtltcp_compat", "iqswap"], super().getDeviceOptionalKeys())) + ["remote"]
|
|
|
|
|
|
|
|
def getProfileOptionalKeys(self):
|
|
|
|
return list(filter(lambda x : x != "iqswap", super().getProfileOptionalKeys()))
|
|
|
|
|