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"
|
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)
|
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),
|
2020-08-08 05:53:56 -04:00
|
|
|
m_dev(nullptr),
|
2015-09-02 21:57:54 -04:00
|
|
|
m_settings(),
|
2020-06-21 05:46:08 -04:00
|
|
|
m_FCDThread(nullptr),
|
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
|
|
|
{
|
2022-03-17 16:10:30 -04:00
|
|
|
m_sampleFifo.setLabel(m_deviceDescription);
|
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();
|
2019-05-20 18:27:08 -04:00
|
|
|
m_deviceAPI->setNbSourceStreams(1);
|
2018-12-26 03:51:59 -05:00
|
|
|
m_networkManager = new QNetworkAccessManager();
|
2022-03-23 17:32:23 -04:00
|
|
|
QObject::connect(
|
|
|
|
m_networkManager,
|
|
|
|
&QNetworkAccessManager::finished,
|
|
|
|
this,
|
|
|
|
&FCDProInput::networkManagerFinished
|
|
|
|
);
|
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
|
|
|
{
|
2022-03-23 17:32:23 -04:00
|
|
|
QObject::disconnect(
|
|
|
|
m_networkManager,
|
|
|
|
&QNetworkAccessManager::finished,
|
|
|
|
this,
|
|
|
|
&FCDProInput::networkManagerFinished
|
|
|
|
);
|
2018-12-26 03:51:59 -05:00
|
|
|
delete m_networkManager;
|
|
|
|
|
2018-11-19 19:48:17 -05:00
|
|
|
if (m_running) {
|
|
|
|
stop();
|
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
{
|
2022-10-22 20:07:59 -04:00
|
|
|
applySettings(m_settings, QList<QString>(), true);
|
2017-12-25 03:10:19 -05:00
|
|
|
}
|
|
|
|
|
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);
|
2020-06-21 05:46:08 -04:00
|
|
|
m_FCDThread->setLog2Decimation(m_settings.m_log2Decim);
|
|
|
|
m_FCDThread->setFcPos(m_settings.m_fcPos);
|
|
|
|
m_FCDThread->setIQOrder(m_settings.m_iqOrder);
|
2015-09-03 02:39:57 -04:00
|
|
|
m_FCDThread->startWork();
|
|
|
|
|
2017-04-13 21:24:21 -04:00
|
|
|
// mutexLocker.unlock();
|
2022-10-22 20:07:59 -04:00
|
|
|
applySettings(m_settings, QList<QString>(), 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();
|
2022-11-17 10:12:13 -05:00
|
|
|
const QList<AudioDeviceInfo>& audioList = audioDeviceManager->getInputDevices();
|
2018-11-19 19:48:17 -05:00
|
|
|
|
|
|
|
for (const auto &itAudio : audioList)
|
|
|
|
{
|
|
|
|
if (itAudio.deviceName().contains(QString(cardname)))
|
|
|
|
{
|
|
|
|
int fcdDeviceIndex = audioDeviceManager->getInputDeviceIndex(itAudio.deviceName());
|
2023-07-09 21:38:40 -04:00
|
|
|
AudioDeviceManager::InputDeviceInfo fcdDeviceInfo;
|
|
|
|
audioDeviceManager->getInputDeviceInfo(itAudio.deviceName(), fcdDeviceInfo);
|
|
|
|
fcdDeviceInfo.sampleRate = fcd_traits<Pro>::sampleRate;
|
|
|
|
audioDeviceManager->setInputDeviceInfo(fcdDeviceIndex, fcdDeviceInfo);
|
|
|
|
audioDeviceManager->addAudioSource(&m_fcdFIFO, getInputMessageQueue(), fcdDeviceIndex);
|
|
|
|
qDebug("FCDProPlusInput::openFCDAudio: %s index %d",
|
|
|
|
itAudio.deviceName().toStdString().c_str(), fcdDeviceIndex);
|
2018-11-19 19:48:17 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
qCritical("FCDProInput::openFCDAudio: device with name %s not found", cardname);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::closeFCDAudio()
|
|
|
|
{
|
2023-07-09 21:38:40 -04:00
|
|
|
AudioDeviceManager *audioDeviceManager = DSPEngine::instance()->getAudioDeviceManager();
|
|
|
|
audioDeviceManager->removeAudioSource(&m_fcdFIFO);
|
2018-11-19 19:48:17 -05:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
MsgConfigureFCDPro* message = MsgConfigureFCDPro::create(m_settings, QList<QString>(), true);
|
2017-12-27 21:21:48 -05:00
|
|
|
m_inputMessageQueue.push(message);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue)
|
|
|
|
{
|
2022-10-22 20:07:59 -04:00
|
|
|
MsgConfigureFCDPro* messageToGUI = MsgConfigureFCDPro::create(m_settings, QList<QString>(), 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;
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
MsgConfigureFCDPro* message = MsgConfigureFCDPro::create(settings, QList<QString>{"centerFrequency"}, false);
|
2017-12-27 21:21:48 -05:00
|
|
|
m_inputMessageQueue.push(message);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue)
|
|
|
|
{
|
2022-10-22 20:07:59 -04:00
|
|
|
MsgConfigureFCDPro* messageToGUI = MsgConfigureFCDPro::create(settings, QList<QString>{"centerFrequency"}, 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;
|
2022-10-22 20:07:59 -04:00
|
|
|
applySettings(conf.getSettings(), conf.getSettingsKeys(), 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())
|
|
|
|
{
|
2022-10-22 20:07:59 -04:00
|
|
|
if (m_deviceAPI->initDeviceEngine()) {
|
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;
|
|
|
|
}
|
2015-09-02 21:57:54 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
void FCDProInput::applySettings(const FCDProSettings& settings, const QList<QString>& settingsKeys, bool force)
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2022-10-22 20:07:59 -04:00
|
|
|
qDebug() << "FCDProInput::applySettings: force: " << force << settings.getDebugString(settingsKeys, force);
|
2017-12-24 05:05:16 -05:00
|
|
|
bool forwardChange = false;
|
2018-12-26 03:51:59 -05:00
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (force || settingsKeys.contains("centerFrequency")
|
|
|
|
|| settingsKeys.contains("LOppmTenths")
|
|
|
|
|| settingsKeys.contains("fcPos")
|
|
|
|
|| settingsKeys.contains("log2Decim")
|
|
|
|
|| settingsKeys.contains("transverterMode")
|
|
|
|
|| settingsKeys.contains("transverterDeltaFrequency"))
|
2019-01-04 18:31:16 -05:00
|
|
|
{
|
|
|
|
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
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (m_dev != 0) {
|
2017-09-25 14:16:25 -04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (settingsKeys.contains("log2Decim") || force)
|
2019-01-04 09:12:35 -05:00
|
|
|
{
|
|
|
|
forwardChange = true;
|
|
|
|
|
2020-06-21 05:46:08 -04:00
|
|
|
if (m_FCDThread)
|
2019-01-04 09:12:35 -05:00
|
|
|
{
|
|
|
|
m_FCDThread->setLog2Decimation(settings.m_log2Decim);
|
|
|
|
qDebug() << "FCDProInput::applySettings: set decimation to " << (1<<settings.m_log2Decim);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (settingsKeys.contains("fcPos") || force)
|
2019-01-04 18:31:16 -05:00
|
|
|
{
|
2020-06-21 05:46:08 -04:00
|
|
|
if (m_FCDThread) {
|
2019-01-04 18:31:16 -05:00
|
|
|
m_FCDThread->setFcPos((int) settings.m_fcPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
qDebug() << "FCDProInput::applySettings: set fc pos (enum) to " << (int) settings.m_fcPos;
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (settingsKeys.contains("iqOrder") || force)
|
2020-06-21 05:46:08 -04:00
|
|
|
{
|
|
|
|
if (m_FCDThread) {
|
|
|
|
m_FCDThread->setIQOrder((int) settings.m_iqOrder);
|
|
|
|
}
|
|
|
|
|
|
|
|
qDebug() << "FCDProInput::applySettings: set IQ order to %s" << (settings.m_iqOrder ? "IQ" : "QI");
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (settingsKeys.contains("lnaGainIndex") || force)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (settingsKeys.contains("rfFilterIndex") || force)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (settingsKeys.contains("lnaEnhanceIndex") || force)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (settingsKeys.contains("bandIndex") || force)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (settingsKeys.contains("mixerGainIndex") || force)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (settingsKeys.contains("mixerFilterIndex") || force)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (settingsKeys.contains("biasCurrentIndex") || force)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (settingsKeys.contains("modeIndex") || force)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (settingsKeys.contains("gain1Index") || force)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (settingsKeys.contains("rcFilterIndex") || force)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (settingsKeys.contains("gain2Index") || force)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (settingsKeys.contains("gain3Index") || force)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (settingsKeys.contains("gain4Index") || force)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (settingsKeys.contains("ifFilterIndex") || force)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (settingsKeys.contains("gain5Index") || force)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (settingsKeys.contains("gain6Index") || force)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (settingsKeys.contains("dcBlock") || force)
|
2015-09-29 23:38:58 -04:00
|
|
|
{
|
2018-12-26 03:51:59 -05:00
|
|
|
m_deviceAPI->configureCorrections(settings.m_dcBlock, settings.m_iqCorrection);
|
2015-09-29 23:38:58 -04:00
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (settingsKeys.contains("iqCorrection") || force)
|
2015-09-29 23:38:58 -04:00
|
|
|
{
|
2018-12-26 03:51:59 -05:00
|
|
|
m_deviceAPI->configureCorrections(settings.m_dcBlock, settings.m_iqCorrection);
|
2015-09-29 23:38:58 -04:00
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (settingsKeys.contains("useReverseAPI"))
|
2018-12-26 03:51:59 -05:00
|
|
|
{
|
2022-10-22 20:07:59 -04:00
|
|
|
bool fullUpdate = (settingsKeys.contains("useReverseAPI") && settings.m_useReverseAPI) ||
|
|
|
|
settingsKeys.contains("reverseAPIAddress") ||
|
|
|
|
settingsKeys.contains("reverseAPIPort") ||
|
|
|
|
settingsKeys.contains("reverseAPIDeviceIndex");
|
|
|
|
webapiReverseSendSettings(settingsKeys, settings, fullUpdate || force);
|
2018-12-26 03:51:59 -05:00
|
|
|
}
|
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
if (force) {
|
|
|
|
m_settings = settings;
|
|
|
|
} else {
|
|
|
|
m_settings.applySettings(settingsKeys, settings);
|
|
|
|
}
|
2018-12-26 03:51:59 -05:00
|
|
|
|
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-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;
|
2019-08-04 14:24:44 -04:00
|
|
|
webapiUpdateDeviceSettings(settings, deviceSettingsKeys, response);
|
2018-05-26 04:27:28 -04:00
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
MsgConfigureFCDPro *msg = MsgConfigureFCDPro::create(settings, deviceSettingsKeys, force);
|
2019-08-04 14:24:44 -04:00
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue) // forward to GUI if any
|
|
|
|
{
|
2022-10-22 20:07:59 -04:00
|
|
|
MsgConfigureFCDPro *msgToGUI = MsgConfigureFCDPro::create(settings, deviceSettingsKeys, force);
|
2019-08-04 14:24:44 -04:00
|
|
|
m_guiMessageQueue->push(msgToGUI);
|
|
|
|
}
|
|
|
|
|
|
|
|
webapiFormatDeviceSettings(response, settings);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProInput::webapiUpdateDeviceSettings(
|
|
|
|
FCDProSettings& settings,
|
|
|
|
const QStringList& deviceSettingsKeys,
|
|
|
|
SWGSDRangel::SWGDeviceSettings& response)
|
|
|
|
{
|
2018-05-26 04:27:28 -04:00
|
|
|
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();
|
|
|
|
}
|
2020-06-21 20:10:35 -04:00
|
|
|
if (deviceSettingsKeys.contains("iqOrder")) {
|
|
|
|
settings.m_iqOrder = response.getFcdProSettings()->getIqOrder() != 0;
|
|
|
|
}
|
2019-01-05 04:07:25 -05:00
|
|
|
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;
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2020-06-21 20:10:35 -04:00
|
|
|
response.getFcdProSettings()->setIqOrder(settings.m_iqOrder ? 1 : 0);
|
2019-01-05 04:07:25 -05:00
|
|
|
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);
|
|
|
|
|
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
|
|
|
|
2022-10-22 20:07:59 -04:00
|
|
|
void FCDProInput::webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const FCDProSettings& settings, bool force)
|
2018-12-26 03:51:59 -05:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
2020-06-21 20:10:35 -04:00
|
|
|
if (deviceSettingsKeys.contains("iqOrder") || force) {
|
|
|
|
swgFCDProSettings->setIqOrder(settings.m_iqOrder ? 1 : 0);
|
|
|
|
}
|
2019-01-05 04:07:25 -05:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
2019-11-12 12:46:21 -05:00
|
|
|
QBuffer *buffer = new QBuffer();
|
2018-12-26 03:51:59 -05:00
|
|
|
buffer->open((QBuffer::ReadWrite));
|
|
|
|
buffer->write(swgDeviceSettings->asJson().toUtf8());
|
|
|
|
buffer->seek(0);
|
|
|
|
|
|
|
|
// Always use PATCH to avoid passing reverse API settings
|
2019-11-12 12:46:21 -05:00
|
|
|
QNetworkReply *reply = m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
|
|
|
|
buffer->setParent(reply);
|
2018-12-26 03:51:59 -05:00
|
|
|
|
|
|
|
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");
|
|
|
|
|
2019-11-12 12:46:21 -05:00
|
|
|
QBuffer *buffer = new QBuffer();
|
2019-03-25 10:21:17 -04:00
|
|
|
buffer->open((QBuffer::ReadWrite));
|
|
|
|
buffer->write(swgDeviceSettings->asJson().toUtf8());
|
|
|
|
buffer->seek(0);
|
2019-11-12 12:46:21 -05:00
|
|
|
QNetworkReply *reply;
|
2018-12-26 03:51:59 -05:00
|
|
|
|
|
|
|
if (start) {
|
2019-11-12 12:46:21 -05:00
|
|
|
reply = m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
|
2018-12-26 03:51:59 -05:00
|
|
|
} else {
|
2019-11-12 12:46:21 -05:00
|
|
|
reply = m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
|
2018-12-26 03:51:59 -05:00
|
|
|
}
|
2019-06-14 10:58:09 -04:00
|
|
|
|
2019-11-12 12:46:21 -05:00
|
|
|
buffer->setParent(reply);
|
2019-06-14 10:58:09 -04:00
|
|
|
delete swgDeviceSettings;
|
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();
|
2019-11-12 12:46:21 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QString answer = reply->readAll();
|
|
|
|
answer.chop(1); // remove last \n
|
|
|
|
qDebug("FCDProInput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
|
2018-12-26 03:51:59 -05:00
|
|
|
}
|
|
|
|
|
2019-11-12 12:46:21 -05:00
|
|
|
reply->deleteLater();
|
2018-12-26 03:51:59 -05:00
|
|
|
}
|