2015-09-02 21:57:54 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
2018-11-19 19:48:17 -05:00
|
|
|
// Copyright (C) 2015-2018 Edouard Griffiths, F4EXB //
|
2015-09-02 21:57:54 -04:00
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
2019-04-11 00:57:41 -04:00
|
|
|
// (at your option) any later version. //
|
2015-09-02 21:57:54 -04:00
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
2017-12-14 12:15:27 -05:00
|
|
|
|
2018-12-26 03:51:59 -05:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QNetworkReply>
|
|
|
|
#include <QBuffer>
|
|
|
|
|
2017-12-14 12:15:27 -05:00
|
|
|
#include "SWGDeviceSettings.h"
|
|
|
|
#include "SWGDeviceState.h"
|
2016-05-12 17:35:30 -04:00
|
|
|
|
2015-09-02 21:57:54 -04:00
|
|
|
#include "dsp/dspcommands.h"
|
2015-09-27 06:50:38 -04:00
|
|
|
#include "dsp/dspengine.h"
|
2017-09-04 17:35:57 -04:00
|
|
|
#include "dsp/filerecord.h"
|
2019-05-08 16:11:53 -04:00
|
|
|
#include "device/deviceapi.h"
|
2016-10-10 19:17:55 -04:00
|
|
|
|
2018-11-19 19:48:17 -05:00
|
|
|
#include "fcdproinput.h"
|
2015-09-03 22:10:38 -04:00
|
|
|
#include "fcdprothread.h"
|
2015-09-04 23:50:29 -04:00
|
|
|
#include "fcdtraits.h"
|
2015-09-06 22:55:55 -04:00
|
|
|
#include "fcdproconst.h"
|
2015-09-03 22:10:38 -04:00
|
|
|
|
2018-05-26 04:27:28 -04:00
|
|
|
MESSAGE_CLASS_DEFINITION(FCDProInput::MsgConfigureFCDPro, Message)
|
2017-12-14 12:02:49 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(FCDProInput::MsgStartStop, Message)
|
2017-09-04 17:35:57 -04:00
|
|
|
MESSAGE_CLASS_DEFINITION(FCDProInput::MsgFileRecord, Message)
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
FCDProInput::FCDProInput(DeviceAPI *deviceAPI) :
|
2016-05-15 20:14:36 -04:00
|
|
|
m_deviceAPI(deviceAPI),
|
2015-09-02 21:57:54 -04:00
|
|
|
m_dev(0),
|
|
|
|
m_settings(),
|
|
|
|
m_FCDThread(0),
|
2017-04-13 21:17:04 -04:00
|
|
|
m_deviceDescription(fcd_traits<Pro>::displayedName),
|
|
|
|
m_running(false)
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2018-11-19 19:48:17 -05:00
|
|
|
m_fcdFIFO.setSize(20*fcd_traits<Pro>::convBufSize);
|
2017-04-13 21:24:21 -04:00
|
|
|
openDevice();
|
2018-05-08 05:03:09 -04:00
|
|
|
m_fileSink = new FileRecord(QString("test_%1.sdriq").arg(m_deviceAPI->getDeviceUID()));
|
2019-05-20 18:27:08 -04:00
|
|
|
m_deviceAPI->setNbSourceStreams(1);
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceAPI->addAncillarySink(m_fileSink);
|
2018-12-26 03:51:59 -05:00
|
|
|
m_networkManager = new QNetworkAccessManager();
|
|
|
|
connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
|
2015-09-02 21:57:54 -04:00
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
FCDProInput::~FCDProInput()
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2018-12-26 03:51:59 -05:00
|
|
|
disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
|
|
|
|
delete m_networkManager;
|
|
|
|
|
2018-11-19 19:48:17 -05:00
|
|
|
if (m_running) {
|
|
|
|
stop();
|
|
|
|
}
|
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceAPI->removeAncillarySink(m_fileSink);
|
2017-09-04 17:35:57 -04:00
|
|
|
delete m_fileSink;
|
2018-11-19 19:48:17 -05:00
|
|
|
|
2017-04-13 21:24:21 -04:00
|
|
|
closeDevice();
|
|
|
|
}
|
|
|
|
|
2017-09-14 20:32:30 -04:00
|
|
|
void FCDProInput::destroy()
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
2017-04-13 21:24:21 -04:00
|
|
|
bool FCDProInput::openDevice()
|
|
|
|
{
|
2018-11-19 19:48:17 -05:00
|
|
|
if (m_dev != 0) {
|
2017-04-13 21:24:21 -04:00
|
|
|
closeDevice();
|
|
|
|
}
|
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
int device = m_deviceAPI->getSamplingDeviceSequence();
|
2017-04-13 21:24:21 -04:00
|
|
|
qDebug() << "FCDProInput::openDevice with device #" << device;
|
|
|
|
m_dev = fcdOpen(fcd_traits<Pro>::vendorId, fcd_traits<Pro>::productId, device);
|
|
|
|
|
|
|
|
if (m_dev == 0)
|
|
|
|
{
|
|
|
|
qCritical("FCDProInput::start: could not open FCD");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-12-26 04:43:55 -05:00
|
|
|
if (!openFCDAudio(fcd_traits<Pro>::qtDeviceName))
|
|
|
|
{
|
|
|
|
qCritical("FCDProInput::start: could not open FCD audio source");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug("FCDProInput::start: FCD audio source opened");
|
|
|
|
}
|
|
|
|
|
2017-04-13 21:24:21 -04:00
|
|
|
return true;
|
2015-09-02 21:57:54 -04:00
|
|
|
}
|
|
|
|
|
2017-12-25 03:10:19 -05:00
|
|
|
void FCDProInput::init()
|
|
|
|
{
|
|
|
|
applySettings(m_settings, true);
|
|
|
|
}
|
|
|
|
|
2017-04-13 21:40:45 -04:00
|
|
|
bool FCDProInput::start()
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2017-04-13 21:24:21 -04:00
|
|
|
qDebug() << "FCDProInput::start";
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2017-04-13 21:24:21 -04:00
|
|
|
// QMutexLocker mutexLocker(&m_mutex);
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2017-04-13 21:24:21 -04:00
|
|
|
if (!m_dev) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2017-04-13 21:24:21 -04:00
|
|
|
if (m_running) stop();
|
2015-09-02 21:57:54 -04:00
|
|
|
|
|
|
|
/* Apply settings before streaming to avoid bus contention;
|
|
|
|
* there is very little spare bandwidth on a full speed USB device.
|
2015-09-03 02:39:57 -04:00
|
|
|
* Failure is harmless if no device is found
|
|
|
|
* ... This is rubbish...*/
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2015-09-03 02:39:57 -04:00
|
|
|
//applySettings(m_settings, true);
|
2015-09-02 21:57:54 -04:00
|
|
|
|
|
|
|
if(!m_sampleFifo.setSize(96000*4))
|
|
|
|
{
|
|
|
|
qCritical("Could not allocate SampleFifo");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-11-19 19:48:17 -05:00
|
|
|
m_FCDThread = new FCDProThread(&m_sampleFifo, &m_fcdFIFO);
|
2015-09-03 02:39:57 -04:00
|
|
|
m_FCDThread->startWork();
|
|
|
|
|
2017-04-13 21:24:21 -04:00
|
|
|
// mutexLocker.unlock();
|
2015-09-03 02:39:57 -04:00
|
|
|
applySettings(m_settings, true);
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
qDebug("FCDProInput::started");
|
2017-04-13 21:24:21 -04:00
|
|
|
m_running = true;
|
|
|
|
|
2015-09-02 21:57:54 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-04-13 21:24:21 -04:00
|
|
|
void FCDProInput::closeDevice()
|
|
|
|
{
|
2017-04-17 06:00:13 -04:00
|
|
|
if (m_dev == 0) { // was never open
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-13 21:24:21 -04:00
|
|
|
fcdClose(m_dev);
|
|
|
|
m_dev = 0;
|
2018-12-26 04:43:55 -05:00
|
|
|
|
|
|
|
closeFCDAudio();
|
2017-04-13 21:24:21 -04:00
|
|
|
}
|
|
|
|
|
2018-11-19 19:48:17 -05:00
|
|
|
bool FCDProInput::openFCDAudio(const char* cardname)
|
|
|
|
{
|
|
|
|
AudioDeviceManager *audioDeviceManager = DSPEngine::instance()->getAudioDeviceManager();
|
|
|
|
const QList<QAudioDeviceInfo>& audioList = audioDeviceManager->getInputDevices();
|
|
|
|
|
|
|
|
for (const auto &itAudio : audioList)
|
|
|
|
{
|
|
|
|
if (itAudio.deviceName().contains(QString(cardname)))
|
|
|
|
{
|
|
|
|
int fcdDeviceIndex = audioDeviceManager->getInputDeviceIndex(itAudio.deviceName());
|
|
|
|
m_fcdAudioInput.start(fcdDeviceIndex, fcd_traits<Pro>::sampleRate);
|
|
|
|
int fcdSampleRate = m_fcdAudioInput.getRate();
|
|
|
|
qDebug("FCDProPlusInput::openFCDAudio: %s index %d at %d S/s",
|
|
|
|
itAudio.deviceName().toStdString().c_str(), fcdDeviceIndex, fcdSampleRate);
|
|
|
|
m_fcdAudioInput.addFifo(&m_fcdFIFO);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
qCritical("FCDProInput::openFCDAudio: device with name %s not found", cardname);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::closeFCDAudio()
|
|
|
|
{
|
|
|
|
m_fcdAudioInput.removeFifo(&m_fcdFIFO);
|
|
|
|
m_fcdAudioInput.stop();
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
void FCDProInput::stop()
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2017-04-13 21:24:21 -04:00
|
|
|
// QMutexLocker mutexLocker(&m_mutex);
|
2015-09-02 21:57:54 -04:00
|
|
|
|
|
|
|
if (m_FCDThread)
|
|
|
|
{
|
|
|
|
m_FCDThread->stopWork();
|
|
|
|
// wait for thread to quit ?
|
|
|
|
delete m_FCDThread;
|
2018-11-19 19:48:17 -05:00
|
|
|
m_FCDThread = nullptr;
|
2015-09-02 21:57:54 -04:00
|
|
|
}
|
|
|
|
|
2017-04-13 21:24:21 -04:00
|
|
|
m_running = false;
|
2015-09-02 21:57:54 -04:00
|
|
|
}
|
|
|
|
|
2017-12-27 21:21:48 -05:00
|
|
|
QByteArray FCDProInput::serialize() const
|
|
|
|
{
|
|
|
|
return m_settings.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FCDProInput::deserialize(const QByteArray& data)
|
|
|
|
{
|
|
|
|
bool success = true;
|
|
|
|
|
|
|
|
if (!m_settings.deserialize(data))
|
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
|
2018-05-26 04:27:28 -04:00
|
|
|
MsgConfigureFCDPro* message = MsgConfigureFCDPro::create(m_settings, true);
|
2017-12-27 21:21:48 -05:00
|
|
|
m_inputMessageQueue.push(message);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue)
|
|
|
|
{
|
2018-05-26 04:27:28 -04:00
|
|
|
MsgConfigureFCDPro* messageToGUI = MsgConfigureFCDPro::create(m_settings, true);
|
2017-12-27 21:21:48 -05:00
|
|
|
m_guiMessageQueue->push(messageToGUI);
|
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
const QString& FCDProInput::getDeviceDescription() const
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
|
|
|
return m_deviceDescription;
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
int FCDProInput::getSampleRate() const
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2019-01-04 09:12:35 -05:00
|
|
|
return fcd_traits<Pro>::sampleRate/(1<<m_settings.m_log2Decim);
|
2015-09-02 21:57:54 -04:00
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
quint64 FCDProInput::getCenterFrequency() const
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
return m_settings.m_centerFrequency;
|
2015-09-02 21:57:54 -04:00
|
|
|
}
|
|
|
|
|
2017-12-27 21:21:48 -05:00
|
|
|
void FCDProInput::setCenterFrequency(qint64 centerFrequency)
|
|
|
|
{
|
|
|
|
FCDProSettings settings = m_settings;
|
|
|
|
settings.m_centerFrequency = centerFrequency;
|
|
|
|
|
2018-05-26 04:27:28 -04:00
|
|
|
MsgConfigureFCDPro* message = MsgConfigureFCDPro::create(settings, false);
|
2017-12-27 21:21:48 -05:00
|
|
|
m_inputMessageQueue.push(message);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue)
|
|
|
|
{
|
2018-05-26 04:27:28 -04:00
|
|
|
MsgConfigureFCDPro* messageToGUI = MsgConfigureFCDPro::create(settings, false);
|
2017-12-27 21:21:48 -05:00
|
|
|
m_guiMessageQueue->push(messageToGUI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
bool FCDProInput::handleMessage(const Message& message)
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2018-05-26 04:27:28 -04:00
|
|
|
if(MsgConfigureFCDPro::match(message))
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2015-09-03 22:10:38 -04:00
|
|
|
qDebug() << "FCDProInput::handleMessage: MsgConfigureFCD";
|
2018-05-26 04:27:28 -04:00
|
|
|
MsgConfigureFCDPro& conf = (MsgConfigureFCDPro&) message;
|
2017-10-14 03:35:39 -04:00
|
|
|
applySettings(conf.getSettings(), conf.getForce());
|
2015-09-02 21:57:54 -04:00
|
|
|
return true;
|
|
|
|
}
|
2017-12-14 12:02:49 -05:00
|
|
|
else if (MsgStartStop::match(message))
|
|
|
|
{
|
|
|
|
MsgStartStop& cmd = (MsgStartStop&) message;
|
|
|
|
qDebug() << "FCDProInput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
|
|
|
|
|
|
|
|
if (cmd.getStartStop())
|
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
if (m_deviceAPI->initDeviceEngine())
|
2017-12-14 12:02:49 -05:00
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceAPI->startDeviceEngine();
|
2017-12-14 12:02:49 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceAPI->stopDeviceEngine();
|
2017-12-14 12:02:49 -05:00
|
|
|
}
|
|
|
|
|
2018-12-26 03:51:59 -05:00
|
|
|
if (m_settings.m_useReverseAPI) {
|
|
|
|
webapiReverseSendStartStop(cmd.getStartStop());
|
|
|
|
}
|
|
|
|
|
2017-12-14 12:02:49 -05:00
|
|
|
return true;
|
|
|
|
}
|
2017-09-04 17:35:57 -04:00
|
|
|
else if (MsgFileRecord::match(message))
|
|
|
|
{
|
|
|
|
MsgFileRecord& conf = (MsgFileRecord&) message;
|
|
|
|
qDebug() << "FCDProInput::handleMessage: MsgFileRecord: " << conf.getStartStop();
|
|
|
|
|
2018-05-09 11:39:48 -04:00
|
|
|
if (conf.getStartStop())
|
|
|
|
{
|
|
|
|
if (m_settings.m_fileRecordName.size() != 0) {
|
|
|
|
m_fileSink->setFileName(m_settings.m_fileRecordName);
|
|
|
|
} else {
|
2018-05-11 03:08:20 -04:00
|
|
|
m_fileSink->genUniqueFileName(m_deviceAPI->getDeviceUID());
|
2018-05-09 11:39:48 -04:00
|
|
|
}
|
|
|
|
|
2017-09-04 17:35:57 -04:00
|
|
|
m_fileSink->startRecording();
|
2018-05-09 11:39:48 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-04 17:35:57 -04:00
|
|
|
m_fileSink->stopRecording();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2015-09-02 21:57:54 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
void FCDProInput::applySettings(const FCDProSettings& settings, bool force)
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2017-12-24 05:05:16 -05:00
|
|
|
bool forwardChange = false;
|
2018-12-26 03:51:59 -05:00
|
|
|
QList<QString> reverseAPIKeys;
|
|
|
|
|
|
|
|
if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency)) {
|
|
|
|
reverseAPIKeys.append("centerFrequency");
|
|
|
|
}
|
|
|
|
if (force || (m_settings.m_transverterMode != settings.m_transverterMode)) {
|
|
|
|
reverseAPIKeys.append("transverterMode");
|
|
|
|
}
|
|
|
|
if (force || (m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency)) {
|
|
|
|
reverseAPIKeys.append("transverterDeltaFrequency");
|
|
|
|
}
|
2019-01-04 18:31:16 -05:00
|
|
|
if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force) {
|
|
|
|
reverseAPIKeys.append("LOppmTenths");
|
|
|
|
}
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2017-09-25 14:16:25 -04:00
|
|
|
if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency)
|
2019-01-04 18:31:16 -05:00
|
|
|
|| (m_settings.m_LOppmTenths != settings.m_LOppmTenths)
|
|
|
|
|| (m_settings.m_fcPos != settings.m_fcPos)
|
|
|
|
|| (m_settings.m_log2Decim != settings.m_log2Decim)
|
|
|
|
|| (m_settings.m_transverterMode != settings.m_transverterMode)
|
|
|
|
|| (m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency))
|
|
|
|
{
|
|
|
|
qint64 deviceCenterFrequency = DeviceSampleSource::calculateDeviceCenterFrequency(
|
|
|
|
settings.m_centerFrequency,
|
|
|
|
settings.m_transverterDeltaFrequency,
|
|
|
|
settings.m_log2Decim,
|
|
|
|
(DeviceSampleSource::fcPos_t) settings.m_fcPos,
|
|
|
|
fcd_traits<Pro>::sampleRate,
|
2019-04-01 19:10:03 -04:00
|
|
|
DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD,
|
2019-01-04 18:31:16 -05:00
|
|
|
settings.m_transverterMode);
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2017-09-25 14:16:25 -04:00
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
|
|
|
set_center_freq((double) deviceCenterFrequency);
|
|
|
|
}
|
|
|
|
|
|
|
|
qDebug() << "FCDProInput::applySettings: center freq: " << settings.m_centerFrequency << " Hz"
|
|
|
|
<< " device center freq: " << deviceCenterFrequency << " Hz";
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2017-12-24 05:05:16 -05:00
|
|
|
forwardChange = (m_settings.m_centerFrequency != settings.m_centerFrequency) || force;
|
|
|
|
|
2017-09-25 14:16:25 -04:00
|
|
|
m_settings.m_centerFrequency = settings.m_centerFrequency;
|
2015-09-02 21:57:54 -04:00
|
|
|
}
|
|
|
|
|
2019-01-04 09:12:35 -05:00
|
|
|
if ((m_settings.m_log2Decim != settings.m_log2Decim) || force)
|
|
|
|
{
|
|
|
|
reverseAPIKeys.append("log2Decim");
|
|
|
|
forwardChange = true;
|
|
|
|
|
|
|
|
if (m_FCDThread != 0)
|
|
|
|
{
|
|
|
|
m_FCDThread->setLog2Decimation(settings.m_log2Decim);
|
|
|
|
qDebug() << "FCDProInput::applySettings: set decimation to " << (1<<settings.m_log2Decim);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-04 18:31:16 -05:00
|
|
|
if ((m_settings.m_fcPos != settings.m_fcPos) || force)
|
|
|
|
{
|
|
|
|
reverseAPIKeys.append("fcPos");
|
|
|
|
|
|
|
|
if (m_FCDThread != 0) {
|
|
|
|
m_FCDThread->setFcPos((int) settings.m_fcPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
qDebug() << "FCDProInput::applySettings: set fc pos (enum) to " << (int) settings.m_fcPos;
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_lnaGainIndex != settings.m_lnaGainIndex) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2018-12-26 03:51:59 -05:00
|
|
|
reverseAPIKeys.append("lnaGainIndex");
|
2015-09-06 23:35:01 -04:00
|
|
|
|
2018-12-26 03:51:59 -05:00
|
|
|
if (m_dev != 0) {
|
2015-09-29 23:38:58 -04:00
|
|
|
set_lnaGain(settings.m_lnaGainIndex);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_rfFilterIndex != settings.m_rfFilterIndex) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2018-12-26 03:51:59 -05:00
|
|
|
reverseAPIKeys.append("rfFilterIndex");
|
2015-09-06 23:35:01 -04:00
|
|
|
|
2018-12-26 03:51:59 -05:00
|
|
|
if (m_dev != 0) {
|
2015-09-29 23:38:58 -04:00
|
|
|
set_rfFilter(settings.m_rfFilterIndex);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_lnaEnhanceIndex != settings.m_lnaEnhanceIndex) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2018-12-26 03:51:59 -05:00
|
|
|
reverseAPIKeys.append("lnaEnhanceIndex");
|
2015-09-06 23:35:01 -04:00
|
|
|
|
2018-12-26 03:51:59 -05:00
|
|
|
if (m_dev != 0) {
|
2015-09-29 23:38:58 -04:00
|
|
|
set_lnaEnhance(settings.m_lnaEnhanceIndex);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_bandIndex != settings.m_bandIndex) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2018-12-26 03:51:59 -05:00
|
|
|
reverseAPIKeys.append("bandIndex");
|
2015-09-06 23:35:01 -04:00
|
|
|
|
2018-12-26 03:51:59 -05:00
|
|
|
if (m_dev != 0) {
|
2015-09-29 23:38:58 -04:00
|
|
|
set_band(settings.m_bandIndex);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_mixerGainIndex != settings.m_mixerGainIndex) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2018-12-26 03:51:59 -05:00
|
|
|
reverseAPIKeys.append("mixerGainIndex");
|
2015-09-06 23:35:01 -04:00
|
|
|
|
2018-12-26 03:51:59 -05:00
|
|
|
if (m_dev != 0) {
|
2015-09-29 23:38:58 -04:00
|
|
|
set_mixerGain(settings.m_mixerGainIndex);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_mixerFilterIndex != settings.m_mixerFilterIndex) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2018-12-26 03:51:59 -05:00
|
|
|
reverseAPIKeys.append("mixerFilterIndex");
|
2015-09-06 23:35:01 -04:00
|
|
|
|
2018-12-26 03:51:59 -05:00
|
|
|
if (m_dev != 0) {
|
2015-09-29 23:38:58 -04:00
|
|
|
set_mixerFilter(settings.m_mixerFilterIndex);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_biasCurrentIndex != settings.m_biasCurrentIndex) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2018-12-26 03:51:59 -05:00
|
|
|
reverseAPIKeys.append("biasCurrentIndex");
|
2015-09-06 23:35:01 -04:00
|
|
|
|
2018-12-26 03:51:59 -05:00
|
|
|
if (m_dev != 0) {
|
2015-09-29 23:38:58 -04:00
|
|
|
set_biasCurrent(settings.m_biasCurrentIndex);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_modeIndex != settings.m_modeIndex) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2018-12-26 03:51:59 -05:00
|
|
|
reverseAPIKeys.append("modeIndex");
|
2015-09-06 23:35:01 -04:00
|
|
|
|
2018-12-26 03:51:59 -05:00
|
|
|
if (m_dev != 0) {
|
2015-09-29 23:38:58 -04:00
|
|
|
set_mode(settings.m_modeIndex);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_gain1Index != settings.m_gain1Index) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2018-12-26 03:51:59 -05:00
|
|
|
reverseAPIKeys.append("gain1Index");
|
2015-09-06 23:35:01 -04:00
|
|
|
|
2018-12-26 03:51:59 -05:00
|
|
|
if (m_dev != 0) {
|
2015-09-29 23:38:58 -04:00
|
|
|
set_gain1(settings.m_gain1Index);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_rcFilterIndex != settings.m_rcFilterIndex) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2018-12-26 03:51:59 -05:00
|
|
|
reverseAPIKeys.append("rcFilterIndex");
|
2015-09-06 23:35:01 -04:00
|
|
|
|
2018-12-26 03:51:59 -05:00
|
|
|
if (m_dev != 0) {
|
2015-09-29 23:38:58 -04:00
|
|
|
set_rcFilter(settings.m_rcFilterIndex);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_gain2Index != settings.m_gain2Index) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2018-12-26 03:51:59 -05:00
|
|
|
reverseAPIKeys.append("gain2Index");
|
2015-09-06 23:35:01 -04:00
|
|
|
|
2018-12-26 03:51:59 -05:00
|
|
|
if (m_dev != 0) {
|
2015-09-29 23:38:58 -04:00
|
|
|
set_gain2(settings.m_gain2Index);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_gain3Index != settings.m_gain3Index) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2018-12-26 03:51:59 -05:00
|
|
|
reverseAPIKeys.append("gain3Index");
|
2015-09-06 23:35:01 -04:00
|
|
|
|
2018-12-26 03:51:59 -05:00
|
|
|
if (m_dev != 0) {
|
2015-09-29 23:38:58 -04:00
|
|
|
set_gain3(settings.m_gain3Index);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_gain4Index != settings.m_gain4Index) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2018-12-26 03:51:59 -05:00
|
|
|
reverseAPIKeys.append("gain4Index");
|
2015-09-06 23:35:01 -04:00
|
|
|
|
2018-12-26 03:51:59 -05:00
|
|
|
if (m_dev != 0) {
|
2015-09-29 23:38:58 -04:00
|
|
|
set_gain4(settings.m_gain4Index);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_ifFilterIndex != settings.m_ifFilterIndex) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2018-12-26 03:51:59 -05:00
|
|
|
reverseAPIKeys.append("ifFilterIndex");
|
2015-09-06 23:35:01 -04:00
|
|
|
|
2018-12-26 03:51:59 -05:00
|
|
|
if (m_dev != 0) {
|
2015-09-29 23:38:58 -04:00
|
|
|
set_ifFilter(settings.m_ifFilterIndex);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_gain5Index != settings.m_gain5Index) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2018-12-26 03:51:59 -05:00
|
|
|
reverseAPIKeys.append("gain5Index");
|
2015-09-06 23:35:01 -04:00
|
|
|
|
2018-12-26 03:51:59 -05:00
|
|
|
if (m_dev != 0) {
|
2015-09-29 23:38:58 -04:00
|
|
|
set_gain5(settings.m_gain5Index);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_gain6Index != settings.m_gain6Index) || force)
|
2015-09-06 23:35:01 -04:00
|
|
|
{
|
2018-12-26 03:51:59 -05:00
|
|
|
reverseAPIKeys.append("gain6Index");
|
2015-09-06 23:35:01 -04:00
|
|
|
|
2018-12-26 03:51:59 -05:00
|
|
|
if (m_dev != 0) {
|
2015-09-29 23:38:58 -04:00
|
|
|
set_gain6(settings.m_gain6Index);
|
2015-09-06 23:35:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 23:38:58 -04:00
|
|
|
if ((m_settings.m_dcBlock != settings.m_dcBlock) || force)
|
|
|
|
{
|
2018-12-26 03:51:59 -05:00
|
|
|
reverseAPIKeys.append("dcBlock");
|
|
|
|
m_deviceAPI->configureCorrections(settings.m_dcBlock, settings.m_iqCorrection);
|
2015-09-29 23:38:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((m_settings.m_iqCorrection != settings.m_iqCorrection) || force)
|
|
|
|
{
|
2018-12-26 03:51:59 -05:00
|
|
|
reverseAPIKeys.append("iqCorrection");
|
|
|
|
m_deviceAPI->configureCorrections(settings.m_dcBlock, settings.m_iqCorrection);
|
2015-09-29 23:38:58 -04:00
|
|
|
}
|
|
|
|
|
2018-12-26 03:51:59 -05:00
|
|
|
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;
|
|
|
|
|
2017-12-24 05:05:16 -05:00
|
|
|
if (forwardChange)
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2019-01-04 09:12:35 -05:00
|
|
|
DSPSignalNotification *notif = new DSPSignalNotification(fcd_traits<Pro>::sampleRate/(1<<m_settings.m_log2Decim), m_settings.m_centerFrequency);
|
2017-09-04 17:35:57 -04:00
|
|
|
m_fileSink->handleMessage(*notif); // forward to file sink
|
2017-09-13 17:40:06 -04:00
|
|
|
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
2015-09-02 21:57:54 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
void FCDProInput::set_center_freq(double freq)
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2015-09-29 23:38:58 -04:00
|
|
|
freq += freq*(((double) m_settings.m_LOppmTenths)/10000000.0);
|
2015-09-07 19:27:18 -04:00
|
|
|
|
2015-09-02 21:57:54 -04:00
|
|
|
if (fcdAppSetFreq(m_dev, freq) == FCD_MODE_NONE)
|
|
|
|
{
|
|
|
|
qDebug("No FCD HID found for frquency change");
|
|
|
|
}
|
2015-09-07 19:27:18 -04:00
|
|
|
|
2015-09-02 21:57:54 -04:00
|
|
|
}
|
|
|
|
|
2018-11-13 02:51:14 -05:00
|
|
|
void FCDProInput::set_bias_t(bool on)
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2018-11-13 02:51:14 -05:00
|
|
|
(void) on;
|
2017-05-25 14:13:34 -04:00
|
|
|
//quint8 cmd = on ? 1 : 0;
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2015-09-05 00:24:02 -04:00
|
|
|
// TODO: use FCD Pro controls
|
|
|
|
//fcdAppSetParam(m_dev, FCD_CMD_APP_SET_BIAS_TEE, &cmd, 1);
|
2015-09-02 21:57:54 -04:00
|
|
|
}
|
|
|
|
|
2015-09-06 22:55:55 -04:00
|
|
|
void FCDProInput::set_lnaGain(int index)
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2015-09-06 22:55:55 -04:00
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_lna_gain_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2015-09-06 22:55:55 -04:00
|
|
|
quint8 cmd_value = FCDProConstants::lna_gains[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_LNA_GAIN, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_lnaGain: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_rfFilter(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_rf_filter_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::rf_filters[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_RF_FILTER, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_rfFilter: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_lnaEnhance(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_lna_enhance_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::lna_enhances[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_LNA_ENHANCE, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_lnaEnhance: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_band(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_band_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::bands[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_BAND, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_band: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_mixerGain(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_mixer_gain_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::mixer_gains[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_MIXER_GAIN, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_mixerGain: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_mixerFilter(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_mixer_filter_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::mixer_filters[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_MIXER_FILTER, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_mixerFilter: failed to set at " << cmd_value;
|
|
|
|
}
|
2015-09-02 21:57:54 -04:00
|
|
|
}
|
|
|
|
|
2015-09-06 22:55:55 -04:00
|
|
|
void FCDProInput::set_biasCurrent(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_bias_current_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::bias_currents[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_BIAS_CURRENT, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_biasCurrent: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2015-09-06 22:55:55 -04:00
|
|
|
void FCDProInput::set_mode(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_if_gain_mode_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::if_gain_modes[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_IF_GAIN_MODE, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_mode: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_gain1(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_if_gain1_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::if_gains1[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_IF_GAIN1, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_gain1: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_rcFilter(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_if_rc_filter_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::if_rc_filters[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_IF_RC_FILTER, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_rcFilter: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_gain2(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_if_gain2_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::if_gains2[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_IF_GAIN2, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_gain2: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_gain3(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_if_gain3_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::if_gains3[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_IF_GAIN3, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_gain3: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_gain4(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_if_gain4_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::if_gains4[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_IF_GAIN4, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_gain4: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_ifFilter(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_if_filter_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::if_filters[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_IF_FILTER, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_ifFilter: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_gain5(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_if_gain5_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::if_gains5[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_IF_GAIN5, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_gain5: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::set_gain6(int index)
|
|
|
|
{
|
|
|
|
if ((index < 0) || (index >= FCDProConstants::fcdpro_if_gain6_nb_values()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint8 cmd_value = FCDProConstants::if_gains6[index].value;
|
|
|
|
|
|
|
|
if (fcdAppSetParam(m_dev, FCDPRO_HID_CMD_SET_IF_GAIN6, &cmd_value, 1) != FCD_MODE_APP)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProPlusInput::set_gain6: failed to set at " << cmd_value;
|
|
|
|
}
|
|
|
|
}
|
2015-09-07 19:27:18 -04:00
|
|
|
|
2017-12-14 12:15:27 -05:00
|
|
|
int FCDProInput::webapiRunGet(
|
|
|
|
SWGSDRangel::SWGDeviceState& response,
|
2018-11-13 02:51:14 -05:00
|
|
|
QString& errorMessage)
|
2017-12-14 12:15:27 -05:00
|
|
|
{
|
2018-11-13 02:51:14 -05:00
|
|
|
(void) errorMessage;
|
2017-12-14 12:15:27 -05:00
|
|
|
m_deviceAPI->getDeviceEngineStateStr(*response.getState());
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
int FCDProInput::webapiRun(
|
|
|
|
bool run,
|
|
|
|
SWGSDRangel::SWGDeviceState& response,
|
2018-11-13 02:51:14 -05:00
|
|
|
QString& errorMessage)
|
2017-12-14 12:15:27 -05:00
|
|
|
{
|
2018-11-13 02:51:14 -05:00
|
|
|
(void) errorMessage;
|
2017-12-14 17:29:12 -05:00
|
|
|
m_deviceAPI->getDeviceEngineStateStr(*response.getState());
|
2017-12-14 12:15:27 -05:00
|
|
|
MsgStartStop *message = MsgStartStop::create(run);
|
|
|
|
m_inputMessageQueue.push(message);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue) // forward to GUI if any
|
|
|
|
{
|
|
|
|
MsgStartStop *msgToGUI = MsgStartStop::create(run);
|
|
|
|
m_guiMessageQueue->push(msgToGUI);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 200;
|
|
|
|
}
|
2018-05-26 04:27:28 -04:00
|
|
|
|
|
|
|
int FCDProInput::webapiSettingsGet(
|
|
|
|
SWGSDRangel::SWGDeviceSettings& response,
|
2018-11-13 02:51:14 -05:00
|
|
|
QString& errorMessage)
|
2018-05-26 04:27:28 -04:00
|
|
|
{
|
2018-11-13 02:51:14 -05:00
|
|
|
(void) errorMessage;
|
2018-05-26 04:27:28 -04:00
|
|
|
response.setFcdProSettings(new SWGSDRangel::SWGFCDProSettings());
|
|
|
|
response.getFcdProSettings()->init();
|
|
|
|
webapiFormatDeviceSettings(response, m_settings);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
int FCDProInput::webapiSettingsPutPatch(
|
|
|
|
bool force,
|
|
|
|
const QStringList& deviceSettingsKeys,
|
|
|
|
SWGSDRangel::SWGDeviceSettings& response, // query + response
|
2018-11-13 02:51:14 -05:00
|
|
|
QString& errorMessage)
|
2018-05-26 04:27:28 -04:00
|
|
|
{
|
2018-11-13 02:51:14 -05:00
|
|
|
(void) errorMessage;
|
2018-05-26 04:27:28 -04:00
|
|
|
FCDProSettings settings = m_settings;
|
|
|
|
|
|
|
|
if (deviceSettingsKeys.contains("centerFrequency")) {
|
|
|
|
settings.m_centerFrequency = response.getFcdProSettings()->getCenterFrequency();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("LOppmTenths")) {
|
|
|
|
settings.m_LOppmTenths = response.getFcdProSettings()->getLOppmTenths();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("lnaGainIndex")) {
|
|
|
|
settings.m_lnaGainIndex = response.getFcdProSettings()->getLnaGainIndex();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("rfFilterIndex")) {
|
|
|
|
settings.m_rfFilterIndex = response.getFcdProSettings()->getRfFilterIndex();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("lnaEnhanceIndex")) {
|
|
|
|
settings.m_lnaEnhanceIndex = response.getFcdProSettings()->getLnaEnhanceIndex();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("bandIndex")) {
|
|
|
|
settings.m_bandIndex = response.getFcdProSettings()->getBandIndex();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("mixerGainIndex")) {
|
|
|
|
settings.m_mixerGainIndex = response.getFcdProSettings()->getMixerGainIndex();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("mixerFilterIndex")) {
|
|
|
|
settings.m_mixerFilterIndex = response.getFcdProSettings()->getMixerFilterIndex();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("biasCurrentIndex")) {
|
|
|
|
settings.m_biasCurrentIndex = response.getFcdProSettings()->getBiasCurrentIndex();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("modeIndex")) {
|
|
|
|
settings.m_modeIndex = response.getFcdProSettings()->getModeIndex();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("gain1Index")) {
|
|
|
|
settings.m_gain1Index = response.getFcdProSettings()->getGain1Index();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("gain2Index")) {
|
|
|
|
settings.m_gain2Index = response.getFcdProSettings()->getGain2Index();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("gain3Index")) {
|
|
|
|
settings.m_gain3Index = response.getFcdProSettings()->getGain3Index();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("gain4Index")) {
|
|
|
|
settings.m_gain4Index = response.getFcdProSettings()->getGain4Index();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("gain5Index")) {
|
|
|
|
settings.m_gain5Index = response.getFcdProSettings()->getGain5Index();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("gain6Index")) {
|
|
|
|
settings.m_gain6Index = response.getFcdProSettings()->getGain6Index();
|
|
|
|
}
|
2019-01-05 04:07:25 -05:00
|
|
|
if (deviceSettingsKeys.contains("log2Decim")) {
|
|
|
|
settings.m_log2Decim = response.getFcdProSettings()->getLog2Decim();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("fcPos")) {
|
|
|
|
settings.m_fcPos = (FCDProSettings::fcPos_t) response.getFcdProSettings()->getFcPos();
|
|
|
|
}
|
2018-05-26 04:27:28 -04:00
|
|
|
if (deviceSettingsKeys.contains("rcFilterIndex")) {
|
|
|
|
settings.m_rcFilterIndex = response.getFcdProSettings()->getRcFilterIndex();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("ifFilterIndex")) {
|
|
|
|
settings.m_ifFilterIndex = response.getFcdProSettings()->getIfFilterIndex();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("dcBlock")) {
|
|
|
|
settings.m_dcBlock = response.getFcdProSettings()->getDcBlock() != 0;
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("iqCorrection")) {
|
|
|
|
settings.m_iqCorrection = response.getFcdProSettings()->getIqCorrection() != 0;
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("transverterDeltaFrequency")) {
|
|
|
|
settings.m_transverterDeltaFrequency = response.getFcdProSettings()->getTransverterDeltaFrequency();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("transverterMode")) {
|
|
|
|
settings.m_transverterMode = response.getFcdProSettings()->getTransverterMode() != 0;
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("fileRecordName")) {
|
|
|
|
settings.m_fileRecordName = *response.getFcdProSettings()->getFileRecordName();
|
|
|
|
}
|
2019-01-11 08:45:00 -05:00
|
|
|
if (deviceSettingsKeys.contains("useReverseAPI")) {
|
|
|
|
settings.m_useReverseAPI = response.getFcdProSettings()->getUseReverseApi() != 0;
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("reverseAPIAddress")) {
|
|
|
|
settings.m_reverseAPIAddress = *response.getFcdProSettings()->getReverseApiAddress();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("reverseAPIPort")) {
|
|
|
|
settings.m_reverseAPIPort = response.getFcdProSettings()->getReverseApiPort();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
|
|
|
|
settings.m_reverseAPIDeviceIndex = response.getFcdProSettings()->getReverseApiDeviceIndex();
|
|
|
|
}
|
2018-05-26 04:27:28 -04:00
|
|
|
|
|
|
|
MsgConfigureFCDPro *msg = MsgConfigureFCDPro::create(settings, force);
|
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue) // forward to GUI if any
|
|
|
|
{
|
|
|
|
MsgConfigureFCDPro *msgToGUI = MsgConfigureFCDPro::create(settings, force);
|
|
|
|
m_guiMessageQueue->push(msgToGUI);
|
|
|
|
}
|
|
|
|
|
|
|
|
webapiFormatDeviceSettings(response, settings);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const FCDProSettings& settings)
|
|
|
|
{
|
|
|
|
response.getFcdProSettings()->setCenterFrequency(settings.m_centerFrequency);
|
|
|
|
response.getFcdProSettings()->setLOppmTenths(settings.m_LOppmTenths);
|
|
|
|
response.getFcdProSettings()->setLnaGainIndex(settings.m_lnaGainIndex);
|
2018-05-26 04:54:31 -04:00
|
|
|
response.getFcdProSettings()->setRfFilterIndex(settings.m_rfFilterIndex);
|
2018-05-26 04:27:28 -04:00
|
|
|
response.getFcdProSettings()->setLnaEnhanceIndex(settings.m_lnaEnhanceIndex);
|
|
|
|
response.getFcdProSettings()->setBandIndex(settings.m_bandIndex);
|
|
|
|
response.getFcdProSettings()->setMixerGainIndex(settings.m_mixerGainIndex);
|
|
|
|
response.getFcdProSettings()->setMixerFilterIndex(settings.m_mixerFilterIndex);
|
|
|
|
response.getFcdProSettings()->setBiasCurrentIndex(settings.m_biasCurrentIndex);
|
|
|
|
response.getFcdProSettings()->setModeIndex(settings.m_modeIndex);
|
|
|
|
response.getFcdProSettings()->setGain1Index(settings.m_gain1Index);
|
|
|
|
response.getFcdProSettings()->setGain2Index(settings.m_gain2Index);
|
|
|
|
response.getFcdProSettings()->setGain3Index(settings.m_gain3Index);
|
|
|
|
response.getFcdProSettings()->setGain4Index(settings.m_gain4Index);
|
|
|
|
response.getFcdProSettings()->setGain5Index(settings.m_gain5Index);
|
|
|
|
response.getFcdProSettings()->setGain6Index(settings.m_gain6Index);
|
2019-01-05 04:07:25 -05:00
|
|
|
response.getFcdProSettings()->setLog2Decim(settings.m_log2Decim);
|
|
|
|
response.getFcdProSettings()->setFcPos((int) settings.m_fcPos);
|
2018-05-26 04:27:28 -04:00
|
|
|
response.getFcdProSettings()->setRcFilterIndex(settings.m_rcFilterIndex);
|
|
|
|
response.getFcdProSettings()->setIfFilterIndex(settings.m_ifFilterIndex);
|
|
|
|
response.getFcdProSettings()->setDcBlock(settings.m_dcBlock ? 1 : 0);
|
|
|
|
response.getFcdProSettings()->setIqCorrection(settings.m_iqCorrection ? 1 : 0);
|
|
|
|
response.getFcdProSettings()->setTransverterDeltaFrequency(settings.m_transverterDeltaFrequency);
|
|
|
|
response.getFcdProSettings()->setTransverterMode(settings.m_transverterMode ? 1 : 0);
|
|
|
|
|
|
|
|
if (response.getFcdProSettings()->getFileRecordName()) {
|
|
|
|
*response.getFcdProSettings()->getFileRecordName() = settings.m_fileRecordName;
|
|
|
|
} else {
|
|
|
|
response.getFcdProSettings()->setFileRecordName(new QString(settings.m_fileRecordName));
|
|
|
|
}
|
2019-01-11 08:45:00 -05:00
|
|
|
|
|
|
|
response.getFcdProSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
|
|
|
|
|
|
|
|
if (response.getFcdProSettings()->getReverseApiAddress()) {
|
|
|
|
*response.getFcdProSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress;
|
|
|
|
} else {
|
|
|
|
response.getFcdProSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
|
|
|
|
}
|
|
|
|
|
|
|
|
response.getFcdProSettings()->setReverseApiPort(settings.m_reverseAPIPort);
|
|
|
|
response.getFcdProSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
|
2018-05-26 04:27:28 -04:00
|
|
|
}
|
2018-12-26 03:51:59 -05:00
|
|
|
|
|
|
|
void FCDProInput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const FCDProSettings& settings, bool force)
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
2019-05-07 08:43:38 -04:00
|
|
|
swgDeviceSettings->setDirection(0); // single Rx
|
2019-03-25 08:41:38 -04:00
|
|
|
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
|
2018-12-26 03:51:59 -05:00
|
|
|
swgDeviceSettings->setDeviceHwType(new QString("FCDPro"));
|
|
|
|
swgDeviceSettings->setFcdProSettings(new SWGSDRangel::SWGFCDProSettings());
|
|
|
|
SWGSDRangel::SWGFCDProSettings *swgFCDProSettings = swgDeviceSettings->getFcdProSettings();
|
|
|
|
|
|
|
|
// transfer data that has been modified. When force is on transfer all data except reverse API data
|
|
|
|
|
|
|
|
if (deviceSettingsKeys.contains("centerFrequency") || force) {
|
|
|
|
swgFCDProSettings->setCenterFrequency(settings.m_centerFrequency);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("LOppmTenths") || force) {
|
|
|
|
swgFCDProSettings->setLOppmTenths(settings.m_LOppmTenths);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("lnaGainIndex") || force) {
|
|
|
|
swgFCDProSettings->setLnaGainIndex(settings.m_lnaGainIndex);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("rfFilterIndex") || force) {
|
|
|
|
swgFCDProSettings->setRfFilterIndex(settings.m_rfFilterIndex);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("lnaEnhanceIndex") || force) {
|
|
|
|
swgFCDProSettings->setLnaEnhanceIndex(settings.m_lnaEnhanceIndex);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("bandIndex") || force) {
|
|
|
|
swgFCDProSettings->setBandIndex(settings.m_bandIndex);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("mixerGainIndex") || force) {
|
|
|
|
swgFCDProSettings->setMixerGainIndex(settings.m_mixerGainIndex);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("mixerFilterIndex") || force) {
|
|
|
|
swgFCDProSettings->setMixerFilterIndex(settings.m_mixerFilterIndex);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("biasCurrentIndex") || force) {
|
|
|
|
swgFCDProSettings->setBiasCurrentIndex(settings.m_biasCurrentIndex);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("modeIndex") || force) {
|
|
|
|
swgFCDProSettings->setModeIndex(settings.m_modeIndex);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("gain1Index") || force) {
|
|
|
|
swgFCDProSettings->setGain1Index(settings.m_gain1Index);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("gain2Index") || force) {
|
|
|
|
swgFCDProSettings->setGain2Index(settings.m_gain2Index);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("gain3Index") || force) {
|
|
|
|
swgFCDProSettings->setGain3Index(settings.m_gain3Index);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("gain4Index") || force) {
|
|
|
|
swgFCDProSettings->setGain4Index(settings.m_gain4Index);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("gain5Index") || force) {
|
|
|
|
swgFCDProSettings->setGain5Index(settings.m_gain5Index);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("gain6Index") || force) {
|
|
|
|
swgFCDProSettings->setGain6Index(settings.m_gain6Index);
|
|
|
|
}
|
2019-01-05 04:07:25 -05:00
|
|
|
if (deviceSettingsKeys.contains("log2Decim") || force) {
|
|
|
|
swgFCDProSettings->setLog2Decim(settings.m_log2Decim);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("fcPos") || force) {
|
|
|
|
swgFCDProSettings->setFcPos(settings.m_fcPos);
|
|
|
|
}
|
2018-12-26 03:51:59 -05:00
|
|
|
if (deviceSettingsKeys.contains("rcFilterIndex") || force) {
|
|
|
|
swgFCDProSettings->setRcFilterIndex(settings.m_rcFilterIndex);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("ifFilterIndex") || force) {
|
|
|
|
swgFCDProSettings->setIfFilterIndex(settings.m_ifFilterIndex);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("dcBlock") || force) {
|
|
|
|
swgFCDProSettings->setDcBlock(settings.m_dcBlock ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("iqCorrection") || force) {
|
|
|
|
swgFCDProSettings->setIqCorrection(settings.m_iqCorrection ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("transverterDeltaFrequency") || force) {
|
|
|
|
swgFCDProSettings->setTransverterDeltaFrequency(settings.m_transverterDeltaFrequency);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("transverterMode") || force) {
|
|
|
|
swgFCDProSettings->setTransverterMode(settings.m_transverterMode ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("fileRecordName") || force) {
|
|
|
|
swgFCDProSettings->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 FCDProInput::webapiReverseSendStartStop(bool start)
|
|
|
|
{
|
2019-03-25 10:21:17 -04:00
|
|
|
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
2019-05-07 08:43:38 -04:00
|
|
|
swgDeviceSettings->setDirection(0); // single Rx
|
2019-03-25 10:21:17 -04:00
|
|
|
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
|
|
|
|
swgDeviceSettings->setDeviceHwType(new QString("FCDPro"));
|
|
|
|
|
2018-12-26 03:51:59 -05:00
|
|
|
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));
|
2019-03-25 10:21:17 -04:00
|
|
|
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
|
|
|
|
|
|
|
QBuffer *buffer=new QBuffer();
|
|
|
|
buffer->open((QBuffer::ReadWrite));
|
|
|
|
buffer->write(swgDeviceSettings->asJson().toUtf8());
|
|
|
|
buffer->seek(0);
|
2018-12-26 03:51:59 -05:00
|
|
|
|
|
|
|
if (start) {
|
2019-03-25 10:21:17 -04:00
|
|
|
m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
|
2018-12-26 03:51:59 -05:00
|
|
|
} else {
|
2019-03-25 10:21:17 -04:00
|
|
|
m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
|
2018-12-26 03:51:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::networkManagerFinished(QNetworkReply *reply)
|
|
|
|
{
|
|
|
|
QNetworkReply::NetworkError replyError = reply->error();
|
|
|
|
|
|
|
|
if (replyError)
|
|
|
|
{
|
|
|
|
qWarning() << "FCDProInput::networkManagerFinished:"
|
|
|
|
<< " error(" << (int) replyError
|
|
|
|
<< "): " << replyError
|
|
|
|
<< ": " << reply->errorString();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString answer = reply->readAll();
|
|
|
|
answer.chop(1); // remove last \n
|
|
|
|
qDebug("FCDProInput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
|
|
|
|
}
|