mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-06-24 21:15:24 -04:00
Reverse API: SoapySDR input
This commit is contained in:
parent
c6e057b143
commit
bc4c9aeba6
@ -15,6 +15,8 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QBuffer>
|
||||||
|
|
||||||
#include "util/simpleserializer.h"
|
#include "util/simpleserializer.h"
|
||||||
|
|
||||||
@ -54,10 +56,16 @@ SoapySDRInput::SoapySDRInput(DeviceSourceAPI *deviceAPI) :
|
|||||||
|
|
||||||
m_fileSink = new FileRecord(QString("test_%1.sdriq").arg(m_deviceAPI->getDeviceUID()));
|
m_fileSink = new FileRecord(QString("test_%1.sdriq").arg(m_deviceAPI->getDeviceUID()));
|
||||||
m_deviceAPI->addSink(m_fileSink);
|
m_deviceAPI->addSink(m_fileSink);
|
||||||
|
|
||||||
|
m_networkManager = new QNetworkAccessManager();
|
||||||
|
connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
|
||||||
}
|
}
|
||||||
|
|
||||||
SoapySDRInput::~SoapySDRInput()
|
SoapySDRInput::~SoapySDRInput()
|
||||||
{
|
{
|
||||||
|
disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
|
||||||
|
delete m_networkManager;
|
||||||
|
|
||||||
if (m_running) {
|
if (m_running) {
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
@ -811,6 +819,10 @@ bool SoapySDRInput::handleMessage(const Message& message)
|
|||||||
m_deviceAPI->stopAcquisition();
|
m_deviceAPI->stopAcquisition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_settings.m_useReverseAPI) {
|
||||||
|
webapiReverseSendStartStop(cmd.getStartStop());
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (DeviceSoapySDRShared::MsgReportBuddyChange::match(message))
|
else if (DeviceSoapySDRShared::MsgReportBuddyChange::match(message))
|
||||||
@ -888,6 +900,7 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
|
|||||||
bool globalGainChanged = false;
|
bool globalGainChanged = false;
|
||||||
bool individualGainsChanged = false;
|
bool individualGainsChanged = false;
|
||||||
bool deviceArgsChanged = false;
|
bool deviceArgsChanged = false;
|
||||||
|
QList<QString> reverseAPIKeys;
|
||||||
|
|
||||||
SoapySDR::Device *dev = m_deviceShared.m_device;
|
SoapySDR::Device *dev = m_deviceShared.m_device;
|
||||||
SoapySDRInputThread *inputThread = findThread();
|
SoapySDRInputThread *inputThread = findThread();
|
||||||
@ -896,6 +909,13 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
|
|||||||
xlatedDeviceCenterFrequency -= settings.m_transverterMode ? settings.m_transverterDeltaFrequency : 0;
|
xlatedDeviceCenterFrequency -= settings.m_transverterMode ? settings.m_transverterDeltaFrequency : 0;
|
||||||
xlatedDeviceCenterFrequency = xlatedDeviceCenterFrequency < 0 ? 0 : xlatedDeviceCenterFrequency;
|
xlatedDeviceCenterFrequency = xlatedDeviceCenterFrequency < 0 ? 0 : xlatedDeviceCenterFrequency;
|
||||||
|
|
||||||
|
if ((m_settings.m_softDCCorrection != settings.m_softDCCorrection) || force) {
|
||||||
|
reverseAPIKeys.append("softDCCorrection");
|
||||||
|
}
|
||||||
|
if ((m_settings.m_softIQCorrection != settings.m_softIQCorrection) || force) {
|
||||||
|
reverseAPIKeys.append("softIQCorrection");
|
||||||
|
}
|
||||||
|
|
||||||
if ((m_settings.m_softDCCorrection != settings.m_softDCCorrection) ||
|
if ((m_settings.m_softDCCorrection != settings.m_softDCCorrection) ||
|
||||||
(m_settings.m_softIQCorrection != settings.m_softIQCorrection) || force)
|
(m_settings.m_softIQCorrection != settings.m_softIQCorrection) || force)
|
||||||
{
|
{
|
||||||
@ -904,6 +924,7 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
|
|||||||
|
|
||||||
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force)
|
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force)
|
||||||
{
|
{
|
||||||
|
reverseAPIKeys.append("devSampleRate");
|
||||||
forwardChangeOwnDSP = true;
|
forwardChangeOwnDSP = true;
|
||||||
forwardChangeToBuddies = true;
|
forwardChangeToBuddies = true;
|
||||||
|
|
||||||
@ -935,6 +956,8 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
|
|||||||
|
|
||||||
if ((m_settings.m_fcPos != settings.m_fcPos) || force)
|
if ((m_settings.m_fcPos != settings.m_fcPos) || force)
|
||||||
{
|
{
|
||||||
|
reverseAPIKeys.append("fcPos");
|
||||||
|
|
||||||
if (inputThread != 0)
|
if (inputThread != 0)
|
||||||
{
|
{
|
||||||
inputThread->setFcPos(requestedChannel, (int) settings.m_fcPos);
|
inputThread->setFcPos(requestedChannel, (int) settings.m_fcPos);
|
||||||
@ -944,6 +967,7 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
|
|||||||
|
|
||||||
if ((m_settings.m_log2Decim != settings.m_log2Decim) || force)
|
if ((m_settings.m_log2Decim != settings.m_log2Decim) || force)
|
||||||
{
|
{
|
||||||
|
reverseAPIKeys.append("log2Decim");
|
||||||
forwardChangeOwnDSP = true;
|
forwardChangeOwnDSP = true;
|
||||||
SoapySDRInputThread *inputThread = findThread();
|
SoapySDRInputThread *inputThread = findThread();
|
||||||
|
|
||||||
@ -954,6 +978,19 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force) {
|
||||||
|
reverseAPIKeys.append("centerFrequency");
|
||||||
|
}
|
||||||
|
if ((m_settings.m_transverterMode != settings.m_transverterMode) || force) {
|
||||||
|
reverseAPIKeys.append("transverterMode");
|
||||||
|
}
|
||||||
|
if ((m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency) || force) {
|
||||||
|
reverseAPIKeys.append("transverterDeltaFrequency");
|
||||||
|
}
|
||||||
|
if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force) {
|
||||||
|
reverseAPIKeys.append("LOppmTenths");
|
||||||
|
}
|
||||||
|
|
||||||
if ((m_settings.m_centerFrequency != settings.m_centerFrequency)
|
if ((m_settings.m_centerFrequency != settings.m_centerFrequency)
|
||||||
|| (m_settings.m_transverterMode != settings.m_transverterMode)
|
|| (m_settings.m_transverterMode != settings.m_transverterMode)
|
||||||
|| (m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency)
|
|| (m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency)
|
||||||
@ -979,6 +1016,8 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
|
|||||||
|
|
||||||
if ((m_settings.m_antenna != settings.m_antenna) || force)
|
if ((m_settings.m_antenna != settings.m_antenna) || force)
|
||||||
{
|
{
|
||||||
|
reverseAPIKeys.append("antenna");
|
||||||
|
|
||||||
if (dev != 0)
|
if (dev != 0)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -996,6 +1035,7 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
|
|||||||
|
|
||||||
if ((m_settings.m_bandwidth != settings.m_bandwidth) || force)
|
if ((m_settings.m_bandwidth != settings.m_bandwidth) || force)
|
||||||
{
|
{
|
||||||
|
reverseAPIKeys.append("bandwidth");
|
||||||
forwardChangeToBuddies = true;
|
forwardChangeToBuddies = true;
|
||||||
|
|
||||||
if (dev != 0)
|
if (dev != 0)
|
||||||
@ -1040,6 +1080,8 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
|
|||||||
|
|
||||||
if ((m_settings.m_globalGain != settings.m_globalGain) || force)
|
if ((m_settings.m_globalGain != settings.m_globalGain) || force)
|
||||||
{
|
{
|
||||||
|
reverseAPIKeys.append("globalGain");
|
||||||
|
|
||||||
if (dev != 0)
|
if (dev != 0)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -1084,6 +1126,8 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
|
|||||||
|
|
||||||
if ((m_settings.m_autoGain != settings.m_autoGain) || force)
|
if ((m_settings.m_autoGain != settings.m_autoGain) || force)
|
||||||
{
|
{
|
||||||
|
reverseAPIKeys.append("autoGain");
|
||||||
|
|
||||||
if (dev != 0)
|
if (dev != 0)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -1100,6 +1144,8 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
|
|||||||
|
|
||||||
if ((m_settings.m_autoDCCorrection != settings.m_autoDCCorrection) || force)
|
if ((m_settings.m_autoDCCorrection != settings.m_autoDCCorrection) || force)
|
||||||
{
|
{
|
||||||
|
reverseAPIKeys.append("autoDCCorrection");
|
||||||
|
|
||||||
if ((dev != 0) && hasDCAutoCorrection())
|
if ((dev != 0) && hasDCAutoCorrection())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -1116,6 +1162,8 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
|
|||||||
|
|
||||||
if ((m_settings.m_dcCorrection != settings.m_dcCorrection) || force)
|
if ((m_settings.m_dcCorrection != settings.m_dcCorrection) || force)
|
||||||
{
|
{
|
||||||
|
reverseAPIKeys.append("dcCorrection");
|
||||||
|
|
||||||
if ((dev != 0) && hasDCCorrectionValue())
|
if ((dev != 0) && hasDCCorrectionValue())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -1132,6 +1180,8 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
|
|||||||
|
|
||||||
if ((m_settings.m_iqCorrection != settings.m_iqCorrection) || force)
|
if ((m_settings.m_iqCorrection != settings.m_iqCorrection) || force)
|
||||||
{
|
{
|
||||||
|
reverseAPIKeys.append("iqCorrection");
|
||||||
|
|
||||||
if ((dev != 0) && hasIQCorrectionValue())
|
if ((dev != 0) && hasIQCorrectionValue())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -1255,6 +1305,20 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settings.m_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);
|
||||||
|
|
||||||
|
if (fullUpdate || force) {
|
||||||
|
webapiReverseSendSettings(reverseAPIKeys, settings, true);
|
||||||
|
} else if (reverseAPIKeys.size() != 0) {
|
||||||
|
webapiReverseSendSettings(reverseAPIKeys, settings, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_settings = settings;
|
m_settings = settings;
|
||||||
|
|
||||||
if (globalGainChanged || individualGainsChanged)
|
if (globalGainChanged || individualGainsChanged)
|
||||||
@ -1799,3 +1863,126 @@ void SoapySDRInput::webapiFormatArgInfo(const SoapySDR::ArgInfo& arg, SWGSDRange
|
|||||||
argInfo->getOptionNames()->append(new QString(itOpt.c_str()));
|
argInfo->getOptionNames()->append(new QString(itOpt.c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SoapySDRInput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const SoapySDRInputSettings& settings, bool force)
|
||||||
|
{
|
||||||
|
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
||||||
|
swgDeviceSettings->setTx(0);
|
||||||
|
swgDeviceSettings->setDeviceHwType(new QString("SoapySDR"));
|
||||||
|
swgDeviceSettings->setSoapySdrInputSettings(new SWGSDRangel::SWGSoapySDRInputSettings());
|
||||||
|
swgDeviceSettings->getSoapySdrInputSettings()->init();
|
||||||
|
SWGSDRangel::SWGSoapySDRInputSettings *swgSoapySDRInputSettings = swgDeviceSettings->getSoapySdrInputSettings();
|
||||||
|
|
||||||
|
// transfer data that has been modified. When force is on transfer all data except reverse API data
|
||||||
|
|
||||||
|
if (deviceSettingsKeys.contains("centerFrequency") || force) {
|
||||||
|
swgSoapySDRInputSettings->setCenterFrequency(settings.m_centerFrequency);
|
||||||
|
}
|
||||||
|
if (deviceSettingsKeys.contains("LOppmTenths") || force) {
|
||||||
|
swgSoapySDRInputSettings->setLOppmTenths(settings.m_LOppmTenths);
|
||||||
|
}
|
||||||
|
if (deviceSettingsKeys.contains("devSampleRate") || force) {
|
||||||
|
swgSoapySDRInputSettings->setDevSampleRate(settings.m_devSampleRate);
|
||||||
|
}
|
||||||
|
if (deviceSettingsKeys.contains("bandwidth") || force) {
|
||||||
|
swgSoapySDRInputSettings->setBandwidth(settings.m_bandwidth);
|
||||||
|
}
|
||||||
|
if (deviceSettingsKeys.contains("log2Decim") || force) {
|
||||||
|
swgSoapySDRInputSettings->setLog2Decim(settings.m_log2Decim);
|
||||||
|
}
|
||||||
|
if (deviceSettingsKeys.contains("fcPos") || force) {
|
||||||
|
swgSoapySDRInputSettings->setFcPos((int) settings.m_fcPos);
|
||||||
|
}
|
||||||
|
if (deviceSettingsKeys.contains("softDCCorrection") || force) {
|
||||||
|
swgSoapySDRInputSettings->setSoftDcCorrection(settings.m_softDCCorrection ? 1 : 0);
|
||||||
|
}
|
||||||
|
if (deviceSettingsKeys.contains("softIQCorrection") || force) {
|
||||||
|
swgSoapySDRInputSettings->setSoftIqCorrection(settings.m_softIQCorrection ? 1 : 0);
|
||||||
|
}
|
||||||
|
if (deviceSettingsKeys.contains("transverterDeltaFrequency") || force) {
|
||||||
|
swgSoapySDRInputSettings->setTransverterDeltaFrequency(settings.m_transverterDeltaFrequency);
|
||||||
|
}
|
||||||
|
if (deviceSettingsKeys.contains("transverterMode") || force) {
|
||||||
|
swgSoapySDRInputSettings->setTransverterMode(settings.m_transverterMode ? 1 : 0);
|
||||||
|
}
|
||||||
|
if (deviceSettingsKeys.contains("fileRecordName") || force) {
|
||||||
|
swgSoapySDRInputSettings->setFileRecordName(new QString(settings.m_fileRecordName));
|
||||||
|
}
|
||||||
|
if (deviceSettingsKeys.contains("antenna") || force) {
|
||||||
|
swgSoapySDRInputSettings->setAntenna(new QString(settings.m_antenna));
|
||||||
|
}
|
||||||
|
if (deviceSettingsKeys.contains("globalGain") || force) {
|
||||||
|
swgSoapySDRInputSettings->setGlobalGain(settings.m_globalGain);
|
||||||
|
}
|
||||||
|
if (deviceSettingsKeys.contains("autoGain") || force) {
|
||||||
|
swgSoapySDRInputSettings->setAutoGain(settings.m_autoGain ? 1 : 0);
|
||||||
|
}
|
||||||
|
if (deviceSettingsKeys.contains("autoDCCorrection") || force) {
|
||||||
|
swgSoapySDRInputSettings->setAutoDcCorrection(settings.m_autoDCCorrection ? 1 : 0);
|
||||||
|
}
|
||||||
|
if (deviceSettingsKeys.contains("autoIQCorrection") || force) {
|
||||||
|
swgSoapySDRInputSettings->setAutoIqCorrection(settings.m_autoIQCorrection ? 1 : 0);
|
||||||
|
}
|
||||||
|
if (deviceSettingsKeys.contains("dcCorrection") || force)
|
||||||
|
{
|
||||||
|
swgSoapySDRInputSettings->setDcCorrection(new SWGSDRangel::SWGComplex());
|
||||||
|
swgSoapySDRInputSettings->getDcCorrection()->setReal(settings.m_dcCorrection.real());
|
||||||
|
swgSoapySDRInputSettings->getDcCorrection()->setImag(settings.m_dcCorrection.imag());
|
||||||
|
}
|
||||||
|
if (deviceSettingsKeys.contains("iqCorrection") || force)
|
||||||
|
{
|
||||||
|
swgSoapySDRInputSettings->setIqCorrection(new SWGSDRangel::SWGComplex());
|
||||||
|
swgSoapySDRInputSettings->getIqCorrection()->setReal(settings.m_iqCorrection.real());
|
||||||
|
swgSoapySDRInputSettings->getIqCorrection()->setImag(settings.m_iqCorrection.imag());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/settings")
|
||||||
|
.arg(settings.m_reverseAPIAddress)
|
||||||
|
.arg(settings.m_reverseAPIPort)
|
||||||
|
.arg(settings.m_reverseAPIDeviceIndex);
|
||||||
|
m_networkRequest.setUrl(QUrl(deviceSettingsURL));
|
||||||
|
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||||
|
|
||||||
|
QBuffer *buffer=new QBuffer();
|
||||||
|
buffer->open((QBuffer::ReadWrite));
|
||||||
|
buffer->write(swgDeviceSettings->asJson().toUtf8());
|
||||||
|
buffer->seek(0);
|
||||||
|
|
||||||
|
// Always use PATCH to avoid passing reverse API settings
|
||||||
|
m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
|
||||||
|
|
||||||
|
delete swgDeviceSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SoapySDRInput::webapiReverseSendStartStop(bool start)
|
||||||
|
{
|
||||||
|
QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
|
||||||
|
.arg(m_settings.m_reverseAPIAddress)
|
||||||
|
.arg(m_settings.m_reverseAPIPort)
|
||||||
|
.arg(m_settings.m_reverseAPIDeviceIndex);
|
||||||
|
m_networkRequest.setUrl(QUrl(deviceSettingsURL));
|
||||||
|
|
||||||
|
if (start) {
|
||||||
|
m_networkManager->sendCustomRequest(m_networkRequest, "POST");
|
||||||
|
} else {
|
||||||
|
m_networkManager->sendCustomRequest(m_networkRequest, "DELETE");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SoapySDRInput::networkManagerFinished(QNetworkReply *reply)
|
||||||
|
{
|
||||||
|
QNetworkReply::NetworkError replyError = reply->error();
|
||||||
|
|
||||||
|
if (replyError)
|
||||||
|
{
|
||||||
|
qWarning() << "SoapySDRInput::networkManagerFinished:"
|
||||||
|
<< " error(" << (int) replyError
|
||||||
|
<< "): " << replyError
|
||||||
|
<< ": " << reply->errorString();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString answer = reply->readAll();
|
||||||
|
answer.chop(1); // remove last \n
|
||||||
|
qDebug("SoapySDRInput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
|
||||||
|
}
|
||||||
|
@ -17,15 +17,19 @@
|
|||||||
#ifndef PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUT_H_
|
#ifndef PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUT_H_
|
||||||
#define PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUT_H_
|
#define PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUT_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <stdint.h>
|
#include <QNetworkRequest>
|
||||||
|
|
||||||
#include "soapysdr/devicesoapysdrshared.h"
|
#include "soapysdr/devicesoapysdrshared.h"
|
||||||
#include "dsp/devicesamplesource.h"
|
#include "dsp/devicesamplesource.h"
|
||||||
|
|
||||||
#include "soapysdrinputsettings.h"
|
#include "soapysdrinputsettings.h"
|
||||||
|
|
||||||
|
class QNetworkAccessManager;
|
||||||
|
class QNetworkReply;
|
||||||
class DeviceSourceAPI;
|
class DeviceSourceAPI;
|
||||||
class SoapySDRInputThread;
|
class SoapySDRInputThread;
|
||||||
class FileRecord;
|
class FileRecord;
|
||||||
@ -44,6 +48,7 @@ namespace SWGSDRangel
|
|||||||
|
|
||||||
class SoapySDRInput : public DeviceSampleSource
|
class SoapySDRInput : public DeviceSampleSource
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
class MsgConfigureSoapySDRInput : public Message {
|
class MsgConfigureSoapySDRInput : public Message {
|
||||||
MESSAGE_CLASS_DECLARATION
|
MESSAGE_CLASS_DECLARATION
|
||||||
@ -205,6 +210,8 @@ private:
|
|||||||
SoapySDRInputThread *m_thread;
|
SoapySDRInputThread *m_thread;
|
||||||
DeviceSoapySDRShared m_deviceShared;
|
DeviceSoapySDRShared m_deviceShared;
|
||||||
FileRecord *m_fileSink; //!< File sink to record device I/Q output
|
FileRecord *m_fileSink; //!< File sink to record device I/Q output
|
||||||
|
QNetworkAccessManager *m_networkManager;
|
||||||
|
QNetworkRequest m_networkRequest;
|
||||||
|
|
||||||
bool openDevice();
|
bool openDevice();
|
||||||
void closeDevice();
|
void closeDevice();
|
||||||
@ -219,6 +226,11 @@ private:
|
|||||||
QVariant webapiVariantFromArgValue(SWGSDRangel::SWGArgValue *argValue);
|
QVariant webapiVariantFromArgValue(SWGSDRangel::SWGArgValue *argValue);
|
||||||
void webapiFormatArgValue(const QVariant& v, SWGSDRangel::SWGArgValue *argValue);
|
void webapiFormatArgValue(const QVariant& v, SWGSDRangel::SWGArgValue *argValue);
|
||||||
void webapiFormatArgInfo(const SoapySDR::ArgInfo& arg, SWGSDRangel::SWGArgInfo *argInfo);
|
void webapiFormatArgInfo(const SoapySDR::ArgInfo& arg, SWGSDRangel::SWGArgInfo *argInfo);
|
||||||
|
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const SoapySDRInputSettings& settings, bool force);
|
||||||
|
void webapiReverseSendStartStop(bool start);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void networkManagerFinished(QNetworkReply *reply);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#include "device/deviceuiset.h"
|
#include "device/deviceuiset.h"
|
||||||
#include "util/simpleserializer.h"
|
#include "util/simpleserializer.h"
|
||||||
#include "gui/glspectrum.h"
|
#include "gui/glspectrum.h"
|
||||||
|
#include "gui/crightclickenabler.h"
|
||||||
|
#include "gui/basicdevicesettingsdialog.h"
|
||||||
#include "soapygui/discreterangegui.h"
|
#include "soapygui/discreterangegui.h"
|
||||||
#include "soapygui/intervalrangegui.h"
|
#include "soapygui/intervalrangegui.h"
|
||||||
#include "soapygui/stringrangegui.h"
|
#include "soapygui/stringrangegui.h"
|
||||||
@ -88,6 +90,9 @@ SoapySDRInputGui::SoapySDRInputGui(DeviceUISet *deviceUISet, QWidget* parent) :
|
|||||||
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
||||||
m_statusTimer.start(500);
|
m_statusTimer.start(500);
|
||||||
|
|
||||||
|
CRightClickEnabler *startStopRightClickEnabler = new CRightClickEnabler(ui->startStop);
|
||||||
|
connect(startStopRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(openDeviceSettingsDialog(const QPoint &)));
|
||||||
|
|
||||||
displaySettings();
|
displaySettings();
|
||||||
|
|
||||||
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection);
|
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection);
|
||||||
@ -926,3 +931,21 @@ void SoapySDRInputGui::updateStatus()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SoapySDRInputGui::openDeviceSettingsDialog(const QPoint& p)
|
||||||
|
{
|
||||||
|
BasicDeviceSettingsDialog dialog(this);
|
||||||
|
dialog.setUseReverseAPI(m_settings.m_useReverseAPI);
|
||||||
|
dialog.setReverseAPIAddress(m_settings.m_reverseAPIAddress);
|
||||||
|
dialog.setReverseAPIPort(m_settings.m_reverseAPIPort);
|
||||||
|
dialog.setReverseAPIDeviceIndex(m_settings.m_reverseAPIDeviceIndex);
|
||||||
|
|
||||||
|
dialog.move(p);
|
||||||
|
dialog.exec();
|
||||||
|
|
||||||
|
m_settings.m_useReverseAPI = dialog.useReverseAPI();
|
||||||
|
m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress();
|
||||||
|
m_settings.m_reverseAPIPort = dialog.getReverseAPIPort();
|
||||||
|
m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex();
|
||||||
|
|
||||||
|
sendSettings();
|
||||||
|
}
|
||||||
|
@ -139,6 +139,7 @@ private slots:
|
|||||||
void on_record_toggled(bool checked);
|
void on_record_toggled(bool checked);
|
||||||
void updateHardware();
|
void updateHardware();
|
||||||
void updateStatus();
|
void updateStatus();
|
||||||
|
void openDeviceSettingsDialog(const QPoint& p);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,6 +45,10 @@ void SoapySDRInputSettings::resetToDefaults()
|
|||||||
m_autoIQCorrection = false;
|
m_autoIQCorrection = false;
|
||||||
m_dcCorrection = std::complex<double>{0,0};
|
m_dcCorrection = std::complex<double>{0,0};
|
||||||
m_iqCorrection = std::complex<double>{0,0};
|
m_iqCorrection = std::complex<double>{0,0};
|
||||||
|
m_useReverseAPI = false;
|
||||||
|
m_reverseAPIAddress = "127.0.0.1";
|
||||||
|
m_reverseAPIPort = 8888;
|
||||||
|
m_reverseAPIDeviceIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray SoapySDRInputSettings::serialize() const
|
QByteArray SoapySDRInputSettings::serialize() const
|
||||||
@ -73,6 +77,10 @@ QByteArray SoapySDRInputSettings::serialize() const
|
|||||||
s.writeDouble(20, m_iqCorrection.imag());
|
s.writeDouble(20, m_iqCorrection.imag());
|
||||||
s.writeBlob(21, serializeArgumentMap(m_streamArgSettings));
|
s.writeBlob(21, serializeArgumentMap(m_streamArgSettings));
|
||||||
s.writeBlob(22, serializeArgumentMap(m_deviceArgSettings));
|
s.writeBlob(22, serializeArgumentMap(m_deviceArgSettings));
|
||||||
|
s.writeBool(23, m_useReverseAPI);
|
||||||
|
s.writeString(24, m_reverseAPIAddress);
|
||||||
|
s.writeU32(25, m_reverseAPIPort);
|
||||||
|
s.writeU32(26, m_reverseAPIDeviceIndex);
|
||||||
|
|
||||||
return s.final();
|
return s.final();
|
||||||
}
|
}
|
||||||
@ -90,6 +98,7 @@ bool SoapySDRInputSettings::deserialize(const QByteArray& data)
|
|||||||
if (d.getVersion() == 1)
|
if (d.getVersion() == 1)
|
||||||
{
|
{
|
||||||
int intval;
|
int intval;
|
||||||
|
uint32_t uintval;
|
||||||
QByteArray blob;
|
QByteArray blob;
|
||||||
double realval, imagval;
|
double realval, imagval;
|
||||||
|
|
||||||
@ -122,6 +131,18 @@ bool SoapySDRInputSettings::deserialize(const QByteArray& data)
|
|||||||
deserializeArgumentMap(blob, m_streamArgSettings);
|
deserializeArgumentMap(blob, m_streamArgSettings);
|
||||||
d.readBlob(22, &blob);
|
d.readBlob(22, &blob);
|
||||||
deserializeArgumentMap(blob, m_deviceArgSettings);
|
deserializeArgumentMap(blob, m_deviceArgSettings);
|
||||||
|
d.readBool(23, &m_useReverseAPI, false);
|
||||||
|
d.readString(24, &m_reverseAPIAddress, "127.0.0.1");
|
||||||
|
d.readU32(25, &uintval, 0);
|
||||||
|
|
||||||
|
if ((uintval > 1023) && (uintval < 65535)) {
|
||||||
|
m_reverseAPIPort = uintval;
|
||||||
|
} else {
|
||||||
|
m_reverseAPIPort = 8888;
|
||||||
|
}
|
||||||
|
|
||||||
|
d.readU32(26, &uintval, 0);
|
||||||
|
m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,10 @@ struct SoapySDRInputSettings {
|
|||||||
std::complex<double> m_iqCorrection;
|
std::complex<double> m_iqCorrection;
|
||||||
QMap<QString, QVariant> m_streamArgSettings;
|
QMap<QString, QVariant> m_streamArgSettings;
|
||||||
QMap<QString, QVariant> m_deviceArgSettings;
|
QMap<QString, QVariant> m_deviceArgSettings;
|
||||||
|
bool m_useReverseAPI;
|
||||||
|
QString m_reverseAPIAddress;
|
||||||
|
uint16_t m_reverseAPIPort;
|
||||||
|
uint16_t m_reverseAPIDeviceIndex;
|
||||||
|
|
||||||
SoapySDRInputSettings();
|
SoapySDRInputSettings();
|
||||||
void resetToDefaults();
|
void resetToDefaults();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user