1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-25 20:22:10 -05:00

SDRdaemon: added data address and port options

This commit is contained in:
f4exb 2018-08-19 01:07:31 +02:00
parent 44fe60b56f
commit d7c7eb9f43
2 changed files with 52 additions and 14 deletions

View File

@ -28,30 +28,39 @@
SDRDaemonParser::SDRDaemonParser() :
m_serverAddressOption(QStringList() << "a" << "api-address",
"Web API server address.",
"address",
"API server and data (Tx) address.",
"localAddress",
"127.0.0.1"),
m_serverPortOption(QStringList() << "p" << "api-port",
"Web API server port.",
"port",
"apiPort",
"9091"),
m_dataAddressOption(QStringList() << "A" << "data-address",
"Remote data address (Rx).",
"remoteAddress",
"127.0.0.1"),
m_dataPortOption(QStringList() << "D" << "data-port",
"UDP stream data port.",
"dataPort",
"9091"),
m_deviceTypeOption(QStringList() << "T" << "device-type",
"Device type.",
"deviceType",
"TestSource"),
m_txOption(QStringList() << "t" << "tx",
"Tx indicator.",
"tx"),
"Tx indicator."),
m_serialOption(QStringList() << "s" << "serial",
"Device serial number.",
"serial"),
m_sequenceOption(QStringList() << "n" << "sequence",
"Device sequence number in enumeration for the same device type.",
"serial")
"sequence")
{
m_serverAddress = "127.0.0.1";
m_serverPort = 9091;
m_dataAddress = "127.0.0.1";
m_dataPort = 9090;
m_deviceType = "TestSource";
m_tx = false;
m_sequence = 0;
@ -64,6 +73,8 @@ SDRDaemonParser::SDRDaemonParser() :
m_parser.addOption(m_serverAddressOption);
m_parser.addOption(m_serverPortOption);
m_parser.addOption(m_dataAddressOption);
m_parser.addOption(m_dataPortOption);
m_parser.addOption(m_deviceTypeOption);
m_parser.addOption(m_txOption);
m_parser.addOption(m_serialOption);
@ -108,6 +119,27 @@ void SDRDaemonParser::parse(const QCoreApplication& app)
qWarning() << "SDRDaemonParser::parse: server port invalid. Defaulting to " << m_serverPort;
}
// data address
QString dataAddress = m_parser.value(m_dataAddressOption);
if (ipValidator.validate(dataAddress, pos) == QValidator::Acceptable) {
m_dataAddress = dataAddress;
} else {
qWarning() << "SDRDaemonParser::parse: data address invalid. Defaulting to " << m_dataAddress;
}
// server port
QString dataPortStr = m_parser.value(m_dataPortOption);
serverPort = serverPortStr.toInt(&ok);
if (ok && (serverPort > 1023) && (serverPort < 65536)) {
m_dataPort = serverPort;
} else {
qWarning() << "SDRDaemonParser::parse: data port invalid. Defaulting to " << m_dataPort;
}
// hardware Id
QString deviceType = m_parser.value(m_deviceTypeOption);

View File

@ -36,6 +36,8 @@ public:
const QString& getServerAddress() const { return m_serverAddress; }
uint16_t getServerPort() const { return m_serverPort; }
const QString& getDataAddress() const { return m_dataAddress; }
uint16_t getDataPort() const { return m_dataPort; }
const QString& getDeviceType() const { return m_deviceType; }
bool getTx() const { return m_tx; }
const QString& getSerial() const { return m_serial; }
@ -45,8 +47,10 @@ public:
bool hasSerial() const { return m_hasSerial; }
private:
QString m_serverAddress;
uint16_t m_serverPort;
QString m_serverAddress; //!< Address of interface the API and UDP data (Tx) listens on
uint16_t m_serverPort; //!< Port the API listens on
QString m_dataAddress; //!< Address of destination of UDP stream (Rx)
uint16_t m_dataPort; //!< Destination port of UDP stream (Rx) or listening port (Tx)
QString m_deviceType; //!< Identifies the type of device
bool m_tx; //!< True for Tx
QString m_serial; //!< Serial number of the device
@ -57,6 +61,8 @@ private:
QCommandLineParser m_parser;
QCommandLineOption m_serverAddressOption;
QCommandLineOption m_serverPortOption;
QCommandLineOption m_dataAddressOption;
QCommandLineOption m_dataPortOption;
QCommandLineOption m_deviceTypeOption;
QCommandLineOption m_txOption;
QCommandLineOption m_serialOption;