2017-05-14 22:58:56 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
2017-05-21 11:32:56 +00:00
|
|
|
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
|
2017-05-14 22:58:56 +00: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 //
|
|
|
|
// //
|
|
|
|
// 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>
|
|
|
|
#include <QDebug>
|
2018-09-03 07:17:29 +00:00
|
|
|
#include <QNetworkAccessManager>
|
|
|
|
#include <QNetworkReply>
|
|
|
|
#include <QJsonParseError>
|
2018-12-26 21:30:35 +00:00
|
|
|
#include <QBuffer>
|
2017-05-14 22:58:56 +00:00
|
|
|
|
2017-12-14 17:22:45 +00:00
|
|
|
#include "SWGDeviceSettings.h"
|
|
|
|
#include "SWGDeviceState.h"
|
2018-05-27 22:40:33 +00:00
|
|
|
#include "SWGDeviceReport.h"
|
|
|
|
#include "SWGSDRdaemonSinkReport.h"
|
2017-12-14 17:22:45 +00:00
|
|
|
|
2017-05-14 22:58:56 +00:00
|
|
|
#include "util/simpleserializer.h"
|
|
|
|
#include "dsp/dspcommands.h"
|
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "dsp/filerecord.h"
|
|
|
|
|
|
|
|
#include "device/devicesinkapi.h"
|
|
|
|
|
|
|
|
#include "sdrdaemonsinkoutput.h"
|
|
|
|
#include "sdrdaemonsinkthread.h"
|
|
|
|
|
2017-05-21 02:19:12 +00:00
|
|
|
MESSAGE_CLASS_DEFINITION(SDRdaemonSinkOutput::MsgConfigureSDRdaemonSink, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(SDRdaemonSinkOutput::MsgConfigureSDRdaemonSinkWork, Message)
|
2017-12-14 17:02:49 +00:00
|
|
|
MESSAGE_CLASS_DEFINITION(SDRdaemonSinkOutput::MsgStartStop, Message)
|
2017-06-04 23:18:35 +00:00
|
|
|
MESSAGE_CLASS_DEFINITION(SDRdaemonSinkOutput::MsgConfigureSDRdaemonSinkChunkCorrection, Message)
|
2017-05-21 02:19:12 +00:00
|
|
|
|
2018-09-03 16:13:57 +00:00
|
|
|
const uint32_t SDRdaemonSinkOutput::NbSamplesForRateCorrection = 5000000;
|
|
|
|
|
2017-09-14 11:55:57 +00:00
|
|
|
SDRdaemonSinkOutput::SDRdaemonSinkOutput(DeviceSinkAPI *deviceAPI) :
|
2017-05-14 22:58:56 +00:00
|
|
|
m_deviceAPI(deviceAPI),
|
|
|
|
m_settings(),
|
2018-09-06 22:58:09 +00:00
|
|
|
m_centerFrequency(0),
|
2017-05-25 18:13:34 +00:00
|
|
|
m_sdrDaemonSinkThread(0),
|
2017-05-21 10:58:57 +00:00
|
|
|
m_deviceDescription("SDRdaemonSink"),
|
2017-05-25 18:13:34 +00:00
|
|
|
m_startingTimeStamp(0),
|
2018-09-03 07:17:29 +00:00
|
|
|
m_masterTimer(deviceAPI->getMasterTimer()),
|
|
|
|
m_tickCount(0),
|
2018-09-03 16:13:57 +00:00
|
|
|
m_tickMultiplier(20),
|
2018-09-04 06:43:07 +00:00
|
|
|
m_lastRemoteSampleCount(0),
|
2018-09-03 07:17:29 +00:00
|
|
|
m_lastSampleCount(0),
|
2018-09-04 06:43:07 +00:00
|
|
|
m_lastRemoteTimestampRateCorrection(0),
|
2018-09-03 07:17:29 +00:00
|
|
|
m_lastTimestampRateCorrection(0),
|
2018-09-07 07:22:17 +00:00
|
|
|
m_lastQueueLength(-2),
|
2018-09-04 06:43:07 +00:00
|
|
|
m_nbRemoteSamplesSinceRateCorrection(0),
|
2018-09-03 07:17:29 +00:00
|
|
|
m_nbSamplesSinceRateCorrection(0),
|
|
|
|
m_chunkSizeCorrection(0)
|
2017-05-14 22:58:56 +00:00
|
|
|
{
|
2018-09-03 07:17:29 +00:00
|
|
|
m_networkManager = new QNetworkAccessManager();
|
|
|
|
connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
|
|
|
|
connect(&m_masterTimer, SIGNAL(timeout()), this, SLOT(tick()));
|
2017-05-14 22:58:56 +00:00
|
|
|
}
|
|
|
|
|
2017-05-21 02:19:12 +00:00
|
|
|
SDRdaemonSinkOutput::~SDRdaemonSinkOutput()
|
2017-05-14 22:58:56 +00:00
|
|
|
{
|
2018-09-03 07:17:29 +00:00
|
|
|
disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
|
2017-05-14 22:58:56 +00:00
|
|
|
stop();
|
2018-09-03 07:17:29 +00:00
|
|
|
delete m_networkManager;
|
2017-05-14 22:58:56 +00:00
|
|
|
}
|
|
|
|
|
2017-09-16 09:34:25 +00:00
|
|
|
void SDRdaemonSinkOutput::destroy()
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
2017-05-21 02:19:12 +00:00
|
|
|
bool SDRdaemonSinkOutput::start()
|
2017-05-14 22:58:56 +00:00
|
|
|
{
|
|
|
|
QMutexLocker mutexLocker(&m_mutex);
|
2017-05-21 10:58:57 +00:00
|
|
|
qDebug() << "SDRdaemonSinkOutput::start";
|
2017-05-14 22:58:56 +00:00
|
|
|
|
2018-02-24 09:29:27 +00:00
|
|
|
m_sdrDaemonSinkThread = new SDRdaemonSinkThread(&m_sampleSourceFifo);
|
2018-08-29 16:39:40 +00:00
|
|
|
m_sdrDaemonSinkThread->setDataAddress(m_settings.m_dataAddress, m_settings.m_dataPort);
|
2017-05-21 10:58:57 +00:00
|
|
|
m_sdrDaemonSinkThread->setSamplerate(m_settings.m_sampleRate);
|
2017-05-22 23:41:30 +00:00
|
|
|
m_sdrDaemonSinkThread->setNbBlocksFEC(m_settings.m_nbFECBlocks);
|
2017-05-21 10:58:57 +00:00
|
|
|
m_sdrDaemonSinkThread->connectTimer(m_masterTimer);
|
|
|
|
m_sdrDaemonSinkThread->startWork();
|
2017-05-14 22:58:56 +00:00
|
|
|
|
2018-09-10 22:24:18 +00:00
|
|
|
// restart auto rate correction
|
2018-09-04 20:28:10 +00:00
|
|
|
m_lastRemoteTimestampRateCorrection = 0;
|
|
|
|
m_lastTimestampRateCorrection = 0;
|
2018-09-07 07:22:17 +00:00
|
|
|
m_lastQueueLength = -2; // set first value out of bounds
|
2018-09-10 22:24:18 +00:00
|
|
|
m_chunkSizeCorrection = 0;
|
2018-09-04 20:28:10 +00:00
|
|
|
|
2018-09-10 23:01:43 +00:00
|
|
|
m_sdrDaemonSinkThread->setTxDelay(m_settings.m_txDelay);
|
2017-06-07 22:01:56 +00:00
|
|
|
|
2017-05-14 22:58:56 +00:00
|
|
|
mutexLocker.unlock();
|
|
|
|
//applySettings(m_generalSettings, m_settings, true);
|
2017-05-21 10:58:57 +00:00
|
|
|
qDebug("SDRdaemonSinkOutput::start: started");
|
2017-05-14 22:58:56 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-12-25 11:59:44 +00:00
|
|
|
void SDRdaemonSinkOutput::init()
|
|
|
|
{
|
|
|
|
applySettings(m_settings, true);
|
|
|
|
}
|
|
|
|
|
2017-05-21 02:19:12 +00:00
|
|
|
void SDRdaemonSinkOutput::stop()
|
2017-05-14 22:58:56 +00:00
|
|
|
{
|
2017-05-21 10:58:57 +00:00
|
|
|
qDebug() << "SDRdaemonSinkOutput::stop";
|
2017-05-14 22:58:56 +00:00
|
|
|
QMutexLocker mutexLocker(&m_mutex);
|
|
|
|
|
2017-05-21 10:58:57 +00:00
|
|
|
if(m_sdrDaemonSinkThread != 0)
|
2017-05-14 22:58:56 +00:00
|
|
|
{
|
2017-05-21 10:58:57 +00:00
|
|
|
m_sdrDaemonSinkThread->stopWork();
|
|
|
|
delete m_sdrDaemonSinkThread;
|
|
|
|
m_sdrDaemonSinkThread = 0;
|
2017-05-14 22:58:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-28 03:04:50 +00:00
|
|
|
QByteArray SDRdaemonSinkOutput::serialize() const
|
|
|
|
{
|
|
|
|
return m_settings.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SDRdaemonSinkOutput::deserialize(const QByteArray& data)
|
|
|
|
{
|
|
|
|
bool success = true;
|
|
|
|
|
|
|
|
if (!m_settings.deserialize(data))
|
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
MsgConfigureSDRdaemonSink* message = MsgConfigureSDRdaemonSink::create(m_settings, true);
|
|
|
|
m_inputMessageQueue.push(message);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue)
|
|
|
|
{
|
|
|
|
MsgConfigureSDRdaemonSink* messageToGUI = MsgConfigureSDRdaemonSink::create(m_settings, true);
|
|
|
|
m_guiMessageQueue->push(messageToGUI);
|
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2017-05-21 02:19:12 +00:00
|
|
|
const QString& SDRdaemonSinkOutput::getDeviceDescription() const
|
2017-05-14 22:58:56 +00:00
|
|
|
{
|
|
|
|
return m_deviceDescription;
|
|
|
|
}
|
|
|
|
|
2017-05-21 02:19:12 +00:00
|
|
|
int SDRdaemonSinkOutput::getSampleRate() const
|
2017-05-14 22:58:56 +00:00
|
|
|
{
|
|
|
|
return m_settings.m_sampleRate;
|
|
|
|
}
|
|
|
|
|
2017-05-21 02:19:12 +00:00
|
|
|
quint64 SDRdaemonSinkOutput::getCenterFrequency() const
|
2017-05-14 22:58:56 +00:00
|
|
|
{
|
2018-09-06 22:58:09 +00:00
|
|
|
return m_centerFrequency;
|
2017-12-28 03:04:50 +00:00
|
|
|
}
|
|
|
|
|
2017-05-21 02:19:12 +00:00
|
|
|
std::time_t SDRdaemonSinkOutput::getStartingTimeStamp() const
|
2017-05-14 22:58:56 +00:00
|
|
|
{
|
|
|
|
return m_startingTimeStamp;
|
|
|
|
}
|
|
|
|
|
2017-05-21 02:19:12 +00:00
|
|
|
bool SDRdaemonSinkOutput::handleMessage(const Message& message)
|
2017-05-14 22:58:56 +00:00
|
|
|
{
|
2017-05-22 23:41:30 +00:00
|
|
|
|
|
|
|
if (MsgConfigureSDRdaemonSink::match(message))
|
2017-05-14 22:58:56 +00:00
|
|
|
{
|
2017-05-22 23:41:30 +00:00
|
|
|
qDebug() << "SDRdaemonSinkOutput::handleMessage:" << message.getIdentifier();
|
2017-05-21 02:19:12 +00:00
|
|
|
MsgConfigureSDRdaemonSink& conf = (MsgConfigureSDRdaemonSink&) message;
|
2017-05-22 23:41:30 +00:00
|
|
|
applySettings(conf.getSettings(), conf.getForce());
|
2017-05-14 22:58:56 +00:00
|
|
|
return true;
|
|
|
|
}
|
2017-05-21 02:19:12 +00:00
|
|
|
else if (MsgConfigureSDRdaemonSinkWork::match(message))
|
2017-05-14 22:58:56 +00:00
|
|
|
{
|
2017-05-21 02:19:12 +00:00
|
|
|
MsgConfigureSDRdaemonSinkWork& conf = (MsgConfigureSDRdaemonSinkWork&) message;
|
2017-05-14 22:58:56 +00:00
|
|
|
bool working = conf.isWorking();
|
|
|
|
|
2017-05-21 10:58:57 +00:00
|
|
|
if (m_sdrDaemonSinkThread != 0)
|
2017-05-14 22:58:56 +00:00
|
|
|
{
|
|
|
|
if (working)
|
|
|
|
{
|
2017-05-21 10:58:57 +00:00
|
|
|
m_sdrDaemonSinkThread->startWork();
|
2017-05-14 22:58:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-05-21 10:58:57 +00:00
|
|
|
m_sdrDaemonSinkThread->stopWork();
|
2017-05-14 22:58:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2017-12-14 17:02:49 +00:00
|
|
|
else if (MsgStartStop::match(message))
|
|
|
|
{
|
|
|
|
MsgStartStop& cmd = (MsgStartStop&) message;
|
|
|
|
qDebug() << "SDRdaemonSinkOutput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
|
|
|
|
|
|
|
|
if (cmd.getStartStop())
|
|
|
|
{
|
|
|
|
if (m_deviceAPI->initGeneration())
|
|
|
|
{
|
|
|
|
m_deviceAPI->startGeneration();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_deviceAPI->stopGeneration();
|
|
|
|
}
|
|
|
|
|
2018-12-26 21:30:35 +00:00
|
|
|
if (m_settings.m_useReverseAPI) {
|
|
|
|
webapiReverseSendStartStop(cmd.getStartStop());
|
|
|
|
}
|
|
|
|
|
2017-12-14 17:02:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
2017-06-04 23:18:35 +00:00
|
|
|
else if (MsgConfigureSDRdaemonSinkChunkCorrection::match(message))
|
|
|
|
{
|
|
|
|
MsgConfigureSDRdaemonSinkChunkCorrection& conf = (MsgConfigureSDRdaemonSinkChunkCorrection&) message;
|
|
|
|
|
|
|
|
if (m_sdrDaemonSinkThread != 0)
|
|
|
|
{
|
|
|
|
m_sdrDaemonSinkThread->setChunkCorrection(conf.getChunkCorrection());
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2017-05-14 22:58:56 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-21 10:58:57 +00:00
|
|
|
void SDRdaemonSinkOutput::applySettings(const SDRdaemonSinkSettings& settings, bool force)
|
2017-05-14 22:58:56 +00:00
|
|
|
{
|
|
|
|
QMutexLocker mutexLocker(&m_mutex);
|
|
|
|
bool forwardChange = false;
|
2017-06-07 22:01:56 +00:00
|
|
|
bool changeTxDelay = false;
|
2018-12-26 21:30:35 +00:00
|
|
|
QList<QString> reverseAPIKeys;
|
|
|
|
|
|
|
|
if ((m_settings.m_dataAddress != settings.m_dataAddress) || force) {
|
|
|
|
reverseAPIKeys.append("dataAddress");
|
|
|
|
}
|
|
|
|
if ((m_settings.m_dataPort != settings.m_dataPort) || force) {
|
|
|
|
reverseAPIKeys.append("dataPort");
|
|
|
|
}
|
|
|
|
if ((m_settings.m_apiAddress != settings.m_apiAddress) || force) {
|
|
|
|
reverseAPIKeys.append("apiAddress");
|
|
|
|
}
|
|
|
|
if ((m_settings.m_apiPort != settings.m_apiPort) || force) {
|
|
|
|
reverseAPIKeys.append("apiPort");
|
|
|
|
}
|
2017-05-14 22:58:56 +00:00
|
|
|
|
2018-08-29 16:39:40 +00:00
|
|
|
if (force || (m_settings.m_dataAddress != settings.m_dataAddress) || (m_settings.m_dataPort != settings.m_dataPort))
|
2017-05-21 18:13:17 +00:00
|
|
|
{
|
2018-08-28 04:29:59 +00:00
|
|
|
if (m_sdrDaemonSinkThread != 0) {
|
2018-08-29 16:39:40 +00:00
|
|
|
m_sdrDaemonSinkThread->setDataAddress(settings.m_dataAddress, settings.m_dataPort);
|
2017-05-21 18:13:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-14 22:58:56 +00:00
|
|
|
if (force || (m_settings.m_sampleRate != settings.m_sampleRate))
|
|
|
|
{
|
2018-12-26 21:30:35 +00:00
|
|
|
reverseAPIKeys.append("sampleRate");
|
|
|
|
|
2018-08-28 04:29:59 +00:00
|
|
|
if (m_sdrDaemonSinkThread != 0) {
|
|
|
|
m_sdrDaemonSinkThread->setSamplerate(settings.m_sampleRate);
|
2017-05-14 22:58:56 +00:00
|
|
|
}
|
|
|
|
|
2018-09-04 06:43:07 +00:00
|
|
|
m_tickMultiplier = (21*NbSamplesForRateCorrection) / (2*settings.m_sampleRate); // two times per sample filling period plus small extension
|
2018-09-03 16:13:57 +00:00
|
|
|
m_tickMultiplier = m_tickMultiplier < 20 ? 20 : m_tickMultiplier; // not below half a second
|
|
|
|
|
2017-05-14 22:58:56 +00:00
|
|
|
forwardChange = true;
|
2017-06-07 22:01:56 +00:00
|
|
|
changeTxDelay = true;
|
2017-05-14 22:58:56 +00:00
|
|
|
}
|
|
|
|
|
2017-06-07 22:01:56 +00:00
|
|
|
if (force || (m_settings.m_nbFECBlocks != settings.m_nbFECBlocks))
|
2017-05-21 18:13:17 +00:00
|
|
|
{
|
2018-12-26 21:30:35 +00:00
|
|
|
reverseAPIKeys.append("nbFECBlocks");
|
|
|
|
|
2018-08-28 04:29:59 +00:00
|
|
|
if (m_sdrDaemonSinkThread != 0) {
|
|
|
|
m_sdrDaemonSinkThread->setNbBlocksFEC(settings.m_nbFECBlocks);
|
2017-05-14 22:58:56 +00:00
|
|
|
}
|
2017-06-07 22:01:56 +00:00
|
|
|
|
|
|
|
changeTxDelay = true;
|
2017-05-21 18:13:17 +00:00
|
|
|
}
|
2017-05-14 22:58:56 +00:00
|
|
|
|
2017-06-07 22:01:56 +00:00
|
|
|
if (force || (m_settings.m_txDelay != settings.m_txDelay))
|
2017-05-21 18:13:17 +00:00
|
|
|
{
|
2018-12-26 21:30:35 +00:00
|
|
|
reverseAPIKeys.append("txDelay");
|
2017-06-07 22:01:56 +00:00
|
|
|
changeTxDelay = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changeTxDelay)
|
|
|
|
{
|
2018-09-10 23:01:43 +00:00
|
|
|
if (m_sdrDaemonSinkThread != 0) {
|
|
|
|
m_sdrDaemonSinkThread->setTxDelay(settings.m_txDelay);
|
2017-05-21 18:13:17 +00:00
|
|
|
}
|
2017-05-14 22:58:56 +00:00
|
|
|
}
|
|
|
|
|
2017-05-21 18:13:17 +00:00
|
|
|
mutexLocker.unlock();
|
|
|
|
|
2018-08-28 04:29:59 +00:00
|
|
|
qDebug() << "SDRdaemonSinkOutput::applySettings:"
|
|
|
|
<< " m_sampleRate: " << settings.m_sampleRate
|
|
|
|
<< " m_txDelay: " << settings.m_txDelay
|
|
|
|
<< " m_nbFECBlocks: " << settings.m_nbFECBlocks
|
2018-08-29 16:39:40 +00:00
|
|
|
<< " m_apiAddress: " << settings.m_apiAddress
|
|
|
|
<< " m_apiPort: " << settings.m_apiPort
|
|
|
|
<< " m_dataAddress: " << settings.m_dataAddress
|
2018-08-28 04:29:59 +00:00
|
|
|
<< " m_dataPort: " << settings.m_dataPort;
|
2017-05-21 10:58:57 +00:00
|
|
|
|
2017-05-14 22:58:56 +00:00
|
|
|
if (forwardChange)
|
|
|
|
{
|
2018-09-06 22:58:09 +00:00
|
|
|
DSPSignalNotification *notif = new DSPSignalNotification(settings.m_sampleRate, m_centerFrequency);
|
2017-09-13 21:42:28 +00:00
|
|
|
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
2017-05-14 22:58:56 +00:00
|
|
|
}
|
2018-08-28 04:29:59 +00:00
|
|
|
|
2018-12-26 21:30:35 +00: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);
|
|
|
|
}
|
|
|
|
|
2018-08-28 04:29:59 +00:00
|
|
|
m_settings = settings;
|
2017-12-14 17:22:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int SDRdaemonSinkOutput::webapiRunGet(
|
|
|
|
SWGSDRangel::SWGDeviceState& response,
|
2018-11-13 07:51:14 +00:00
|
|
|
QString& errorMessage)
|
2017-12-14 17:22:45 +00:00
|
|
|
{
|
2018-11-13 07:51:14 +00:00
|
|
|
(void) errorMessage;
|
2017-12-14 17:22:45 +00:00
|
|
|
m_deviceAPI->getDeviceEngineStateStr(*response.getState());
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SDRdaemonSinkOutput::webapiRun(
|
|
|
|
bool run,
|
|
|
|
SWGSDRangel::SWGDeviceState& response,
|
2018-11-13 07:51:14 +00:00
|
|
|
QString& errorMessage)
|
2017-12-14 17:22:45 +00:00
|
|
|
{
|
2018-11-13 07:51:14 +00:00
|
|
|
(void) errorMessage;
|
2017-12-14 22:29:12 +00:00
|
|
|
m_deviceAPI->getDeviceEngineStateStr(*response.getState());
|
2017-12-14 17:22:45 +00:00
|
|
|
MsgStartStop *message = MsgStartStop::create(run);
|
|
|
|
m_inputMessageQueue.push(message);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue)
|
|
|
|
{
|
|
|
|
MsgStartStop *messagetoGui = MsgStartStop::create(run);
|
|
|
|
m_guiMessageQueue->push(messagetoGui);
|
|
|
|
}
|
2017-05-14 22:58:56 +00:00
|
|
|
|
2017-12-14 17:22:45 +00:00
|
|
|
return 200;
|
2017-05-14 22:58:56 +00:00
|
|
|
}
|
2017-12-14 17:22:45 +00:00
|
|
|
|
2018-05-27 22:40:33 +00:00
|
|
|
int SDRdaemonSinkOutput::webapiSettingsGet(
|
|
|
|
SWGSDRangel::SWGDeviceSettings& response,
|
2018-11-13 07:51:14 +00:00
|
|
|
QString& errorMessage)
|
2018-05-27 22:40:33 +00:00
|
|
|
{
|
2018-11-13 07:51:14 +00:00
|
|
|
(void) errorMessage;
|
2018-05-27 22:40:33 +00:00
|
|
|
response.setSdrDaemonSinkSettings(new SWGSDRangel::SWGSDRdaemonSinkSettings());
|
|
|
|
response.getSdrDaemonSinkSettings()->init();
|
|
|
|
webapiFormatDeviceSettings(response, m_settings);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SDRdaemonSinkOutput::webapiSettingsPutPatch(
|
|
|
|
bool force,
|
|
|
|
const QStringList& deviceSettingsKeys,
|
|
|
|
SWGSDRangel::SWGDeviceSettings& response, // query + response
|
2018-11-13 07:51:14 +00:00
|
|
|
QString& errorMessage)
|
2018-05-27 22:40:33 +00:00
|
|
|
{
|
2018-11-13 07:51:14 +00:00
|
|
|
(void) errorMessage;
|
2018-05-27 22:40:33 +00:00
|
|
|
SDRdaemonSinkSettings settings = m_settings;
|
|
|
|
|
|
|
|
if (deviceSettingsKeys.contains("sampleRate")) {
|
|
|
|
settings.m_sampleRate = response.getSdrDaemonSinkSettings()->getSampleRate();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("txDelay")) {
|
|
|
|
settings.m_txDelay = response.getSdrDaemonSinkSettings()->getTxDelay();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("nbFECBlocks")) {
|
|
|
|
settings.m_nbFECBlocks = response.getSdrDaemonSinkSettings()->getNbFecBlocks();
|
|
|
|
}
|
2018-08-29 16:39:40 +00:00
|
|
|
if (deviceSettingsKeys.contains("apiAddress")) {
|
|
|
|
settings.m_apiAddress = *response.getSdrDaemonSinkSettings()->getApiAddress();
|
2018-05-27 22:40:33 +00:00
|
|
|
}
|
2018-08-29 16:39:40 +00:00
|
|
|
if (deviceSettingsKeys.contains("apiPort")) {
|
|
|
|
settings.m_apiPort = response.getSdrDaemonSinkSettings()->getApiPort();
|
2018-05-27 22:40:33 +00:00
|
|
|
}
|
2018-08-29 16:39:40 +00:00
|
|
|
if (deviceSettingsKeys.contains("dataAddress")) {
|
|
|
|
settings.m_dataAddress = *response.getSdrDaemonSinkSettings()->getDataAddress();
|
2018-05-27 22:40:33 +00:00
|
|
|
}
|
2018-08-29 16:39:40 +00:00
|
|
|
if (deviceSettingsKeys.contains("dataPort")) {
|
|
|
|
settings.m_dataPort = response.getSdrDaemonSinkSettings()->getDataPort();
|
2018-05-27 22:40:33 +00:00
|
|
|
}
|
2018-09-01 08:44:12 +00:00
|
|
|
if (deviceSettingsKeys.contains("deviceIndex")) {
|
|
|
|
settings.m_deviceIndex = response.getSdrDaemonSinkSettings()->getDeviceIndex();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("channelIndex")) {
|
|
|
|
settings.m_channelIndex = response.getSdrDaemonSinkSettings()->getChannelIndex();
|
|
|
|
}
|
2019-01-11 13:45:00 +00:00
|
|
|
if (deviceSettingsKeys.contains("useReverseAPI")) {
|
|
|
|
settings.m_useReverseAPI = response.getSdrDaemonSinkSettings()->getUseReverseApi() != 0;
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("reverseAPIAddress")) {
|
|
|
|
settings.m_reverseAPIAddress = *response.getSdrDaemonSinkSettings()->getReverseApiAddress();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("reverseAPIPort")) {
|
|
|
|
settings.m_reverseAPIPort = response.getSdrDaemonSinkSettings()->getReverseApiPort();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
|
|
|
|
settings.m_reverseAPIDeviceIndex = response.getSdrDaemonSinkSettings()->getReverseApiDeviceIndex();
|
|
|
|
}
|
2018-05-27 22:40:33 +00:00
|
|
|
|
|
|
|
MsgConfigureSDRdaemonSink *msg = MsgConfigureSDRdaemonSink::create(settings, force);
|
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue) // forward to GUI if any
|
|
|
|
{
|
|
|
|
MsgConfigureSDRdaemonSink *msgToGUI = MsgConfigureSDRdaemonSink::create(settings, force);
|
|
|
|
m_guiMessageQueue->push(msgToGUI);
|
|
|
|
}
|
|
|
|
|
|
|
|
webapiFormatDeviceSettings(response, settings);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SDRdaemonSinkOutput::webapiReportGet(
|
|
|
|
SWGSDRangel::SWGDeviceReport& response,
|
2018-11-13 07:51:14 +00:00
|
|
|
QString& errorMessage)
|
2018-05-27 22:40:33 +00:00
|
|
|
{
|
2018-11-13 07:51:14 +00:00
|
|
|
(void) errorMessage;
|
2018-05-27 22:40:33 +00:00
|
|
|
response.setSdrDaemonSinkReport(new SWGSDRangel::SWGSDRdaemonSinkReport());
|
|
|
|
response.getSdrDaemonSinkReport()->init();
|
|
|
|
webapiFormatDeviceReport(response);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SDRdaemonSinkOutput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const SDRdaemonSinkSettings& settings)
|
|
|
|
{
|
2018-09-06 22:58:09 +00:00
|
|
|
response.getSdrDaemonSinkSettings()->setCenterFrequency(m_centerFrequency);
|
2018-05-27 22:40:33 +00:00
|
|
|
response.getSdrDaemonSinkSettings()->setSampleRate(settings.m_sampleRate);
|
|
|
|
response.getSdrDaemonSinkSettings()->setTxDelay(settings.m_txDelay);
|
|
|
|
response.getSdrDaemonSinkSettings()->setNbFecBlocks(settings.m_nbFECBlocks);
|
2018-08-29 16:39:40 +00:00
|
|
|
response.getSdrDaemonSinkSettings()->setApiAddress(new QString(settings.m_apiAddress));
|
|
|
|
response.getSdrDaemonSinkSettings()->setApiPort(settings.m_apiPort);
|
|
|
|
response.getSdrDaemonSinkSettings()->setDataAddress(new QString(settings.m_dataAddress));
|
2018-05-27 22:40:33 +00:00
|
|
|
response.getSdrDaemonSinkSettings()->setDataPort(settings.m_dataPort);
|
2018-09-01 08:44:12 +00:00
|
|
|
response.getSdrDaemonSinkSettings()->setDeviceIndex(settings.m_deviceIndex);
|
|
|
|
response.getSdrDaemonSinkSettings()->setChannelIndex(settings.m_channelIndex);
|
2019-01-11 13:45:00 +00:00
|
|
|
response.getSdrDaemonSinkSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
|
|
|
|
|
|
|
|
if (response.getSdrDaemonSinkSettings()->getReverseApiAddress()) {
|
|
|
|
*response.getSdrDaemonSinkSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress;
|
|
|
|
} else {
|
|
|
|
response.getSdrDaemonSinkSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
|
|
|
|
}
|
|
|
|
|
|
|
|
response.getSdrDaemonSinkSettings()->setReverseApiPort(settings.m_reverseAPIPort);
|
|
|
|
response.getSdrDaemonSinkSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
|
2018-05-27 22:40:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SDRdaemonSinkOutput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response)
|
|
|
|
{
|
2018-11-13 13:21:36 +00:00
|
|
|
uint64_t ts_usecs;
|
2018-05-27 22:40:33 +00:00
|
|
|
response.getSdrDaemonSinkReport()->setBufferRwBalance(m_sampleSourceFifo.getRWBalance());
|
2018-11-13 13:21:36 +00:00
|
|
|
response.getSdrDaemonSinkReport()->setSampleCount(m_sdrDaemonSinkThread ? (int) m_sdrDaemonSinkThread->getSamplesCount(ts_usecs) : 0);
|
2018-05-27 22:40:33 +00:00
|
|
|
}
|
|
|
|
|
2018-09-03 07:17:29 +00:00
|
|
|
void SDRdaemonSinkOutput::tick()
|
|
|
|
{
|
2018-09-03 16:13:57 +00:00
|
|
|
if (++m_tickCount == m_tickMultiplier)
|
2018-09-03 07:17:29 +00:00
|
|
|
{
|
|
|
|
QString reportURL;
|
|
|
|
|
|
|
|
reportURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/report")
|
|
|
|
.arg(m_settings.m_apiAddress)
|
|
|
|
.arg(m_settings.m_apiPort)
|
|
|
|
.arg(m_settings.m_deviceIndex)
|
|
|
|
.arg(m_settings.m_channelIndex);
|
|
|
|
|
|
|
|
m_networkRequest.setUrl(QUrl(reportURL));
|
|
|
|
m_networkManager->get(m_networkRequest);
|
|
|
|
|
|
|
|
m_tickCount = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SDRdaemonSinkOutput::networkManagerFinished(QNetworkReply *reply)
|
|
|
|
{
|
|
|
|
if (reply->error())
|
|
|
|
{
|
|
|
|
qInfo("SDRdaemonSinkOutput::networkManagerFinished: error: %s", qPrintable(reply->errorString()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString answer = reply->readAll();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
QByteArray jsonBytes(answer.toStdString().c_str());
|
|
|
|
QJsonParseError error;
|
|
|
|
QJsonDocument doc = QJsonDocument::fromJson(jsonBytes, &error);
|
|
|
|
|
|
|
|
if (error.error == QJsonParseError::NoError)
|
|
|
|
{
|
2018-12-26 21:30:35 +00:00
|
|
|
analyzeApiReply(doc.object(), answer);
|
2018-09-03 07:17:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QString errorMsg = QString("Reply JSON error: ") + error.errorString() + QString(" at offset ") + QString::number(error.offset);
|
|
|
|
qInfo().noquote() << "SDRdaemonSinkOutput::networkManagerFinished" << errorMsg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (const std::exception& ex)
|
|
|
|
{
|
|
|
|
QString errorMsg = QString("Error parsing request: ") + ex.what();
|
|
|
|
qInfo().noquote() << "SDRdaemonSinkOutput::networkManagerFinished" << errorMsg;
|
|
|
|
}
|
|
|
|
}
|
2017-12-14 17:22:45 +00:00
|
|
|
|
2018-12-26 21:30:35 +00:00
|
|
|
void SDRdaemonSinkOutput::analyzeApiReply(const QJsonObject& jsonObject, const QString& answer)
|
2018-09-03 07:17:29 +00:00
|
|
|
{
|
2018-09-04 18:35:54 +00:00
|
|
|
if (jsonObject.contains("DaemonSourceReport"))
|
2018-09-03 07:17:29 +00:00
|
|
|
{
|
2018-09-04 18:35:54 +00:00
|
|
|
QJsonObject report = jsonObject["DaemonSourceReport"].toObject();
|
2018-09-06 22:58:09 +00:00
|
|
|
m_centerFrequency = report["deviceCenterFreq"].toInt() * 1000;
|
2018-09-17 22:08:15 +00:00
|
|
|
|
|
|
|
if (!m_sdrDaemonSinkThread) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-09-03 07:17:29 +00:00
|
|
|
int queueSize = report["queueSize"].toInt();
|
|
|
|
queueSize = queueSize == 0 ? 10 : queueSize;
|
|
|
|
int queueLength = report["queueLength"].toInt();
|
|
|
|
int queueLengthPercent = (queueLength*100)/queueSize;
|
2018-09-04 06:43:07 +00:00
|
|
|
uint64_t remoteTimestampUs = report["tvSec"].toInt()*1000000ULL + report["tvUSec"].toInt();
|
|
|
|
|
|
|
|
uint32_t remoteSampleCountDelta, remoteSampleCount;
|
|
|
|
remoteSampleCount = report["samplesCount"].toInt();
|
|
|
|
|
|
|
|
if (remoteSampleCount < m_lastRemoteSampleCount) {
|
|
|
|
remoteSampleCountDelta = (0xFFFFFFFFU - m_lastRemoteSampleCount) + remoteSampleCount + 1;
|
|
|
|
} else {
|
|
|
|
remoteSampleCountDelta = remoteSampleCount - m_lastRemoteSampleCount;
|
|
|
|
}
|
2018-09-03 07:17:29 +00:00
|
|
|
|
|
|
|
uint32_t sampleCountDelta, sampleCount;
|
2018-11-13 13:21:36 +00:00
|
|
|
uint64_t timestampUs;
|
|
|
|
sampleCount = m_sdrDaemonSinkThread->getSamplesCount(timestampUs);
|
2018-09-03 07:17:29 +00:00
|
|
|
|
|
|
|
if (sampleCount < m_lastSampleCount) {
|
|
|
|
sampleCountDelta = (0xFFFFFFFFU - m_lastSampleCount) + sampleCount + 1;
|
|
|
|
} else {
|
|
|
|
sampleCountDelta = sampleCount - m_lastSampleCount;
|
|
|
|
}
|
|
|
|
|
2018-09-07 07:22:17 +00:00
|
|
|
// on initial state wait for queue stabilization
|
|
|
|
if ((m_lastRemoteTimestampRateCorrection == 0) && (queueLength >= m_lastQueueLength-1) && (queueLength <= m_lastQueueLength+1))
|
2018-09-04 06:43:07 +00:00
|
|
|
{
|
|
|
|
m_lastRemoteTimestampRateCorrection = remoteTimestampUs;
|
2018-09-03 16:13:57 +00:00
|
|
|
m_lastTimestampRateCorrection = timestampUs;
|
2018-09-04 20:28:10 +00:00
|
|
|
m_nbRemoteSamplesSinceRateCorrection = 0;
|
|
|
|
m_nbSamplesSinceRateCorrection = 0;
|
2018-09-03 16:13:57 +00:00
|
|
|
}
|
|
|
|
else
|
2018-09-03 07:17:29 +00:00
|
|
|
{
|
2018-09-04 06:43:07 +00:00
|
|
|
m_nbRemoteSamplesSinceRateCorrection += remoteSampleCountDelta;
|
2018-09-03 16:13:57 +00:00
|
|
|
m_nbSamplesSinceRateCorrection += sampleCountDelta;
|
|
|
|
|
2018-09-04 06:43:07 +00:00
|
|
|
qDebug("SDRdaemonSinkOutput::analyzeApiReply: queueLengthPercent: %d m_nbSamplesSinceRateCorrection: %u",
|
2018-09-03 16:13:57 +00:00
|
|
|
queueLengthPercent,
|
2018-09-04 06:43:07 +00:00
|
|
|
m_nbRemoteSamplesSinceRateCorrection);
|
2018-09-03 16:13:57 +00:00
|
|
|
|
2018-09-04 06:43:07 +00:00
|
|
|
if (m_nbRemoteSamplesSinceRateCorrection > NbSamplesForRateCorrection)
|
2018-09-03 07:17:29 +00:00
|
|
|
{
|
2018-09-04 06:43:07 +00:00
|
|
|
sampleRateCorrection(remoteTimestampUs - m_lastRemoteTimestampRateCorrection,
|
|
|
|
timestampUs - m_lastTimestampRateCorrection,
|
|
|
|
m_nbRemoteSamplesSinceRateCorrection,
|
|
|
|
m_nbSamplesSinceRateCorrection);
|
|
|
|
m_lastRemoteTimestampRateCorrection = remoteTimestampUs;
|
2018-09-03 16:13:57 +00:00
|
|
|
m_lastTimestampRateCorrection = timestampUs;
|
2018-09-04 06:43:07 +00:00
|
|
|
m_nbRemoteSamplesSinceRateCorrection = 0;
|
2018-09-03 16:13:57 +00:00
|
|
|
m_nbSamplesSinceRateCorrection = 0;
|
2018-09-03 07:17:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-04 06:43:07 +00:00
|
|
|
m_lastRemoteSampleCount = remoteSampleCount;
|
2018-09-03 07:17:29 +00:00
|
|
|
m_lastSampleCount = sampleCount;
|
2018-09-07 07:22:17 +00:00
|
|
|
m_lastQueueLength = queueLength;
|
2018-09-03 07:17:29 +00:00
|
|
|
}
|
2018-12-26 21:30:35 +00:00
|
|
|
else if (jsonObject.contains("sdrDaemonSinkSettings"))
|
|
|
|
{
|
|
|
|
qDebug("SDRdaemonSinkOutput::analyzeApiReply: reply:\n%s", answer.toStdString().c_str());
|
|
|
|
}
|
2018-09-03 07:17:29 +00:00
|
|
|
}
|
|
|
|
|
2018-09-04 06:43:07 +00:00
|
|
|
void SDRdaemonSinkOutput::sampleRateCorrection(double remoteTimeDeltaUs, double timeDeltaUs, uint32_t remoteSampleCount, uint32_t sampleCount)
|
2018-09-03 07:17:29 +00:00
|
|
|
{
|
2018-09-04 06:43:07 +00:00
|
|
|
double deltaSR = (remoteSampleCount/remoteTimeDeltaUs) - (sampleCount/timeDeltaUs);
|
|
|
|
double chunkCorr = 50000 * deltaSR; // for 50ms chunk intervals (50000us)
|
|
|
|
m_chunkSizeCorrection += roundf(chunkCorr);
|
2018-09-03 07:17:29 +00:00
|
|
|
|
2018-09-04 06:43:07 +00:00
|
|
|
qDebug("SDRdaemonSinkOutput::sampleRateCorrection: %d (%f) samples", m_chunkSizeCorrection, chunkCorr);
|
2018-09-03 07:17:29 +00:00
|
|
|
|
|
|
|
MsgConfigureSDRdaemonSinkChunkCorrection* message = MsgConfigureSDRdaemonSinkChunkCorrection::create(m_chunkSizeCorrection);
|
|
|
|
getInputMessageQueue()->push(message);
|
|
|
|
}
|
2018-12-26 21:30:35 +00:00
|
|
|
|
|
|
|
void SDRdaemonSinkOutput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const SDRdaemonSinkSettings& settings, bool force)
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
|
|
|
swgDeviceSettings->setTx(1);
|
|
|
|
swgDeviceSettings->setDeviceHwType(new QString("SDRdaemonSink"));
|
|
|
|
swgDeviceSettings->setSdrDaemonSinkSettings(new SWGSDRangel::SWGSDRdaemonSinkSettings());
|
|
|
|
SWGSDRangel::SWGSDRdaemonSinkSettings *swgSdrDaemonSinkSettings = swgDeviceSettings->getSdrDaemonSinkSettings();
|
|
|
|
|
|
|
|
// transfer data that has been modified. When force is on transfer all data except reverse API data
|
|
|
|
|
|
|
|
if (deviceSettingsKeys.contains("sampleRate") || force) {
|
|
|
|
swgSdrDaemonSinkSettings->setSampleRate(settings.m_sampleRate);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("txDelay") || force) {
|
|
|
|
swgSdrDaemonSinkSettings->setTxDelay(settings.m_txDelay);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("nbFECBlocks") || force) {
|
|
|
|
swgSdrDaemonSinkSettings->setNbFecBlocks(settings.m_nbFECBlocks);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("apiAddress") || force) {
|
|
|
|
swgSdrDaemonSinkSettings->setApiAddress(new QString(settings.m_apiAddress));
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("apiPort") || force) {
|
|
|
|
swgSdrDaemonSinkSettings->setApiPort(settings.m_apiPort);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("dataAddress") || force) {
|
|
|
|
swgSdrDaemonSinkSettings->setDataAddress(new QString(settings.m_dataAddress));
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("dataPort") || force) {
|
|
|
|
swgSdrDaemonSinkSettings->setDataPort(settings.m_dataPort);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("deviceIndex") || force) {
|
|
|
|
swgSdrDaemonSinkSettings->setDeviceIndex(settings.m_deviceIndex);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("channelIndex") || force) {
|
|
|
|
swgSdrDaemonSinkSettings->setChannelIndex(settings.m_channelIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
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 SDRdaemonSinkOutput::webapiReverseSendStartStop(bool start)
|
|
|
|
{
|
|
|
|
QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
|
|
|
|
.arg(m_settings.m_reverseAPIAddress)
|
|
|
|
.arg(m_settings.m_reverseAPIPort)
|
|
|
|
.arg(m_settings.m_reverseAPIDeviceIndex);
|
|
|
|
m_networkRequest.setUrl(QUrl(deviceSettingsURL));
|
|
|
|
|
|
|
|
if (start) {
|
|
|
|
m_networkManager->sendCustomRequest(m_networkRequest, "POST");
|
|
|
|
} else {
|
|
|
|
m_networkManager->sendCustomRequest(m_networkRequest, "DELETE");
|
|
|
|
}
|
|
|
|
}
|