2019-02-24 18:13:57 -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-24 18:13:57 -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 <QDebug>
|
|
|
|
#include <QNetworkAccessManager>
|
|
|
|
#include <QNetworkReply>
|
|
|
|
#include <QBuffer>
|
2019-12-08 04:09:24 -05:00
|
|
|
#include <QThread>
|
2019-02-24 20:29:59 -05:00
|
|
|
|
2019-02-24 18:13:57 -05:00
|
|
|
#include "SWGChannelSettings.h"
|
2019-02-24 20:06:15 -05:00
|
|
|
#include "SWGFreeDVDemodSettings.h"
|
2019-02-24 18:13:57 -05:00
|
|
|
#include "SWGChannelReport.h"
|
2019-02-24 20:06:15 -05:00
|
|
|
#include "SWGFreeDVDemodReport.h"
|
2019-02-24 18:13:57 -05:00
|
|
|
|
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "dsp/dspcommands.h"
|
2019-09-22 19:25:17 -04:00
|
|
|
#include "dsp/devicesamplemimo.h"
|
2019-05-08 16:11:53 -04:00
|
|
|
#include "device/deviceapi.h"
|
2019-02-24 18:13:57 -05:00
|
|
|
#include "util/db.h"
|
|
|
|
|
|
|
|
#include "freedvdemod.h"
|
|
|
|
|
|
|
|
MESSAGE_CLASS_DEFINITION(FreeDVDemod::MsgConfigureFreeDVDemod, Message)
|
2019-02-27 08:53:50 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(FreeDVDemod::MsgResyncFreeDVDemod, Message)
|
2019-02-24 18:13:57 -05:00
|
|
|
|
|
|
|
const QString FreeDVDemod::m_channelIdURI = "sdrangel.channel.freedvdemod";
|
|
|
|
const QString FreeDVDemod::m_channelId = "FreeDVDemod";
|
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
FreeDVDemod::FreeDVDemod(DeviceAPI *deviceAPI) :
|
2019-05-09 11:27:12 -04:00
|
|
|
ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSink),
|
2020-04-30 03:57:05 -04:00
|
|
|
m_deviceAPI(deviceAPI),
|
|
|
|
m_spectrumVis(SDR_RX_SCALEF)
|
2019-02-24 18:13:57 -05:00
|
|
|
{
|
|
|
|
setObjectName(m_channelId);
|
|
|
|
|
2019-12-08 04:09:24 -05:00
|
|
|
m_thread = new QThread(this);
|
|
|
|
m_basebandSink = new FreeDVDemodBaseband();
|
2020-04-30 03:57:05 -04:00
|
|
|
m_basebandSink->setSpectrumSink(&m_spectrumVis);
|
2019-12-08 04:09:24 -05:00
|
|
|
m_basebandSink->moveToThread(m_thread);
|
2019-02-24 18:13:57 -05:00
|
|
|
|
2019-12-08 04:09:24 -05:00
|
|
|
applySettings(m_settings, true);
|
2019-02-24 18:13:57 -05:00
|
|
|
|
2019-12-08 04:09:24 -05:00
|
|
|
m_deviceAPI->addChannelSink(this);
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceAPI->addChannelSinkAPI(this);
|
2019-02-24 18:13:57 -05:00
|
|
|
|
|
|
|
m_networkManager = new QNetworkAccessManager();
|
|
|
|
connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
|
|
|
|
}
|
|
|
|
|
|
|
|
FreeDVDemod::~FreeDVDemod()
|
|
|
|
{
|
|
|
|
disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
|
|
|
|
delete m_networkManager;
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceAPI->removeChannelSinkAPI(this);
|
2019-12-08 04:09:24 -05:00
|
|
|
m_deviceAPI->removeChannelSink(this);
|
|
|
|
delete m_basebandSink;
|
|
|
|
delete m_thread;
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
|
2019-09-22 19:25:17 -04:00
|
|
|
uint32_t FreeDVDemod::getNumberOfDeviceStreams() const
|
|
|
|
{
|
|
|
|
return m_deviceAPI->getNbSourceStreams();
|
|
|
|
}
|
|
|
|
|
2019-02-24 18:13:57 -05:00
|
|
|
void FreeDVDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly)
|
|
|
|
{
|
|
|
|
(void) positiveOnly;
|
2019-12-08 04:09:24 -05:00
|
|
|
m_basebandSink->feed(begin, end);
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
|
2019-12-08 04:09:24 -05:00
|
|
|
void FreeDVDemod::start()
|
2019-06-09 13:04:32 -04:00
|
|
|
{
|
2019-12-08 04:09:24 -05:00
|
|
|
qDebug() << "FreeDVDemod::start";
|
2019-06-09 13:04:32 -04:00
|
|
|
|
2019-12-08 04:09:24 -05:00
|
|
|
if (m_basebandSampleRate != 0) {
|
|
|
|
m_basebandSink->setBasebandSampleRate(m_basebandSampleRate);
|
2019-06-09 13:04:32 -04:00
|
|
|
}
|
|
|
|
|
2019-12-08 04:09:24 -05:00
|
|
|
m_basebandSink->reset();
|
|
|
|
m_thread->start();
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVDemod::stop()
|
|
|
|
{
|
2019-12-08 04:09:24 -05:00
|
|
|
qDebug() << "FreeDVDemod::stop";
|
|
|
|
m_thread->exit();
|
|
|
|
m_thread->wait();
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool FreeDVDemod::handleMessage(const Message& cmd)
|
|
|
|
{
|
2019-12-08 04:09:24 -05:00
|
|
|
if (MsgConfigureFreeDVDemod::match(cmd))
|
2019-02-24 18:13:57 -05:00
|
|
|
{
|
|
|
|
MsgConfigureFreeDVDemod& cfg = (MsgConfigureFreeDVDemod&) cmd;
|
|
|
|
qDebug("FreeDVDemod::handleMessage: MsgConfigureFreeDVDemod");
|
|
|
|
|
|
|
|
applySettings(cfg.getSettings(), cfg.getForce());
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2019-02-27 08:53:50 -05:00
|
|
|
else if (MsgResyncFreeDVDemod::match(cmd))
|
|
|
|
{
|
|
|
|
qDebug("FreeDVDemod::handleMessage: MsgResyncFreeDVDemod");
|
2019-12-08 04:09:24 -05:00
|
|
|
FreeDVDemodBaseband::MsgResyncFreeDVDemod *msg = FreeDVDemodBaseband::MsgResyncFreeDVDemod::create();
|
|
|
|
m_basebandSink->getInputMessageQueue()->push(msg);
|
2019-02-24 18:13:57 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (DSPSignalNotification::match(cmd))
|
|
|
|
{
|
2019-12-08 04:09:24 -05:00
|
|
|
DSPSignalNotification& notif = (DSPSignalNotification&) cmd;
|
|
|
|
m_basebandSampleRate = notif.getSampleRate();
|
|
|
|
// Forward to the sink
|
|
|
|
DSPSignalNotification* rep = new DSPSignalNotification(notif); // make a copy
|
|
|
|
qDebug() << "FreeDVDemod::handleMessage: DSPSignalNotification";
|
|
|
|
m_basebandSink->getInputMessageQueue()->push(rep);
|
|
|
|
|
2019-02-24 18:13:57 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-08 04:09:24 -05:00
|
|
|
return false;
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FreeDVDemod::applySettings(const FreeDVDemodSettings& settings, bool force)
|
|
|
|
{
|
|
|
|
qDebug() << "FreeDVDemod::applySettings:"
|
|
|
|
<< " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset
|
2019-08-26 17:55:23 -04:00
|
|
|
<< " m_freeDVMode: " << (int) settings.m_freeDVMode
|
2019-02-24 18:13:57 -05:00
|
|
|
<< " m_volume: " << settings.m_volume
|
2019-02-28 11:55:03 -05:00
|
|
|
<< " m_volumeIn: " << settings.m_volumeIn
|
2019-02-24 18:13:57 -05:00
|
|
|
<< " m_spanLog2: " << settings.m_spanLog2
|
|
|
|
<< " m_audioMute: " << settings.m_audioMute
|
|
|
|
<< " m_agcActive: " << settings.m_agc
|
|
|
|
<< " m_audioDeviceName: " << settings.m_audioDeviceName
|
2019-09-22 19:25:17 -04:00
|
|
|
<< " m_streamIndex: " << settings.m_streamIndex
|
2019-04-20 13:53:16 -04:00
|
|
|
<< " m_useReverseAPI: " << settings.m_useReverseAPI
|
|
|
|
<< " m_reverseAPIAddress: " << settings.m_reverseAPIAddress
|
|
|
|
<< " m_reverseAPIPort: " << settings.m_reverseAPIPort
|
|
|
|
<< " m_reverseAPIDeviceIndex: " << settings.m_reverseAPIDeviceIndex
|
|
|
|
<< " m_reverseAPIChannelIndex: " << settings.m_reverseAPIChannelIndex
|
2019-02-24 18:13:57 -05:00
|
|
|
<< " force: " << force;
|
|
|
|
|
|
|
|
QList<QString> reverseAPIKeys;
|
|
|
|
|
|
|
|
if((m_settings.m_inputFrequencyOffset != settings.m_inputFrequencyOffset) || force) {
|
|
|
|
reverseAPIKeys.append("inputFrequencyOffset");
|
|
|
|
}
|
2019-12-08 04:09:24 -05:00
|
|
|
if ((m_settings.m_volume != settings.m_volume) || force) {
|
2019-02-24 18:13:57 -05:00
|
|
|
reverseAPIKeys.append("volume");
|
|
|
|
}
|
2019-12-08 04:09:24 -05:00
|
|
|
if ((m_settings.m_volumeIn != settings.m_volumeIn) || force) {
|
2019-02-28 11:55:03 -05:00
|
|
|
reverseAPIKeys.append("volumeIn");
|
|
|
|
}
|
2019-12-08 04:09:24 -05:00
|
|
|
if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force) {
|
2019-02-24 18:13:57 -05:00
|
|
|
reverseAPIKeys.append("audioDeviceName");
|
|
|
|
}
|
|
|
|
if ((m_settings.m_spanLog2 != settings.m_spanLog2) || force) {
|
|
|
|
reverseAPIKeys.append("spanLog2");
|
|
|
|
}
|
|
|
|
if ((m_settings.m_audioMute != settings.m_audioMute) || force) {
|
|
|
|
reverseAPIKeys.append("audioMute");
|
|
|
|
}
|
|
|
|
if ((m_settings.m_agc != settings.m_agc) || force) {
|
|
|
|
reverseAPIKeys.append("agc");
|
|
|
|
}
|
2019-09-22 19:25:17 -04: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->removeChannelSinkAPI(this);
|
2019-12-08 04:09:24 -05:00
|
|
|
m_deviceAPI->removeChannelSink(this, m_settings.m_streamIndex);
|
|
|
|
m_deviceAPI->addChannelSink(this, settings.m_streamIndex);
|
2019-12-23 17:41:35 -05:00
|
|
|
m_deviceAPI->addChannelSinkAPI(this);
|
2019-09-22 19:25:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
reverseAPIKeys.append("streamIndex");
|
|
|
|
}
|
|
|
|
|
2019-12-08 04:09:24 -05:00
|
|
|
FreeDVDemodBaseband::MsgConfigureFreeDVDemodBaseband *msg = FreeDVDemodBaseband::MsgConfigureFreeDVDemodBaseband::create(settings, force);
|
|
|
|
m_basebandSink->getInputMessageQueue()->push(msg);
|
|
|
|
|
2019-02-24 18:13:57 -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);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_settings = settings;
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray FreeDVDemod::serialize() const
|
|
|
|
{
|
|
|
|
return m_settings.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FreeDVDemod::deserialize(const QByteArray& data)
|
|
|
|
{
|
|
|
|
if (m_settings.deserialize(data))
|
|
|
|
{
|
|
|
|
MsgConfigureFreeDVDemod *msg = MsgConfigureFreeDVDemod::create(m_settings, true);
|
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
|
|
|
MsgConfigureFreeDVDemod *msg = MsgConfigureFreeDVDemod::create(m_settings, true);
|
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int FreeDVDemod::webapiSettingsGet(
|
|
|
|
SWGSDRangel::SWGChannelSettings& response,
|
|
|
|
QString& errorMessage)
|
|
|
|
{
|
|
|
|
(void) errorMessage;
|
2019-02-24 20:06:15 -05:00
|
|
|
response.setFreeDvDemodSettings(new SWGSDRangel::SWGFreeDVDemodSettings());
|
|
|
|
response.getFreeDvDemodSettings()->init();
|
2019-02-24 18:13:57 -05:00
|
|
|
webapiFormatChannelSettings(response, m_settings);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
int FreeDVDemod::webapiSettingsPutPatch(
|
|
|
|
bool force,
|
|
|
|
const QStringList& channelSettingsKeys,
|
|
|
|
SWGSDRangel::SWGChannelSettings& response,
|
|
|
|
QString& errorMessage)
|
|
|
|
{
|
|
|
|
(void) errorMessage;
|
|
|
|
FreeDVDemodSettings settings = m_settings;
|
2019-08-01 17:21:57 -04:00
|
|
|
webapiUpdateChannelSettings(settings, channelSettingsKeys, response);
|
2019-02-24 18:13:57 -05:00
|
|
|
|
2019-08-01 17:21:57 -04:00
|
|
|
MsgConfigureFreeDVDemod *msg = MsgConfigureFreeDVDemod::create(settings, force);
|
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
|
|
|
|
qDebug("FreeDVDemod::webapiSettingsPutPatch: forward to GUI: %p", m_guiMessageQueue);
|
|
|
|
if (m_guiMessageQueue) // forward to GUI if any
|
|
|
|
{
|
|
|
|
MsgConfigureFreeDVDemod *msgToGUI = MsgConfigureFreeDVDemod::create(settings, force);
|
|
|
|
m_guiMessageQueue->push(msgToGUI);
|
|
|
|
}
|
|
|
|
|
|
|
|
webapiFormatChannelSettings(response, settings);
|
|
|
|
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVDemod::webapiUpdateChannelSettings(
|
|
|
|
FreeDVDemodSettings& settings,
|
|
|
|
const QStringList& channelSettingsKeys,
|
|
|
|
SWGSDRangel::SWGChannelSettings& response)
|
|
|
|
{
|
|
|
|
if (channelSettingsKeys.contains("inputFrequencyOffset")) {
|
2019-02-24 20:06:15 -05:00
|
|
|
settings.m_inputFrequencyOffset = response.getFreeDvDemodSettings()->getInputFrequencyOffset();
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
2019-04-17 18:50:49 -04:00
|
|
|
if (channelSettingsKeys.contains("freeDVMode")) {
|
|
|
|
settings.m_freeDVMode = (FreeDVDemodSettings::FreeDVMode) response.getFreeDvDemodSettings()->getFreeDvMode();
|
|
|
|
}
|
2019-02-24 18:13:57 -05:00
|
|
|
if (channelSettingsKeys.contains("volume")) {
|
2019-02-24 20:06:15 -05:00
|
|
|
settings.m_volume = response.getFreeDvDemodSettings()->getVolume();
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
2019-02-28 11:55:03 -05:00
|
|
|
if (channelSettingsKeys.contains("volumeIn")) {
|
|
|
|
settings.m_volumeIn = response.getFreeDvDemodSettings()->getVolumeIn();
|
|
|
|
}
|
2019-02-24 18:13:57 -05:00
|
|
|
if (channelSettingsKeys.contains("spanLog2")) {
|
2019-02-24 20:06:15 -05:00
|
|
|
settings.m_spanLog2 = response.getFreeDvDemodSettings()->getSpanLog2();
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioMute")) {
|
2019-02-24 20:06:15 -05:00
|
|
|
settings.m_audioMute = response.getFreeDvDemodSettings()->getAudioMute() != 0;
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("agc")) {
|
2019-02-24 20:06:15 -05:00
|
|
|
settings.m_agc = response.getFreeDvDemodSettings()->getAgc() != 0;
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("rgbColor")) {
|
2019-02-24 20:06:15 -05:00
|
|
|
settings.m_rgbColor = response.getFreeDvDemodSettings()->getRgbColor();
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("title")) {
|
2019-02-24 20:06:15 -05:00
|
|
|
settings.m_title = *response.getFreeDvDemodSettings()->getTitle();
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioDeviceName")) {
|
2019-02-24 20:06:15 -05:00
|
|
|
settings.m_audioDeviceName = *response.getFreeDvDemodSettings()->getAudioDeviceName();
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
2019-09-22 19:25:17 -04:00
|
|
|
if (channelSettingsKeys.contains("streamIndex")) {
|
|
|
|
settings.m_streamIndex = response.getFreeDvDemodSettings()->getStreamIndex();
|
|
|
|
}
|
2019-04-20 13:53:16 -04:00
|
|
|
if (channelSettingsKeys.contains("useReverseAPI")) {
|
|
|
|
settings.m_useReverseAPI = response.getFreeDvDemodSettings()->getUseReverseApi() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIAddress")) {
|
|
|
|
settings.m_reverseAPIAddress = *response.getFreeDvDemodSettings()->getReverseApiAddress();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIPort")) {
|
|
|
|
settings.m_reverseAPIPort = response.getFreeDvDemodSettings()->getReverseApiPort();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
|
|
|
|
settings.m_reverseAPIDeviceIndex = response.getFreeDvDemodSettings()->getReverseApiDeviceIndex();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
|
|
|
|
settings.m_reverseAPIChannelIndex = response.getFreeDvDemodSettings()->getReverseApiChannelIndex();
|
|
|
|
}
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int FreeDVDemod::webapiReportGet(
|
|
|
|
SWGSDRangel::SWGChannelReport& response,
|
|
|
|
QString& errorMessage)
|
|
|
|
{
|
|
|
|
(void) errorMessage;
|
2019-02-24 20:06:15 -05:00
|
|
|
response.setFreeDvDemodReport(new SWGSDRangel::SWGFreeDVDemodReport());
|
|
|
|
response.getFreeDvDemodReport()->init();
|
2019-02-24 18:13:57 -05:00
|
|
|
webapiFormatChannelReport(response);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVDemod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const FreeDVDemodSettings& settings)
|
|
|
|
{
|
2019-02-24 20:06:15 -05:00
|
|
|
response.getFreeDvDemodSettings()->setAudioMute(settings.m_audioMute ? 1 : 0);
|
|
|
|
response.getFreeDvDemodSettings()->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
|
|
|
|
response.getFreeDvDemodSettings()->setVolume(settings.m_volume);
|
2019-02-28 11:55:03 -05:00
|
|
|
response.getFreeDvDemodSettings()->setVolumeIn(settings.m_volumeIn);
|
2019-02-24 20:06:15 -05:00
|
|
|
response.getFreeDvDemodSettings()->setSpanLog2(settings.m_spanLog2);
|
|
|
|
response.getFreeDvDemodSettings()->setAudioMute(settings.m_audioMute ? 1 : 0);
|
|
|
|
response.getFreeDvDemodSettings()->setAgc(settings.m_agc ? 1 : 0);
|
|
|
|
response.getFreeDvDemodSettings()->setRgbColor(settings.m_rgbColor);
|
2019-04-17 11:34:02 -04:00
|
|
|
response.getFreeDvDemodSettings()->setFreeDvMode((int) settings.m_freeDVMode);
|
2019-02-24 20:06:15 -05:00
|
|
|
|
|
|
|
if (response.getFreeDvDemodSettings()->getTitle()) {
|
|
|
|
*response.getFreeDvDemodSettings()->getTitle() = settings.m_title;
|
2019-02-24 18:13:57 -05:00
|
|
|
} else {
|
2019-02-24 20:06:15 -05:00
|
|
|
response.getFreeDvDemodSettings()->setTitle(new QString(settings.m_title));
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
|
2019-02-24 20:06:15 -05:00
|
|
|
if (response.getFreeDvDemodSettings()->getAudioDeviceName()) {
|
|
|
|
*response.getFreeDvDemodSettings()->getAudioDeviceName() = settings.m_audioDeviceName;
|
2019-02-24 18:13:57 -05:00
|
|
|
} else {
|
2019-02-24 20:06:15 -05:00
|
|
|
response.getFreeDvDemodSettings()->setAudioDeviceName(new QString(settings.m_audioDeviceName));
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
2019-04-20 13:53:16 -04:00
|
|
|
|
2019-09-22 19:25:17 -04:00
|
|
|
response.getFreeDvDemodSettings()->setStreamIndex(settings.m_streamIndex);
|
2019-04-20 13:53:16 -04:00
|
|
|
response.getFreeDvDemodSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
|
|
|
|
|
|
|
|
if (response.getFreeDvDemodSettings()->getReverseApiAddress()) {
|
|
|
|
*response.getFreeDvDemodSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress;
|
|
|
|
} else {
|
|
|
|
response.getFreeDvDemodSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
|
|
|
|
}
|
|
|
|
|
|
|
|
response.getFreeDvDemodSettings()->setReverseApiPort(settings.m_reverseAPIPort);
|
|
|
|
response.getFreeDvDemodSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
|
|
|
|
response.getFreeDvDemodSettings()->setReverseApiChannelIndex(settings.m_reverseAPIChannelIndex);
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVDemod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response)
|
|
|
|
{
|
|
|
|
double magsqAvg, magsqPeak;
|
|
|
|
int nbMagsqSamples;
|
|
|
|
getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples);
|
|
|
|
|
2019-02-24 20:06:15 -05:00
|
|
|
response.getFreeDvDemodReport()->setChannelPowerDb(CalcDb::dbPower(magsqAvg));
|
2019-12-08 04:09:24 -05:00
|
|
|
response.getFreeDvDemodReport()->setSquelch(getAudioActive() ? 1 : 0);
|
|
|
|
response.getFreeDvDemodReport()->setAudioSampleRate(getAudioSampleRate());
|
|
|
|
response.getFreeDvDemodReport()->setChannelSampleRate(m_basebandSink->getChannelSampleRate());
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVDemod::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const FreeDVDemodSettings& settings, bool force)
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
|
2019-05-07 08:43:38 -04:00
|
|
|
swgChannelSettings->setDirection(0); // single sink (Rx)
|
2019-03-25 08:53:48 -04:00
|
|
|
swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet());
|
|
|
|
swgChannelSettings->setOriginatorDeviceSetIndex(getDeviceSetIndex());
|
2019-08-26 18:20:15 -04:00
|
|
|
swgChannelSettings->setChannelType(new QString("FreeDVDemod"));
|
2019-02-24 20:06:15 -05:00
|
|
|
swgChannelSettings->setFreeDvDemodSettings(new SWGSDRangel::SWGFreeDVDemodSettings());
|
|
|
|
SWGSDRangel::SWGFreeDVDemodSettings *swgFreeDVDemodSettings = swgChannelSettings->getFreeDvDemodSettings();
|
2019-02-24 18:13:57 -05:00
|
|
|
|
|
|
|
// transfer data that has been modified. When force is on transfer all data except reverse API data
|
|
|
|
|
|
|
|
if (channelSettingsKeys.contains("inputFrequencyOffset") || force) {
|
2019-02-24 20:06:15 -05:00
|
|
|
swgFreeDVDemodSettings->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
2019-04-17 18:50:49 -04:00
|
|
|
if (channelSettingsKeys.contains("freeDVMode") || force) {
|
|
|
|
swgFreeDVDemodSettings->setFreeDvMode((int) settings.m_freeDVMode);
|
|
|
|
}
|
2019-02-24 18:13:57 -05:00
|
|
|
if (channelSettingsKeys.contains("volume") || force) {
|
2019-02-24 20:06:15 -05:00
|
|
|
swgFreeDVDemodSettings->setVolume(settings.m_volume);
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
2019-02-28 11:55:03 -05:00
|
|
|
if (channelSettingsKeys.contains("volumeIn") || force) {
|
|
|
|
swgFreeDVDemodSettings->setVolumeIn(settings.m_volumeIn);
|
|
|
|
}
|
2019-02-24 18:13:57 -05:00
|
|
|
if (channelSettingsKeys.contains("spanLog2") || force) {
|
2019-02-24 20:06:15 -05:00
|
|
|
swgFreeDVDemodSettings->setSpanLog2(settings.m_spanLog2);
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioMute") || force) {
|
2019-02-24 20:06:15 -05:00
|
|
|
swgFreeDVDemodSettings->setAudioMute(settings.m_audioMute ? 1 : 0);
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("agc") || force) {
|
2019-02-24 20:06:15 -05:00
|
|
|
swgFreeDVDemodSettings->setAgc(settings.m_agc ? 1 : 0);
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("rgbColor") || force) {
|
2019-02-24 20:06:15 -05:00
|
|
|
swgFreeDVDemodSettings->setRgbColor(settings.m_rgbColor);
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("title") || force) {
|
2019-02-24 20:06:15 -05:00
|
|
|
swgFreeDVDemodSettings->setTitle(new QString(settings.m_title));
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioDeviceName") || force) {
|
2019-02-24 20:06:15 -05:00
|
|
|
swgFreeDVDemodSettings->setAudioDeviceName(new QString(settings.m_audioDeviceName));
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
2019-09-22 19:25:17 -04:00
|
|
|
if (channelSettingsKeys.contains("streamIndex") || force) {
|
|
|
|
swgFreeDVDemodSettings->setStreamIndex(settings.m_streamIndex);
|
|
|
|
}
|
2019-02-24 18:13:57 -05:00
|
|
|
|
|
|
|
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");
|
|
|
|
|
2019-11-12 12:46:21 -05:00
|
|
|
QBuffer *buffer = new QBuffer();
|
2019-02-24 18:13:57 -05:00
|
|
|
buffer->open((QBuffer::ReadWrite));
|
|
|
|
buffer->write(swgChannelSettings->asJson().toUtf8());
|
|
|
|
buffer->seek(0);
|
|
|
|
|
|
|
|
// Always use PATCH to avoid passing reverse API settings
|
2019-11-12 12:46:21 -05:00
|
|
|
QNetworkReply *reply = m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
|
|
|
|
buffer->setParent(reply);
|
2019-02-24 18:13:57 -05:00
|
|
|
|
|
|
|
delete swgChannelSettings;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVDemod::networkManagerFinished(QNetworkReply *reply)
|
|
|
|
{
|
|
|
|
QNetworkReply::NetworkError replyError = reply->error();
|
|
|
|
|
|
|
|
if (replyError)
|
|
|
|
{
|
|
|
|
qWarning() << "FreeDVDemod::networkManagerFinished:"
|
|
|
|
<< " error(" << (int) replyError
|
|
|
|
<< "): " << replyError
|
|
|
|
<< ": " << reply->errorString();
|
2019-11-12 12:46:21 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QString answer = reply->readAll();
|
|
|
|
answer.chop(1); // remove last \n
|
|
|
|
qDebug("FreeDVDemod::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
|
2019-11-12 12:46:21 -05:00
|
|
|
reply->deleteLater();
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
2019-08-27 18:57:33 -04:00
|
|
|
|
2019-12-08 04:09:24 -05:00
|
|
|
void FreeDVDemod::setLevelMeter(QObject *levelMeter)
|
2019-08-27 18:57:33 -04:00
|
|
|
{
|
2019-12-08 04:09:24 -05:00
|
|
|
connect(m_basebandSink, SIGNAL(levelChanged(qreal, qreal, int)), levelMeter, SLOT(levelChanged(qreal, qreal, int)));
|
2019-08-27 18:57:33 -04:00
|
|
|
}
|