add always-on feature
This commit is contained in:
parent
036442aa69
commit
42828dbf65
@ -37,7 +37,7 @@ class SdrSource(ABC):
|
|||||||
self.activateProfile()
|
self.activateProfile()
|
||||||
self.rtlProps = self.props.collect(*self.getEventNames()).defaults(PropertyManager.getSharedInstance())
|
self.rtlProps = self.props.collect(*self.getEventNames()).defaults(PropertyManager.getSharedInstance())
|
||||||
self.wireEvents()
|
self.wireEvents()
|
||||||
self.commandMapper = CommandMapper()
|
self.commandMapper = None
|
||||||
|
|
||||||
if "port" in props and props["port"] is not None:
|
if "port" in props and props["port"] is not None:
|
||||||
self.port = props["port"]
|
self.port = props["port"]
|
||||||
@ -53,6 +53,12 @@ class SdrSource(ABC):
|
|||||||
self.state = SdrSource.STATE_STOPPED
|
self.state = SdrSource.STATE_STOPPED
|
||||||
self.busyState = SdrSource.BUSYSTATE_IDLE
|
self.busyState = SdrSource.BUSYSTATE_IDLE
|
||||||
|
|
||||||
|
if self.isAlwaysOn():
|
||||||
|
self.start()
|
||||||
|
|
||||||
|
def isAlwaysOn(self):
|
||||||
|
return "always-on" in self.props and self.props["always-on"]
|
||||||
|
|
||||||
def getEventNames(self):
|
def getEventNames(self):
|
||||||
return [
|
return [
|
||||||
"samp_rate",
|
"samp_rate",
|
||||||
@ -63,6 +69,8 @@ class SdrSource(ABC):
|
|||||||
]
|
]
|
||||||
|
|
||||||
def getCommandMapper(self):
|
def getCommandMapper(self):
|
||||||
|
if self.commandMapper is None:
|
||||||
|
self.commandMapper = CommandMapper()
|
||||||
return self.commandMapper
|
return self.commandMapper
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
@ -233,6 +241,10 @@ class SdrSource(ABC):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# no need to check for users if we are always-on
|
||||||
|
if self.isAlwaysOn():
|
||||||
|
return
|
||||||
|
|
||||||
hasUsers = self.hasClients(SdrSource.CLIENT_USER)
|
hasUsers = self.hasClients(SdrSource.CLIENT_USER)
|
||||||
hasBackgroundTasks = self.hasClients(SdrSource.CLIENT_BACKGROUND)
|
hasBackgroundTasks = self.hasClients(SdrSource.CLIENT_BACKGROUND)
|
||||||
self.setBusyState(SdrSource.BUSYSTATE_BUSY if hasUsers else SdrSource.BUSYSTATE_IDLE)
|
self.setBusyState(SdrSource.BUSYSTATE_BUSY if hasUsers else SdrSource.BUSYSTATE_IDLE)
|
||||||
|
@ -3,9 +3,8 @@ from .soapy import SoapyConnectorSource
|
|||||||
|
|
||||||
|
|
||||||
class AirspySource(SoapyConnectorSource):
|
class AirspySource(SoapyConnectorSource):
|
||||||
def __init__(self, id, props):
|
def getCommandMapper(self):
|
||||||
super().__init__(id, props)
|
return super().getCommandMapper().setMappings({"bias_tee": Flag("-t biastee=true")})
|
||||||
self.getCommandMapper().setMappings({"bias_tee": Flag("-t biastee=true")})
|
|
||||||
|
|
||||||
def getDriver(self):
|
def getDriver(self):
|
||||||
return "airspy"
|
return "airspy"
|
||||||
|
@ -10,10 +10,12 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class ConnectorSource(SdrSource):
|
class ConnectorSource(SdrSource):
|
||||||
def __init__(self, id, props):
|
def __init__(self, id, props):
|
||||||
super().__init__(id, props)
|
|
||||||
self.controlSocket = None
|
self.controlSocket = None
|
||||||
self.controlPort = getAvailablePort()
|
self.controlPort = getAvailablePort()
|
||||||
self.getCommandMapper().setMappings(
|
super().__init__(id, props)
|
||||||
|
|
||||||
|
def getCommandMapper(self):
|
||||||
|
return super().getCommandMapper().setMappings(
|
||||||
{
|
{
|
||||||
"samp_rate": Option("-s"),
|
"samp_rate": Option("-s"),
|
||||||
"tuner_freq": Option("-f"),
|
"tuner_freq": Option("-f"),
|
||||||
|
@ -8,9 +8,8 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class FifiSdrSource(DirectSource):
|
class FifiSdrSource(DirectSource):
|
||||||
def __init__(self, id, props):
|
def getCommandMapper(self):
|
||||||
super().__init__(id, props)
|
return super().getCommandMapper().setBase("arecord").setMappings(
|
||||||
self.getCommandMapper().setBase("arecord").setMappings(
|
|
||||||
{"device": Option("-D"), "samp_rate": Option("-r")}
|
{"device": Option("-D"), "samp_rate": Option("-r")}
|
||||||
).setStatic("-f S16_LE -c2 -")
|
).setStatic("-f S16_LE -c2 -")
|
||||||
|
|
||||||
|
@ -3,9 +3,8 @@ from owrx.command import Flag, Option
|
|||||||
|
|
||||||
|
|
||||||
class HackrfSource(DirectSource):
|
class HackrfSource(DirectSource):
|
||||||
def __init__(self, id, props):
|
def getCommandMapper(self):
|
||||||
super().__init__(id, props)
|
return super().getCommandMapper().setBase("hackrf_transfer").setMappings(
|
||||||
self.getCommandMapper().setBase("hackrf_transfer").setMappings(
|
|
||||||
{
|
{
|
||||||
"samp_rate": Option("-s"),
|
"samp_rate": Option("-s"),
|
||||||
"tuner_freq": Option("-f"),
|
"tuner_freq": Option("-f"),
|
||||||
|
@ -2,6 +2,5 @@ from .connector import ConnectorSource
|
|||||||
|
|
||||||
|
|
||||||
class RtlSdrSource(ConnectorSource):
|
class RtlSdrSource(ConnectorSource):
|
||||||
def __init__(self, id, props):
|
def getCommandMapper(self):
|
||||||
super().__init__(id, props)
|
return super().getCommandMapper().setBase("rtl_connector")
|
||||||
self.getCommandMapper().setBase("rtl_connector")
|
|
||||||
|
@ -5,9 +5,8 @@ from .connector import ConnectorSource
|
|||||||
|
|
||||||
|
|
||||||
class SoapyConnectorSource(ConnectorSource, metaclass=ABCMeta):
|
class SoapyConnectorSource(ConnectorSource, metaclass=ABCMeta):
|
||||||
def __init__(self, id, props):
|
def getCommandMapper(self):
|
||||||
super().__init__(id, props)
|
return super().getCommandMapper().setBase("soapy_connector").setMappings({"antenna": Option("-a")})
|
||||||
self.getCommandMapper().setBase("soapy_connector").setMappings({"antenna": Option("-a")})
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
must be implemented by child classes to be able to build a driver-based device selector by default.
|
must be implemented by child classes to be able to build a driver-based device selector by default.
|
||||||
|
Loading…
Reference in New Issue
Block a user