2019-02-22 01:17:27 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
|
|
|
|
// //
|
|
|
|
// 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:39:30 -04:00
|
|
|
// (at your option) any later version. //
|
2019-02-22 01:17:27 -05: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 <QTime>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QMutexLocker>
|
|
|
|
#include <QNetworkAccessManager>
|
|
|
|
#include <QNetworkReply>
|
|
|
|
#include <QBuffer>
|
2019-11-14 19:04:24 -05:00
|
|
|
#include <QThread>
|
2019-02-22 01:17:27 -05:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <complex.h>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include "SWGChannelSettings.h"
|
2022-05-13 16:24:48 -04:00
|
|
|
#include "SWGWorkspaceInfo.h"
|
2019-02-22 01:17:27 -05:00
|
|
|
#include "SWGChannelReport.h"
|
|
|
|
#include "SWGFreeDVModReport.h"
|
|
|
|
|
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "dsp/dspcommands.h"
|
2019-05-08 16:11:53 -04:00
|
|
|
#include "device/deviceapi.h"
|
2020-10-22 18:11:18 -04:00
|
|
|
#include "feature/feature.h"
|
2019-02-22 01:17:27 -05:00
|
|
|
#include "util/db.h"
|
2020-10-22 18:11:18 -04:00
|
|
|
#include "maincore.h"
|
2019-02-22 01:17:27 -05:00
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
#include "freedvmodbaseband.h"
|
|
|
|
#include "freedvmod.h"
|
|
|
|
|
2019-02-22 01:17:27 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(FreeDVMod::MsgConfigureFreeDVMod, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(FreeDVMod::MsgConfigureFileSourceName, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(FreeDVMod::MsgConfigureFileSourceSeek, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(FreeDVMod::MsgConfigureFileSourceStreamTiming, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(FreeDVMod::MsgReportFileSourceStreamData, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(FreeDVMod::MsgReportFileSourceStreamTiming, Message)
|
|
|
|
|
2020-11-21 14:24:18 -05:00
|
|
|
const char* const FreeDVMod::m_channelIdURI = "sdrangel.channeltx.freedvmod";
|
|
|
|
const char* const FreeDVMod::m_channelId = "FreeDVMod";
|
2019-02-22 01:17:27 -05:00
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
FreeDVMod::FreeDVMod(DeviceAPI *deviceAPI) :
|
2019-05-09 11:27:12 -04:00
|
|
|
ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSource),
|
2019-02-22 01:17:27 -05:00
|
|
|
m_deviceAPI(deviceAPI),
|
2020-04-30 03:57:05 -04:00
|
|
|
m_spectrumVis(SDR_TX_SCALEF),
|
2019-02-22 01:17:27 -05:00
|
|
|
m_fileSize(0),
|
|
|
|
m_recordLength(0),
|
2019-11-14 19:04:24 -05:00
|
|
|
m_fileSampleRate(8000) // all modes take 8000 S/s input
|
2019-02-22 01:17:27 -05:00
|
|
|
{
|
|
|
|
setObjectName(m_channelId);
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
m_thread = new QThread(this);
|
|
|
|
m_basebandSource = new FreeDVModBaseband();
|
2020-04-30 03:57:05 -04:00
|
|
|
m_basebandSource->setSpectrumSampleSink(&m_spectrumVis);
|
2019-11-14 19:04:24 -05:00
|
|
|
m_basebandSource->setInputFileStream(&m_ifstream);
|
|
|
|
m_basebandSource->moveToThread(m_thread);
|
2019-02-22 01:17:27 -05:00
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
applySettings(m_settings, true);
|
2019-02-22 01:17:27 -05:00
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
m_deviceAPI->addChannelSource(this);
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceAPI->addChannelSourceAPI(this);
|
2019-02-22 01:17:27 -05:00
|
|
|
|
|
|
|
m_networkManager = new QNetworkAccessManager();
|
2022-03-23 17:32:23 -04:00
|
|
|
QObject::connect(
|
|
|
|
m_networkManager,
|
|
|
|
&QNetworkAccessManager::finished,
|
|
|
|
this,
|
|
|
|
&FreeDVMod::networkManagerFinished
|
|
|
|
);
|
2019-02-22 01:17:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
FreeDVMod::~FreeDVMod()
|
|
|
|
{
|
2022-03-23 17:32:23 -04:00
|
|
|
QObject::disconnect(
|
|
|
|
m_networkManager,
|
|
|
|
&QNetworkAccessManager::finished,
|
|
|
|
this,
|
|
|
|
&FreeDVMod::networkManagerFinished
|
|
|
|
);
|
2019-02-22 01:17:27 -05:00
|
|
|
delete m_networkManager;
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceAPI->removeChannelSourceAPI(this);
|
2019-11-14 19:04:24 -05:00
|
|
|
m_deviceAPI->removeChannelSource(this);
|
|
|
|
delete m_basebandSource;
|
|
|
|
delete m_thread;
|
2019-02-22 01:17:27 -05:00
|
|
|
}
|
|
|
|
|
2022-04-16 10:45:53 -04:00
|
|
|
void FreeDVMod::setDeviceAPI(DeviceAPI *deviceAPI)
|
|
|
|
{
|
|
|
|
if (deviceAPI != m_deviceAPI)
|
|
|
|
{
|
|
|
|
m_deviceAPI->removeChannelSourceAPI(this);
|
|
|
|
m_deviceAPI->removeChannelSource(this);
|
|
|
|
m_deviceAPI = deviceAPI;
|
|
|
|
m_deviceAPI->addChannelSource(this);
|
|
|
|
m_deviceAPI->addChannelSinkAPI(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
void FreeDVMod::start()
|
2019-02-24 14:59:09 -05:00
|
|
|
{
|
2019-11-14 19:04:24 -05:00
|
|
|
qDebug("FreeDVMod::start");
|
|
|
|
m_basebandSource->reset();
|
|
|
|
m_thread->start();
|
2020-05-04 21:24:10 -04:00
|
|
|
|
2021-04-20 04:32:21 -04:00
|
|
|
SpectrumSettings spectrumSettings = m_spectrumVis.getSettings();
|
2020-05-04 21:24:10 -04:00
|
|
|
spectrumSettings.m_ssb = true;
|
|
|
|
SpectrumVis::MsgConfigureSpectrumVis *msg = SpectrumVis::MsgConfigureSpectrumVis::create(spectrumSettings, false);
|
|
|
|
m_spectrumVis.getInputMessageQueue()->push(msg);
|
2019-02-24 14:59:09 -05:00
|
|
|
}
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
void FreeDVMod::stop()
|
2019-02-22 01:17:27 -05:00
|
|
|
{
|
2019-11-14 19:04:24 -05:00
|
|
|
qDebug("FreeDVMod::stop");
|
|
|
|
m_thread->exit();
|
|
|
|
m_thread->wait();
|
2019-02-22 01:17:27 -05:00
|
|
|
}
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
void FreeDVMod::pull(SampleVector::iterator& begin, unsigned int nbSamples)
|
2019-02-22 01:17:27 -05:00
|
|
|
{
|
2019-11-14 19:04:24 -05:00
|
|
|
m_basebandSource->pull(begin, nbSamples);
|
2019-02-22 01:17:27 -05:00
|
|
|
}
|
|
|
|
|
2022-01-06 16:47:41 -05:00
|
|
|
void FreeDVMod::setCenterFrequency(qint64 frequency)
|
|
|
|
{
|
|
|
|
FreeDVModSettings settings = m_settings;
|
|
|
|
settings.m_inputFrequencyOffset = frequency;
|
|
|
|
applySettings(settings, false);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue) // forward to GUI if any
|
|
|
|
{
|
|
|
|
MsgConfigureFreeDVMod *msgToGUI = MsgConfigureFreeDVMod::create(settings, false);
|
|
|
|
m_guiMessageQueue->push(msgToGUI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-22 01:17:27 -05:00
|
|
|
bool FreeDVMod::handleMessage(const Message& cmd)
|
|
|
|
{
|
2019-11-20 18:40:55 -05:00
|
|
|
if (MsgConfigureFreeDVMod::match(cmd))
|
2019-02-22 01:17:27 -05:00
|
|
|
{
|
|
|
|
MsgConfigureFreeDVMod& cfg = (MsgConfigureFreeDVMod&) cmd;
|
|
|
|
qDebug() << "FreeDVMod::handleMessage: MsgConfigureFreeDVMod";
|
|
|
|
|
|
|
|
applySettings(cfg.getSettings(), cfg.getForce());
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MsgConfigureFileSourceName::match(cmd))
|
|
|
|
{
|
|
|
|
MsgConfigureFileSourceName& conf = (MsgConfigureFileSourceName&) cmd;
|
|
|
|
m_fileName = conf.getFileName();
|
|
|
|
openFileStream();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MsgConfigureFileSourceSeek::match(cmd))
|
|
|
|
{
|
|
|
|
MsgConfigureFileSourceSeek& conf = (MsgConfigureFileSourceSeek&) cmd;
|
|
|
|
int seekPercentage = conf.getPercentage();
|
|
|
|
seekFileStream(seekPercentage);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MsgConfigureFileSourceStreamTiming::match(cmd))
|
|
|
|
{
|
|
|
|
std::size_t samplesCount;
|
|
|
|
|
|
|
|
if (m_ifstream.eof()) {
|
2019-02-26 14:45:50 -05:00
|
|
|
samplesCount = m_fileSize / sizeof(int16_t);
|
2019-02-22 01:17:27 -05:00
|
|
|
} else {
|
2019-02-26 14:45:50 -05:00
|
|
|
samplesCount = m_ifstream.tellg() / sizeof(int16_t);
|
2019-02-22 01:17:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (getMessageQueueToGUI())
|
|
|
|
{
|
|
|
|
MsgReportFileSourceStreamTiming *report;
|
|
|
|
report = MsgReportFileSourceStreamTiming::create(samplesCount);
|
|
|
|
getMessageQueueToGUI()->push(report);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (CWKeyer::MsgConfigureCWKeyer::match(cmd))
|
|
|
|
{
|
|
|
|
const CWKeyer::MsgConfigureCWKeyer& cfg = (CWKeyer::MsgConfigureCWKeyer&) cmd;
|
|
|
|
|
|
|
|
if (m_settings.m_useReverseAPI) {
|
|
|
|
webapiReverseSendCWSettings(cfg.getSettings());
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (DSPSignalNotification::match(cmd))
|
|
|
|
{
|
2019-11-14 19:04:24 -05:00
|
|
|
// Forward to the source
|
|
|
|
DSPSignalNotification& notif = (DSPSignalNotification&) cmd;
|
|
|
|
DSPSignalNotification* rep = new DSPSignalNotification(notif); // make a copy
|
|
|
|
qDebug() << "FreeDVMod::handleMessage: DSPSignalNotification";
|
|
|
|
m_basebandSource->getInputMessageQueue()->push(rep);
|
2022-04-13 05:08:21 -04:00
|
|
|
// Forward to GUI if any
|
|
|
|
if (getMessageQueueToGUI()) {
|
|
|
|
getMessageQueueToGUI()->push(new DSPSignalNotification(notif));
|
|
|
|
}
|
2019-11-14 19:04:24 -05:00
|
|
|
|
2019-02-22 01:17:27 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVMod::openFileStream()
|
|
|
|
{
|
|
|
|
if (m_ifstream.is_open()) {
|
|
|
|
m_ifstream.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_ifstream.open(m_fileName.toStdString().c_str(), std::ios::binary | std::ios::ate);
|
|
|
|
m_fileSize = m_ifstream.tellg();
|
|
|
|
m_ifstream.seekg(0,std::ios_base::beg);
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
m_recordLength = m_fileSize / (sizeof(int16_t) * m_fileSampleRate);
|
2019-02-22 01:17:27 -05:00
|
|
|
|
|
|
|
qDebug() << "FreeDVMod::openFileStream: " << m_fileName.toStdString().c_str()
|
|
|
|
<< " fileSize: " << m_fileSize << "bytes"
|
|
|
|
<< " length: " << m_recordLength << " seconds";
|
|
|
|
|
|
|
|
if (getMessageQueueToGUI())
|
|
|
|
{
|
|
|
|
MsgReportFileSourceStreamData *report;
|
2019-11-14 19:04:24 -05:00
|
|
|
report = MsgReportFileSourceStreamData::create(m_fileSampleRate, m_recordLength);
|
2019-02-22 01:17:27 -05:00
|
|
|
getMessageQueueToGUI()->push(report);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVMod::seekFileStream(int seekPercentage)
|
|
|
|
{
|
|
|
|
QMutexLocker mutexLocker(&m_settingsMutex);
|
|
|
|
|
|
|
|
if (m_ifstream.is_open())
|
|
|
|
{
|
2019-11-14 19:04:24 -05:00
|
|
|
int seekPoint = ((m_recordLength * seekPercentage) / 100) * m_fileSampleRate;
|
2019-02-22 01:17:27 -05:00
|
|
|
seekPoint *= sizeof(Real);
|
|
|
|
m_ifstream.clear();
|
|
|
|
m_ifstream.seekg(seekPoint, std::ios::beg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVMod::applySettings(const FreeDVModSettings& settings, bool force)
|
|
|
|
{
|
|
|
|
QList<QString> reverseAPIKeys;
|
|
|
|
|
|
|
|
if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force) {
|
|
|
|
reverseAPIKeys.append("inputFrequencyOffset");
|
|
|
|
}
|
|
|
|
if ((settings.m_toneFrequency != m_settings.m_toneFrequency) || force) {
|
|
|
|
reverseAPIKeys.append("toneFrequency");
|
|
|
|
}
|
|
|
|
if ((settings.m_volumeFactor != m_settings.m_volumeFactor) || force) {
|
|
|
|
reverseAPIKeys.append("volumeFactor");
|
|
|
|
}
|
|
|
|
if ((settings.m_spanLog2 != m_settings.m_spanLog2) || force) {
|
|
|
|
reverseAPIKeys.append("spanLog2");
|
|
|
|
}
|
|
|
|
if ((settings.m_audioMute != m_settings.m_audioMute) || force) {
|
|
|
|
reverseAPIKeys.append("audioMute");
|
|
|
|
}
|
|
|
|
if ((settings.m_playLoop != m_settings.m_playLoop) || force) {
|
|
|
|
reverseAPIKeys.append("playLoop");
|
|
|
|
}
|
2019-02-24 14:59:09 -05:00
|
|
|
if ((settings.m_playLoop != m_settings.m_gaugeInputElseModem) || force) {
|
|
|
|
reverseAPIKeys.append("gaugeInputElseModem");
|
|
|
|
}
|
2019-02-22 01:17:27 -05:00
|
|
|
if ((settings.m_rgbColor != m_settings.m_rgbColor) || force) {
|
|
|
|
reverseAPIKeys.append("rgbColor");
|
|
|
|
}
|
|
|
|
if ((settings.m_title != m_settings.m_title) || force) {
|
|
|
|
reverseAPIKeys.append("title");
|
|
|
|
}
|
2019-02-22 09:30:51 -05:00
|
|
|
if ((settings.m_freeDVMode != m_settings.m_freeDVMode) || force) {
|
|
|
|
reverseAPIKeys.append("freeDVMode");
|
|
|
|
}
|
2019-02-22 01:17:27 -05:00
|
|
|
if ((settings.m_modAFInput != m_settings.m_modAFInput) || force) {
|
|
|
|
reverseAPIKeys.append("modAFInput");
|
|
|
|
}
|
|
|
|
if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force) {
|
|
|
|
reverseAPIKeys.append("audioDeviceName");
|
|
|
|
}
|
2019-11-14 19:04:24 -05:00
|
|
|
if ((settings.m_toneFrequency != m_settings.m_toneFrequency) || force) {
|
|
|
|
reverseAPIKeys.append("toneFrequency");
|
|
|
|
}
|
|
|
|
if ((m_settings.m_freeDVMode != settings.m_freeDVMode) || force) {
|
|
|
|
reverseAPIKeys.append("freeDVMode");
|
2019-02-22 01:17:27 -05:00
|
|
|
}
|
2019-11-20 18:40:55 -05:00
|
|
|
if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force) {
|
|
|
|
reverseAPIKeys.append("audioDeviceName");
|
2019-02-22 01:17:27 -05:00
|
|
|
}
|
|
|
|
|
2019-11-18 19:22:55 -05:00
|
|
|
if (m_settings.m_streamIndex != settings.m_streamIndex)
|
|
|
|
{
|
|
|
|
if (m_deviceAPI->getSampleMIMO()) // change of stream is possible for MIMO devices only
|
|
|
|
{
|
2019-12-23 17:41:35 -05:00
|
|
|
m_deviceAPI->removeChannelSourceAPI(this);
|
2019-11-18 19:22:55 -05:00
|
|
|
m_deviceAPI->removeChannelSource(this, m_settings.m_streamIndex);
|
|
|
|
m_deviceAPI->addChannelSource(this, settings.m_streamIndex);
|
2019-12-23 17:41:35 -05:00
|
|
|
m_deviceAPI->addChannelSourceAPI(this);
|
2019-11-18 19:22:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
reverseAPIKeys.append("streamIndex");
|
|
|
|
}
|
|
|
|
|
2020-05-04 21:24:10 -04:00
|
|
|
if ((settings.m_freeDVMode != m_settings.m_freeDVMode)
|
|
|
|
|| (settings.m_spanLog2 != m_settings.m_spanLog2) || force)
|
|
|
|
{
|
|
|
|
DSPSignalNotification *msg = new DSPSignalNotification(
|
|
|
|
FreeDVModSettings::getModSampleRate(settings.m_freeDVMode)/(1<<settings.m_spanLog2),
|
|
|
|
0);
|
|
|
|
m_spectrumVis.getInputMessageQueue()->push(msg);
|
|
|
|
}
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
FreeDVModBaseband::MsgConfigureFreeDVModBaseband *msg = FreeDVModBaseband::MsgConfigureFreeDVModBaseband::create(settings, force);
|
|
|
|
m_basebandSource->getInputMessageQueue()->push(msg);
|
2019-02-22 09:30:51 -05:00
|
|
|
|
2019-02-22 01:17:27 -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) ||
|
|
|
|
(m_settings.m_reverseAPIChannelIndex != settings.m_reverseAPIChannelIndex);
|
|
|
|
webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
|
|
|
|
}
|
|
|
|
|
2022-03-02 17:07:15 -05:00
|
|
|
QList<ObjectPipe*> pipes;
|
2022-03-02 17:57:35 -05:00
|
|
|
MainCore::instance()->getMessagePipes().getMessagePipes(this, "settings", pipes);
|
2020-12-13 07:04:36 -05:00
|
|
|
|
2022-03-02 17:07:15 -05:00
|
|
|
if (pipes.size() > 0) {
|
|
|
|
sendChannelSettings(pipes, reverseAPIKeys, settings, force);
|
2020-10-22 18:11:18 -04:00
|
|
|
}
|
|
|
|
|
2019-02-22 01:17:27 -05:00
|
|
|
m_settings = settings;
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray FreeDVMod::serialize() const
|
|
|
|
{
|
|
|
|
return m_settings.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FreeDVMod::deserialize(const QByteArray& data)
|
|
|
|
{
|
|
|
|
if (m_settings.deserialize(data))
|
|
|
|
{
|
|
|
|
MsgConfigureFreeDVMod *msg = MsgConfigureFreeDVMod::create(m_settings, true);
|
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
|
|
|
MsgConfigureFreeDVMod *msg = MsgConfigureFreeDVMod::create(m_settings, true);
|
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int FreeDVMod::webapiSettingsGet(
|
|
|
|
SWGSDRangel::SWGChannelSettings& response,
|
|
|
|
QString& errorMessage)
|
|
|
|
{
|
|
|
|
(void) errorMessage;
|
|
|
|
response.setFreeDvModSettings(new SWGSDRangel::SWGFreeDVModSettings());
|
|
|
|
response.getFreeDvModSettings()->init();
|
|
|
|
webapiFormatChannelSettings(response, m_settings);
|
2019-08-01 17:21:57 -04:00
|
|
|
|
|
|
|
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getFreeDvModSettings()->getCwKeyer();
|
2019-11-14 19:04:24 -05:00
|
|
|
const CWKeyerSettings& cwKeyerSettings = m_basebandSource->getCWKeyer().getSettings();
|
2019-08-01 17:21:57 -04:00
|
|
|
CWKeyer::webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings);
|
|
|
|
|
2019-02-22 01:17:27 -05:00
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
2022-05-13 16:24:48 -04:00
|
|
|
int FreeDVMod::webapiWorkspaceGet(
|
|
|
|
SWGSDRangel::SWGWorkspaceInfo& response,
|
|
|
|
QString& errorMessage)
|
|
|
|
{
|
|
|
|
(void) errorMessage;
|
|
|
|
response.setIndex(m_settings.m_workspaceIndex);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
2019-02-22 01:17:27 -05:00
|
|
|
int FreeDVMod::webapiSettingsPutPatch(
|
|
|
|
bool force,
|
|
|
|
const QStringList& channelSettingsKeys,
|
|
|
|
SWGSDRangel::SWGChannelSettings& response,
|
|
|
|
QString& errorMessage)
|
|
|
|
{
|
|
|
|
(void) errorMessage;
|
|
|
|
FreeDVModSettings settings = m_settings;
|
2019-08-01 17:21:57 -04:00
|
|
|
webapiUpdateChannelSettings(settings, channelSettingsKeys, response);
|
|
|
|
|
|
|
|
if (channelSettingsKeys.contains("cwKeyer"))
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getFreeDvModSettings()->getCwKeyer();
|
2019-11-14 19:04:24 -05:00
|
|
|
CWKeyerSettings cwKeyerSettings = m_basebandSource->getCWKeyer().getSettings();
|
2019-08-01 17:21:57 -04:00
|
|
|
CWKeyer::webapiSettingsPutPatch(channelSettingsKeys, cwKeyerSettings, apiCwKeyerSettings);
|
|
|
|
|
|
|
|
CWKeyer::MsgConfigureCWKeyer *msgCwKeyer = CWKeyer::MsgConfigureCWKeyer::create(cwKeyerSettings, force);
|
2019-11-14 19:04:24 -05:00
|
|
|
m_basebandSource->getCWKeyer().getInputMessageQueue()->push(msgCwKeyer);
|
2019-08-01 17:21:57 -04:00
|
|
|
|
|
|
|
if (m_guiMessageQueue) // forward to GUI if any
|
|
|
|
{
|
|
|
|
CWKeyer::MsgConfigureCWKeyer *msgCwKeyerToGUI = CWKeyer::MsgConfigureCWKeyer::create(cwKeyerSettings, force);
|
|
|
|
m_guiMessageQueue->push(msgCwKeyerToGUI);
|
|
|
|
}
|
|
|
|
}
|
2019-02-22 01:17:27 -05:00
|
|
|
|
2019-08-01 17:21:57 -04:00
|
|
|
MsgConfigureFreeDVMod *msg = MsgConfigureFreeDVMod::create(settings, force);
|
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue) // forward to GUI if any
|
|
|
|
{
|
|
|
|
MsgConfigureFreeDVMod *msgToGUI = MsgConfigureFreeDVMod::create(settings, force);
|
|
|
|
m_guiMessageQueue->push(msgToGUI);
|
|
|
|
}
|
|
|
|
|
|
|
|
webapiFormatChannelSettings(response, settings);
|
|
|
|
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVMod::webapiUpdateChannelSettings(
|
|
|
|
FreeDVModSettings& settings,
|
|
|
|
const QStringList& channelSettingsKeys,
|
|
|
|
SWGSDRangel::SWGChannelSettings& response)
|
|
|
|
{
|
|
|
|
if (channelSettingsKeys.contains("inputFrequencyOffset")) {
|
2019-02-22 01:17:27 -05:00
|
|
|
settings.m_inputFrequencyOffset = response.getFreeDvModSettings()->getInputFrequencyOffset();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("toneFrequency")) {
|
|
|
|
settings.m_toneFrequency = response.getFreeDvModSettings()->getToneFrequency();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("volumeFactor")) {
|
|
|
|
settings.m_volumeFactor = response.getFreeDvModSettings()->getVolumeFactor();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("spanLog2")) {
|
|
|
|
settings.m_spanLog2 = response.getFreeDvModSettings()->getSpanLog2();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioMute")) {
|
|
|
|
settings.m_audioMute = response.getFreeDvModSettings()->getAudioMute() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("playLoop")) {
|
|
|
|
settings.m_playLoop = response.getFreeDvModSettings()->getPlayLoop() != 0;
|
|
|
|
}
|
2019-02-24 14:59:09 -05:00
|
|
|
if (channelSettingsKeys.contains("gaugeInputElseModem")) {
|
|
|
|
settings.m_gaugeInputElseModem = response.getFreeDvModSettings()->getGaugeInputElseModem() != 0;
|
|
|
|
}
|
2019-02-22 01:17:27 -05:00
|
|
|
if (channelSettingsKeys.contains("rgbColor")) {
|
|
|
|
settings.m_rgbColor = response.getFreeDvModSettings()->getRgbColor();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("title")) {
|
|
|
|
settings.m_title = *response.getFreeDvModSettings()->getTitle();
|
|
|
|
}
|
2019-02-22 09:30:51 -05:00
|
|
|
if (channelSettingsKeys.contains("freeDVMode")) {
|
|
|
|
settings.m_freeDVMode = (FreeDVModSettings::FreeDVMode) response.getFreeDvModSettings()->getFreeDvMode();
|
|
|
|
}
|
2019-02-22 01:17:27 -05:00
|
|
|
if (channelSettingsKeys.contains("modAFInput")) {
|
|
|
|
settings.m_modAFInput = (FreeDVModSettings::FreeDVModInputAF) response.getFreeDvModSettings()->getModAfInput();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioDeviceName")) {
|
|
|
|
settings.m_audioDeviceName = *response.getFreeDvModSettings()->getAudioDeviceName();
|
|
|
|
}
|
2019-11-17 05:09:07 -05:00
|
|
|
if (channelSettingsKeys.contains("streamIndex")) {
|
|
|
|
settings.m_streamIndex = response.getFreeDvModSettings()->getStreamIndex();
|
|
|
|
}
|
2019-02-22 01:17:27 -05:00
|
|
|
if (channelSettingsKeys.contains("useReverseAPI")) {
|
|
|
|
settings.m_useReverseAPI = response.getFreeDvModSettings()->getUseReverseApi() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIAddress")) {
|
2019-04-20 13:53:16 -04:00
|
|
|
settings.m_reverseAPIAddress = *response.getFreeDvModSettings()->getReverseApiAddress();
|
2019-02-22 01:17:27 -05:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIPort")) {
|
|
|
|
settings.m_reverseAPIPort = response.getFreeDvModSettings()->getReverseApiPort();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
|
|
|
|
settings.m_reverseAPIDeviceIndex = response.getFreeDvModSettings()->getReverseApiDeviceIndex();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
|
|
|
|
settings.m_reverseAPIChannelIndex = response.getFreeDvModSettings()->getReverseApiChannelIndex();
|
|
|
|
}
|
2021-11-30 18:20:14 -05:00
|
|
|
if (settings.m_spectrumGUI && channelSettingsKeys.contains("spectrumConfig")) {
|
|
|
|
settings.m_spectrumGUI->updateFrom(channelSettingsKeys, response.getFreeDvModSettings()->getSpectrumConfig());
|
|
|
|
}
|
2021-12-03 16:32:54 -05:00
|
|
|
if (settings.m_channelMarker && channelSettingsKeys.contains("channelMarker")) {
|
|
|
|
settings.m_channelMarker->updateFrom(channelSettingsKeys, response.getFreeDvModSettings()->getChannelMarker());
|
|
|
|
}
|
2022-01-08 23:27:12 -05:00
|
|
|
if (settings.m_rollupState && channelSettingsKeys.contains("rollupState")) {
|
|
|
|
settings.m_rollupState->updateFrom(channelSettingsKeys, response.getFreeDvModSettings()->getRollupState());
|
|
|
|
}
|
2019-02-22 01:17:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int FreeDVMod::webapiReportGet(
|
|
|
|
SWGSDRangel::SWGChannelReport& response,
|
|
|
|
QString& errorMessage)
|
|
|
|
{
|
|
|
|
(void) errorMessage;
|
|
|
|
response.setFreeDvModReport(new SWGSDRangel::SWGFreeDVModReport());
|
|
|
|
response.getFreeDvModReport()->init();
|
|
|
|
webapiFormatChannelReport(response);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVMod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const FreeDVModSettings& settings)
|
|
|
|
{
|
|
|
|
response.getFreeDvModSettings()->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
|
|
|
|
response.getFreeDvModSettings()->setToneFrequency(settings.m_toneFrequency);
|
|
|
|
response.getFreeDvModSettings()->setVolumeFactor(settings.m_volumeFactor);
|
|
|
|
response.getFreeDvModSettings()->setSpanLog2(settings.m_spanLog2);
|
|
|
|
response.getFreeDvModSettings()->setAudioMute(settings.m_audioMute ? 1 : 0);
|
|
|
|
response.getFreeDvModSettings()->setPlayLoop(settings.m_playLoop ? 1 : 0);
|
|
|
|
response.getFreeDvModSettings()->setRgbColor(settings.m_rgbColor);
|
2019-02-24 14:59:09 -05:00
|
|
|
response.getFreeDvModSettings()->setGaugeInputElseModem(settings.m_gaugeInputElseModem ? 1 : 0);
|
2019-02-22 01:17:27 -05:00
|
|
|
|
|
|
|
if (response.getFreeDvModSettings()->getTitle()) {
|
|
|
|
*response.getFreeDvModSettings()->getTitle() = settings.m_title;
|
|
|
|
} else {
|
|
|
|
response.getFreeDvModSettings()->setTitle(new QString(settings.m_title));
|
|
|
|
}
|
|
|
|
|
|
|
|
response.getFreeDvModSettings()->setModAfInput((int) settings.m_modAFInput);
|
2019-04-17 11:34:02 -04:00
|
|
|
response.getFreeDvModSettings()->setFreeDvMode((int) settings.m_freeDVMode);
|
2019-02-22 01:17:27 -05:00
|
|
|
|
|
|
|
if (response.getFreeDvModSettings()->getAudioDeviceName()) {
|
|
|
|
*response.getFreeDvModSettings()->getAudioDeviceName() = settings.m_audioDeviceName;
|
|
|
|
} else {
|
|
|
|
response.getFreeDvModSettings()->setAudioDeviceName(new QString(settings.m_audioDeviceName));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!response.getFreeDvModSettings()->getCwKeyer()) {
|
|
|
|
response.getFreeDvModSettings()->setCwKeyer(new SWGSDRangel::SWGCWKeyerSettings);
|
|
|
|
}
|
|
|
|
|
2019-02-24 14:59:09 -05:00
|
|
|
response.getFreeDvModSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
|
2019-02-22 01:17:27 -05:00
|
|
|
|
2019-02-24 14:59:09 -05:00
|
|
|
if (response.getFreeDvModSettings()->getReverseApiAddress()) {
|
|
|
|
*response.getFreeDvModSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress;
|
2019-02-22 01:17:27 -05:00
|
|
|
} else {
|
2019-02-24 14:59:09 -05:00
|
|
|
response.getFreeDvModSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
|
2019-02-22 01:17:27 -05:00
|
|
|
}
|
|
|
|
|
2019-02-24 14:59:09 -05:00
|
|
|
response.getFreeDvModSettings()->setReverseApiPort(settings.m_reverseAPIPort);
|
|
|
|
response.getFreeDvModSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
|
|
|
|
response.getFreeDvModSettings()->setReverseApiChannelIndex(settings.m_reverseAPIChannelIndex);
|
2021-11-30 18:20:14 -05:00
|
|
|
|
|
|
|
if (settings.m_spectrumGUI)
|
|
|
|
{
|
|
|
|
if (response.getFreeDvModSettings()->getSpectrumConfig())
|
|
|
|
{
|
|
|
|
settings.m_spectrumGUI->formatTo(response.getFreeDvModSettings()->getSpectrumConfig());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGGLSpectrum *swgGLSpectrum = new SWGSDRangel::SWGGLSpectrum();
|
|
|
|
settings.m_spectrumGUI->formatTo(swgGLSpectrum);
|
|
|
|
response.getFreeDvModSettings()->setSpectrumConfig(swgGLSpectrum);
|
|
|
|
}
|
|
|
|
}
|
2021-12-03 16:32:54 -05:00
|
|
|
|
|
|
|
if (settings.m_channelMarker)
|
|
|
|
{
|
|
|
|
if (response.getFreeDvModSettings()->getChannelMarker())
|
|
|
|
{
|
|
|
|
settings.m_channelMarker->formatTo(response.getFreeDvModSettings()->getChannelMarker());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGChannelMarker *swgChannelMarker = new SWGSDRangel::SWGChannelMarker();
|
|
|
|
settings.m_channelMarker->formatTo(swgChannelMarker);
|
|
|
|
response.getFreeDvModSettings()->setChannelMarker(swgChannelMarker);
|
|
|
|
}
|
|
|
|
}
|
2022-01-08 23:27:12 -05:00
|
|
|
|
|
|
|
if (settings.m_rollupState)
|
|
|
|
{
|
|
|
|
if (response.getFreeDvModSettings()->getRollupState())
|
|
|
|
{
|
|
|
|
settings.m_rollupState->formatTo(response.getFreeDvModSettings()->getRollupState());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGRollupState *swgRollupState = new SWGSDRangel::SWGRollupState();
|
|
|
|
settings.m_rollupState->formatTo(swgRollupState);
|
|
|
|
response.getFreeDvModSettings()->setRollupState(swgRollupState);
|
|
|
|
}
|
|
|
|
}
|
2019-02-22 01:17:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVMod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response)
|
|
|
|
{
|
|
|
|
response.getFreeDvModReport()->setChannelPowerDb(CalcDb::dbPower(getMagSq()));
|
2019-11-14 19:04:24 -05:00
|
|
|
response.getFreeDvModReport()->setAudioSampleRate(m_basebandSource->getAudioSampleRate());
|
|
|
|
response.getFreeDvModReport()->setChannelSampleRate(m_basebandSource->getChannelSampleRate());
|
2019-02-22 01:17:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVMod::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const FreeDVModSettings& settings, bool force)
|
2020-10-22 18:11:18 -04:00
|
|
|
{
|
|
|
|
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
|
|
|
|
webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force);
|
|
|
|
|
|
|
|
QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
|
|
|
|
.arg(settings.m_reverseAPIAddress)
|
|
|
|
.arg(settings.m_reverseAPIPort)
|
|
|
|
.arg(settings.m_reverseAPIDeviceIndex)
|
|
|
|
.arg(settings.m_reverseAPIChannelIndex);
|
|
|
|
m_networkRequest.setUrl(QUrl(channelSettingsURL));
|
|
|
|
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
|
|
|
|
|
|
|
QBuffer *buffer = new QBuffer();
|
|
|
|
buffer->open((QBuffer::ReadWrite));
|
|
|
|
buffer->write(swgChannelSettings->asJson().toUtf8());
|
|
|
|
buffer->seek(0);
|
|
|
|
|
|
|
|
// Always use PATCH to avoid passing reverse API settings
|
|
|
|
QNetworkReply *reply = m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
|
|
|
|
buffer->setParent(reply);
|
|
|
|
|
|
|
|
delete swgChannelSettings;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVMod::webapiReverseSendCWSettings(const CWKeyerSettings& cwKeyerSettings)
|
2019-02-22 01:17:27 -05:00
|
|
|
{
|
|
|
|
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
|
2020-10-22 18:11:18 -04:00
|
|
|
swgChannelSettings->setDirection(1); // single source (Tx)
|
|
|
|
swgChannelSettings->setChannelType(new QString("FreeDVMod"));
|
|
|
|
swgChannelSettings->setFreeDvModSettings(new SWGSDRangel::SWGFreeDVModSettings());
|
|
|
|
SWGSDRangel::SWGFreeDVModSettings *swgFreeDVModSettings = swgChannelSettings->getFreeDvModSettings();
|
|
|
|
|
|
|
|
swgFreeDVModSettings->setCwKeyer(new SWGSDRangel::SWGCWKeyerSettings());
|
|
|
|
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = swgFreeDVModSettings->getCwKeyer();
|
|
|
|
m_basebandSource->getCWKeyer().webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings);
|
|
|
|
|
|
|
|
QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
|
|
|
|
.arg(m_settings.m_reverseAPIAddress)
|
|
|
|
.arg(m_settings.m_reverseAPIPort)
|
|
|
|
.arg(m_settings.m_reverseAPIDeviceIndex)
|
|
|
|
.arg(m_settings.m_reverseAPIChannelIndex);
|
|
|
|
m_networkRequest.setUrl(QUrl(channelSettingsURL));
|
|
|
|
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
|
|
|
|
|
|
|
QBuffer *buffer = new QBuffer();
|
|
|
|
buffer->open((QBuffer::ReadWrite));
|
|
|
|
buffer->write(swgChannelSettings->asJson().toUtf8());
|
|
|
|
buffer->seek(0);
|
|
|
|
|
|
|
|
// Always use PATCH to avoid passing reverse API settings
|
|
|
|
QNetworkReply *reply = m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
|
|
|
|
buffer->setParent(reply);
|
|
|
|
|
|
|
|
delete swgChannelSettings;
|
|
|
|
}
|
|
|
|
|
2020-12-13 07:04:36 -05:00
|
|
|
void FreeDVMod::sendChannelSettings(
|
2022-03-02 17:07:15 -05:00
|
|
|
const QList<ObjectPipe*>& pipes,
|
2020-12-13 07:04:36 -05:00
|
|
|
QList<QString>& channelSettingsKeys,
|
|
|
|
const FreeDVModSettings& settings,
|
|
|
|
bool force)
|
2020-10-22 18:11:18 -04:00
|
|
|
{
|
2022-03-02 17:07:15 -05:00
|
|
|
for (const auto& pipe : pipes)
|
2020-10-22 18:11:18 -04:00
|
|
|
{
|
2022-03-02 17:07:15 -05:00
|
|
|
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
|
|
|
|
|
|
|
|
if (messageQueue)
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
|
|
|
|
webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force);
|
|
|
|
MainCore::MsgChannelSettings *msg = MainCore::MsgChannelSettings::create(
|
|
|
|
this,
|
|
|
|
channelSettingsKeys,
|
|
|
|
swgChannelSettings,
|
|
|
|
force
|
|
|
|
);
|
|
|
|
messageQueue->push(msg);
|
|
|
|
}
|
2020-10-22 18:11:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVMod::webapiFormatChannelSettings(
|
|
|
|
QList<QString>& channelSettingsKeys,
|
|
|
|
SWGSDRangel::SWGChannelSettings *swgChannelSettings,
|
|
|
|
const FreeDVModSettings& settings,
|
|
|
|
bool force
|
|
|
|
)
|
|
|
|
{
|
2019-05-07 08:43:38 -04:00
|
|
|
swgChannelSettings->setDirection(1); // single source (Tx)
|
2019-03-25 08:57:59 -04:00
|
|
|
swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet());
|
|
|
|
swgChannelSettings->setOriginatorDeviceSetIndex(getDeviceSetIndex());
|
2020-10-22 18:11:18 -04:00
|
|
|
swgChannelSettings->setChannelType(new QString(m_channelId));
|
2019-02-22 01:17:27 -05:00
|
|
|
swgChannelSettings->setFreeDvModSettings(new SWGSDRangel::SWGFreeDVModSettings());
|
|
|
|
SWGSDRangel::SWGFreeDVModSettings *swgFreeDVModSettings = swgChannelSettings->getFreeDvModSettings();
|
|
|
|
|
|
|
|
// transfer data that has been modified. When force is on transfer all data except reverse API data
|
|
|
|
|
|
|
|
if (channelSettingsKeys.contains("inputFrequencyOffset") || force) {
|
|
|
|
swgFreeDVModSettings->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("toneFrequency") || force) {
|
|
|
|
swgFreeDVModSettings->setToneFrequency(settings.m_toneFrequency);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("volumeFactor") || force) {
|
|
|
|
swgFreeDVModSettings->setVolumeFactor(settings.m_volumeFactor);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("spanLog2") || force) {
|
|
|
|
swgFreeDVModSettings->setSpanLog2(settings.m_spanLog2);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioMute") || force) {
|
|
|
|
swgFreeDVModSettings->setAudioMute(settings.m_audioMute ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("playLoop") || force) {
|
|
|
|
swgFreeDVModSettings->setPlayLoop(settings.m_playLoop ? 1 : 0);
|
|
|
|
}
|
2019-02-24 14:59:09 -05:00
|
|
|
if (channelSettingsKeys.contains("gaugeInputElseModem") || force) {
|
|
|
|
swgFreeDVModSettings->setPlayLoop(settings.m_gaugeInputElseModem ? 1 : 0);
|
|
|
|
}
|
2019-02-22 01:17:27 -05:00
|
|
|
if (channelSettingsKeys.contains("rgbColor") || force) {
|
|
|
|
swgFreeDVModSettings->setRgbColor(settings.m_rgbColor);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("title") || force) {
|
|
|
|
swgFreeDVModSettings->setTitle(new QString(settings.m_title));
|
|
|
|
}
|
2019-02-22 09:30:51 -05:00
|
|
|
if (channelSettingsKeys.contains("freeDVMode") || force) {
|
|
|
|
swgFreeDVModSettings->setFreeDvMode((int) settings.m_freeDVMode);
|
|
|
|
}
|
2019-02-22 01:17:27 -05:00
|
|
|
if (channelSettingsKeys.contains("modAFInput") || force) {
|
|
|
|
swgFreeDVModSettings->setModAfInput((int) settings.m_modAFInput);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioDeviceName") || force) {
|
|
|
|
swgFreeDVModSettings->setAudioDeviceName(new QString(settings.m_audioDeviceName));
|
|
|
|
}
|
2019-11-17 05:09:07 -05:00
|
|
|
if (channelSettingsKeys.contains("streamIndex") || force) {
|
|
|
|
swgFreeDVModSettings->setStreamIndex(settings.m_streamIndex);
|
|
|
|
}
|
2021-12-03 16:32:54 -05:00
|
|
|
|
2021-11-30 18:20:14 -05:00
|
|
|
if (settings.m_spectrumGUI && (channelSettingsKeys.contains("spectrunConfig") || force))
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGGLSpectrum *swgGLSpectrum = new SWGSDRangel::SWGGLSpectrum();
|
|
|
|
settings.m_spectrumGUI->formatTo(swgGLSpectrum);
|
|
|
|
swgFreeDVModSettings->setSpectrumConfig(swgGLSpectrum);
|
|
|
|
}
|
2019-02-22 01:17:27 -05:00
|
|
|
|
2021-12-03 16:32:54 -05:00
|
|
|
if (settings.m_channelMarker && (channelSettingsKeys.contains("channelMarker") || force))
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGChannelMarker *swgChannelMarker = new SWGSDRangel::SWGChannelMarker();
|
|
|
|
settings.m_channelMarker->formatTo(swgChannelMarker);
|
|
|
|
swgFreeDVModSettings->setChannelMarker(swgChannelMarker);
|
|
|
|
}
|
|
|
|
|
2022-01-08 23:27:12 -05:00
|
|
|
if (settings.m_rollupState && (channelSettingsKeys.contains("rollupState") || force))
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGRollupState *swgRollupState = new SWGSDRangel::SWGRollupState();
|
|
|
|
settings.m_rollupState->formatTo(swgRollupState);
|
|
|
|
swgFreeDVModSettings->setRollupState(swgRollupState);
|
|
|
|
}
|
|
|
|
|
2019-02-22 01:17:27 -05:00
|
|
|
if (force)
|
|
|
|
{
|
2019-11-14 19:04:24 -05:00
|
|
|
const CWKeyerSettings& cwKeyerSettings = m_basebandSource->getCWKeyer().getSettings();
|
2019-02-22 01:17:27 -05:00
|
|
|
swgFreeDVModSettings->setCwKeyer(new SWGSDRangel::SWGCWKeyerSettings());
|
|
|
|
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = swgFreeDVModSettings->getCwKeyer();
|
2019-11-14 19:04:24 -05:00
|
|
|
m_basebandSource->getCWKeyer().webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings);
|
2019-02-22 01:17:27 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVMod::networkManagerFinished(QNetworkReply *reply)
|
|
|
|
{
|
|
|
|
QNetworkReply::NetworkError replyError = reply->error();
|
|
|
|
|
|
|
|
if (replyError)
|
|
|
|
{
|
|
|
|
qWarning() << "FreeDVMod::networkManagerFinished:"
|
|
|
|
<< " error(" << (int) replyError
|
|
|
|
<< "): " << replyError
|
|
|
|
<< ": " << reply->errorString();
|
2019-11-14 19:04:24 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QString answer = reply->readAll();
|
|
|
|
answer.chop(1); // remove last \n
|
|
|
|
qDebug("FreeDVMod::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
|
2019-02-22 01:17:27 -05:00
|
|
|
}
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
reply->deleteLater();
|
|
|
|
}
|
|
|
|
|
2020-08-02 04:11:41 -04:00
|
|
|
int FreeDVMod::getAudioSampleRate() const
|
2019-11-14 19:04:24 -05:00
|
|
|
{
|
|
|
|
return m_basebandSource->getAudioSampleRate();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t FreeDVMod::getModemSampleRate() const
|
|
|
|
{
|
|
|
|
return m_basebandSource->getModemSampleRate();
|
|
|
|
}
|
|
|
|
|
|
|
|
Real FreeDVMod::getLowCutoff() const
|
|
|
|
{
|
|
|
|
return m_basebandSource->getLowCutoff();
|
|
|
|
}
|
|
|
|
|
|
|
|
Real FreeDVMod::getHiCutoff() const
|
|
|
|
{
|
|
|
|
return m_basebandSource->getHiCutoff();
|
|
|
|
}
|
|
|
|
|
|
|
|
double FreeDVMod::getMagSq() const
|
|
|
|
{
|
|
|
|
return m_basebandSource->getMagSq();
|
|
|
|
}
|
|
|
|
|
|
|
|
CWKeyer *FreeDVMod::getCWKeyer()
|
|
|
|
{
|
|
|
|
return &m_basebandSource->getCWKeyer();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVMod::setLevelMeter(QObject *levelMeter)
|
|
|
|
{
|
|
|
|
connect(m_basebandSource, SIGNAL(levelChanged(qreal, qreal, int)), levelMeter, SLOT(levelChanged(qreal, qreal, int)));
|
2019-02-22 01:17:27 -05:00
|
|
|
}
|
2019-11-17 05:09:07 -05:00
|
|
|
|
|
|
|
uint32_t FreeDVMod::getNumberOfDeviceStreams() const
|
|
|
|
{
|
|
|
|
return m_deviceAPI->getNbSinkStreams();
|
2020-10-22 18:11:18 -04:00
|
|
|
}
|