diff --git a/sdrdaemon/sdrdaemonparser.cpp b/sdrdaemon/sdrdaemonparser.cpp index 7048fa0d1..6d9d71fd9 100644 --- a/sdrdaemon/sdrdaemonparser.cpp +++ b/sdrdaemon/sdrdaemonparser.cpp @@ -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); diff --git a/sdrdaemon/sdrdaemonparser.h b/sdrdaemon/sdrdaemonparser.h index 7378adf79..fb794ee80 100644 --- a/sdrdaemon/sdrdaemonparser.h +++ b/sdrdaemon/sdrdaemonparser.h @@ -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,18 +47,22 @@ public: bool hasSerial() const { return m_hasSerial; } private: - QString m_serverAddress; - uint16_t m_serverPort; - QString m_deviceType; //!< Identifies the type of device - bool m_tx; //!< True for Tx - QString m_serial; //!< Serial number of the device - uint16_t m_sequence; //!< Sequence of the device for the same type of device in enumeration process - bool m_hasSerial; //!< True if serial was specified - bool m_hasSequence; //!< True if sequence was specified + 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 + uint16_t m_sequence; //!< Sequence of the device for the same type of device in enumeration process + bool m_hasSerial; //!< True if serial was specified + bool m_hasSequence; //!< True if sequence was specified QCommandLineParser m_parser; QCommandLineOption m_serverAddressOption; QCommandLineOption m_serverPortOption; + QCommandLineOption m_dataAddressOption; + QCommandLineOption m_dataPortOption; QCommandLineOption m_deviceTypeOption; QCommandLineOption m_txOption; QCommandLineOption m_serialOption;