2016-11-29 17:58:41 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2016 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. //
|
2016-11-29 17:58:41 -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>
|
2018-12-20 00:04:14 -05:00
|
|
|
#include <QNetworkAccessManager>
|
|
|
|
#include <QNetworkReply>
|
|
|
|
#include <QBuffer>
|
2019-11-14 19:04:24 -05:00
|
|
|
#include <QThread>
|
2017-10-12 15:26:33 -04:00
|
|
|
|
2017-12-10 14:27:08 -05:00
|
|
|
#include "SWGChannelSettings.h"
|
|
|
|
#include "SWGCWKeyerSettings.h"
|
2018-03-18 15:17:11 -04:00
|
|
|
#include "SWGChannelReport.h"
|
|
|
|
#include "SWGNFMModReport.h"
|
2017-12-10 14:27:08 -05:00
|
|
|
|
2016-11-29 17:58:41 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <complex.h>
|
2016-12-01 20:00:53 -05:00
|
|
|
#include <algorithm>
|
2017-10-12 15:26:33 -04:00
|
|
|
|
2016-11-29 17:58:41 -05:00
|
|
|
#include "dsp/dspengine.h"
|
2018-02-14 14:11:36 -05:00
|
|
|
#include "dsp/dspcommands.h"
|
2019-11-14 19:04:24 -05:00
|
|
|
#include "dsp/cwkeyer.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"
|
2018-03-18 15:17:11 -04:00
|
|
|
#include "util/db.h"
|
2020-10-22 18:11:18 -04:00
|
|
|
#include "maincore.h"
|
2017-10-12 15:26:33 -04:00
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
#include "nfmmodbaseband.h"
|
2016-11-29 17:58:41 -05:00
|
|
|
#include "nfmmod.h"
|
|
|
|
|
|
|
|
MESSAGE_CLASS_DEFINITION(NFMMod::MsgConfigureNFMMod, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(NFMMod::MsgConfigureFileSourceName, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(NFMMod::MsgConfigureFileSourceSeek, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(NFMMod::MsgConfigureFileSourceStreamTiming, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(NFMMod::MsgReportFileSourceStreamData, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(NFMMod::MsgReportFileSourceStreamTiming, Message)
|
|
|
|
|
2020-11-21 14:24:18 -05:00
|
|
|
const char* const NFMMod::m_channelIdURI = "sdrangel.channeltx.modnfm";
|
|
|
|
const char* const NFMMod::m_channelId = "NFMMod";
|
2016-11-29 17:58:41 -05:00
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
NFMMod::NFMMod(DeviceAPI *deviceAPI) :
|
2019-05-09 11:27:12 -04:00
|
|
|
ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSource),
|
2017-10-12 15:26:33 -04:00
|
|
|
m_deviceAPI(deviceAPI),
|
2016-11-29 17:58:41 -05:00
|
|
|
m_settingsMutex(QMutex::Recursive),
|
|
|
|
m_fileSize(0),
|
|
|
|
m_recordLength(0),
|
2019-11-14 19:04:24 -05:00
|
|
|
m_sampleRate(48000)
|
2016-11-29 17:58:41 -05:00
|
|
|
{
|
2017-11-22 19:19:32 -05:00
|
|
|
setObjectName(m_channelId);
|
2016-11-29 17:58:41 -05:00
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
m_thread = new QThread(this);
|
|
|
|
m_basebandSource = new NFMModBaseband();
|
|
|
|
m_basebandSource->setInputFileStream(&m_ifstream);
|
|
|
|
m_basebandSource->moveToThread(m_thread);
|
2016-11-29 17:58:41 -05:00
|
|
|
|
2018-03-16 05:26:49 -04:00
|
|
|
applySettings(m_settings, true);
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
m_deviceAPI->addChannelSource(this);
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceAPI->addChannelSourceAPI(this);
|
2018-12-20 00:04:14 -05:00
|
|
|
|
|
|
|
m_networkManager = new QNetworkAccessManager();
|
|
|
|
connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
|
2016-11-29 17:58:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
NFMMod::~NFMMod()
|
|
|
|
{
|
2018-12-20 00:04:14 -05:00
|
|
|
disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
|
|
|
|
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;
|
2016-11-29 17:58:41 -05:00
|
|
|
}
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
void NFMMod::start()
|
2016-11-29 17:58:41 -05:00
|
|
|
{
|
2019-11-14 19:04:24 -05:00
|
|
|
qDebug("NFMMod::start");
|
|
|
|
m_basebandSource->reset();
|
|
|
|
m_thread->start();
|
2016-11-29 17:58:41 -05:00
|
|
|
}
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
void NFMMod::stop()
|
2016-12-25 19:39:34 -05:00
|
|
|
{
|
2019-11-14 19:04:24 -05:00
|
|
|
qDebug("NFMMod::stop");
|
|
|
|
m_thread->exit();
|
|
|
|
m_thread->wait();
|
2016-12-25 19:39:34 -05:00
|
|
|
}
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
void NFMMod::pull(SampleVector::iterator& begin, unsigned int nbSamples)
|
2016-11-30 07:39:25 -05:00
|
|
|
{
|
2019-11-14 19:04:24 -05:00
|
|
|
m_basebandSource->pull(begin, nbSamples);
|
2016-11-30 07:39:25 -05:00
|
|
|
}
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
bool NFMMod::handleMessage(const Message& cmd)
|
2016-11-29 17:58:41 -05:00
|
|
|
{
|
2019-11-20 18:40:55 -05:00
|
|
|
if (MsgConfigureNFMMod::match(cmd))
|
2019-07-30 20:38:50 -04:00
|
|
|
{
|
2019-11-14 19:04:24 -05:00
|
|
|
MsgConfigureNFMMod& cfg = (MsgConfigureNFMMod&) cmd;
|
|
|
|
qDebug() << "NFMMod::handleMessage: MsgConfigureNFMMod";
|
2019-07-30 20:38:50 -04:00
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
applySettings(cfg.getSettings(), cfg.getForce());
|
2019-07-30 20:38:50 -04:00
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
return true;
|
2016-12-01 20:00:53 -05:00
|
|
|
}
|
2019-11-14 19:04:24 -05:00
|
|
|
else if (MsgConfigureFileSourceName::match(cmd))
|
2016-12-01 20:00:53 -05:00
|
|
|
{
|
2019-11-14 19:04:24 -05:00
|
|
|
MsgConfigureFileSourceName& conf = (MsgConfigureFileSourceName&) cmd;
|
|
|
|
m_fileName = conf.getFileName();
|
|
|
|
openFileStream();
|
|
|
|
qDebug() << "NFMMod::handleMessage: MsgConfigureFileSourceName:"
|
|
|
|
<< " m_fileName: " << m_fileName;
|
|
|
|
return true;
|
2016-12-01 20:00:53 -05:00
|
|
|
}
|
2019-11-14 19:04:24 -05:00
|
|
|
else if (MsgConfigureFileSourceSeek::match(cmd))
|
2017-10-12 14:33:16 -04:00
|
|
|
{
|
2019-11-14 19:04:24 -05:00
|
|
|
MsgConfigureFileSourceSeek& conf = (MsgConfigureFileSourceSeek&) cmd;
|
|
|
|
int seekPercentage = conf.getPercentage();
|
|
|
|
seekFileStream(seekPercentage);
|
|
|
|
qDebug() << "NFMMod::handleMessage: MsgConfigureFileSourceSeek:"
|
|
|
|
<< " seekPercentage: " << seekPercentage;
|
2017-10-12 14:33:16 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2019-11-14 19:04:24 -05:00
|
|
|
else if (MsgConfigureFileSourceStreamTiming::match(cmd))
|
2017-10-12 14:16:37 -04:00
|
|
|
{
|
2019-11-14 19:04:24 -05:00
|
|
|
std::size_t samplesCount;
|
2017-10-12 14:16:37 -04:00
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
if (m_ifstream.eof()) {
|
|
|
|
samplesCount = m_fileSize / sizeof(Real);
|
|
|
|
} else {
|
|
|
|
samplesCount = m_ifstream.tellg() / sizeof(Real);
|
|
|
|
}
|
|
|
|
|
|
|
|
MsgReportFileSourceStreamTiming *report;
|
|
|
|
report = MsgReportFileSourceStreamTiming::create(samplesCount);
|
|
|
|
getMessageQueueToGUI()->push(report);
|
2017-10-12 14:16:37 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2016-11-29 17:58:41 -05:00
|
|
|
else if (MsgConfigureFileSourceName::match(cmd))
|
|
|
|
{
|
|
|
|
MsgConfigureFileSourceName& conf = (MsgConfigureFileSourceName&) cmd;
|
|
|
|
m_fileName = conf.getFileName();
|
|
|
|
openFileStream();
|
2017-12-12 09:58:04 -05:00
|
|
|
qDebug() << "NFMMod::handleMessage: MsgConfigureFileSourceName:"
|
|
|
|
<< " m_fileName: " << m_fileName;
|
2016-11-29 17:58:41 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MsgConfigureFileSourceSeek::match(cmd))
|
|
|
|
{
|
|
|
|
MsgConfigureFileSourceSeek& conf = (MsgConfigureFileSourceSeek&) cmd;
|
|
|
|
int seekPercentage = conf.getPercentage();
|
|
|
|
seekFileStream(seekPercentage);
|
2017-12-12 09:58:04 -05:00
|
|
|
qDebug() << "NFMMod::handleMessage: MsgConfigureFileSourceSeek:"
|
|
|
|
<< " seekPercentage: " << seekPercentage;
|
2016-11-29 17:58:41 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MsgConfigureFileSourceStreamTiming::match(cmd))
|
|
|
|
{
|
|
|
|
std::size_t samplesCount;
|
|
|
|
|
|
|
|
if (m_ifstream.eof()) {
|
|
|
|
samplesCount = m_fileSize / sizeof(Real);
|
|
|
|
} else {
|
|
|
|
samplesCount = m_ifstream.tellg() / sizeof(Real);
|
|
|
|
}
|
|
|
|
|
|
|
|
MsgReportFileSourceStreamTiming *report;
|
|
|
|
report = MsgReportFileSourceStreamTiming::create(samplesCount);
|
2017-09-28 02:33:05 -04:00
|
|
|
getMessageQueueToGUI()->push(report);
|
2016-11-29 17:58:41 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2018-12-20 00:04:14 -05:00
|
|
|
else if (CWKeyer::MsgConfigureCWKeyer::match(cmd))
|
|
|
|
{
|
|
|
|
const CWKeyer::MsgConfigureCWKeyer& cfg = (CWKeyer::MsgConfigureCWKeyer&) cmd;
|
|
|
|
|
|
|
|
if (m_settings.m_useReverseAPI) {
|
|
|
|
webapiReverseSendCWSettings(cfg.getSettings());
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2018-02-14 14:11:36 -05:00
|
|
|
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() << "NFMMod::handleMessage: DSPSignalNotification";
|
|
|
|
m_basebandSource->getInputMessageQueue()->push(rep);
|
|
|
|
|
2018-02-14 14:11:36 -05:00
|
|
|
return true;
|
|
|
|
}
|
2016-11-29 17:58:41 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void NFMMod::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);
|
|
|
|
|
|
|
|
m_sampleRate = 48000; // fixed rate
|
|
|
|
m_recordLength = m_fileSize / (sizeof(Real) * m_sampleRate);
|
|
|
|
|
2016-11-29 18:55:35 -05:00
|
|
|
qDebug() << "NFMMod::openFileStream: " << m_fileName.toStdString().c_str()
|
2016-11-29 17:58:41 -05:00
|
|
|
<< " fileSize: " << m_fileSize << "bytes"
|
|
|
|
<< " length: " << m_recordLength << " seconds";
|
|
|
|
|
|
|
|
MsgReportFileSourceStreamData *report;
|
|
|
|
report = MsgReportFileSourceStreamData::create(m_sampleRate, m_recordLength);
|
2017-09-28 02:33:05 -04:00
|
|
|
getMessageQueueToGUI()->push(report);
|
2016-11-29 17:58:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void NFMMod::seekFileStream(int seekPercentage)
|
|
|
|
{
|
|
|
|
QMutexLocker mutexLocker(&m_settingsMutex);
|
|
|
|
|
|
|
|
if (m_ifstream.is_open())
|
|
|
|
{
|
|
|
|
int seekPoint = ((m_recordLength * seekPercentage) / 100) * m_sampleRate;
|
|
|
|
seekPoint *= sizeof(Real);
|
|
|
|
m_ifstream.clear();
|
|
|
|
m_ifstream.seekg(seekPoint, std::ios::beg);
|
|
|
|
}
|
|
|
|
}
|
2017-10-12 14:16:37 -04:00
|
|
|
|
2017-12-29 18:18:51 -05:00
|
|
|
void NFMMod::applySettings(const NFMModSettings& settings, bool force)
|
|
|
|
{
|
|
|
|
qDebug() << "NFMMod::applySettings:"
|
|
|
|
<< " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset
|
|
|
|
<< " m_rfBandwidth: " << settings.m_rfBandwidth
|
|
|
|
<< " m_afBandwidth: " << settings.m_afBandwidth
|
|
|
|
<< " m_fmDeviation: " << settings.m_fmDeviation
|
|
|
|
<< " m_volumeFactor: " << settings.m_volumeFactor
|
|
|
|
<< " m_toneFrequency: " << settings.m_toneFrequency
|
|
|
|
<< " m_ctcssIndex: " << settings.m_ctcssIndex
|
|
|
|
<< " m_ctcssOn: " << settings.m_ctcssOn
|
|
|
|
<< " m_channelMute: " << settings.m_channelMute
|
|
|
|
<< " m_playLoop: " << settings.m_playLoop
|
2018-12-20 00:04:14 -05:00
|
|
|
<< " m_modAFInput " << settings.m_modAFInput
|
2018-03-29 09:42:20 -04:00
|
|
|
<< " m_audioDeviceName: " << settings.m_audioDeviceName
|
2018-12-20 00:04:14 -05:00
|
|
|
<< " m_useReverseAPI: " << settings.m_useReverseAPI
|
|
|
|
<< " m_reverseAPIAddress: " << settings.m_reverseAPIAddress
|
|
|
|
<< " m_reverseAPIAddress: " << settings.m_reverseAPIPort
|
|
|
|
<< " m_reverseAPIDeviceIndex: " << settings.m_reverseAPIDeviceIndex
|
|
|
|
<< " m_reverseAPIChannelIndex: " << settings.m_reverseAPIChannelIndex
|
2017-12-29 18:18:51 -05:00
|
|
|
<< " force: " << force;
|
|
|
|
|
2018-12-20 00:04:14 -05:00
|
|
|
QList<QString> reverseAPIKeys;
|
|
|
|
|
|
|
|
if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force) {
|
|
|
|
reverseAPIKeys.append("inputFrequencyOffset");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_fmDeviation != m_settings.m_fmDeviation) || force) {
|
|
|
|
reverseAPIKeys.append("fmDeviation");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_volumeFactor != m_settings.m_volumeFactor) || force) {
|
|
|
|
reverseAPIKeys.append("volumeFactor");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_ctcssOn != m_settings.m_ctcssOn) || force) {
|
|
|
|
reverseAPIKeys.append("ctcssOn");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_channelMute != m_settings.m_channelMute) || force) {
|
|
|
|
reverseAPIKeys.append("channelMute");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_playLoop != m_settings.m_playLoop) || force) {
|
|
|
|
reverseAPIKeys.append("playLoop");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_modAFInput != m_settings.m_modAFInput) || force) {
|
|
|
|
reverseAPIKeys.append("modAFInput");
|
|
|
|
}
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
if((settings.m_rfBandwidth != m_settings.m_rfBandwidth) || force) {
|
2018-12-20 00:04:14 -05:00
|
|
|
reverseAPIKeys.append("rfBandwidth");
|
2017-10-12 14:16:37 -04:00
|
|
|
}
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
if ((settings.m_afBandwidth != m_settings.m_afBandwidth) || force) {
|
2018-12-20 00:04:14 -05:00
|
|
|
reverseAPIKeys.append("afBandwidth");
|
2017-10-12 14:16:37 -04:00
|
|
|
}
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
if ((settings.m_toneFrequency != m_settings.m_toneFrequency) || force) {
|
2018-12-20 00:04:14 -05:00
|
|
|
reverseAPIKeys.append("toneFrequency");
|
2017-10-12 14:16:37 -04:00
|
|
|
}
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
if ((settings.m_ctcssIndex != m_settings.m_ctcssIndex) || force) {
|
2018-12-20 00:04:14 -05:00
|
|
|
reverseAPIKeys.append("ctcssIndex");
|
2017-10-12 14:16:37 -04:00
|
|
|
}
|
2019-11-20 18:40:55 -05:00
|
|
|
if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force) {
|
2018-12-20 00:04:14 -05:00
|
|
|
reverseAPIKeys.append("audioDeviceName");
|
2019-07-30 20:38:50 -04:00
|
|
|
}
|
2019-11-20 18:40:55 -05:00
|
|
|
if ((settings.m_feedbackAudioDeviceName != m_settings.m_feedbackAudioDeviceName) || force) {
|
2019-07-30 20:38:50 -04:00
|
|
|
reverseAPIKeys.append("feedbackAudioDeviceName");
|
2017-10-12 14:16:37 -04: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");
|
|
|
|
}
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
NFMModBaseband::MsgConfigureNFMModBaseband *msg = NFMModBaseband::MsgConfigureNFMModBaseband::create(settings, force);
|
|
|
|
m_basebandSource->getInputMessageQueue()->push(msg);
|
|
|
|
|
2018-12-20 00:04:14 -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);
|
|
|
|
}
|
|
|
|
|
2020-12-13 07:04:36 -05:00
|
|
|
QList<MessageQueue*> *messageQueues = MainCore::instance()->getMessagePipes().getMessageQueues(this, "settings");
|
|
|
|
|
|
|
|
if (messageQueues) {
|
|
|
|
sendChannelSettings(messageQueues, reverseAPIKeys, settings, force);
|
2020-10-22 18:11:18 -04:00
|
|
|
}
|
|
|
|
|
2017-10-12 14:16:37 -04:00
|
|
|
m_settings = settings;
|
|
|
|
}
|
|
|
|
|
2017-12-17 17:15:42 -05:00
|
|
|
QByteArray NFMMod::serialize() const
|
|
|
|
{
|
|
|
|
return m_settings.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NFMMod::deserialize(const QByteArray& data)
|
|
|
|
{
|
2017-12-27 21:29:26 -05:00
|
|
|
bool success = true;
|
|
|
|
|
|
|
|
if (!m_settings.deserialize(data))
|
2017-12-17 17:15:42 -05:00
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
2017-12-27 21:29:26 -05:00
|
|
|
success = false;
|
2017-12-17 17:15:42 -05:00
|
|
|
}
|
2017-12-27 21:29:26 -05:00
|
|
|
|
|
|
|
MsgConfigureNFMMod *msg = MsgConfigureNFMMod::create(m_settings, true);
|
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
|
|
|
|
return success;
|
2017-12-17 17:15:42 -05:00
|
|
|
}
|
|
|
|
|
2017-12-10 14:27:08 -05:00
|
|
|
int NFMMod::webapiSettingsGet(
|
|
|
|
SWGSDRangel::SWGChannelSettings& response,
|
2018-11-12 18:45:03 -05:00
|
|
|
QString& errorMessage)
|
2017-12-10 14:27:08 -05:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) errorMessage;
|
2017-12-10 14:27:08 -05:00
|
|
|
response.setNfmModSettings(new SWGSDRangel::SWGNFMModSettings());
|
2018-02-21 07:50:50 -05:00
|
|
|
response.getNfmModSettings()->init();
|
2018-02-14 14:11:36 -05:00
|
|
|
webapiFormatChannelSettings(response, m_settings);
|
2019-08-01 17:21:57 -04:00
|
|
|
|
|
|
|
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getNfmModSettings()->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);
|
|
|
|
|
2017-12-10 14:27:08 -05:00
|
|
|
return 200;
|
|
|
|
}
|
2017-12-11 12:18:47 -05:00
|
|
|
|
|
|
|
int NFMMod::webapiSettingsPutPatch(
|
|
|
|
bool force,
|
2017-12-23 21:27:07 -05:00
|
|
|
const QStringList& channelSettingsKeys,
|
2017-12-11 12:18:47 -05:00
|
|
|
SWGSDRangel::SWGChannelSettings& response,
|
2018-11-12 18:45:03 -05:00
|
|
|
QString& errorMessage)
|
2017-12-11 12:18:47 -05:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) errorMessage;
|
2018-08-08 03:17:25 -04:00
|
|
|
NFMModSettings settings = m_settings;
|
2019-08-01 17:21:57 -04:00
|
|
|
webapiUpdateChannelSettings(settings, channelSettingsKeys, response);
|
|
|
|
|
|
|
|
if (channelSettingsKeys.contains("cwKeyer"))
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getNfmModSettings()->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);
|
2017-12-23 22:19:44 -05:00
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2017-12-23 22:19:44 -05:00
|
|
|
|
2019-08-01 17:21:57 -04:00
|
|
|
MsgConfigureNFMMod *msg = MsgConfigureNFMMod::create(settings, force);
|
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue) // forward to GUI if any
|
|
|
|
{
|
|
|
|
MsgConfigureNFMMod *msgToGUI = MsgConfigureNFMMod::create(settings, force);
|
|
|
|
m_guiMessageQueue->push(msgToGUI);
|
|
|
|
}
|
|
|
|
|
|
|
|
webapiFormatChannelSettings(response, settings);
|
|
|
|
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NFMMod::webapiUpdateChannelSettings(
|
|
|
|
NFMModSettings& settings,
|
|
|
|
const QStringList& channelSettingsKeys,
|
|
|
|
SWGSDRangel::SWGChannelSettings& response)
|
|
|
|
{
|
2017-12-23 22:19:44 -05:00
|
|
|
if (channelSettingsKeys.contains("afBandwidth")) {
|
|
|
|
settings.m_afBandwidth = response.getNfmModSettings()->getAfBandwidth();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("channelMute")) {
|
|
|
|
settings.m_channelMute = response.getNfmModSettings()->getChannelMute() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("ctcssIndex")) {
|
|
|
|
settings.m_ctcssIndex = response.getNfmModSettings()->getCtcssIndex();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("ctcssOn")) {
|
|
|
|
settings.m_ctcssOn = response.getNfmModSettings()->getCtcssOn() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("fmDeviation")) {
|
|
|
|
settings.m_fmDeviation = response.getNfmModSettings()->getFmDeviation();
|
|
|
|
}
|
2019-08-01 17:21:57 -04:00
|
|
|
if (channelSettingsKeys.contains("inputFrequencyOffset")) {
|
2017-12-23 22:19:44 -05:00
|
|
|
settings.m_inputFrequencyOffset = response.getNfmModSettings()->getInputFrequencyOffset();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("modAFInput")) {
|
|
|
|
settings.m_modAFInput = (NFMModSettings::NFMModInputAF) response.getNfmModSettings()->getModAfInput();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("playLoop")) {
|
|
|
|
settings.m_playLoop = response.getNfmModSettings()->getPlayLoop() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("rfBandwidth")) {
|
|
|
|
settings.m_rfBandwidth = response.getNfmModSettings()->getRfBandwidth();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("rgbColor")) {
|
|
|
|
settings.m_rgbColor = response.getNfmModSettings()->getRgbColor();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("title")) {
|
|
|
|
settings.m_title = *response.getNfmModSettings()->getTitle();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("toneFrequency")) {
|
|
|
|
settings.m_toneFrequency = response.getNfmModSettings()->getToneFrequency();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("volumeFactor")) {
|
|
|
|
settings.m_volumeFactor = response.getNfmModSettings()->getVolumeFactor();
|
|
|
|
}
|
2019-11-17 05:09:07 -05:00
|
|
|
if (channelSettingsKeys.contains("streamIndex")) {
|
|
|
|
settings.m_streamIndex = response.getNfmModSettings()->getStreamIndex();
|
|
|
|
}
|
2018-12-20 02:29:48 -05:00
|
|
|
if (channelSettingsKeys.contains("useReverseAPI")) {
|
|
|
|
settings.m_useReverseAPI = response.getNfmModSettings()->getUseReverseApi() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIAddress")) {
|
2019-04-20 13:53:16 -04:00
|
|
|
settings.m_reverseAPIAddress = *response.getNfmModSettings()->getReverseApiAddress();
|
2018-12-20 02:29:48 -05:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIPort")) {
|
|
|
|
settings.m_reverseAPIPort = response.getNfmModSettings()->getReverseApiPort();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
|
|
|
|
settings.m_reverseAPIDeviceIndex = response.getNfmModSettings()->getReverseApiDeviceIndex();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
|
|
|
|
settings.m_reverseAPIChannelIndex = response.getNfmModSettings()->getReverseApiChannelIndex();
|
|
|
|
}
|
2017-12-11 12:18:47 -05:00
|
|
|
}
|
2018-02-14 14:11:36 -05:00
|
|
|
|
2018-03-18 15:17:11 -04:00
|
|
|
int NFMMod::webapiReportGet(
|
|
|
|
SWGSDRangel::SWGChannelReport& response,
|
2018-11-12 18:45:03 -05:00
|
|
|
QString& errorMessage)
|
2018-03-18 15:17:11 -04:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) errorMessage;
|
2018-03-18 15:17:11 -04:00
|
|
|
response.setNfmModReport(new SWGSDRangel::SWGNFMModReport());
|
|
|
|
response.getNfmModReport()->init();
|
|
|
|
webapiFormatChannelReport(response);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
2018-02-14 14:11:36 -05:00
|
|
|
void NFMMod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const NFMModSettings& settings)
|
|
|
|
{
|
2018-02-14 17:39:23 -05:00
|
|
|
response.getNfmModSettings()->setAfBandwidth(settings.m_afBandwidth);
|
|
|
|
response.getNfmModSettings()->setChannelMute(settings.m_channelMute ? 1 : 0);
|
|
|
|
response.getNfmModSettings()->setCtcssIndex(settings.m_ctcssIndex);
|
|
|
|
response.getNfmModSettings()->setCtcssOn(settings.m_ctcssOn ? 1 : 0);
|
|
|
|
response.getNfmModSettings()->setFmDeviation(settings.m_fmDeviation);
|
|
|
|
response.getNfmModSettings()->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
|
|
|
|
response.getNfmModSettings()->setModAfInput((int) settings.m_modAFInput);
|
|
|
|
response.getNfmModSettings()->setPlayLoop(settings.m_playLoop ? 1 : 0);
|
|
|
|
response.getNfmModSettings()->setRfBandwidth(settings.m_rfBandwidth);
|
|
|
|
response.getNfmModSettings()->setRgbColor(settings.m_rgbColor);
|
2018-02-14 14:11:36 -05:00
|
|
|
|
|
|
|
if (response.getNfmModSettings()->getTitle()) {
|
2018-02-14 17:39:23 -05:00
|
|
|
*response.getNfmModSettings()->getTitle() = settings.m_title;
|
2018-02-14 14:11:36 -05:00
|
|
|
} else {
|
|
|
|
response.getNfmModSettings()->setTitle(new QString(settings.m_title));
|
|
|
|
}
|
|
|
|
|
2018-02-14 17:39:23 -05:00
|
|
|
response.getNfmModSettings()->setToneFrequency(settings.m_toneFrequency);
|
|
|
|
response.getNfmModSettings()->setVolumeFactor(settings.m_volumeFactor);
|
2018-02-14 14:11:36 -05:00
|
|
|
|
|
|
|
if (!response.getNfmModSettings()->getCwKeyer()) {
|
|
|
|
response.getNfmModSettings()->setCwKeyer(new SWGSDRangel::SWGCWKeyerSettings);
|
|
|
|
}
|
|
|
|
|
2018-04-05 18:54:18 -04:00
|
|
|
if (response.getNfmModSettings()->getAudioDeviceName()) {
|
|
|
|
*response.getNfmModSettings()->getAudioDeviceName() = settings.m_audioDeviceName;
|
2018-03-29 09:42:20 -04:00
|
|
|
} else {
|
2018-04-05 18:54:18 -04:00
|
|
|
response.getNfmModSettings()->setAudioDeviceName(new QString(settings.m_audioDeviceName));
|
2018-03-29 09:42:20 -04:00
|
|
|
}
|
|
|
|
|
2018-12-20 02:29:48 -05:00
|
|
|
response.getNfmModSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
|
|
|
|
|
|
|
|
if (response.getNfmModSettings()->getReverseApiAddress()) {
|
|
|
|
*response.getNfmModSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress;
|
|
|
|
} else {
|
|
|
|
response.getNfmModSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
|
|
|
|
}
|
|
|
|
|
|
|
|
response.getNfmModSettings()->setReverseApiPort(settings.m_reverseAPIPort);
|
|
|
|
response.getNfmModSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
|
|
|
|
response.getNfmModSettings()->setReverseApiChannelIndex(settings.m_reverseAPIChannelIndex);
|
2018-02-14 14:11:36 -05:00
|
|
|
}
|
2018-03-18 15:17:11 -04:00
|
|
|
|
|
|
|
void NFMMod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response)
|
|
|
|
{
|
|
|
|
response.getNfmModReport()->setChannelPowerDb(CalcDb::dbPower(getMagSq()));
|
2019-11-14 19:04:24 -05:00
|
|
|
response.getNfmModReport()->setAudioSampleRate(m_basebandSource->getAudioSampleRate());
|
|
|
|
response.getNfmModReport()->setChannelSampleRate(m_basebandSource->getChannelSampleRate());
|
2018-03-18 15:17:11 -04:00
|
|
|
}
|
2018-12-20 00:04:14 -05:00
|
|
|
|
|
|
|
void NFMMod::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const NFMModSettings& settings, bool force)
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
|
2020-10-22 18:11:18 -04:00
|
|
|
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 NFMMod::webapiReverseSendCWSettings(const CWKeyerSettings& cwKeyerSettings)
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
|
|
|
|
swgChannelSettings->setDirection(1); // single source (Tx)
|
|
|
|
swgChannelSettings->setChannelType(new QString("NFMMod"));
|
|
|
|
swgChannelSettings->setNfmModSettings(new SWGSDRangel::SWGNFMModSettings());
|
|
|
|
SWGSDRangel::SWGNFMModSettings *swgNFModSettings = swgChannelSettings->getNfmModSettings();
|
|
|
|
|
|
|
|
swgNFModSettings->setCwKeyer(new SWGSDRangel::SWGCWKeyerSettings());
|
|
|
|
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = swgNFModSettings->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 NFMMod::sendChannelSettings(
|
|
|
|
QList<MessageQueue*> *messageQueues,
|
|
|
|
QList<QString>& channelSettingsKeys,
|
|
|
|
const NFMModSettings& settings,
|
|
|
|
bool force)
|
2020-10-22 18:11:18 -04:00
|
|
|
{
|
2020-12-13 07:04:36 -05:00
|
|
|
QList<MessageQueue*>::iterator it = messageQueues->begin();
|
2020-10-22 18:11:18 -04:00
|
|
|
|
2020-12-13 07:04:36 -05:00
|
|
|
for (; it != messageQueues->end(); ++it)
|
2020-10-22 18:11:18 -04:00
|
|
|
{
|
2020-12-13 07:04:36 -05:00
|
|
|
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
|
|
|
|
webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force);
|
|
|
|
MainCore::MsgChannelSettings *msg = MainCore::MsgChannelSettings::create(
|
|
|
|
this,
|
|
|
|
channelSettingsKeys,
|
|
|
|
swgChannelSettings,
|
|
|
|
force
|
|
|
|
);
|
|
|
|
(*it)->push(msg);
|
2020-10-22 18:11:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void NFMMod::webapiFormatChannelSettings(
|
|
|
|
QList<QString>& channelSettingsKeys,
|
|
|
|
SWGSDRangel::SWGChannelSettings *swgChannelSettings,
|
|
|
|
const NFMModSettings& 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));
|
2018-12-20 00:04:14 -05:00
|
|
|
swgChannelSettings->setNfmModSettings(new SWGSDRangel::SWGNFMModSettings());
|
|
|
|
SWGSDRangel::SWGNFMModSettings *swgNFMModSettings = swgChannelSettings->getNfmModSettings();
|
|
|
|
|
|
|
|
// transfer data that has been modified. When force is on transfer all data except reverse API data
|
|
|
|
|
|
|
|
if (channelSettingsKeys.contains("channelMute") || force) {
|
|
|
|
swgNFMModSettings->setChannelMute(settings.m_channelMute ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("inputFrequencyOffset") || force) {
|
|
|
|
swgNFMModSettings->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("modAFInput") || force) {
|
|
|
|
swgNFMModSettings->setModAfInput((int) settings.m_modAFInput);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioDeviceName") || force) {
|
|
|
|
swgNFMModSettings->setAudioDeviceName(new QString(settings.m_audioDeviceName));
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("playLoop") || force) {
|
|
|
|
swgNFMModSettings->setPlayLoop(settings.m_playLoop ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("afBandwidth") || force) {
|
|
|
|
swgNFMModSettings->setAfBandwidth(settings.m_afBandwidth);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("fmDeviation") || force) {
|
|
|
|
swgNFMModSettings->setFmDeviation(settings.m_fmDeviation);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("rfBandwidth") || force) {
|
|
|
|
swgNFMModSettings->setRfBandwidth(settings.m_rfBandwidth);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("rgbColor") || force) {
|
|
|
|
swgNFMModSettings->setRgbColor(settings.m_rgbColor);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("title") || force) {
|
|
|
|
swgNFMModSettings->setTitle(new QString(settings.m_title));
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("toneFrequency") || force) {
|
|
|
|
swgNFMModSettings->setToneFrequency(settings.m_toneFrequency);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("volumeFactor") || force) {
|
|
|
|
swgNFMModSettings->setVolumeFactor(settings.m_volumeFactor);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("ctcssOn") || force) {
|
|
|
|
swgNFMModSettings->setCtcssOn(settings.m_ctcssOn ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("ctcssIndex") || force) {
|
|
|
|
swgNFMModSettings->setCtcssIndex(settings.m_ctcssIndex);
|
|
|
|
}
|
2019-11-17 05:09:07 -05:00
|
|
|
if (channelSettingsKeys.contains("streamIndex") || force) {
|
|
|
|
swgNFMModSettings->setStreamIndex(settings.m_streamIndex);
|
|
|
|
}
|
2018-12-20 00:04:14 -05:00
|
|
|
|
|
|
|
if (force)
|
|
|
|
{
|
2019-11-14 19:04:24 -05:00
|
|
|
const CWKeyerSettings& cwKeyerSettings = m_basebandSource->getCWKeyer().getSettings();
|
2018-12-20 00:04:14 -05:00
|
|
|
swgNFMModSettings->setCwKeyer(new SWGSDRangel::SWGCWKeyerSettings());
|
|
|
|
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = swgNFMModSettings->getCwKeyer();
|
2019-11-14 19:04:24 -05:00
|
|
|
m_basebandSource->getCWKeyer().webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings);
|
2018-12-20 00:04:14 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void NFMMod::networkManagerFinished(QNetworkReply *reply)
|
|
|
|
{
|
|
|
|
QNetworkReply::NetworkError replyError = reply->error();
|
|
|
|
|
|
|
|
if (replyError)
|
|
|
|
{
|
|
|
|
qWarning() << "NFMMod::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("NFMMod::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
|
2018-12-20 00:04:14 -05:00
|
|
|
}
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
reply->deleteLater();
|
|
|
|
}
|
|
|
|
|
|
|
|
double NFMMod::getMagSq() const
|
|
|
|
{
|
|
|
|
return m_basebandSource->getMagSq();
|
2018-12-20 00:04:14 -05:00
|
|
|
}
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
CWKeyer *NFMMod::getCWKeyer()
|
|
|
|
{
|
|
|
|
return &m_basebandSource->getCWKeyer();
|
|
|
|
}
|
|
|
|
|
|
|
|
void NFMMod::setLevelMeter(QObject *levelMeter)
|
|
|
|
{
|
|
|
|
connect(m_basebandSource, SIGNAL(levelChanged(qreal, qreal, int)), levelMeter, SLOT(levelChanged(qreal, qreal, int)));
|
|
|
|
}
|
2019-11-17 05:09:07 -05:00
|
|
|
|
|
|
|
uint32_t NFMMod::getNumberOfDeviceStreams() const
|
|
|
|
{
|
|
|
|
return m_deviceAPI->getNbSinkStreams();
|
2020-08-02 04:11:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int NFMMod::getAudioSampleRate() const
|
|
|
|
{
|
|
|
|
return m_basebandSource->getAudioSampleRate();
|
|
|
|
}
|
|
|
|
|
|
|
|
int NFMMod::getFeedbackAudioSampleRate() const
|
|
|
|
{
|
|
|
|
return m_basebandSource->getFeedbackAudioSampleRate();
|
|
|
|
}
|