1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-04 07:51:14 -05:00

Add support for settings keys.

Bind to requested interface.
Set RTLSDR device ID according to tuner type.
This commit is contained in:
Jon Beniston 2023-09-15 09:30:49 +01:00
parent d76521ef9a
commit a278cf0373
12 changed files with 297 additions and 146 deletions

View File

@ -30,7 +30,7 @@ Specifies number of bits per I/Q sample transmitted via TCP/IP.
<h3>5: IP address</h3>
IP address of the local network interface on which the server will listen for TCP/IP connections from network clients.
IP address of the local network interface on which the server will listen for TCP/IP connections from network clients. Use 0.0.0.0 for any interface.
<h3>6: Port</h3>

View File

@ -56,7 +56,7 @@ RemoteTCPSink::RemoteTCPSink(DeviceAPI *deviceAPI) :
m_basebandSink->setMessageQueueToChannel(&m_inputMessageQueue);
m_basebandSink->moveToThread(&m_thread);
applySettings(m_settings, true);
applySettings(m_settings, QStringList(), true);
m_deviceAPI->addChannelSink(this);
m_deviceAPI->addChannelSinkAPI(this);
@ -147,7 +147,7 @@ bool RemoteTCPSink::handleMessage(const Message& cmd)
{
MsgConfigureRemoteTCPSink& cfg = (MsgConfigureRemoteTCPSink&) cmd;
qDebug() << "RemoteTCPSink::handleMessage: MsgConfigureRemoteTCPSink";
applySettings(cfg.getSettings(), cfg.getForce(), cfg.getRemoteChange());
applySettings(cfg.getSettings(), cfg.getSettingsKeys(), cfg.getForce(), cfg.getRemoteChange());
return true;
}
@ -183,14 +183,14 @@ bool RemoteTCPSink::deserialize(const QByteArray& data)
(void) data;
if (m_settings.deserialize(data))
{
MsgConfigureRemoteTCPSink *msg = MsgConfigureRemoteTCPSink::create(m_settings, true);
MsgConfigureRemoteTCPSink *msg = MsgConfigureRemoteTCPSink::create(m_settings, QStringList(), true);
m_inputMessageQueue.push(msg);
return true;
}
else
{
m_settings.resetToDefaults();
MsgConfigureRemoteTCPSink *msg = MsgConfigureRemoteTCPSink::create(m_settings, true);
MsgConfigureRemoteTCPSink *msg = MsgConfigureRemoteTCPSink::create(m_settings, QStringList(), true);
m_inputMessageQueue.push(msg);
return false;
}
@ -200,18 +200,19 @@ void RemoteTCPSink::setCenterFrequency(qint64 frequency)
{
RemoteTCPSinkSettings settings = m_settings;
settings.m_inputFrequencyOffset = frequency;
applySettings(settings, false);
applySettings(settings, {"inputFrequencyOffset"}, false);
if (m_guiMessageQueue) // forward to GUI if any
{
MsgConfigureRemoteTCPSink *msgToGUI = MsgConfigureRemoteTCPSink::create(settings, false);
MsgConfigureRemoteTCPSink *msgToGUI = MsgConfigureRemoteTCPSink::create(settings, {"inputFrequencyOffset"}, false);
m_guiMessageQueue->push(msgToGUI);
}
}
void RemoteTCPSink::applySettings(const RemoteTCPSinkSettings& settings, bool force, bool remoteChange)
void RemoteTCPSink::applySettings(const RemoteTCPSinkSettings& settings, const QStringList& settingsKeys, bool force, bool remoteChange)
{
qDebug() << "RemoteTCPSink::applySettings:"
<< " settingsKeys: " << settingsKeys
<< " m_channelSampleRate: " << settings.m_channelSampleRate
<< " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset
<< " m_gain: " << settings.m_gain
@ -223,37 +224,7 @@ void RemoteTCPSink::applySettings(const RemoteTCPSinkSettings& settings, bool fo
<< " force: " << force
<< " remoteChange: " << remoteChange;
QList<QString> reverseAPIKeys;
if ((m_settings.m_channelSampleRate != settings.m_channelSampleRate) || force) {
reverseAPIKeys.append("m_channelSampleRate");
}
if ((m_settings.m_inputFrequencyOffset != settings.m_inputFrequencyOffset) || force) {
reverseAPIKeys.append("inputFrequencyOffset");
}
if ((m_settings.m_gain != settings.m_gain) || force) {
reverseAPIKeys.append("gain");
}
if ((m_settings.m_sampleBits != settings.m_sampleBits) || force) {
reverseAPIKeys.append("sampleBits");
}
if ((m_settings.m_dataAddress != settings.m_dataAddress) || force) {
reverseAPIKeys.append("dataAddress");
}
if ((m_settings.m_dataPort != settings.m_dataPort) || force) {
reverseAPIKeys.append("dataPort");
}
if ((m_settings.m_protocol != settings.m_protocol) || force) {
reverseAPIKeys.append("protocol");
}
if ((m_settings.m_rgbColor != settings.m_rgbColor) || force) {
reverseAPIKeys.append("rgbColor");
}
if ((m_settings.m_title != settings.m_title) || force) {
reverseAPIKeys.append("title");
}
if (m_settings.m_streamIndex != settings.m_streamIndex)
if (settingsKeys.contains("streamIndex"))
{
if (m_deviceAPI->getSampleMIMO()) // change of stream is possible for MIMO devices only
{
@ -262,31 +233,33 @@ void RemoteTCPSink::applySettings(const RemoteTCPSinkSettings& settings, bool fo
m_deviceAPI->addChannelSink(this, settings.m_streamIndex);
m_deviceAPI->addChannelSinkAPI(this);
}
reverseAPIKeys.append("streamIndex");
}
MsgConfigureRemoteTCPSink *msg = MsgConfigureRemoteTCPSink::create(settings, force, remoteChange);
MsgConfigureRemoteTCPSink *msg = MsgConfigureRemoteTCPSink::create(settings, settingsKeys, force, remoteChange);
m_basebandSink->getInputMessageQueue()->push(msg);
if ((settings.m_useReverseAPI) && (reverseAPIKeys.size() != 0))
if (settingsKeys.contains("useReverseAPI"))
{
bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
(m_settings.m_reverseAPIAddress != settings.m_reverseAPIAddress) ||
(m_settings.m_reverseAPIPort != settings.m_reverseAPIPort) ||
(m_settings.m_reverseAPIDeviceIndex != settings.m_reverseAPIDeviceIndex) ||
(m_settings.m_reverseAPIChannelIndex != settings.m_reverseAPIChannelIndex);
webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
bool fullUpdate = (settingsKeys.contains("useReverseAPI") && settings.m_useReverseAPI) ||
settingsKeys.contains("reverseAPIAddress") ||
settingsKeys.contains("reverseAPIPort") ||
settingsKeys.contains("reverseAPIDeviceIndex") ||
settingsKeys.contains("reverseAPIChannelIndex");
webapiReverseSendSettings(settingsKeys, settings, fullUpdate || force);
}
QList<ObjectPipe*> pipes;
MainCore::instance()->getMessagePipes().getMessagePipes(this, "settings", pipes);
if (pipes.size() > 0) {
sendChannelSettings(pipes, reverseAPIKeys, settings, force);
sendChannelSettings(pipes, settingsKeys, settings, force);
}
m_settings = settings;
if (force) {
m_settings = settings;
} else {
m_settings.applySettings(settingsKeys, settings);
}
}
int RemoteTCPSink::webapiSettingsGet(
@ -319,14 +292,14 @@ int RemoteTCPSink::webapiSettingsPutPatch(
RemoteTCPSinkSettings settings = m_settings;
webapiUpdateChannelSettings(settings, channelSettingsKeys, response);
MsgConfigureRemoteTCPSink *msg = MsgConfigureRemoteTCPSink::create(settings, force);
MsgConfigureRemoteTCPSink *msg = MsgConfigureRemoteTCPSink::create(settings, channelSettingsKeys, force);
m_inputMessageQueue.push(msg);
qDebug("RemoteTCPSink::webapiSettingsPutPatch: forward to GUI: %p", m_guiMessageQueue);
if (m_guiMessageQueue) // forward to GUI if any
{
MsgConfigureRemoteTCPSink *msgToGUI = MsgConfigureRemoteTCPSink::create(settings, force);
MsgConfigureRemoteTCPSink *msgToGUI = MsgConfigureRemoteTCPSink::create(settings, channelSettingsKeys, force);
m_guiMessageQueue->push(msgToGUI);
}
@ -467,7 +440,7 @@ void RemoteTCPSink::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings&
}
}
void RemoteTCPSink::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const RemoteTCPSinkSettings& settings, bool force)
void RemoteTCPSink::webapiReverseSendSettings(const QStringList& channelSettingsKeys, const RemoteTCPSinkSettings& settings, bool force)
{
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force);
@ -494,7 +467,7 @@ void RemoteTCPSink::webapiReverseSendSettings(QList<QString>& channelSettingsKey
void RemoteTCPSink::sendChannelSettings(
const QList<ObjectPipe*>& pipes,
QList<QString>& channelSettingsKeys,
const QStringList& channelSettingsKeys,
const RemoteTCPSinkSettings& settings,
bool force)
{
@ -518,7 +491,7 @@ void RemoteTCPSink::sendChannelSettings(
}
void RemoteTCPSink::webapiFormatChannelSettings(
QList<QString>& channelSettingsKeys,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings *swgChannelSettings,
const RemoteTCPSinkSettings& settings,
bool force

View File

@ -39,22 +39,25 @@ public:
public:
const RemoteTCPSinkSettings& getSettings() const { return m_settings; }
const QList<QString>& getSettingsKeys() const { return m_settingsKeys; }
bool getForce() const { return m_force; }
bool getRemoteChange() const { return m_remoteChange; }
static MsgConfigureRemoteTCPSink* create(const RemoteTCPSinkSettings& settings, bool force, bool remoteChange = false)
static MsgConfigureRemoteTCPSink* create(const RemoteTCPSinkSettings& settings, const QList<QString>& settingsKeys, bool force, bool remoteChange = false)
{
return new MsgConfigureRemoteTCPSink(settings, force, remoteChange);
return new MsgConfigureRemoteTCPSink(settings, settingsKeys, force, remoteChange);
}
private:
RemoteTCPSinkSettings m_settings;
QList<QString> m_settingsKeys;
bool m_force;
bool m_remoteChange; // This change of settings was requested by a remote client, so no need to restart server
MsgConfigureRemoteTCPSink(const RemoteTCPSinkSettings& settings, bool force, bool remoteChange) :
MsgConfigureRemoteTCPSink(const RemoteTCPSinkSettings& settings, const QList<QString>& settingsKeys, bool force, bool remoteChange) :
Message(),
m_settings(settings),
m_settingsKeys(settingsKeys),
m_force(force),
m_remoteChange(remoteChange)
{ }
@ -180,16 +183,16 @@ private:
QNetworkRequest m_networkRequest;
virtual bool handleMessage(const Message& cmd);
void applySettings(const RemoteTCPSinkSettings& settings, bool force = false, bool remoteChange = false);
void webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const RemoteTCPSinkSettings& settings, bool force);
void applySettings(const RemoteTCPSinkSettings& settings, const QStringList& settingsKeys, bool force = false, bool remoteChange = false);
void webapiReverseSendSettings(const QStringList& channelSettingsKeys, const RemoteTCPSinkSettings& settings, bool force);
void sendChannelSettings(
const QList<ObjectPipe*>& pipes,
QList<QString>& channelSettingsKeys,
const QStringList& channelSettingsKeys,
const RemoteTCPSinkSettings& settings,
bool force
);
void webapiFormatChannelSettings(
QList<QString>& channelSettingsKeys,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings *swgChannelSettings,
const RemoteTCPSinkSettings& settings,
bool force

View File

@ -128,7 +128,7 @@ bool RemoteTCPSinkBaseband::handleMessage(const Message& cmd)
RemoteTCPSink::MsgConfigureRemoteTCPSink& cfg = (RemoteTCPSink::MsgConfigureRemoteTCPSink&) cmd;
qDebug() << "RemoteTCPSinkBaseband::handleMessage: MsgConfigureRemoteTCPSink";
applySettings(cfg.getSettings(), cfg.getForce(), cfg.getRemoteChange());
applySettings(cfg.getSettings(), cfg.getSettingsKeys(), cfg.getForce(), cfg.getRemoteChange());
return true;
}
@ -147,22 +147,25 @@ bool RemoteTCPSinkBaseband::handleMessage(const Message& cmd)
}
}
void RemoteTCPSinkBaseband::applySettings(const RemoteTCPSinkSettings& settings, bool force, bool remoteChange)
void RemoteTCPSinkBaseband::applySettings(const RemoteTCPSinkSettings& settings, const QStringList& settingsKeys, bool force, bool remoteChange)
{
qDebug() << "RemoteTCPSinkBaseband::applySettings:"
<< "m_channelSampleRate:" << settings.m_channelSampleRate
<< "m_inputFrequencyOffset:" << settings.m_inputFrequencyOffset
<< " force: " << force;
if ((settings.m_channelSampleRate != m_settings.m_channelSampleRate)
|| (settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force)
if (settingsKeys.contains("channelSampleRate") || settingsKeys.contains("inputFrequencyOffset") || force)
{
m_channelizer->setChannelization(settings.m_channelSampleRate, settings.m_inputFrequencyOffset);
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
}
m_sink.applySettings(settings, force, remoteChange);
m_settings = settings;
m_sink.applySettings(settings, settingsKeys, force, remoteChange);
if (force) {
m_settings = settings;
} else {
m_settings.applySettings(settingsKeys, settings);
}
}
int RemoteTCPSinkBaseband::getChannelSampleRate() const

View File

@ -63,7 +63,7 @@ private:
QRecursiveMutex m_mutex;
bool handleMessage(const Message& cmd);
void applySettings(const RemoteTCPSinkSettings& settings, bool force = false, bool remoteChange = false);
void applySettings(const RemoteTCPSinkSettings& settings, const QStringList& settingsKeys, bool force = false, bool remoteChange = false);
private slots:
void handleInputMessages();

View File

@ -17,6 +17,8 @@
///////////////////////////////////////////////////////////////////////////////////
#include <QLocale>
#include <QHostAddress>
#include <QNetworkInterface>
#include "device/deviceuiset.h"
#include "gui/basicchannelsettingsdialog.h"
@ -46,7 +48,7 @@ void RemoteTCPSinkGUI::resetToDefaults()
{
m_settings.resetToDefaults();
displaySettings();
applySettings(true);
applyAllSettings();
}
QByteArray RemoteTCPSinkGUI::serialize() const
@ -58,7 +60,7 @@ bool RemoteTCPSinkGUI::deserialize(const QByteArray& data)
{
if(m_settings.deserialize(data)) {
displaySettings();
applySettings(true);
applyAllSettings();
return true;
} else {
resetToDefaults();
@ -113,7 +115,11 @@ bool RemoteTCPSinkGUI::handleMessage(const Message& message)
|| (cfg.getSettings().m_sampleBits != m_settings.m_sampleBits)) {
m_bwAvg.reset();
}
m_settings = cfg.getSettings();
if (cfg.getForce()) {
m_settings = cfg.getSettings();
} else {
m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings());
}
blockApplySettings(true);
m_channelMarker.updateSettings(static_cast<const ChannelMarker*>(m_settings.m_channelMarker));
displaySettings();
@ -160,8 +166,7 @@ RemoteTCPSinkGUI::RemoteTCPSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISe
m_pluginAPI(pluginAPI),
m_deviceUISet(deviceUISet),
m_basebandSampleRate(0),
m_deviceCenterFrequency(0),
m_tickCount(0)
m_deviceCenterFrequency(0)
{
setAttribute(Qt::WA_DeleteOnClose, true);
m_helpURL = "plugins/channelrx/remotetcpsink/readme.md";
@ -194,18 +199,27 @@ RemoteTCPSinkGUI::RemoteTCPSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISe
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
// Add all IP addresses
for (const QHostAddress& address: QNetworkInterface::allAddresses())
{
if (address.protocol() == QAbstractSocket::IPv4Protocol && !address.isLoopback()) {
ui->dataAddress->addItem(address.toString());
}
}
connect(&m_channelMarker, SIGNAL(changedByCursor()), this, SLOT(channelMarkerChangedByCursor()));
connect(&m_channelMarker, SIGNAL(highlightedByCursor()), this, SLOT(channelMarkerHighlightedByCursor()));
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
displaySettings();
makeUIConnections();
applySettings(true);
applyAllSettings();
DialPopup::addPopupsToChildDials(this);
}
RemoteTCPSinkGUI::~RemoteTCPSinkGUI()
{
QObject::disconnect(ui->dataAddress->lineEdit(), &QLineEdit::editingFinished, this, &RemoteTCPSinkGUI::on_dataAddress_editingFinished);
delete ui;
}
@ -214,17 +228,27 @@ void RemoteTCPSinkGUI::blockApplySettings(bool block)
m_doApplySettings = !block;
}
void RemoteTCPSinkGUI::applySettings(bool force)
void RemoteTCPSinkGUI::applySetting(const QString& settingsKey)
{
applySettings({settingsKey});
}
void RemoteTCPSinkGUI::applySettings(const QStringList& settingsKeys, bool force)
{
if (m_doApplySettings)
{
setTitleColor(m_channelMarker.getColor());
RemoteTCPSink::MsgConfigureRemoteTCPSink* message = RemoteTCPSink::MsgConfigureRemoteTCPSink::create(m_settings, force);
RemoteTCPSink::MsgConfigureRemoteTCPSink* message = RemoteTCPSink::MsgConfigureRemoteTCPSink::create(m_settings, settingsKeys, force);
m_remoteSink->getInputMessageQueue()->push(message);
}
}
void RemoteTCPSinkGUI::applyAllSettings()
{
applySettings(QStringList(), true);
}
void RemoteTCPSinkGUI::displaySettings()
{
m_channelMarker.blockSignals(true);
@ -244,7 +268,10 @@ void RemoteTCPSinkGUI::displaySettings()
ui->gain->setValue(m_settings.m_gain);
ui->gainText->setText(tr("%1dB").arg(m_settings.m_gain));
ui->sampleBits->setCurrentIndex(m_settings.m_sampleBits/8 - 1);
ui->dataAddress->setText(m_settings.m_dataAddress);
if (ui->dataAddress->findText(m_settings.m_dataAddress) == -1) {
ui->dataAddress->addItem(m_settings.m_dataAddress);
}
ui->dataAddress->setCurrentText(m_settings.m_dataAddress);
ui->dataPort->setText(tr("%1").arg(m_settings.m_dataPort));
ui->protocol->setCurrentIndex((int)m_settings.m_protocol);
getRollupContents()->restoreState(m_rollupState);
@ -288,7 +315,7 @@ void RemoteTCPSinkGUI::onWidgetRolled(QWidget* widget, bool rollDown)
(void) rollDown;
getRollupContents()->saveState(m_rollupState);
applySettings();
applySetting("rollupState");
}
void RemoteTCPSinkGUI::onMenuDialogCalled(const QPoint &p)
@ -325,14 +352,26 @@ void RemoteTCPSinkGUI::onMenuDialogCalled(const QPoint &p)
setTitle(m_channelMarker.getTitle());
setTitleColor(m_settings.m_rgbColor);
QList<QString> settingsKeys({
"m_rgbColor",
"title",
"useReverseAPI",
"reverseAPIAddress",
"reverseAPIPort",
"reverseAPIDeviceIndex",
"reverseAPIChannelIndex"
});
if (m_deviceUISet->m_deviceMIMOEngine)
{
settingsKeys.append("streamIndex");
m_settings.m_streamIndex = dialog.getSelectedStreamIndex();
m_channelMarker.clearStreamIndexes();
m_channelMarker.addStreamIndex(m_settings.m_streamIndex);
updateIndexLabel();
}
applySettings();
applySettings(settingsKeys);
}
resetContextMenuType();
@ -342,7 +381,7 @@ void RemoteTCPSinkGUI::channelMarkerChangedByCursor()
{
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
applySettings();
applySetting("inputFrequencyOffset");
}
void RemoteTCPSinkGUI::channelMarkerHighlightedByCursor()
@ -353,34 +392,42 @@ void RemoteTCPSinkGUI::channelMarkerHighlightedByCursor()
void RemoteTCPSinkGUI::on_deltaFrequency_changed(int index)
{
m_settings.m_inputFrequencyOffset = index;
applySettings();
applySetting("inputFrequencyOffset");
}
void RemoteTCPSinkGUI::on_channelSampleRate_changed(int index)
{
m_settings.m_channelSampleRate = index;
m_bwAvg.reset();
applySettings();
applySetting("channelSampleRate");
}
void RemoteTCPSinkGUI::on_gain_valueChanged(int value)
{
m_settings.m_gain = (float)value;
ui->gainText->setText(tr("%1dB").arg(m_settings.m_gain));
applySettings();
applySetting("gain");
}
void RemoteTCPSinkGUI::on_sampleBits_currentIndexChanged(int index)
{
m_settings.m_sampleBits = 8 * (index + 1);
m_bwAvg.reset();
applySettings();
applySetting("sampleBits");
}
void RemoteTCPSinkGUI::on_dataAddress_editingFinished()
{
m_settings.m_dataAddress = ui->dataAddress->text();
applySettings();
m_settings.m_dataAddress = ui->dataAddress->currentText();
applySetting("dataAddress");
}
void RemoteTCPSinkGUI::on_dataAddress_currentIndexChanged(int index)
{
(void) index;
m_settings.m_dataAddress = ui->dataAddress->currentText();
applySetting("dataAddress");
}
void RemoteTCPSinkGUI::on_dataPort_editingFinished()
@ -397,20 +444,13 @@ void RemoteTCPSinkGUI::on_dataPort_editingFinished()
m_settings.m_dataPort = dataPort;
}
applySettings();
applySetting("dataPort");
}
void RemoteTCPSinkGUI::on_protocol_currentIndexChanged(int index)
{
m_settings.m_protocol = (RemoteTCPSinkSettings::Protocol)index;
applySettings();
}
void RemoteTCPSinkGUI::tick()
{
if (++m_tickCount == 20) { // once per second
m_tickCount = 0;
}
applySetting("protocol");
}
void RemoteTCPSinkGUI::makeUIConnections()
@ -419,7 +459,8 @@ void RemoteTCPSinkGUI::makeUIConnections()
QObject::connect(ui->channelSampleRate, &ValueDial::changed, this, &RemoteTCPSinkGUI::on_channelSampleRate_changed);
QObject::connect(ui->gain, &QDial::valueChanged, this, &RemoteTCPSinkGUI::on_gain_valueChanged);
QObject::connect(ui->sampleBits, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &RemoteTCPSinkGUI::on_sampleBits_currentIndexChanged);
QObject::connect(ui->dataAddress, &QLineEdit::editingFinished, this, &RemoteTCPSinkGUI::on_dataAddress_editingFinished);
QObject::connect(ui->dataAddress->lineEdit(), &QLineEdit::editingFinished, this, &RemoteTCPSinkGUI::on_dataAddress_editingFinished);
QObject::connect(ui->dataAddress, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &RemoteTCPSinkGUI::on_dataAddress_currentIndexChanged);
QObject::connect(ui->dataPort, &QLineEdit::editingFinished, this, &RemoteTCPSinkGUI::on_dataPort_editingFinished);
QObject::connect(ui->protocol, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &RemoteTCPSinkGUI::on_protocol_currentIndexChanged);
}

View File

@ -81,14 +81,15 @@ private:
RemoteTCPSink* m_remoteSink;
MessageQueue m_inputMessageQueue;
uint32_t m_tickCount;
MovingAverageUtil<float, float, 10> m_bwAvg;
explicit RemoteTCPSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel, QWidget* parent = 0);
virtual ~RemoteTCPSinkGUI();
void blockApplySettings(bool block);
void applySettings(bool force = false);
void applySetting(const QString& settingsKey);
void applySettings(const QStringList& settingsKeys, bool force = false);
void applyAllSettings();
void displaySettings();
void displayRateAndShift();
bool handleMessage(const Message& message);
@ -109,11 +110,11 @@ private slots:
void on_gain_valueChanged(int value);
void on_sampleBits_currentIndexChanged(int index);
void on_dataAddress_editingFinished();
void on_dataAddress_currentIndexChanged(int index);
void on_dataPort_editingFinished();
void on_protocol_currentIndexChanged(int index);
void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDialogCalled(const QPoint& p);
void tick();
};
#endif /* PLUGINS_CHANNELRX_REMOTETCPSINK_REMOTETCPSINKGUI_H_ */

View File

@ -308,21 +308,12 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="dataAddress">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<widget class="QComboBox" name="dataAddress">
<property name="toolTip">
<string>IP address of local network interface to start TCP server on</string>
<string>IP address of local network interface to start TCP server on. Use 0.0.0.0 for any interface.</string>
</property>
<property name="inputMask">
<string>000.000.000.000</string>
</property>
<property name="text">
<string>0...</string>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>

View File

@ -35,7 +35,7 @@ void RemoteTCPSinkSettings::resetToDefaults()
m_inputFrequencyOffset = 0;
m_gain = 0;
m_sampleBits = 8;
m_dataAddress = "127.0.0.1";
m_dataAddress = "0.0.0.0";
m_dataPort = 1234;
m_protocol = SDRA;
m_rgbColor = QColor(140, 4, 4).rgb();
@ -106,7 +106,7 @@ bool RemoteTCPSinkSettings::deserialize(const QByteArray& data)
d.readS32(2, &m_inputFrequencyOffset, 0);
d.readS32(3, &m_gain, 0);
d.readU32(4, &m_sampleBits, 8);
d.readString(5, &m_dataAddress, "127.0.0.1");
d.readString(5, &m_dataAddress, "0.0.0.0");
d.readU32(6, &tmp, 0);
if ((tmp > 1023) && (tmp < 65535)) {
@ -158,3 +158,117 @@ bool RemoteTCPSinkSettings::deserialize(const QByteArray& data)
return false;
}
}
void RemoteTCPSinkSettings::applySettings(const QStringList& settingsKeys, const RemoteTCPSinkSettings& settings)
{
if (settingsKeys.contains("channelSampleRate")) {
m_channelSampleRate = settings.m_channelSampleRate;
}
if (settingsKeys.contains("inputFrequencyOffset")) {
m_inputFrequencyOffset = settings.m_inputFrequencyOffset;
}
if (settingsKeys.contains("gain")) {
m_gain = settings.m_gain;
}
if (settingsKeys.contains("sampleBits")) {
m_sampleBits = settings.m_sampleBits;
}
if (settingsKeys.contains("dataAddress")) {
m_dataAddress = settings.m_dataAddress;
}
if (settingsKeys.contains("dataPort")) {
m_dataPort = settings.m_dataPort;
}
if (settingsKeys.contains("protocol")) {
m_protocol = settings.m_protocol;
}
if (settingsKeys.contains("rgbColor")) {
m_rgbColor = settings.m_rgbColor;
}
if (settingsKeys.contains("title")) {
m_title = settings.m_title;
}
if (settingsKeys.contains("streamIndex")) {
m_streamIndex = settings.m_streamIndex;
}
if (settingsKeys.contains("useReverseAPI")) {
m_useReverseAPI = settings.m_useReverseAPI;
}
if (settingsKeys.contains("reverseAPIAddress")) {
m_reverseAPIAddress = settings.m_reverseAPIAddress;
}
if (settingsKeys.contains("reverseAPIPort")) {
m_reverseAPIPort = settings.m_reverseAPIPort;
}
if (settingsKeys.contains("reverseAPIDeviceIndex")) {
m_reverseAPIDeviceIndex = settings.m_reverseAPIDeviceIndex;
}
if (settingsKeys.contains("reverseAPIChannelIndex")) {
m_reverseAPIChannelIndex = settings.m_reverseAPIChannelIndex;
}
if (settingsKeys.contains("workspaceIndex")) {
m_workspaceIndex = settings.m_workspaceIndex;
}
if (settingsKeys.contains("hidden")) {
m_hidden = settings.m_hidden;
}
}
QString RemoteTCPSinkSettings::getDebugString(const QStringList& settingsKeys, bool force) const
{
std::ostringstream ostr;
if (settingsKeys.contains("channelSampleRate") || force) {
ostr << " m_channelSampleRate: " << m_channelSampleRate;
}
if (settingsKeys.contains("inputFrequencyOffset") || force) {
ostr << " m_inputFrequencyOffset: " << m_inputFrequencyOffset;
}
if (settingsKeys.contains("gain") || force) {
ostr << " m_gain: " << m_gain;
}
if (settingsKeys.contains("sampleBits") || force) {
ostr << " m_sampleBits: " << m_sampleBits;
}
if (settingsKeys.contains("dataAddress") || force) {
ostr << " m_dataAddress: " << m_dataAddress.toStdString();
}
if (settingsKeys.contains("dataPort") || force) {
ostr << " m_dataPort: " << m_dataPort;
}
if (settingsKeys.contains("protocol") || force) {
ostr << " m_protocol: " << m_protocol;
}
if (settingsKeys.contains("rgbColor") || force) {
ostr << " m_rgbColor: " << m_rgbColor;
}
if (settingsKeys.contains("title") || force) {
ostr << " m_title: " << m_title.toStdString();
}
if (settingsKeys.contains("streamIndex") || force) {
ostr << " m_streamIndex: " << m_streamIndex;
}
if (settingsKeys.contains("useReverseAPI") || force) {
ostr << " m_useReverseAPI: " << m_useReverseAPI;
}
if (settingsKeys.contains("reverseAPIAddress") || force) {
ostr << " m_reverseAPIAddress: " << m_reverseAPIAddress.toStdString();
}
if (settingsKeys.contains("reverseAPIPort") || force) {
ostr << " m_reverseAPIPort: " << m_reverseAPIPort;
}
if (settingsKeys.contains("reverseAPIDeviceIndex") || force) {
ostr << " m_reverseAPIDeviceIndex: " << m_reverseAPIDeviceIndex;
}
if (settingsKeys.contains("reverseAPIChannelIndex") || force) {
ostr << " m_reverseAPIChannelIndex: " << m_reverseAPIChannelIndex;
}
if (settingsKeys.contains("workspaceIndex") || force) {
ostr << " m_workspaceIndex: " << m_workspaceIndex;
}
if (settingsKeys.contains("hidden") || force) {
ostr << " m_hidden: " << m_hidden;
}
return QString(ostr.str().c_str());
}

View File

@ -59,6 +59,8 @@ struct RemoteTCPSinkSettings
void setRollupState(Serializable *rollupState) { m_rollupState = rollupState; }
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
void applySettings(const QStringList& settingsKeys, const RemoteTCPSinkSettings& settings);
QString getDebugString(const QStringList& settingsKeys, bool force=false) const;
};
#endif /* INCLUDE_REMOTECHANNELSINKSETTINGS_H_ */

View File

@ -39,7 +39,7 @@ RemoteTCPSinkSink::RemoteTCPSinkSink() :
m_server(nullptr)
{
qDebug("RemoteTCPSinkSink::RemoteTCPSinkSink");
applySettings(m_settings, true);
applySettings(m_settings, QStringList(), true);
applyChannelSettings(m_channelSampleRate, m_channelFrequencyOffset, true);
}
@ -237,21 +237,18 @@ void RemoteTCPSinkSink::applyChannelSettings(int channelSampleRate, int channelF
m_channelFrequencyOffset = channelFrequencyOffset;
}
void RemoteTCPSinkSink::applySettings(const RemoteTCPSinkSettings& settings, bool force, bool remoteChange)
void RemoteTCPSinkSink::applySettings(const RemoteTCPSinkSettings& settings, const QStringList& settingsKeys, bool force, bool remoteChange)
{
QMutexLocker mutexLocker(&m_mutex);
qDebug() << "RemoteTCPSinkSink::applySettings:"
<< " m_dataAddress: " << settings.m_dataAddress
<< " m_dataPort: " << settings.m_dataPort
<< " m_channelSampleRate: " << settings.m_channelSampleRate
<< " m_streamIndex: " << settings.m_streamIndex
<< " force: " << force
<< " remoteChange: " << remoteChange;
qDebug() << "RemoteTCPSinkSink::applySettings:" << settings.getDebugString(settingsKeys, force) << " force: " << force;
m_linearGain = powf(10.0f, m_settings.m_gain/20.0f);
if (settingsKeys.contains("gain") || force)
{
m_linearGain = powf(10.0f, settings.m_gain/20.0f);
}
if ((m_settings.m_channelSampleRate != settings.m_channelSampleRate) || force)
if (settingsKeys.contains("channelSampleRate") || force)
{
m_interpolator.create(16, m_channelSampleRate, settings.m_channelSampleRate / 2.0);
m_interpolatorDistance = (Real) m_channelSampleRate / (Real) settings.m_channelSampleRate;
@ -259,15 +256,19 @@ void RemoteTCPSinkSink::applySettings(const RemoteTCPSinkSettings& settings, boo
}
// Do clients need to reconnect to get these updated settings?
bool restart = (m_settings.m_dataAddress != settings.m_dataAddress)
|| (m_settings.m_dataPort != settings.m_dataPort)
|| (m_settings.m_sampleBits != settings.m_sampleBits)
|| (m_settings.m_protocol != settings.m_protocol)
bool restart = (settingsKeys.contains("dataAddress") && (m_settings.m_dataAddress != settings.m_dataAddress))
|| (settingsKeys.contains("dataPort") && (m_settings.m_dataPort != settings.m_dataPort))
|| (settingsKeys.contains("sampleBits") && (m_settings.m_sampleBits != settings.m_sampleBits))
|| (settingsKeys.contains("protocol") && (m_settings.m_protocol != settings.m_protocol))
|| ( !remoteChange
&& (m_settings.m_channelSampleRate != settings.m_channelSampleRate)
&& (settingsKeys.contains("channelSampleRate") && (m_settings.m_channelSampleRate != settings.m_channelSampleRate))
);
m_settings = settings;
if (force) {
m_settings = settings;
} else {
m_settings.applySettings(settingsKeys, settings);
}
if (m_running && restart) {
startServer();
@ -279,14 +280,14 @@ void RemoteTCPSinkSink::startServer()
stopServer();
m_server = new QTcpServer(this);
if (!m_server->listen(QHostAddress::Any, m_settings.m_dataPort))
if (!m_server->listen(QHostAddress(m_settings.m_dataAddress), m_settings.m_dataPort))
{
qDebug() << "RemoteTCPSinkSink::startServer: failed to listen on port " << m_settings.m_dataPort;
qCritical() << "RemoteTCPSink failed to listen on" << m_settings.m_dataAddress << "port" << m_settings.m_dataPort;
// FIXME: Report to GUI?
}
else
{
qDebug() << "RemoteTCPSinkSink::startServer: listening on port " << m_settings.m_dataPort;
qInfo() << "RemoteTCPSink listening on" << m_settings.m_dataAddress << "port" << m_settings.m_dataPort;
connect(m_server, &QTcpServer::newConnection, this, &RemoteTCPSinkSink::acceptConnection);
}
}
@ -339,7 +340,6 @@ RemoteTCPProtocol::Device RemoteTCPSinkSink::getDevice()
{"PlutoSDR", RemoteTCPProtocol::PLUTO_SDR},
{"RemoteInput", RemoteTCPProtocol::REMOTE_INPUT},
{"RemoteTCPInput", RemoteTCPProtocol::REMOTE_TCP_INPUT},
{"RTLSDR", RemoteTCPProtocol::RTLSDR_R820T},
{"SDRplay1", RemoteTCPProtocol::SDRPLAY_1},
{"SigMFFileInput", RemoteTCPProtocol::SIGMF_FILE_INPUT},
{"SoapySDR", RemoteTCPProtocol::SOAPY_SDR},
@ -373,6 +373,29 @@ RemoteTCPProtocol::Device RemoteTCPSinkSink::getDevice()
qDebug() << "RemoteTCPSinkSink::getDevice: Failed to get deviceType for SDRplayV3";
}
}
else if (id == "RTLSDR")
{
QString tunerType;
if (ChannelWebAPIUtils::getDeviceReportValue(m_deviceIndex, "tunerType", tunerType))
{
QHash<QString, RemoteTCPProtocol::Device> rtlsdrMap = {
{"E4000", RemoteTCPProtocol::RTLSDR_E4000},
{"FC0012", RemoteTCPProtocol::RTLSDR_FC0012},
{"FC0013", RemoteTCPProtocol::RTLSDR_FC0013},
{"FC2580", RemoteTCPProtocol::RTLSDR_FC2580},
{"R820T", RemoteTCPProtocol::RTLSDR_R820T},
{"R828D", RemoteTCPProtocol::RTLSDR_R828D},
};
if (rtlsdrMap.contains(tunerType)) {
return rtlsdrMap.value(tunerType);
}
qDebug() << "RemoteTCPSinkSink::getDevice: Unknown RTLSDR tunerType: " << tunerType;
}
else
{
qDebug() << "RemoteTCPSinkSink::getDevice: Failed to get tunerType for RTLSDR";
}
}
}
return RemoteTCPProtocol::UNKNOWN;
}
@ -594,10 +617,10 @@ void RemoteTCPSinkSink::processCommand()
qDebug() << "RemoteTCPSinkSink::processCommand: set channel sample rate " << channelSampleRate;
settings.m_channelSampleRate = channelSampleRate;
if (m_messageQueueToGUI) {
m_messageQueueToGUI->push(RemoteTCPSink::MsgConfigureRemoteTCPSink::create(settings, false, true));
m_messageQueueToGUI->push(RemoteTCPSink::MsgConfigureRemoteTCPSink::create(settings, {"channelSampleRate"}, false, true));
}
if (m_messageQueueToChannel) {
m_messageQueueToChannel->push(RemoteTCPSink::MsgConfigureRemoteTCPSink::create(settings, false, true));
m_messageQueueToChannel->push(RemoteTCPSink::MsgConfigureRemoteTCPSink::create(settings, {"channelSampleRate"}, false, true));
}
break;
}
@ -607,10 +630,10 @@ void RemoteTCPSinkSink::processCommand()
qDebug() << "RemoteTCPSinkSink::processCommand: set channel input frequency offset " << offset;
settings.m_inputFrequencyOffset = offset;
if (m_messageQueueToGUI) {
m_messageQueueToGUI->push(RemoteTCPSink::MsgConfigureRemoteTCPSink::create(settings, false, true));
m_messageQueueToGUI->push(RemoteTCPSink::MsgConfigureRemoteTCPSink::create(settings, {"inputFrequencyOffset"}, false, true));
}
if (m_messageQueueToChannel) {
m_messageQueueToChannel->push(RemoteTCPSink::MsgConfigureRemoteTCPSink::create(settings, false, true));
m_messageQueueToChannel->push(RemoteTCPSink::MsgConfigureRemoteTCPSink::create(settings, {"inputFrequencyOffset"}, false, true));
}
break;
}
@ -620,10 +643,10 @@ void RemoteTCPSinkSink::processCommand()
qDebug() << "RemoteTCPSinkSink::processCommand: set channel gain " << gain;
settings.m_gain = gain;
if (m_messageQueueToGUI) {
m_messageQueueToGUI->push(RemoteTCPSink::MsgConfigureRemoteTCPSink::create(settings, false, true));
m_messageQueueToGUI->push(RemoteTCPSink::MsgConfigureRemoteTCPSink::create(settings, {"gain"}, false, true));
}
if (m_messageQueueToChannel) {
m_messageQueueToChannel->push(RemoteTCPSink::MsgConfigureRemoteTCPSink::create(settings, false, true));
m_messageQueueToChannel->push(RemoteTCPSink::MsgConfigureRemoteTCPSink::create(settings, {"gain"}, false, true));
}
break;
}
@ -633,10 +656,10 @@ void RemoteTCPSinkSink::processCommand()
qDebug() << "RemoteTCPSinkSink::processCommand: set sample bit depth " << bits;
settings.m_sampleBits = bits;
if (m_messageQueueToGUI) {
m_messageQueueToGUI->push(RemoteTCPSink::MsgConfigureRemoteTCPSink::create(settings, false, true));
m_messageQueueToGUI->push(RemoteTCPSink::MsgConfigureRemoteTCPSink::create(settings, {"sampleBits"}, false, true));
}
if (m_messageQueueToChannel) {
m_messageQueueToChannel->push(RemoteTCPSink::MsgConfigureRemoteTCPSink::create(settings, false, true));
m_messageQueueToChannel->push(RemoteTCPSink::MsgConfigureRemoteTCPSink::create(settings, {"sampleBits"}, false, true));
}
break;
}

View File

@ -48,7 +48,7 @@ public:
void stop();
void init();
void applySettings(const RemoteTCPSinkSettings& settings, bool force = false, bool remoteChange = false);
void applySettings(const RemoteTCPSinkSettings& settings, const QStringList& settingsKeys, bool force = false, bool remoteChange = false);
void applyChannelSettings(int channelSampleRate, int channelFrequencyOffset, bool force = false);
void setDeviceIndex(uint32_t deviceIndex) { m_deviceIndex = deviceIndex; }
void setChannelIndex(uint32_t channelIndex) { m_channelIndex = channelIndex; }