mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 09:48:45 -05:00
Reverse API: SDR Play RSP1
This commit is contained in:
parent
82fe8455cc
commit
c6e057b143
@ -30,8 +30,8 @@
|
||||
#include "airspyinput.h"
|
||||
#include "airspyplugin.h"
|
||||
|
||||
#include <device/devicesourceapi.h>
|
||||
#include <dsp/filerecord.h>
|
||||
#include "device/devicesourceapi.h"
|
||||
#include "dsp/filerecord.h"
|
||||
#include "dsp/dspcommands.h"
|
||||
#include "dsp/dspengine.h"
|
||||
#include "airspysettings.h"
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "ui_sdrplaygui.h"
|
||||
#include "gui/colormapper.h"
|
||||
#include "gui/glspectrum.h"
|
||||
#include "gui/crightclickenabler.h"
|
||||
#include "gui/basicdevicesettingsdialog.h"
|
||||
#include "dsp/dspengine.h"
|
||||
#include "dsp/dspcommands.h"
|
||||
|
||||
@ -70,6 +72,9 @@ SDRPlayGui::SDRPlayGui(DeviceUISet *deviceUISet, QWidget* parent) :
|
||||
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
||||
m_statusTimer.start(500);
|
||||
|
||||
CRightClickEnabler *startStopRightClickEnabler = new CRightClickEnabler(ui->startStop);
|
||||
connect(startStopRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(openDeviceSettingsDialog(const QPoint &)));
|
||||
|
||||
displaySettings();
|
||||
|
||||
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection);
|
||||
@ -472,3 +477,21 @@ void SDRPlayGui::on_record_toggled(bool checked)
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
}
|
||||
|
||||
void SDRPlayGui::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();
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ private slots:
|
||||
void on_gainBaseband_valueChanged(int value);
|
||||
void on_startStop_toggled(bool checked);
|
||||
void on_record_toggled(bool checked);
|
||||
void openDeviceSettingsDialog(const QPoint& p);
|
||||
};
|
||||
|
||||
#endif /* PLUGINS_SAMPLESOURCE_SDRPLAY_SDRPLAYGUI_H_ */
|
||||
|
@ -16,7 +16,10 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QNetworkReply>
|
||||
#include <QBuffer>
|
||||
|
||||
#include "SWGDeviceSettings.h"
|
||||
#include "SWGDeviceState.h"
|
||||
@ -51,11 +54,20 @@ SDRPlayInput::SDRPlayInput(DeviceSourceAPI *deviceAPI) :
|
||||
openDevice();
|
||||
m_fileSink = new FileRecord(QString("test_%1.sdriq").arg(m_deviceAPI->getDeviceUID()));
|
||||
m_deviceAPI->addSink(m_fileSink);
|
||||
|
||||
m_networkManager = new QNetworkAccessManager();
|
||||
connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
|
||||
}
|
||||
|
||||
SDRPlayInput::~SDRPlayInput()
|
||||
{
|
||||
if (m_running) stop();
|
||||
disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
|
||||
delete m_networkManager;
|
||||
|
||||
if (m_running) {
|
||||
stop();
|
||||
}
|
||||
|
||||
m_deviceAPI->removeSink(m_fileSink);
|
||||
delete m_fileSink;
|
||||
closeDevice();
|
||||
@ -334,6 +346,10 @@ bool SDRPlayInput::handleMessage(const Message& message)
|
||||
m_deviceAPI->stopAcquisition();
|
||||
}
|
||||
|
||||
if (m_settings.m_useReverseAPI) {
|
||||
webapiReverseSendStartStop(cmd.getStartStop());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -345,38 +361,43 @@ bool SDRPlayInput::handleMessage(const Message& message)
|
||||
bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardChange, bool force)
|
||||
{
|
||||
bool forceGainSetting = false;
|
||||
//settings.debug("SDRPlayInput::applySettings");
|
||||
QList<QString> reverseAPIKeys;
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
|
||||
if ((m_settings.m_dcBlock != settings.m_dcBlock) || force)
|
||||
{
|
||||
m_settings.m_dcBlock = settings.m_dcBlock;
|
||||
m_deviceAPI->configureCorrections(m_settings.m_dcBlock, m_settings.m_iqCorrection);
|
||||
reverseAPIKeys.append("dcBlock");
|
||||
m_deviceAPI->configureCorrections(settings.m_dcBlock, settings.m_iqCorrection);
|
||||
}
|
||||
|
||||
if ((m_settings.m_iqCorrection != settings.m_iqCorrection) || force)
|
||||
{
|
||||
m_settings.m_iqCorrection = settings.m_iqCorrection;
|
||||
m_deviceAPI->configureCorrections(m_settings.m_dcBlock, m_settings.m_iqCorrection);
|
||||
reverseAPIKeys.append("iqCorrection");
|
||||
m_deviceAPI->configureCorrections(settings.m_dcBlock, settings.m_iqCorrection);
|
||||
}
|
||||
|
||||
// gains processing
|
||||
|
||||
if ((m_settings.m_tunerGainMode != settings.m_tunerGainMode) || force)
|
||||
{
|
||||
m_settings.m_tunerGainMode = settings.m_tunerGainMode;
|
||||
reverseAPIKeys.append("tunerGainMode");
|
||||
forceGainSetting = true;
|
||||
}
|
||||
|
||||
if (m_settings.m_tunerGainMode) // auto
|
||||
if ((m_settings.m_tunerGain != settings.m_tunerGain) || force) {
|
||||
reverseAPIKeys.append("tunerGain");
|
||||
}
|
||||
if ((m_settings.m_lnaOn != settings.m_lnaOn) || force) {
|
||||
reverseAPIKeys.append("lnaOn");
|
||||
}
|
||||
|
||||
if (settings.m_tunerGainMode) // auto
|
||||
{
|
||||
if ((m_settings.m_tunerGain != settings.m_tunerGain) || forceGainSetting)
|
||||
{
|
||||
m_settings.m_tunerGain = settings.m_tunerGain;
|
||||
|
||||
if(m_dev != 0)
|
||||
{
|
||||
int r = mirisdr_set_tuner_gain(m_dev, m_settings.m_tunerGain);
|
||||
int r = mirisdr_set_tuner_gain(m_dev, settings.m_tunerGain);
|
||||
|
||||
if (r < 0)
|
||||
{
|
||||
@ -386,7 +407,7 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh
|
||||
{
|
||||
int lnaGain;
|
||||
|
||||
if (m_settings.m_frequencyBandIndex < 3) // bands using AM mode
|
||||
if (settings.m_frequencyBandIndex < 3) // bands using AM mode
|
||||
{
|
||||
lnaGain = mirisdr_get_mixbuffer_gain(m_dev);
|
||||
}
|
||||
@ -415,19 +436,15 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh
|
||||
|
||||
if ((m_settings.m_lnaOn != settings.m_lnaOn) || forceGainSetting)
|
||||
{
|
||||
if(m_dev != 0)
|
||||
if (m_dev != 0)
|
||||
{
|
||||
if (m_settings.m_frequencyBandIndex < 3) // bands using AM mode
|
||||
if (settings.m_frequencyBandIndex < 3) // bands using AM mode
|
||||
{
|
||||
int r = mirisdr_set_mixbuffer_gain(m_dev, settings.m_lnaOn ? 0 : 1); // mirisdr_set_mixbuffer_gain takes gain reduction
|
||||
|
||||
if (r != 0)
|
||||
{
|
||||
if (r != 0) {
|
||||
qDebug("SDRPlayInput::applySettings: could not set mixer buffer gain");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_settings.m_lnaOn = settings.m_lnaOn;
|
||||
} else {
|
||||
anyChange = true;
|
||||
}
|
||||
}
|
||||
@ -435,13 +452,9 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh
|
||||
{
|
||||
int r = mirisdr_set_lna_gain(m_dev, settings.m_lnaOn ? 0 : 1); // mirisdr_set_lna_gain takes gain reduction
|
||||
|
||||
if (r != 0)
|
||||
{
|
||||
if (r != 0) {
|
||||
qDebug("SDRPlayInput::applySettings: could not set LNA gain");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_settings.m_lnaOn = settings.m_lnaOn;
|
||||
} else {
|
||||
anyChange = true;
|
||||
}
|
||||
}
|
||||
@ -450,17 +463,15 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh
|
||||
|
||||
if ((m_settings.m_mixerAmpOn != settings.m_mixerAmpOn) || forceGainSetting)
|
||||
{
|
||||
if(m_dev != 0)
|
||||
reverseAPIKeys.append("mixerAmpOn");
|
||||
|
||||
if (m_dev != 0)
|
||||
{
|
||||
int r = mirisdr_set_mixer_gain(m_dev, settings.m_mixerAmpOn ? 0 : 1); // mirisdr_set_lna_gain takes gain reduction
|
||||
|
||||
if (r != 0)
|
||||
{
|
||||
if (r != 0) {
|
||||
qDebug("SDRPlayInput::applySettings: could not set mixer gain");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_settings.m_mixerAmpOn = settings.m_mixerAmpOn;
|
||||
} else {
|
||||
anyChange = true;
|
||||
}
|
||||
}
|
||||
@ -468,17 +479,15 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh
|
||||
|
||||
if ((m_settings.m_basebandGain != settings.m_basebandGain) || forceGainSetting)
|
||||
{
|
||||
if(m_dev != 0)
|
||||
reverseAPIKeys.append("basebandGain");
|
||||
|
||||
if (m_dev != 0)
|
||||
{
|
||||
int r = mirisdr_set_baseband_gain(m_dev, settings.m_basebandGain);
|
||||
|
||||
if (r != 0)
|
||||
{
|
||||
if (r != 0) {
|
||||
qDebug("SDRPlayInput::applySettings: could not set mixer gain");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_settings.m_basebandGain = settings.m_basebandGain;
|
||||
} else {
|
||||
anyChange = true;
|
||||
}
|
||||
}
|
||||
@ -488,12 +497,9 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh
|
||||
{
|
||||
int lnaGain;
|
||||
|
||||
if (m_settings.m_frequencyBandIndex < 3) // bands using AM mode
|
||||
{
|
||||
if (settings.m_frequencyBandIndex < 3) { // bands using AM mode
|
||||
lnaGain = mirisdr_get_mixbuffer_gain(m_dev);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
lnaGain = mirisdr_get_lna_gain(m_dev);
|
||||
}
|
||||
|
||||
@ -512,22 +518,33 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh
|
||||
|
||||
if ((m_settings.m_log2Decim != settings.m_log2Decim) || force)
|
||||
{
|
||||
reverseAPIKeys.append("log2Decim");
|
||||
|
||||
if (m_sdrPlayThread != 0)
|
||||
{
|
||||
m_sdrPlayThread->setLog2Decimation(m_settings.m_log2Decim);
|
||||
m_sdrPlayThread->setLog2Decimation(settings.m_log2Decim);
|
||||
qDebug() << "SDRPlayInput::applySettings: set decimation to " << (1<<settings.m_log2Decim);
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_fcPos != settings.m_fcPos) || force)
|
||||
{
|
||||
reverseAPIKeys.append("fcPos");
|
||||
|
||||
if (m_sdrPlayThread != 0)
|
||||
{
|
||||
m_sdrPlayThread->setFcPos((int) m_settings.m_fcPos);
|
||||
m_sdrPlayThread->setFcPos((int) settings.m_fcPos);
|
||||
qDebug() << "SDRPlayInput: set fc pos (enum) to " << (int) settings.m_fcPos;
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force) {
|
||||
reverseAPIKeys.append("centerFrequency");
|
||||
}
|
||||
if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force) {
|
||||
reverseAPIKeys.append("LOppmTenths");
|
||||
}
|
||||
|
||||
if ((m_settings.m_centerFrequency != settings.m_centerFrequency)
|
||||
|| (m_settings.m_LOppmTenths != settings.m_LOppmTenths)
|
||||
|| (m_settings.m_fcPos != settings.m_fcPos)
|
||||
@ -538,61 +555,55 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool forwardCh
|
||||
0,
|
||||
settings.m_log2Decim,
|
||||
(DeviceSampleSource::fcPos_t) settings.m_fcPos,
|
||||
SDRPlaySampleRates::getRate(m_settings.m_devSampleRateIndex));
|
||||
|
||||
m_settings.m_centerFrequency = settings.m_centerFrequency;
|
||||
m_settings.m_LOppmTenths = settings.m_LOppmTenths;
|
||||
m_settings.m_fcPos = settings.m_fcPos;
|
||||
m_settings.m_log2Decim = settings.m_log2Decim;
|
||||
SDRPlaySampleRates::getRate(settings.m_devSampleRateIndex));
|
||||
|
||||
forwardChange = true;
|
||||
|
||||
if(m_dev != 0)
|
||||
{
|
||||
if (setDeviceCenterFrequency(deviceCenterFrequency)) {
|
||||
qDebug() << "SDRPlayInput::applySettings: center freq: " << m_settings.m_centerFrequency << " Hz";
|
||||
qDebug() << "SDRPlayInput::applySettings: center freq: " << settings.m_centerFrequency << " Hz";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_frequencyBandIndex != settings.m_frequencyBandIndex) || force)
|
||||
{
|
||||
m_settings.m_frequencyBandIndex = settings.m_frequencyBandIndex;
|
||||
// change of frequency is done already
|
||||
}
|
||||
|
||||
if ((m_settings.m_bandwidthIndex != settings.m_bandwidthIndex) || force)
|
||||
{
|
||||
reverseAPIKeys.append("bandwidthIndex");
|
||||
int bandwidth = SDRPlayBandwidths::getBandwidth(settings.m_bandwidthIndex);
|
||||
int r = mirisdr_set_bandwidth(m_dev, bandwidth);
|
||||
|
||||
if (r < 0)
|
||||
{
|
||||
if (r < 0) {
|
||||
qCritical("SDRPlayInput::applySettings: set bandwidth %d failed: rc: %d", bandwidth, r);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
qDebug("SDRPlayInput::applySettings: bandwidth set to %d", bandwidth);
|
||||
m_settings.m_bandwidthIndex = settings.m_bandwidthIndex;
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_ifFrequencyIndex != settings.m_ifFrequencyIndex) || force)
|
||||
{
|
||||
reverseAPIKeys.append("ifFrequencyIndex");
|
||||
int iFFrequency = SDRPlayIF::getIF(settings.m_ifFrequencyIndex);
|
||||
int r = mirisdr_set_if_freq(m_dev, iFFrequency);
|
||||
|
||||
if (r < 0)
|
||||
{
|
||||
if (r < 0) {
|
||||
qCritical("SDRPlayInput::applySettings: set IF frequency to %d failed: rc: %d", iFFrequency, r);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
qDebug("SDRPlayInput::applySettings: IF frequency set to %d", iFFrequency);
|
||||
m_settings.m_ifFrequencyIndex = settings.m_ifFrequencyIndex;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
|
||||
}
|
||||
|
||||
m_settings = settings;
|
||||
|
||||
if (forwardChange)
|
||||
{
|
||||
int sampleRate = getSampleRate();
|
||||
@ -809,6 +820,116 @@ void SDRPlayInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& respon
|
||||
}
|
||||
}
|
||||
|
||||
void SDRPlayInput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const SDRPlaySettings& settings, bool force)
|
||||
{
|
||||
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
||||
swgDeviceSettings->setTx(0);
|
||||
swgDeviceSettings->setDeviceHwType(new QString("SDRplay1"));
|
||||
swgDeviceSettings->setSdrPlaySettings(new SWGSDRangel::SWGSDRPlaySettings());
|
||||
SWGSDRangel::SWGSDRPlaySettings *swgSDRPlaySettings = swgDeviceSettings->getSdrPlaySettings();
|
||||
|
||||
// transfer data that has been modified. When force is on transfer all data except reverse API data
|
||||
|
||||
if (deviceSettingsKeys.contains("centerFrequency") || force) {
|
||||
swgSDRPlaySettings->setCenterFrequency(settings.m_centerFrequency);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("tunerGain") || force) {
|
||||
swgSDRPlaySettings->setTunerGain(settings.m_tunerGain);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("LOppmTenths") || force) {
|
||||
swgSDRPlaySettings->setLOppmTenths(settings.m_LOppmTenths);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("frequencyBandIndex") || force) {
|
||||
swgSDRPlaySettings->setFrequencyBandIndex(settings.m_frequencyBandIndex);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("ifFrequencyIndex") || force) {
|
||||
swgSDRPlaySettings->setIfFrequencyIndex(settings.m_ifFrequencyIndex);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("bandwidthIndex") || force) {
|
||||
swgSDRPlaySettings->setBandwidthIndex(settings.m_bandwidthIndex);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("devSampleRateIndex") || force) {
|
||||
swgSDRPlaySettings->setDevSampleRateIndex(settings.m_devSampleRateIndex);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("log2Decim") || force) {
|
||||
swgSDRPlaySettings->setLog2Decim(settings.m_log2Decim);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("fcPos") || force) {
|
||||
swgSDRPlaySettings->setFcPos((int) settings.m_fcPos);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("dcBlock") || force) {
|
||||
swgSDRPlaySettings->setDcBlock(settings.m_dcBlock ? 1 : 0);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("iqCorrection") || force) {
|
||||
swgSDRPlaySettings->setIqCorrection(settings.m_iqCorrection ? 1 : 0);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("tunerGainMode") || force) {
|
||||
swgSDRPlaySettings->setTunerGainMode(settings.m_tunerGainMode ? 1 : 0);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("lnaOn") || force) {
|
||||
swgSDRPlaySettings->setLnaOn(settings.m_lnaOn ? 1 : 0);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("mixerAmpOn") || force) {
|
||||
swgSDRPlaySettings->setMixerAmpOn(settings.m_mixerAmpOn ? 1 : 0);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("basebandGain") || force) {
|
||||
swgSDRPlaySettings->setBasebandGain(settings.m_basebandGain);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("fileRecordName") || force) {
|
||||
swgSDRPlaySettings->setFileRecordName(new QString(settings.m_fileRecordName));
|
||||
}
|
||||
|
||||
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 SDRPlayInput::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 SDRPlayInput::networkManagerFinished(QNetworkReply *reply)
|
||||
{
|
||||
QNetworkReply::NetworkError replyError = reply->error();
|
||||
|
||||
if (replyError)
|
||||
{
|
||||
qWarning() << "SDRPlayInput::networkManagerFinished:"
|
||||
<< " error(" << (int) replyError
|
||||
<< "): " << replyError
|
||||
<< ": " << reply->errorString();
|
||||
return;
|
||||
}
|
||||
|
||||
QString answer = reply->readAll();
|
||||
answer.chop(1); // remove last \n
|
||||
qDebug("SDRPlayInput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
||||
unsigned int SDRPlaySampleRates::m_rates[m_nb_rates] = {
|
||||
|
@ -17,19 +17,24 @@
|
||||
#ifndef PLUGINS_SAMPLESOURCE_SDRPLAY_SDRPLAYINPUT_H_
|
||||
#define PLUGINS_SAMPLESOURCE_SDRPLAY_SDRPLAYINPUT_H_
|
||||
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
#include <QNetworkRequest>
|
||||
|
||||
#include <mirisdr.h>
|
||||
#include <dsp/devicesamplesource.h>
|
||||
#include "dsp/devicesamplesource.h"
|
||||
#include "sdrplaysettings.h"
|
||||
|
||||
class QNetworkAccessManager;
|
||||
class QNetworkReply;
|
||||
class DeviceSourceAPI;
|
||||
class SDRPlayThread;
|
||||
class FileRecord;
|
||||
|
||||
class SDRPlayInput : public DeviceSampleSource {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum SDRPlayVariant
|
||||
{
|
||||
@ -174,13 +179,6 @@ public:
|
||||
SDRPlayVariant getVariant() const { return m_variant; }
|
||||
|
||||
private:
|
||||
bool openDevice();
|
||||
void closeDevice();
|
||||
bool applySettings(const SDRPlaySettings& settings, bool forwardChange, bool force);
|
||||
bool setDeviceCenterFrequency(quint64 freq);
|
||||
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const SDRPlaySettings& settings);
|
||||
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response);
|
||||
|
||||
DeviceSourceAPI *m_deviceAPI;
|
||||
QMutex m_mutex;
|
||||
SDRPlayVariant m_variant;
|
||||
@ -191,6 +189,20 @@ private:
|
||||
int m_devNumber;
|
||||
bool m_running;
|
||||
FileRecord *m_fileSink; //!< File sink to record device I/Q output
|
||||
QNetworkAccessManager *m_networkManager;
|
||||
QNetworkRequest m_networkRequest;
|
||||
|
||||
bool openDevice();
|
||||
void closeDevice();
|
||||
bool applySettings(const SDRPlaySettings& settings, bool forwardChange, bool force);
|
||||
bool setDeviceCenterFrequency(quint64 freq);
|
||||
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const SDRPlaySettings& settings);
|
||||
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response);
|
||||
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const SDRPlaySettings& settings, bool force);
|
||||
void webapiReverseSendStartStop(bool start);
|
||||
|
||||
private slots:
|
||||
void networkManagerFinished(QNetworkReply *reply);
|
||||
};
|
||||
|
||||
// ====================================================================
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
const PluginDescriptor SDRPlayPlugin::m_pluginDescriptor = {
|
||||
QString("SDRPlay RSP1 Input"),
|
||||
QString("4.0.0"),
|
||||
QString("4.3.2"),
|
||||
QString("(c) Edouard Griffiths, F4EXB"),
|
||||
QString("https://github.com/f4exb/sdrangel"),
|
||||
true,
|
||||
|
@ -42,6 +42,10 @@ void SDRPlaySettings::resetToDefaults()
|
||||
m_mixerAmpOn = false;
|
||||
m_basebandGain = 29;
|
||||
m_fileRecordName = "";
|
||||
m_useReverseAPI = false;
|
||||
m_reverseAPIAddress = "127.0.0.1";
|
||||
m_reverseAPIPort = 8888;
|
||||
m_reverseAPIDeviceIndex = 0;
|
||||
}
|
||||
|
||||
QByteArray SDRPlaySettings::serialize() const
|
||||
@ -62,6 +66,10 @@ QByteArray SDRPlaySettings::serialize() const
|
||||
s.writeBool(12, m_lnaOn);
|
||||
s.writeBool(13, m_mixerAmpOn);
|
||||
s.writeS32(14, m_basebandGain);
|
||||
s.writeBool(15, m_useReverseAPI);
|
||||
s.writeString(16, m_reverseAPIAddress);
|
||||
s.writeU32(17, m_reverseAPIPort);
|
||||
s.writeU32(18, m_reverseAPIDeviceIndex);
|
||||
|
||||
return s.final();
|
||||
}
|
||||
@ -79,6 +87,7 @@ bool SDRPlaySettings::deserialize(const QByteArray& data)
|
||||
if (d.getVersion() == 1)
|
||||
{
|
||||
int intval;
|
||||
uint32_t uintval;
|
||||
|
||||
d.readS32(1, &m_LOppmTenths, 0);
|
||||
d.readU32(2, &m_frequencyBandIndex, 0);
|
||||
@ -95,6 +104,18 @@ bool SDRPlaySettings::deserialize(const QByteArray& data)
|
||||
d.readBool(12, &m_lnaOn, false);
|
||||
d.readBool(13, &m_mixerAmpOn, false);
|
||||
d.readS32(14, &m_basebandGain, 29);
|
||||
d.readBool(15, &m_useReverseAPI, false);
|
||||
d.readString(16, &m_reverseAPIAddress, "127.0.0.1");
|
||||
d.readU32(17, &uintval, 0);
|
||||
|
||||
if ((uintval > 1023) && (uintval < 65535)) {
|
||||
m_reverseAPIPort = uintval;
|
||||
} else {
|
||||
m_reverseAPIPort = 8888;
|
||||
}
|
||||
|
||||
d.readU32(18, &uintval, 0);
|
||||
m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -45,6 +45,10 @@ struct SDRPlaySettings {
|
||||
bool m_mixerAmpOn;
|
||||
int m_basebandGain;
|
||||
QString m_fileRecordName;
|
||||
bool m_useReverseAPI;
|
||||
QString m_reverseAPIAddress;
|
||||
uint16_t m_reverseAPIPort;
|
||||
uint16_t m_reverseAPIDeviceIndex;
|
||||
|
||||
SDRPlaySettings();
|
||||
void resetToDefaults();
|
||||
|
Loading…
Reference in New Issue
Block a user