2016-12-11 18:48:27 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
2023-11-18 00:36:53 -05:00
|
|
|
// Copyright (C) 2016-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
|
|
|
|
// Copyright (C) 2019 Stefan Biereigel <stefan@biereigel.de> //
|
|
|
|
// Copyright (C) 2020 Kacper Michajłow <kasper93@gmail.com> //
|
|
|
|
// Copyright (C) 2022 Jiří Pinkava <jiri.pinkava@rossum.ai> //
|
2016-12-11 18:48:27 -05:00
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
2019-04-11 00:39:30 -04:00
|
|
|
// (at your option) any later version. //
|
2016-12-11 18:48: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>
|
2018-12-20 20:02:16 -05:00
|
|
|
#include <QNetworkAccessManager>
|
|
|
|
#include <QNetworkReply>
|
|
|
|
#include <QBuffer>
|
2019-11-14 19:04:24 -05:00
|
|
|
#include <QThread>
|
2018-02-14 14:11:36 -05:00
|
|
|
|
2016-12-11 18:48:27 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <complex.h>
|
2018-09-02 13:49:53 -04:00
|
|
|
#include <algorithm>
|
2018-02-14 14:11:36 -05:00
|
|
|
|
2018-04-14 15:46:53 -04:00
|
|
|
#include "SWGChannelSettings.h"
|
2022-05-13 16:24:48 -04:00
|
|
|
#include "SWGWorkspaceInfo.h"
|
2018-04-14 15:46:53 -04:00
|
|
|
#include "SWGChannelReport.h"
|
|
|
|
#include "SWGSSBModReport.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"
|
2017-08-05 13:08:33 -04:00
|
|
|
#include "util/db.h"
|
2020-10-22 18:11:18 -04:00
|
|
|
#include "maincore.h"
|
2016-12-11 18:48:27 -05:00
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
#include "ssbmodbaseband.h"
|
|
|
|
#include "ssbmod.h"
|
|
|
|
|
2016-12-11 18:48:27 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(SSBMod::MsgConfigureSSBMod, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(SSBMod::MsgConfigureFileSourceName, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(SSBMod::MsgConfigureFileSourceSeek, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(SSBMod::MsgConfigureFileSourceStreamTiming, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(SSBMod::MsgReportFileSourceStreamData, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(SSBMod::MsgReportFileSourceStreamTiming, Message)
|
|
|
|
|
2020-11-21 14:24:18 -05:00
|
|
|
const char* const SSBMod::m_channelIdURI = "sdrangel.channeltx.modssb";
|
|
|
|
const char* const SSBMod::m_channelId = "SSBMod";
|
2016-12-11 18:48:27 -05:00
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
SSBMod::SSBMod(DeviceAPI *deviceAPI) :
|
2019-05-09 11:27:12 -04:00
|
|
|
ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSource),
|
2017-10-21 10:01:16 -04:00
|
|
|
m_deviceAPI(deviceAPI),
|
2024-08-24 07:17:02 -04:00
|
|
|
m_spectrumVis(SDR_TX_SCALEF)
|
2016-12-11 18:48:27 -05:00
|
|
|
{
|
2017-11-22 19:19:32 -05:00
|
|
|
setObjectName(m_channelId);
|
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 20:02:16 -05:00
|
|
|
|
|
|
|
m_networkManager = new QNetworkAccessManager();
|
2022-03-23 17:32:23 -04:00
|
|
|
QObject::connect(
|
|
|
|
m_networkManager,
|
|
|
|
&QNetworkAccessManager::finished,
|
|
|
|
this,
|
|
|
|
&SSBMod::networkManagerFinished
|
|
|
|
);
|
2016-12-11 18:48:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
SSBMod::~SSBMod()
|
|
|
|
{
|
2022-03-23 17:32:23 -04:00
|
|
|
QObject::disconnect(
|
|
|
|
m_networkManager,
|
|
|
|
&QNetworkAccessManager::finished,
|
|
|
|
this,
|
|
|
|
&SSBMod::networkManagerFinished
|
|
|
|
);
|
2018-12-20 20:02:16 -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);
|
2024-08-18 07:36:30 -04:00
|
|
|
|
2024-08-24 07:17:02 -04:00
|
|
|
SSBMod::stop();
|
2016-12-11 18:48:27 -05:00
|
|
|
}
|
|
|
|
|
2022-04-16 10:45:53 -04:00
|
|
|
void SSBMod::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 SSBMod::start()
|
2016-12-11 18:48:27 -05:00
|
|
|
{
|
2024-08-18 07:36:30 -04:00
|
|
|
if (m_running) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
qDebug("SSBMod::start");
|
2024-08-18 07:36:30 -04:00
|
|
|
m_thread = new QThread(this);
|
|
|
|
m_basebandSource = new SSBModBaseband();
|
|
|
|
m_basebandSource->setSpectrumSink(&m_spectrumVis);
|
|
|
|
m_basebandSource->setInputFileStream(&m_ifstream);
|
|
|
|
m_basebandSource->setChannel(this);
|
2019-11-14 19:04:24 -05:00
|
|
|
m_basebandSource->reset();
|
2024-08-18 07:36:30 -04:00
|
|
|
m_basebandSource->setCWKeyer(&m_cwKeyer);
|
|
|
|
m_basebandSource->moveToThread(m_thread);
|
|
|
|
|
|
|
|
QObject::connect(
|
|
|
|
m_thread,
|
|
|
|
&QThread::finished,
|
|
|
|
m_basebandSource,
|
|
|
|
&QObject::deleteLater
|
|
|
|
);
|
|
|
|
QObject::connect(
|
|
|
|
m_thread,
|
|
|
|
&QThread::finished,
|
|
|
|
m_thread,
|
|
|
|
&QThread::deleteLater
|
|
|
|
);
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
m_thread->start();
|
2024-08-18 07:36:30 -04:00
|
|
|
|
|
|
|
SSBModBaseband::MsgConfigureSSBModBaseband *msg = SSBModBaseband::MsgConfigureSSBModBaseband::create(m_settings, true);
|
|
|
|
m_basebandSource->getInputMessageQueue()->push(msg);
|
|
|
|
|
|
|
|
if (m_levelMeter) {
|
|
|
|
connect(m_basebandSource, SIGNAL(levelChanged(qreal, qreal, int)), m_levelMeter, SLOT(levelChanged(qreal, qreal, int)));
|
|
|
|
}
|
|
|
|
|
|
|
|
m_running = true;
|
2016-12-11 18:48:27 -05:00
|
|
|
}
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
void SSBMod::stop()
|
2016-12-11 18:48:27 -05:00
|
|
|
{
|
2024-08-18 07:36:30 -04:00
|
|
|
if (!m_running) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
qDebug("SSBMod::stop");
|
2024-08-18 07:36:30 -04:00
|
|
|
m_running = false;
|
2019-11-14 19:04:24 -05:00
|
|
|
m_thread->exit();
|
|
|
|
m_thread->wait();
|
2016-12-11 18:48:27 -05:00
|
|
|
}
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
void SSBMod::pull(SampleVector::iterator& begin, unsigned int nbSamples)
|
2016-12-11 18:48:27 -05:00
|
|
|
{
|
2024-08-18 07:36:30 -04:00
|
|
|
if (m_running) {
|
|
|
|
m_basebandSource->pull(begin, nbSamples);
|
|
|
|
}
|
2016-12-11 18:48:27 -05:00
|
|
|
}
|
|
|
|
|
2022-01-06 16:47:41 -05:00
|
|
|
void SSBMod::setCenterFrequency(qint64 frequency)
|
|
|
|
{
|
|
|
|
SSBModSettings settings = m_settings;
|
|
|
|
settings.m_inputFrequencyOffset = frequency;
|
|
|
|
applySettings(settings, false);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue) // forward to GUI if any
|
|
|
|
{
|
|
|
|
MsgConfigureSSBMod *msgToGUI = MsgConfigureSSBMod::create(settings, false);
|
|
|
|
m_guiMessageQueue->push(msgToGUI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-11 18:48:27 -05:00
|
|
|
bool SSBMod::handleMessage(const Message& cmd)
|
|
|
|
{
|
2019-11-20 18:40:55 -05:00
|
|
|
if (MsgConfigureSSBMod::match(cmd))
|
2017-10-21 06:17:11 -04:00
|
|
|
{
|
2024-08-24 07:17:02 -04:00
|
|
|
auto& cfg = (const MsgConfigureSSBMod&) cmd;
|
2021-03-16 00:16:59 -04:00
|
|
|
qDebug() << "SSBMod::handleMessage: MsgConfigureSSBMod";
|
2016-12-11 18:48:27 -05:00
|
|
|
|
2017-12-29 18:18:51 -05:00
|
|
|
applySettings(cfg.getSettings(), cfg.getForce());
|
2017-10-21 06:17:11 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2016-12-11 18:48:27 -05:00
|
|
|
else if (MsgConfigureFileSourceName::match(cmd))
|
|
|
|
{
|
2024-08-24 07:17:02 -04:00
|
|
|
auto& conf = (const MsgConfigureFileSourceName&) cmd;
|
2016-12-11 18:48:27 -05:00
|
|
|
m_fileName = conf.getFileName();
|
|
|
|
openFileStream();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MsgConfigureFileSourceSeek::match(cmd))
|
|
|
|
{
|
2024-08-24 07:17:02 -04:00
|
|
|
auto& conf = (const MsgConfigureFileSourceSeek&) cmd;
|
2016-12-11 18:48:27 -05:00
|
|
|
int seekPercentage = conf.getPercentage();
|
|
|
|
seekFileStream(seekPercentage);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MsgConfigureFileSourceStreamTiming::match(cmd))
|
|
|
|
{
|
2024-08-24 07:17:02 -04:00
|
|
|
std::size_t samplesCount;
|
2016-12-11 18:48:27 -05:00
|
|
|
|
2024-08-24 07:17:02 -04:00
|
|
|
if (m_ifstream.eof()) {
|
|
|
|
samplesCount = m_fileSize / sizeof(Real);
|
|
|
|
} else {
|
|
|
|
samplesCount = m_ifstream.tellg() / sizeof(Real);
|
|
|
|
}
|
2016-12-11 18:48:27 -05:00
|
|
|
|
2018-03-29 10:57:42 -04:00
|
|
|
if (getMessageQueueToGUI())
|
|
|
|
{
|
2024-08-24 07:17:02 -04:00
|
|
|
auto *report = MsgReportFileSourceStreamTiming::create(samplesCount);
|
2018-03-29 10:57:42 -04:00
|
|
|
getMessageQueueToGUI()->push(report);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2018-12-20 20:02:16 -05:00
|
|
|
else if (CWKeyer::MsgConfigureCWKeyer::match(cmd))
|
|
|
|
{
|
2024-08-24 07:17:02 -04:00
|
|
|
auto& cfg = (const CWKeyer::MsgConfigureCWKeyer&) cmd;
|
2018-12-20 20:02:16 -05:00
|
|
|
|
|
|
|
if (m_settings.m_useReverseAPI) {
|
|
|
|
webapiReverseSendCWSettings(cfg.getSettings());
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2018-02-14 14:11:36 -05:00
|
|
|
else if (DSPSignalNotification::match(cmd))
|
|
|
|
{
|
2024-08-24 07:17:02 -04:00
|
|
|
auto& notif = (const DSPSignalNotification&) cmd;
|
2024-08-18 07:36:30 -04:00
|
|
|
// Forward to the source
|
|
|
|
if (m_running)
|
|
|
|
{
|
2024-08-24 07:17:02 -04:00
|
|
|
auto* rep = new DSPSignalNotification(notif); // make a copy
|
2024-08-18 07:36:30 -04:00
|
|
|
qDebug() << "SSBMod::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
|
|
|
|
2018-02-14 14:11:36 -05:00
|
|
|
return true;
|
2016-12-11 18:48:27 -05:00
|
|
|
}
|
2021-06-29 15:47:27 -04:00
|
|
|
else if (MainCore::MsgChannelDemodQuery::match(cmd))
|
|
|
|
{
|
|
|
|
qDebug() << "SSBMod::handleMessage: MsgChannelDemodQuery";
|
|
|
|
sendSampleRateToDemodAnalyzer();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2016-12-11 18:48:27 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-21 06:17:11 -04:00
|
|
|
void SSBMod::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
|
2024-08-24 07:17:02 -04:00
|
|
|
m_recordLength = (quint32) (m_fileSize / (sizeof(Real) * m_sampleRate));
|
2017-10-21 06:17:11 -04:00
|
|
|
|
|
|
|
qDebug() << "SSBMod::openFileStream: " << m_fileName.toStdString().c_str()
|
|
|
|
<< " fileSize: " << m_fileSize << "bytes"
|
|
|
|
<< " length: " << m_recordLength << " seconds";
|
|
|
|
|
2018-03-29 10:57:42 -04:00
|
|
|
if (getMessageQueueToGUI())
|
|
|
|
{
|
|
|
|
MsgReportFileSourceStreamData *report;
|
|
|
|
report = MsgReportFileSourceStreamData::create(m_sampleRate, m_recordLength);
|
|
|
|
getMessageQueueToGUI()->push(report);
|
|
|
|
}
|
2017-10-21 06:17:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void SSBMod::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-12-29 18:18:51 -05:00
|
|
|
void SSBMod::applySettings(const SSBModSettings& settings, bool force)
|
|
|
|
{
|
|
|
|
float band = settings.m_bandwidth;
|
|
|
|
float lowCutoff = settings.m_lowCutoff;
|
|
|
|
bool usb = settings.m_usb;
|
2018-12-20 20:02:16 -05:00
|
|
|
QList<QString> reverseAPIKeys;
|
|
|
|
|
|
|
|
if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force) {
|
|
|
|
reverseAPIKeys.append("inputFrequencyOffset");
|
|
|
|
}
|
|
|
|
if ((settings.m_bandwidth != m_settings.m_bandwidth) || force) {
|
|
|
|
reverseAPIKeys.append("bandwidth");
|
|
|
|
}
|
|
|
|
if ((settings.m_lowCutoff != m_settings.m_lowCutoff) || force) {
|
|
|
|
reverseAPIKeys.append("lowCutoff");
|
|
|
|
}
|
|
|
|
if ((settings.m_usb != m_settings.m_usb) || force) {
|
|
|
|
reverseAPIKeys.append("usb");
|
|
|
|
}
|
|
|
|
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_audioBinaural != m_settings.m_audioBinaural) || force) {
|
|
|
|
reverseAPIKeys.append("audioBinaural");
|
|
|
|
}
|
|
|
|
if ((settings.m_audioFlipChannels != m_settings.m_audioFlipChannels) || force) {
|
|
|
|
reverseAPIKeys.append("audioFlipChannels");
|
|
|
|
}
|
|
|
|
if ((settings.m_dsb != m_settings.m_dsb) || force) {
|
|
|
|
reverseAPIKeys.append("dsb");
|
|
|
|
}
|
|
|
|
if ((settings.m_audioMute != m_settings.m_audioMute) || force) {
|
|
|
|
reverseAPIKeys.append("audioMute");
|
|
|
|
}
|
|
|
|
if ((settings.m_playLoop != m_settings.m_playLoop) || force) {
|
|
|
|
reverseAPIKeys.append("playLoop");
|
|
|
|
}
|
|
|
|
if ((settings.m_agc != m_settings.m_agc) || force) {
|
|
|
|
reverseAPIKeys.append("agc");
|
|
|
|
}
|
2020-11-25 08:19:21 -05:00
|
|
|
if ((settings.m_cmpPreGainDB != m_settings.m_cmpPreGainDB) || force) {
|
|
|
|
reverseAPIKeys.append("cmpPreGainDB");
|
|
|
|
}
|
|
|
|
if ((settings.m_cmpThresholdDB != m_settings.m_cmpThresholdDB) || force) {
|
|
|
|
reverseAPIKeys.append("cmpThresholdDB");
|
|
|
|
}
|
2018-12-20 20:02:16 -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");
|
|
|
|
}
|
|
|
|
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-20 18:40:55 -05:00
|
|
|
if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force) {
|
|
|
|
reverseAPIKeys.append("audioDeviceName");
|
2018-03-29 10:57:42 -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");
|
|
|
|
}
|
|
|
|
|
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);
|
2023-12-14 15:57:10 -05:00
|
|
|
m_settings.m_streamIndex = settings.m_streamIndex; // make sure ChannelAPI::getStreamIndex() is consistent
|
|
|
|
emit streamIndexChanged(settings.m_streamIndex);
|
2019-11-18 19:22:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
reverseAPIKeys.append("streamIndex");
|
|
|
|
}
|
|
|
|
|
2020-05-04 21:24:10 -04:00
|
|
|
if ((settings.m_dsb != m_settings.m_dsb)
|
|
|
|
|| (settings.m_usb != m_settings.m_usb) || force)
|
|
|
|
{
|
2021-04-20 04:32:21 -04:00
|
|
|
SpectrumSettings spectrumSettings = m_spectrumVis.getSettings();
|
2020-05-04 21:24:10 -04:00
|
|
|
spectrumSettings.m_ssb = !settings.m_dsb;
|
|
|
|
spectrumSettings.m_usb = settings.m_usb;
|
|
|
|
SpectrumVis::MsgConfigureSpectrumVis *msg = SpectrumVis::MsgConfigureSpectrumVis::create(spectrumSettings, false);
|
|
|
|
m_spectrumVis.getInputMessageQueue()->push(msg);
|
|
|
|
}
|
|
|
|
|
2024-08-18 07:36:30 -04:00
|
|
|
if (m_running)
|
|
|
|
{
|
|
|
|
SSBModBaseband::MsgConfigureSSBModBaseband *msg = SSBModBaseband::MsgConfigureSSBModBaseband::create(settings, force);
|
|
|
|
m_basebandSource->getInputMessageQueue()->push(msg);
|
|
|
|
}
|
2019-11-14 19:04:24 -05:00
|
|
|
|
2018-12-20 20:02:16 -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
|
|
|
|
2024-08-24 07:17:02 -04:00
|
|
|
if (!pipes.empty()) {
|
2022-03-02 17:07:15 -05:00
|
|
|
sendChannelSettings(pipes, reverseAPIKeys, settings, force);
|
2020-10-22 18:11:18 -04:00
|
|
|
}
|
|
|
|
|
2017-10-21 06:17:11 -04:00
|
|
|
m_settings = settings;
|
2017-12-29 18:18:51 -05:00
|
|
|
m_settings.m_bandwidth = band;
|
|
|
|
m_settings.m_lowCutoff = lowCutoff;
|
|
|
|
m_settings.m_usb = usb;
|
2016-12-11 18:48:27 -05:00
|
|
|
}
|
2017-12-17 17:15:42 -05:00
|
|
|
|
|
|
|
QByteArray SSBMod::serialize() const
|
|
|
|
{
|
|
|
|
return m_settings.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SSBMod::deserialize(const QByteArray& data)
|
|
|
|
{
|
|
|
|
if (m_settings.deserialize(data))
|
|
|
|
{
|
|
|
|
MsgConfigureSSBMod *msg = MsgConfigureSSBMod::create(m_settings, true);
|
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
|
|
|
MsgConfigureSSBMod *msg = MsgConfigureSSBMod::create(m_settings, true);
|
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2018-04-14 15:46:53 -04:00
|
|
|
|
2024-08-24 07:17:02 -04:00
|
|
|
void SSBMod::sendSampleRateToDemodAnalyzer() const
|
2021-06-29 15:47:27 -04:00
|
|
|
{
|
2022-02-25 17:43:50 -05:00
|
|
|
QList<ObjectPipe*> pipes;
|
2022-03-02 17:57:35 -05:00
|
|
|
MainCore::instance()->getMessagePipes().getMessagePipes(this, "reportdemod", pipes);
|
2021-06-29 15:47:27 -04:00
|
|
|
|
2024-08-24 07:17:02 -04:00
|
|
|
if (!pipes.empty())
|
2021-06-29 15:47:27 -04:00
|
|
|
{
|
2022-02-25 17:43:50 -05:00
|
|
|
for (const auto& pipe : pipes)
|
2021-06-29 15:47:27 -04:00
|
|
|
{
|
2022-02-25 17:43:50 -05:00
|
|
|
MessageQueue* messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
|
2021-06-29 15:47:27 -04:00
|
|
|
MainCore::MsgChannelDemodReport *msg = MainCore::MsgChannelDemodReport::create(
|
|
|
|
this,
|
|
|
|
getAudioSampleRate()
|
|
|
|
);
|
2022-02-25 17:43:50 -05:00
|
|
|
messageQueue->push(msg);
|
2021-06-29 15:47:27 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-14 15:46:53 -04:00
|
|
|
int SSBMod::webapiSettingsGet(
|
|
|
|
SWGSDRangel::SWGChannelSettings& response,
|
2018-11-12 18:45:03 -05:00
|
|
|
QString& errorMessage)
|
2018-04-14 15:46:53 -04:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) errorMessage;
|
2018-04-14 15:46:53 -04:00
|
|
|
response.setSsbModSettings(new SWGSDRangel::SWGSSBModSettings());
|
|
|
|
response.getSsbModSettings()->init();
|
|
|
|
webapiFormatChannelSettings(response, m_settings);
|
2019-08-01 17:21:57 -04:00
|
|
|
|
|
|
|
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getSsbModSettings()->getCwKeyer();
|
2024-08-18 07:36:30 -04:00
|
|
|
const CWKeyerSettings& cwKeyerSettings = m_cwKeyer.getSettings();
|
2019-08-01 17:21:57 -04:00
|
|
|
CWKeyer::webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings);
|
|
|
|
|
2018-04-14 15:46:53 -04:00
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
2022-05-13 16:24:48 -04:00
|
|
|
int SSBMod::webapiWorkspaceGet(
|
|
|
|
SWGSDRangel::SWGWorkspaceInfo& response,
|
|
|
|
QString& errorMessage)
|
|
|
|
{
|
|
|
|
(void) errorMessage;
|
|
|
|
response.setIndex(m_settings.m_workspaceIndex);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
2018-04-14 15:46:53 -04:00
|
|
|
int SSBMod::webapiSettingsPutPatch(
|
|
|
|
bool force,
|
|
|
|
const QStringList& channelSettingsKeys,
|
|
|
|
SWGSDRangel::SWGChannelSettings& response,
|
2018-11-12 18:45:03 -05:00
|
|
|
QString& errorMessage)
|
2018-04-14 15:46:53 -04:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) errorMessage;
|
2018-08-08 03:17:25 -04:00
|
|
|
SSBModSettings settings = m_settings;
|
2019-08-01 17:21:57 -04:00
|
|
|
webapiUpdateChannelSettings(settings, channelSettingsKeys, response);
|
|
|
|
|
|
|
|
if (channelSettingsKeys.contains("cwKeyer"))
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getSsbModSettings()->getCwKeyer();
|
2024-08-18 07:36:30 -04:00
|
|
|
CWKeyerSettings cwKeyerSettings = m_cwKeyer.getSettings();
|
2019-08-01 17:21:57 -04:00
|
|
|
CWKeyer::webapiSettingsPutPatch(channelSettingsKeys, cwKeyerSettings, apiCwKeyerSettings);
|
|
|
|
|
|
|
|
CWKeyer::MsgConfigureCWKeyer *msgCwKeyer = CWKeyer::MsgConfigureCWKeyer::create(cwKeyerSettings, force);
|
2024-08-18 07:36:30 -04:00
|
|
|
m_cwKeyer.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);
|
|
|
|
}
|
|
|
|
}
|
2018-04-14 15:46:53 -04:00
|
|
|
|
2019-08-01 17:21:57 -04:00
|
|
|
MsgConfigureSSBMod *msg = MsgConfigureSSBMod::create(settings, force);
|
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue) // forward to GUI if any
|
|
|
|
{
|
|
|
|
MsgConfigureSSBMod *msgToGUI = MsgConfigureSSBMod::create(settings, force);
|
|
|
|
m_guiMessageQueue->push(msgToGUI);
|
|
|
|
}
|
|
|
|
|
|
|
|
webapiFormatChannelSettings(response, settings);
|
|
|
|
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SSBMod::webapiUpdateChannelSettings(
|
|
|
|
SSBModSettings& settings,
|
|
|
|
const QStringList& channelSettingsKeys,
|
|
|
|
SWGSDRangel::SWGChannelSettings& response)
|
|
|
|
{
|
|
|
|
if (channelSettingsKeys.contains("inputFrequencyOffset")) {
|
2018-04-14 15:46:53 -04:00
|
|
|
settings.m_inputFrequencyOffset = response.getSsbModSettings()->getInputFrequencyOffset();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("bandwidth")) {
|
|
|
|
settings.m_bandwidth = response.getSsbModSettings()->getBandwidth();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("lowCutoff")) {
|
|
|
|
settings.m_lowCutoff = response.getSsbModSettings()->getLowCutoff();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("usb")) {
|
|
|
|
settings.m_usb = response.getSsbModSettings()->getUsb() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("toneFrequency")) {
|
|
|
|
settings.m_toneFrequency = response.getSsbModSettings()->getToneFrequency();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("volumeFactor")) {
|
|
|
|
settings.m_volumeFactor = response.getSsbModSettings()->getVolumeFactor();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("spanLog2")) {
|
|
|
|
settings.m_spanLog2 = response.getSsbModSettings()->getSpanLog2();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioBinaural")) {
|
|
|
|
settings.m_audioBinaural = response.getSsbModSettings()->getAudioBinaural() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioFlipChannels")) {
|
|
|
|
settings.m_audioFlipChannels = response.getSsbModSettings()->getAudioFlipChannels() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("dsb")) {
|
|
|
|
settings.m_dsb = response.getSsbModSettings()->getDsb() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioMute")) {
|
|
|
|
settings.m_audioMute = response.getSsbModSettings()->getAudioMute() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("playLoop")) {
|
|
|
|
settings.m_playLoop = response.getSsbModSettings()->getPlayLoop() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("agc")) {
|
|
|
|
settings.m_agc = response.getSsbModSettings()->getAgc() != 0;
|
|
|
|
}
|
2020-11-25 08:19:21 -05:00
|
|
|
if (channelSettingsKeys.contains("cmpPreGainDB")) {
|
|
|
|
settings.m_cmpPreGainDB = response.getSsbModSettings()->getCmpPreGainDb();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("cmpThresholdDB")) {
|
|
|
|
settings.m_cmpThresholdDB = response.getSsbModSettings()->getCmpThresholdDb();
|
|
|
|
}
|
2018-04-14 15:46:53 -04:00
|
|
|
if (channelSettingsKeys.contains("rgbColor")) {
|
|
|
|
settings.m_rgbColor = response.getSsbModSettings()->getRgbColor();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("title")) {
|
|
|
|
settings.m_title = *response.getSsbModSettings()->getTitle();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("modAFInput")) {
|
|
|
|
settings.m_modAFInput = (SSBModSettings::SSBModInputAF) response.getSsbModSettings()->getModAfInput();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioDeviceName")) {
|
|
|
|
settings.m_audioDeviceName = *response.getSsbModSettings()->getAudioDeviceName();
|
|
|
|
}
|
2019-11-17 05:09:07 -05:00
|
|
|
if (channelSettingsKeys.contains("streamIndex")) {
|
|
|
|
settings.m_streamIndex = response.getSsbModSettings()->getStreamIndex();
|
|
|
|
}
|
2018-12-20 20:02:16 -05:00
|
|
|
if (channelSettingsKeys.contains("useReverseAPI")) {
|
|
|
|
settings.m_useReverseAPI = response.getSsbModSettings()->getUseReverseApi() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIAddress")) {
|
2019-04-20 13:53:16 -04:00
|
|
|
settings.m_reverseAPIAddress = *response.getSsbModSettings()->getReverseApiAddress();
|
2018-12-20 20:02:16 -05:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIPort")) {
|
2024-08-24 07:17:02 -04:00
|
|
|
settings.m_reverseAPIPort = (uint16_t) response.getSsbModSettings()->getReverseApiPort();
|
2018-12-20 20:02:16 -05:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
|
2024-08-24 07:17:02 -04:00
|
|
|
settings.m_reverseAPIDeviceIndex = (uint16_t) response.getSsbModSettings()->getReverseApiDeviceIndex();
|
2018-12-20 20:02:16 -05:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
|
2024-08-24 07:17:02 -04:00
|
|
|
settings.m_reverseAPIChannelIndex = (uint16_t) response.getSsbModSettings()->getReverseApiChannelIndex();
|
2018-12-20 20:02:16 -05:00
|
|
|
}
|
2021-11-30 18:20:14 -05:00
|
|
|
if (settings.m_spectrumGUI && channelSettingsKeys.contains("spectrumConfig")) {
|
|
|
|
settings.m_spectrumGUI->updateFrom(channelSettingsKeys, response.getSsbModSettings()->getSpectrumConfig());
|
|
|
|
}
|
2021-12-03 16:32:54 -05:00
|
|
|
if (settings.m_channelMarker && channelSettingsKeys.contains("channelMarker")) {
|
|
|
|
settings.m_channelMarker->updateFrom(channelSettingsKeys, response.getSsbModSettings()->getChannelMarker());
|
|
|
|
}
|
2022-01-08 23:27:12 -05:00
|
|
|
if (settings.m_rollupState && channelSettingsKeys.contains("rollupState")) {
|
|
|
|
settings.m_rollupState->updateFrom(channelSettingsKeys, response.getSsbModSettings()->getRollupState());
|
|
|
|
}
|
2018-04-14 15:46:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int SSBMod::webapiReportGet(
|
|
|
|
SWGSDRangel::SWGChannelReport& response,
|
2018-11-12 18:45:03 -05:00
|
|
|
QString& errorMessage)
|
2018-04-14 15:46:53 -04:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) errorMessage;
|
2018-04-14 15:46:53 -04:00
|
|
|
response.setSsbModReport(new SWGSDRangel::SWGSSBModReport());
|
|
|
|
response.getSsbModReport()->init();
|
|
|
|
webapiFormatChannelReport(response);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SSBMod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const SSBModSettings& settings)
|
|
|
|
{
|
|
|
|
response.getSsbModSettings()->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
|
|
|
|
response.getSsbModSettings()->setBandwidth(settings.m_bandwidth);
|
|
|
|
response.getSsbModSettings()->setLowCutoff(settings.m_lowCutoff);
|
|
|
|
response.getSsbModSettings()->setUsb(settings.m_usb ? 1 : 0);
|
|
|
|
response.getSsbModSettings()->setToneFrequency(settings.m_toneFrequency);
|
|
|
|
response.getSsbModSettings()->setVolumeFactor(settings.m_volumeFactor);
|
|
|
|
response.getSsbModSettings()->setSpanLog2(settings.m_spanLog2);
|
|
|
|
response.getSsbModSettings()->setAudioBinaural(settings.m_audioBinaural ? 1 : 0);
|
|
|
|
response.getSsbModSettings()->setAudioFlipChannels(settings.m_audioFlipChannels ? 1 : 0);
|
|
|
|
response.getSsbModSettings()->setDsb(settings.m_dsb ? 1 : 0);
|
|
|
|
response.getSsbModSettings()->setAudioMute(settings.m_audioMute ? 1 : 0);
|
|
|
|
response.getSsbModSettings()->setPlayLoop(settings.m_playLoop ? 1 : 0);
|
|
|
|
response.getSsbModSettings()->setAgc(settings.m_agc ? 1 : 0);
|
2020-11-25 08:19:21 -05:00
|
|
|
response.getSsbModSettings()->setCmpPreGainDb(settings.m_cmpPreGainDB);
|
|
|
|
response.getSsbModSettings()->setCmpThresholdDb(settings.m_cmpThresholdDB);
|
2018-04-14 15:46:53 -04:00
|
|
|
response.getSsbModSettings()->setRgbColor(settings.m_rgbColor);
|
|
|
|
|
|
|
|
if (response.getSsbModSettings()->getTitle()) {
|
|
|
|
*response.getSsbModSettings()->getTitle() = settings.m_title;
|
|
|
|
} else {
|
|
|
|
response.getSsbModSettings()->setTitle(new QString(settings.m_title));
|
|
|
|
}
|
|
|
|
|
|
|
|
response.getSsbModSettings()->setModAfInput((int) settings.m_modAFInput);
|
|
|
|
|
|
|
|
if (response.getSsbModSettings()->getAudioDeviceName()) {
|
|
|
|
*response.getSsbModSettings()->getAudioDeviceName() = settings.m_audioDeviceName;
|
|
|
|
} else {
|
|
|
|
response.getSsbModSettings()->setAudioDeviceName(new QString(settings.m_audioDeviceName));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!response.getSsbModSettings()->getCwKeyer()) {
|
|
|
|
response.getSsbModSettings()->setCwKeyer(new SWGSDRangel::SWGCWKeyerSettings);
|
|
|
|
}
|
|
|
|
|
2019-02-24 08:57:06 -05:00
|
|
|
response.getSsbModSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
|
2018-12-20 20:02:16 -05:00
|
|
|
|
2019-02-24 08:57:06 -05:00
|
|
|
if (response.getSsbModSettings()->getReverseApiAddress()) {
|
|
|
|
*response.getSsbModSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress;
|
2018-12-20 20:02:16 -05:00
|
|
|
} else {
|
2019-02-24 08:57:06 -05:00
|
|
|
response.getSsbModSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
|
2018-12-20 20:02:16 -05:00
|
|
|
}
|
|
|
|
|
2019-02-24 08:57:06 -05:00
|
|
|
response.getSsbModSettings()->setReverseApiPort(settings.m_reverseAPIPort);
|
|
|
|
response.getSsbModSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
|
|
|
|
response.getSsbModSettings()->setReverseApiChannelIndex(settings.m_reverseAPIChannelIndex);
|
2021-11-30 18:20:14 -05:00
|
|
|
|
|
|
|
if (settings.m_spectrumGUI)
|
|
|
|
{
|
|
|
|
if (response.getSsbModSettings()->getSpectrumConfig())
|
|
|
|
{
|
|
|
|
settings.m_spectrumGUI->formatTo(response.getSsbModSettings()->getSpectrumConfig());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-24 07:17:02 -04:00
|
|
|
auto *swgGLSpectrum = new SWGSDRangel::SWGGLSpectrum();
|
2021-11-30 18:20:14 -05:00
|
|
|
settings.m_spectrumGUI->formatTo(swgGLSpectrum);
|
|
|
|
response.getSsbModSettings()->setSpectrumConfig(swgGLSpectrum);
|
|
|
|
}
|
|
|
|
}
|
2021-12-03 16:32:54 -05:00
|
|
|
|
|
|
|
if (settings.m_channelMarker)
|
|
|
|
{
|
|
|
|
if (response.getSsbModSettings()->getChannelMarker())
|
|
|
|
{
|
|
|
|
settings.m_channelMarker->formatTo(response.getSsbModSettings()->getChannelMarker());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-24 07:17:02 -04:00
|
|
|
auto *swgChannelMarker = new SWGSDRangel::SWGChannelMarker();
|
2021-12-03 16:32:54 -05:00
|
|
|
settings.m_channelMarker->formatTo(swgChannelMarker);
|
|
|
|
response.getSsbModSettings()->setChannelMarker(swgChannelMarker);
|
|
|
|
}
|
|
|
|
}
|
2022-01-08 23:27:12 -05:00
|
|
|
|
|
|
|
if (settings.m_rollupState)
|
|
|
|
{
|
|
|
|
if (response.getSsbModSettings()->getRollupState())
|
|
|
|
{
|
|
|
|
settings.m_rollupState->formatTo(response.getSsbModSettings()->getRollupState());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-08-24 07:17:02 -04:00
|
|
|
auto *swgRollupState = new SWGSDRangel::SWGRollupState();
|
2022-01-08 23:27:12 -05:00
|
|
|
settings.m_rollupState->formatTo(swgRollupState);
|
|
|
|
response.getSsbModSettings()->setRollupState(swgRollupState);
|
|
|
|
}
|
|
|
|
}
|
2018-04-14 15:46:53 -04:00
|
|
|
}
|
|
|
|
|
2024-08-24 07:17:02 -04:00
|
|
|
void SSBMod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response) const
|
2018-04-14 15:46:53 -04:00
|
|
|
{
|
2024-08-24 07:17:02 -04:00
|
|
|
response.getSsbModReport()->setChannelPowerDb((float) CalcDb::dbPower(getMagSq()));
|
2024-08-18 07:36:30 -04:00
|
|
|
|
|
|
|
if (m_running)
|
|
|
|
{
|
|
|
|
response.getSsbModReport()->setAudioSampleRate(m_basebandSource->getAudioSampleRate());
|
|
|
|
response.getSsbModReport()->setChannelSampleRate(m_basebandSource->getChannelSampleRate());
|
|
|
|
}
|
2018-04-14 15:46:53 -04:00
|
|
|
}
|
|
|
|
|
2024-08-24 07:17:02 -04:00
|
|
|
void SSBMod::webapiReverseSendSettings(const QList<QString>& channelSettingsKeys, const SSBModSettings& settings, bool force)
|
2020-10-22 18:11:18 -04:00
|
|
|
{
|
2024-08-24 07:17:02 -04:00
|
|
|
auto *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");
|
|
|
|
|
2024-08-24 07:17:02 -04:00
|
|
|
auto *buffer = new QBuffer();
|
|
|
|
buffer->open(QBuffer::ReadWrite);
|
2020-10-22 18:11:18 -04:00
|
|
|
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 SSBMod::webapiReverseSendCWSettings(const CWKeyerSettings& cwKeyerSettings)
|
2018-12-20 20:02:16 -05:00
|
|
|
{
|
2024-08-24 07:17:02 -04:00
|
|
|
auto *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
|
2020-10-22 18:11:18 -04:00
|
|
|
swgChannelSettings->setDirection(1); // single source (Tx)
|
|
|
|
swgChannelSettings->setChannelType(new QString("SSBMod"));
|
|
|
|
swgChannelSettings->setSsbModSettings(new SWGSDRangel::SWGSSBModSettings());
|
|
|
|
SWGSDRangel::SWGSSBModSettings *swgSSBModSettings = swgChannelSettings->getSsbModSettings();
|
|
|
|
|
|
|
|
swgSSBModSettings->setCwKeyer(new SWGSDRangel::SWGCWKeyerSettings());
|
|
|
|
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = swgSSBModSettings->getCwKeyer();
|
2024-08-24 07:17:02 -04:00
|
|
|
CWKeyer::webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings);
|
2020-10-22 18:11:18 -04:00
|
|
|
|
|
|
|
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");
|
|
|
|
|
2024-08-24 07:17:02 -04:00
|
|
|
auto *buffer = new QBuffer();
|
|
|
|
buffer->open(QBuffer::ReadWrite);
|
2020-10-22 18:11:18 -04:00
|
|
|
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 SSBMod::sendChannelSettings(
|
2022-03-02 17:07:15 -05:00
|
|
|
const QList<ObjectPipe*>& pipes,
|
2024-08-24 07:17:02 -04:00
|
|
|
const QList<QString>& channelSettingsKeys,
|
2020-12-13 07:04:36 -05:00
|
|
|
const SSBModSettings& settings,
|
2024-08-24 07:17:02 -04:00
|
|
|
bool force) const
|
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)
|
|
|
|
{
|
2024-08-24 07:17:02 -04:00
|
|
|
auto *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
|
2022-03-02 17:07:15 -05:00
|
|
|
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 SSBMod::webapiFormatChannelSettings(
|
2024-08-24 07:17:02 -04:00
|
|
|
const QList<QString>& channelSettingsKeys,
|
2020-10-22 18:11:18 -04:00
|
|
|
SWGSDRangel::SWGChannelSettings *swgChannelSettings,
|
|
|
|
const SSBModSettings& settings,
|
|
|
|
bool force
|
2024-08-24 07:17:02 -04:00
|
|
|
) const
|
2020-10-22 18:11:18 -04:00
|
|
|
{
|
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 20:02:16 -05:00
|
|
|
swgChannelSettings->setSsbModSettings(new SWGSDRangel::SWGSSBModSettings());
|
|
|
|
SWGSDRangel::SWGSSBModSettings *swgSSBModSettings = swgChannelSettings->getSsbModSettings();
|
|
|
|
|
|
|
|
// transfer data that has been modified. When force is on transfer all data except reverse API data
|
|
|
|
|
|
|
|
if (channelSettingsKeys.contains("inputFrequencyOffset") || force) {
|
|
|
|
swgSSBModSettings->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("bandwidth") || force) {
|
|
|
|
swgSSBModSettings->setBandwidth(settings.m_bandwidth);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("lowCutoff") || force) {
|
|
|
|
swgSSBModSettings->setLowCutoff(settings.m_lowCutoff);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("usb") || force) {
|
|
|
|
swgSSBModSettings->setUsb(settings.m_usb ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("toneFrequency") || force) {
|
|
|
|
swgSSBModSettings->setToneFrequency(settings.m_toneFrequency);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("volumeFactor") || force) {
|
|
|
|
swgSSBModSettings->setVolumeFactor(settings.m_volumeFactor);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("spanLog2") || force) {
|
|
|
|
swgSSBModSettings->setSpanLog2(settings.m_spanLog2);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioBinaural") || force) {
|
|
|
|
swgSSBModSettings->setAudioBinaural(settings.m_audioBinaural ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioFlipChannels") || force) {
|
|
|
|
swgSSBModSettings->setAudioFlipChannels(settings.m_audioFlipChannels ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("dsb") || force) {
|
|
|
|
swgSSBModSettings->setDsb(settings.m_dsb ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioMute") || force) {
|
|
|
|
swgSSBModSettings->setAudioMute(settings.m_audioMute ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("playLoop") || force) {
|
|
|
|
swgSSBModSettings->setPlayLoop(settings.m_playLoop ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("agc") || force) {
|
|
|
|
swgSSBModSettings->setAgc(settings.m_agc ? 1 : 0);
|
|
|
|
}
|
2020-11-25 08:19:21 -05:00
|
|
|
if (channelSettingsKeys.contains("cmpPreGainDB") || force) {
|
|
|
|
swgSSBModSettings->setCmpPreGainDb(settings.m_cmpPreGainDB);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("cmpThresholdDB") || force) {
|
|
|
|
swgSSBModSettings->setCmpThresholdDb(settings.m_cmpThresholdDB);
|
|
|
|
}
|
2018-12-20 20:02:16 -05:00
|
|
|
if (channelSettingsKeys.contains("rgbColor") || force) {
|
|
|
|
swgSSBModSettings->setRgbColor(settings.m_rgbColor);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("title") || force) {
|
|
|
|
swgSSBModSettings->setTitle(new QString(settings.m_title));
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("modAFInput") || force) {
|
|
|
|
swgSSBModSettings->setModAfInput((int) settings.m_modAFInput);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioDeviceName") || force) {
|
|
|
|
swgSSBModSettings->setAudioDeviceName(new QString(settings.m_audioDeviceName));
|
|
|
|
}
|
2019-11-17 05:09:07 -05:00
|
|
|
if (channelSettingsKeys.contains("streamIndex") || force) {
|
|
|
|
swgSSBModSettings->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))
|
|
|
|
{
|
2024-08-24 07:17:02 -04:00
|
|
|
auto *swgGLSpectrum = new SWGSDRangel::SWGGLSpectrum();
|
2021-11-30 18:20:14 -05:00
|
|
|
settings.m_spectrumGUI->formatTo(swgGLSpectrum);
|
|
|
|
swgSSBModSettings->setSpectrumConfig(swgGLSpectrum);
|
|
|
|
}
|
2018-12-20 20:02:16 -05:00
|
|
|
|
2021-12-03 16:32:54 -05:00
|
|
|
if (settings.m_channelMarker && (channelSettingsKeys.contains("channelMarker") || force))
|
|
|
|
{
|
2024-08-24 07:17:02 -04:00
|
|
|
auto *swgChannelMarker = new SWGSDRangel::SWGChannelMarker();
|
2021-12-03 16:32:54 -05:00
|
|
|
settings.m_channelMarker->formatTo(swgChannelMarker);
|
|
|
|
swgSSBModSettings->setChannelMarker(swgChannelMarker);
|
|
|
|
}
|
|
|
|
|
2022-01-08 23:27:12 -05:00
|
|
|
if (settings.m_rollupState && (channelSettingsKeys.contains("rollupState") || force))
|
|
|
|
{
|
2024-08-24 07:17:02 -04:00
|
|
|
auto *swgRollupState = new SWGSDRangel::SWGRollupState();
|
2022-01-08 23:27:12 -05:00
|
|
|
settings.m_rollupState->formatTo(swgRollupState);
|
|
|
|
swgSSBModSettings->setRollupState(swgRollupState);
|
|
|
|
}
|
|
|
|
|
2018-12-20 20:02:16 -05:00
|
|
|
if (force)
|
|
|
|
{
|
2024-08-18 07:36:30 -04:00
|
|
|
const CWKeyerSettings& cwKeyerSettings = m_cwKeyer.getSettings();
|
2018-12-20 20:02:16 -05:00
|
|
|
swgSSBModSettings->setCwKeyer(new SWGSDRangel::SWGCWKeyerSettings());
|
|
|
|
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = swgSSBModSettings->getCwKeyer();
|
2024-08-24 07:17:02 -04:00
|
|
|
CWKeyer::webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings);
|
2018-12-20 20:02:16 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-24 07:17:02 -04:00
|
|
|
void SSBMod::networkManagerFinished(QNetworkReply *reply) const
|
2018-12-20 20:02:16 -05:00
|
|
|
{
|
|
|
|
QNetworkReply::NetworkError replyError = reply->error();
|
|
|
|
|
|
|
|
if (replyError)
|
|
|
|
{
|
|
|
|
qWarning() << "SSBMod::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("SSBMod::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
|
2018-12-20 20:02:16 -05:00
|
|
|
}
|
|
|
|
|
2019-11-14 19:04:24 -05:00
|
|
|
reply->deleteLater();
|
2018-12-20 20:02:16 -05:00
|
|
|
}
|
2019-11-14 19:04:24 -05:00
|
|
|
|
|
|
|
double SSBMod::getMagSq() const
|
|
|
|
{
|
2024-08-18 07:36:30 -04:00
|
|
|
if (m_running) {
|
|
|
|
return m_basebandSource->getMagSq();
|
|
|
|
}
|
2019-11-14 19:04:24 -05:00
|
|
|
|
2024-08-18 07:36:30 -04:00
|
|
|
return 0;
|
2019-11-14 19:04:24 -05:00
|
|
|
}
|
|
|
|
|
2024-08-18 07:36:30 -04:00
|
|
|
CWKeyer *SSBMod::getCWKeyer()
|
2019-11-14 19:04:24 -05:00
|
|
|
{
|
2024-08-18 07:36:30 -04:00
|
|
|
return &m_cwKeyer;
|
2019-11-14 19:04:24 -05:00
|
|
|
}
|
|
|
|
|
2020-08-02 04:11:41 -04:00
|
|
|
int SSBMod::getAudioSampleRate() const
|
2019-11-14 19:04:24 -05:00
|
|
|
{
|
2024-08-18 07:36:30 -04:00
|
|
|
if (m_running) {
|
|
|
|
return m_basebandSource->getAudioSampleRate();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2019-11-14 19:04:24 -05:00
|
|
|
}
|
|
|
|
|
2020-08-02 04:11:41 -04:00
|
|
|
int SSBMod::getFeedbackAudioSampleRate() const
|
|
|
|
{
|
2024-08-18 07:36:30 -04:00
|
|
|
if (m_running) {
|
|
|
|
return m_basebandSource->getFeedbackAudioSampleRate();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2020-08-02 04:11:41 -04:00
|
|
|
}
|
|
|
|
|
2019-11-17 05:09:07 -05:00
|
|
|
uint32_t SSBMod::getNumberOfDeviceStreams() const
|
|
|
|
{
|
|
|
|
return m_deviceAPI->getNbSinkStreams();
|
2020-10-22 18:11:18 -04:00
|
|
|
}
|