2015-12-06 13:47:55 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
2023-11-18 06:02:48 -05:00
|
|
|
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
|
|
|
|
// written by Christian Daniel //
|
|
|
|
// Copyright (C) 2014-2015 John Greb <hexameron@spam.no> //
|
|
|
|
// Copyright (C) 2015-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
|
|
|
|
// Copyright (C) 2020 Kacper Michajłow <kasper93@gmail.com> //
|
2015-11-18 21:27:37 -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. //
|
2015-11-18 21:27:37 -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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2015-12-01 20:28:31 -05:00
|
|
|
#include <QUdpSocket>
|
2015-12-02 22:02:21 -05:00
|
|
|
#include <QHostAddress>
|
2018-12-24 04:27:35 -05:00
|
|
|
#include <QNetworkAccessManager>
|
|
|
|
#include <QNetworkReply>
|
|
|
|
#include <QBuffer>
|
2019-12-08 04:09:24 -05:00
|
|
|
#include <QThread>
|
2017-08-17 18:10:15 -04:00
|
|
|
|
2018-05-25 04:45:40 -04:00
|
|
|
#include "SWGChannelSettings.h"
|
2022-05-13 16:24:48 -04:00
|
|
|
#include "SWGWorkspaceInfo.h"
|
2018-09-11 18:36:30 -04:00
|
|
|
#include "SWGUDPSinkSettings.h"
|
2018-05-25 04:45:40 -04:00
|
|
|
#include "SWGChannelReport.h"
|
2018-09-11 18:36:30 -04:00
|
|
|
#include "SWGUDPSinkReport.h"
|
2018-05-25 04:45:40 -04:00
|
|
|
|
2017-08-17 18:10:15 -04:00
|
|
|
#include "util/db.h"
|
2018-02-14 14:11:36 -05:00
|
|
|
#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"
|
2020-10-22 18:11:18 -04:00
|
|
|
#include "maincore.h"
|
2016-10-02 07:18:07 -04:00
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
#include "udpsink.h"
|
2015-11-18 21:27:37 -05:00
|
|
|
|
2019-12-08 04:09:24 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(UDPSink::MsgConfigureUDPSink, Message)
|
2015-11-18 21:27:37 -05:00
|
|
|
|
2020-11-21 14:24:18 -05:00
|
|
|
const char* const UDPSink::m_channelIdURI = "sdrangel.channel.udpsink";
|
|
|
|
const char* const UDPSink::m_channelId = "UDPSink";
|
2017-11-08 08:23:49 -05:00
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
UDPSink::UDPSink(DeviceAPI *deviceAPI) :
|
2019-05-09 11:27:12 -04:00
|
|
|
ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSink),
|
2017-12-20 17:57:06 -05:00
|
|
|
m_deviceAPI(deviceAPI),
|
2020-04-30 03:57:05 -04:00
|
|
|
m_spectrumVis(SDR_RX_SCALEF),
|
2019-12-08 04:09:24 -05:00
|
|
|
m_channelSampleRate(48000),
|
|
|
|
m_channelFrequencyOffset(0)
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2017-11-22 19:19:32 -05:00
|
|
|
setObjectName(m_channelId);
|
2015-11-18 21:27:37 -05:00
|
|
|
|
2019-12-08 04:09:24 -05:00
|
|
|
m_thread = new QThread(this);
|
|
|
|
m_basebandSink = new UDPSinkBaseband();
|
2020-04-30 03:57:05 -04:00
|
|
|
m_basebandSink->setSpectrum(&m_spectrumVis);
|
2019-12-08 04:09:24 -05:00
|
|
|
m_basebandSink->moveToThread(m_thread);
|
2017-11-05 19:39:44 -05:00
|
|
|
|
2019-12-08 04:09:24 -05:00
|
|
|
applySettings(m_settings, true);
|
2018-03-16 05:24:19 -04: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);
|
2018-12-24 04:27:35 -05:00
|
|
|
|
|
|
|
m_networkManager = new QNetworkAccessManager();
|
2022-03-23 17:32:23 -04:00
|
|
|
QObject::connect(
|
|
|
|
m_networkManager,
|
|
|
|
&QNetworkAccessManager::finished,
|
|
|
|
this,
|
|
|
|
&UDPSink::networkManagerFinished
|
|
|
|
);
|
2022-03-18 12:08:04 -04:00
|
|
|
QObject::connect(
|
|
|
|
this,
|
|
|
|
&ChannelAPI::indexInDeviceSetChanged,
|
|
|
|
this,
|
|
|
|
&UDPSink::handleIndexInDeviceSetChanged
|
|
|
|
);
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
UDPSink::~UDPSink()
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2022-03-23 17:32:23 -04:00
|
|
|
QObject::disconnect(
|
|
|
|
m_networkManager,
|
|
|
|
&QNetworkAccessManager::finished,
|
|
|
|
this,
|
|
|
|
&UDPSink::networkManagerFinished
|
|
|
|
);
|
2018-12-24 04:27:35 -05:00
|
|
|
delete m_networkManager;
|
2019-12-08 04:09:24 -05:00
|
|
|
m_deviceAPI->removeChannelSinkAPI(this);
|
|
|
|
m_deviceAPI->removeChannelSink(this);
|
|
|
|
delete m_basebandSink;
|
|
|
|
delete m_thread;
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2022-04-16 10:45:53 -04:00
|
|
|
void UDPSink::setDeviceAPI(DeviceAPI *deviceAPI)
|
|
|
|
{
|
|
|
|
if (deviceAPI != m_deviceAPI)
|
|
|
|
{
|
|
|
|
m_deviceAPI->removeChannelSinkAPI(this);
|
|
|
|
m_deviceAPI->removeChannelSink(this);
|
|
|
|
m_deviceAPI = deviceAPI;
|
|
|
|
m_deviceAPI->addChannelSink(this);
|
|
|
|
m_deviceAPI->addChannelSinkAPI(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-22 19:25:17 -04:00
|
|
|
uint32_t UDPSink::getNumberOfDeviceStreams() const
|
|
|
|
{
|
|
|
|
return m_deviceAPI->getNbSourceStreams();
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSink::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly)
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2019-12-08 04:09:24 -05:00
|
|
|
(void) positiveOnly;
|
|
|
|
m_basebandSink->feed(begin, end);
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSink::start()
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2019-12-08 04:09:24 -05:00
|
|
|
qDebug() << "UDPSink::start";
|
|
|
|
|
|
|
|
if (m_basebandSampleRate != 0) {
|
|
|
|
m_basebandSink->setBasebandSampleRate(m_basebandSampleRate);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_basebandSink->reset();
|
|
|
|
m_thread->start();
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSink::stop()
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2019-12-08 04:09:24 -05:00
|
|
|
qDebug() << "UDPSink::stop";
|
|
|
|
m_thread->exit();
|
|
|
|
m_thread->wait();
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
bool UDPSink::handleMessage(const Message& cmd)
|
2015-11-18 21:27:37 -05:00
|
|
|
{
|
2019-12-08 04:09:24 -05:00
|
|
|
if (MsgConfigureUDPSink::match(cmd))
|
2017-10-06 23:44:43 -04:00
|
|
|
{
|
2019-12-08 04:09:24 -05:00
|
|
|
MsgConfigureUDPSink& cfg = (MsgConfigureUDPSink&) cmd;
|
|
|
|
qDebug("UDPSink::handleMessage: MsgConfigureUDPSink");
|
2017-10-06 23:44:43 -04:00
|
|
|
|
2017-12-29 05:04:47 -05:00
|
|
|
applySettings(cfg.getSettings(), cfg.getForce());
|
2017-10-06 23:44:43 -04:00
|
|
|
|
2017-10-04 16:41:58 -04:00
|
|
|
return true;
|
|
|
|
}
|
2018-02-14 14:11:36 -05:00
|
|
|
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() << "UDPSink::handleMessage: DSPSignalNotification";
|
|
|
|
m_basebandSink->getInputMessageQueue()->push(rep);
|
2022-04-13 05:08:21 -04:00
|
|
|
// Forward to GUI if any
|
|
|
|
if (getMessageQueueToGUI()) {
|
|
|
|
getMessageQueueToGUI()->push(new DSPSignalNotification(notif));
|
|
|
|
}
|
2019-12-08 04:09:24 -05:00
|
|
|
|
2018-02-14 14:11:36 -05:00
|
|
|
return true;
|
|
|
|
}
|
2015-11-18 21:27:37 -05:00
|
|
|
else
|
|
|
|
{
|
2019-12-08 04:09:24 -05:00
|
|
|
return false;
|
2015-11-18 21:27:37 -05:00
|
|
|
}
|
|
|
|
}
|
2015-12-02 22:02:21 -05:00
|
|
|
|
2022-01-06 16:47:41 -05:00
|
|
|
void UDPSink::setCenterFrequency(qint64 frequency)
|
|
|
|
{
|
|
|
|
UDPSinkSettings settings = m_settings;
|
|
|
|
settings.m_inputFrequencyOffset = frequency;
|
|
|
|
applySettings(settings, false);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue) // forward to GUI if any
|
|
|
|
{
|
|
|
|
MsgConfigureUDPSink *msgToGUI = MsgConfigureUDPSink::create(settings, false);
|
|
|
|
m_guiMessageQueue->push(msgToGUI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSink::applySettings(const UDPSinkSettings& settings, bool force)
|
2017-08-18 18:12:56 -04:00
|
|
|
{
|
2018-09-11 18:36:30 -04:00
|
|
|
qDebug() << "UDPSink::applySettings:"
|
2017-12-29 05:04:47 -05:00
|
|
|
<< " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset
|
|
|
|
<< " m_audioActive: " << settings.m_audioActive
|
|
|
|
<< " m_audioStereo: " << settings.m_audioStereo
|
|
|
|
<< " m_gain: " << settings.m_gain
|
|
|
|
<< " m_volume: " << settings.m_volume
|
|
|
|
<< " m_squelchEnabled: " << settings.m_squelchEnabled
|
|
|
|
<< " m_squelchdB: " << settings.m_squelchdB
|
|
|
|
<< " m_squelchGate" << settings.m_squelchGate
|
|
|
|
<< " m_agc" << settings.m_agc
|
|
|
|
<< " m_sampleFormat: " << settings.m_sampleFormat
|
|
|
|
<< " m_outputSampleRate: " << settings.m_outputSampleRate
|
|
|
|
<< " m_rfBandwidth: " << settings.m_rfBandwidth
|
|
|
|
<< " m_fmDeviation: " << settings.m_fmDeviation
|
|
|
|
<< " m_udpAddressStr: " << settings.m_udpAddress
|
|
|
|
<< " m_udpPort: " << settings.m_udpPort
|
|
|
|
<< " m_audioPort: " << settings.m_audioPort
|
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
|
2017-12-29 05:04:47 -05:00
|
|
|
<< " force: " << force;
|
|
|
|
|
2018-12-24 04:27:35 -05:00
|
|
|
QList<QString> reverseAPIKeys;
|
|
|
|
|
|
|
|
if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force) {
|
|
|
|
reverseAPIKeys.append("inputFrequencyOffset");
|
|
|
|
}
|
|
|
|
if ((settings.m_audioActive != m_settings.m_audioActive) || force) {
|
|
|
|
reverseAPIKeys.append("audioActive");
|
|
|
|
}
|
|
|
|
if ((settings.m_audioStereo != m_settings.m_audioStereo) || force) {
|
|
|
|
reverseAPIKeys.append("audioStereo");
|
|
|
|
}
|
|
|
|
if ((settings.m_gain != m_settings.m_gain) || force) {
|
|
|
|
reverseAPIKeys.append("gain");
|
|
|
|
}
|
|
|
|
if ((settings.m_volume != m_settings.m_volume) || force) {
|
|
|
|
reverseAPIKeys.append("volume");
|
|
|
|
}
|
|
|
|
if ((settings.m_squelchEnabled != m_settings.m_squelchEnabled) || force) {
|
|
|
|
reverseAPIKeys.append("squelchEnabled");
|
|
|
|
}
|
|
|
|
if ((settings.m_squelchdB != m_settings.m_squelchdB) || force) {
|
|
|
|
reverseAPIKeys.append("squelchDB");
|
|
|
|
}
|
|
|
|
if ((settings.m_squelchGate != m_settings.m_squelchGate) || force) {
|
|
|
|
reverseAPIKeys.append("squelchGate");
|
|
|
|
}
|
|
|
|
if ((settings.m_agc != m_settings.m_agc) || force) {
|
|
|
|
reverseAPIKeys.append("agc");
|
|
|
|
}
|
|
|
|
if ((settings.m_sampleFormat != m_settings.m_sampleFormat) || force) {
|
|
|
|
reverseAPIKeys.append("sampleFormat");
|
|
|
|
}
|
|
|
|
if ((settings.m_outputSampleRate != m_settings.m_outputSampleRate) || force) {
|
|
|
|
reverseAPIKeys.append("outputSampleRate");
|
|
|
|
}
|
|
|
|
if ((settings.m_rfBandwidth != m_settings.m_rfBandwidth) || force) {
|
|
|
|
reverseAPIKeys.append("rfBandwidth");
|
|
|
|
}
|
|
|
|
if ((settings.m_fmDeviation != m_settings.m_fmDeviation) || force) {
|
|
|
|
reverseAPIKeys.append("fmDeviation");
|
|
|
|
}
|
|
|
|
if ((settings.m_udpAddress != m_settings.m_udpAddress) || force) {
|
|
|
|
reverseAPIKeys.append("udpAddress");
|
|
|
|
}
|
|
|
|
if ((settings.m_udpPort != m_settings.m_udpPort) || force) {
|
|
|
|
reverseAPIKeys.append("udpPort");
|
|
|
|
}
|
|
|
|
if ((settings.m_audioPort != m_settings.m_audioPort) || force) {
|
|
|
|
reverseAPIKeys.append("audioPort");
|
|
|
|
}
|
|
|
|
|
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);
|
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-09-22 19:25:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
reverseAPIKeys.append("streamIndex");
|
|
|
|
}
|
|
|
|
|
2019-12-08 04:09:24 -05:00
|
|
|
UDPSinkBaseband::MsgConfigureUDPSinkBaseband *msg = UDPSinkBaseband::MsgConfigureUDPSinkBaseband::create(settings, force);
|
|
|
|
m_basebandSink->getInputMessageQueue()->push(msg);
|
|
|
|
|
2018-12-24 04:27:35 -05:00
|
|
|
if (settings.m_useReverseAPI)
|
|
|
|
{
|
|
|
|
bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
|
|
|
|
(m_settings.m_reverseAPIAddress != settings.m_reverseAPIAddress) ||
|
|
|
|
(m_settings.m_reverseAPIPort != settings.m_reverseAPIPort) ||
|
|
|
|
(m_settings.m_reverseAPIDeviceIndex != settings.m_reverseAPIDeviceIndex) ||
|
|
|
|
(m_settings.m_reverseAPIChannelIndex != settings.m_reverseAPIChannelIndex);
|
|
|
|
webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
|
|
|
|
}
|
|
|
|
|
2022-03-02 17:07:15 -05:00
|
|
|
QList<ObjectPipe*> pipes;
|
2022-03-02 17:57:35 -05:00
|
|
|
MainCore::instance()->getMessagePipes().getMessagePipes(this, "settings", pipes);
|
2020-12-13 07:04:36 -05:00
|
|
|
|
2022-03-02 17:07:15 -05:00
|
|
|
if (pipes.size() > 0) {
|
|
|
|
sendChannelSettings(pipes, reverseAPIKeys, settings, force);
|
2020-10-22 18:11:18 -04:00
|
|
|
}
|
|
|
|
|
2017-10-07 00:30:30 -04:00
|
|
|
m_settings = settings;
|
2015-12-02 22:02:21 -05:00
|
|
|
}
|
2017-12-17 17:15:42 -05:00
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
QByteArray UDPSink::serialize() const
|
2017-12-17 17:15:42 -05:00
|
|
|
{
|
|
|
|
return m_settings.serialize();
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
bool UDPSink::deserialize(const QByteArray& data)
|
2017-12-17 17:15:42 -05:00
|
|
|
{
|
|
|
|
if (m_settings.deserialize(data))
|
|
|
|
{
|
2019-12-08 04:09:24 -05:00
|
|
|
MsgConfigureUDPSink *msg = MsgConfigureUDPSink::create(m_settings, true);
|
2017-12-17 17:15:42 -05:00
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
2019-12-08 04:09:24 -05:00
|
|
|
MsgConfigureUDPSink *msg = MsgConfigureUDPSink::create(m_settings, true);
|
2017-12-17 17:15:42 -05:00
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2018-05-25 04:45:40 -04:00
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
int UDPSink::webapiSettingsGet(
|
2018-05-25 12:44:24 -04:00
|
|
|
SWGSDRangel::SWGChannelSettings& response,
|
2018-11-12 18:45:03 -05:00
|
|
|
QString& errorMessage)
|
2018-05-25 12:44:24 -04:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) errorMessage;
|
2018-09-11 18:36:30 -04:00
|
|
|
response.setUdpSinkSettings(new SWGSDRangel::SWGUDPSinkSettings());
|
|
|
|
response.getUdpSinkSettings()->init();
|
2018-05-25 12:44:24 -04:00
|
|
|
webapiFormatChannelSettings(response, m_settings);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
2022-05-13 16:24:48 -04:00
|
|
|
int UDPSink::webapiWorkspaceGet(
|
|
|
|
SWGSDRangel::SWGWorkspaceInfo& response,
|
|
|
|
QString& errorMessage)
|
|
|
|
{
|
|
|
|
(void) errorMessage;
|
|
|
|
response.setIndex(m_settings.m_workspaceIndex);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
int UDPSink::webapiSettingsPutPatch(
|
2018-05-25 12:44:24 -04:00
|
|
|
bool force,
|
|
|
|
const QStringList& channelSettingsKeys,
|
|
|
|
SWGSDRangel::SWGChannelSettings& response,
|
2018-11-12 18:45:03 -05:00
|
|
|
QString& errorMessage)
|
2018-05-25 12:44:24 -04:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) errorMessage;
|
2018-09-11 18:08:47 -04:00
|
|
|
UDPSinkSettings settings = m_settings;
|
2019-08-01 17:21:57 -04:00
|
|
|
webapiUpdateChannelSettings(settings, channelSettingsKeys, response);
|
2018-05-25 12:44:24 -04:00
|
|
|
|
2019-12-08 04:09:24 -05:00
|
|
|
MsgConfigureUDPSink *msg = MsgConfigureUDPSink::create(settings, force);
|
2019-08-01 17:21:57 -04:00
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
|
|
|
|
qDebug("getUdpSinkSettings::webapiSettingsPutPatch: forward to GUI: %p", m_guiMessageQueue);
|
|
|
|
if (m_guiMessageQueue) // forward to GUI if any
|
|
|
|
{
|
2019-12-08 04:09:24 -05:00
|
|
|
MsgConfigureUDPSink *msgToGUI = MsgConfigureUDPSink::create(settings, force);
|
2019-08-01 17:21:57 -04:00
|
|
|
m_guiMessageQueue->push(msgToGUI);
|
|
|
|
}
|
|
|
|
|
|
|
|
webapiFormatChannelSettings(response, settings);
|
|
|
|
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSink::webapiUpdateChannelSettings(
|
|
|
|
UDPSinkSettings& settings,
|
|
|
|
const QStringList& channelSettingsKeys,
|
|
|
|
SWGSDRangel::SWGChannelSettings& response)
|
|
|
|
{
|
2018-05-25 12:44:24 -04:00
|
|
|
if (channelSettingsKeys.contains("outputSampleRate")) {
|
2018-09-11 18:36:30 -04:00
|
|
|
settings.m_outputSampleRate = response.getUdpSinkSettings()->getOutputSampleRate();
|
2018-05-25 12:44:24 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("sampleFormat")) {
|
2018-09-11 18:36:30 -04:00
|
|
|
settings.m_sampleFormat = (UDPSinkSettings::SampleFormat) response.getUdpSinkSettings()->getSampleFormat();
|
2018-05-25 12:44:24 -04:00
|
|
|
}
|
2019-08-01 17:21:57 -04:00
|
|
|
if (channelSettingsKeys.contains("inputFrequencyOffset")) {
|
2018-09-11 18:36:30 -04:00
|
|
|
settings.m_inputFrequencyOffset = response.getUdpSinkSettings()->getInputFrequencyOffset();
|
2018-05-25 12:44:24 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("rfBandwidth")) {
|
2018-09-11 18:36:30 -04:00
|
|
|
settings.m_rfBandwidth = response.getUdpSinkSettings()->getRfBandwidth();
|
2018-05-25 12:44:24 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("fmDeviation")) {
|
2018-09-11 18:36:30 -04:00
|
|
|
settings.m_fmDeviation = response.getUdpSinkSettings()->getFmDeviation();
|
2018-05-25 12:44:24 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("channelMute")) {
|
2018-09-11 18:36:30 -04:00
|
|
|
settings.m_channelMute = response.getUdpSinkSettings()->getChannelMute() != 0;
|
2018-05-25 12:44:24 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("gain")) {
|
2018-09-11 18:36:30 -04:00
|
|
|
settings.m_gain = response.getUdpSinkSettings()->getGain();
|
2018-05-25 12:44:24 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("squelchDB")) {
|
2018-09-11 18:36:30 -04:00
|
|
|
settings.m_squelchdB = response.getUdpSinkSettings()->getSquelchDb();
|
2018-05-25 12:44:24 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("squelchGate")) {
|
2018-09-11 18:36:30 -04:00
|
|
|
settings.m_squelchGate = response.getUdpSinkSettings()->getSquelchGate();
|
2018-05-25 12:44:24 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("squelchEnabled")) {
|
2018-09-11 18:36:30 -04:00
|
|
|
settings.m_squelchEnabled = response.getUdpSinkSettings()->getSquelchEnabled() != 0;
|
2018-05-25 12:44:24 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("agc")) {
|
2018-09-11 18:36:30 -04:00
|
|
|
settings.m_agc = response.getUdpSinkSettings()->getAgc() != 0;
|
2018-05-25 12:44:24 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioActive")) {
|
2018-09-11 18:36:30 -04:00
|
|
|
settings.m_audioActive = response.getUdpSinkSettings()->getAudioActive() != 0;
|
2018-05-25 12:44:24 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioStereo")) {
|
2018-09-11 18:36:30 -04:00
|
|
|
settings.m_audioStereo = response.getUdpSinkSettings()->getAudioStereo() != 0;
|
2018-05-25 12:44:24 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("volume")) {
|
2018-09-11 18:36:30 -04:00
|
|
|
settings.m_volume = response.getUdpSinkSettings()->getVolume();
|
2018-05-25 12:44:24 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("udpAddress")) {
|
2018-09-11 18:36:30 -04:00
|
|
|
settings.m_udpAddress = *response.getUdpSinkSettings()->getUdpAddress();
|
2018-05-25 12:44:24 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("udpPort")) {
|
2018-09-11 18:36:30 -04:00
|
|
|
settings.m_udpPort = response.getUdpSinkSettings()->getUdpPort();
|
2018-05-25 12:44:24 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioPort")) {
|
2018-09-11 18:36:30 -04:00
|
|
|
settings.m_audioPort = response.getUdpSinkSettings()->getAudioPort();
|
2018-05-25 12:44:24 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("rgbColor")) {
|
2018-09-11 18:36:30 -04:00
|
|
|
settings.m_rgbColor = response.getUdpSinkSettings()->getRgbColor();
|
2018-05-25 12:44:24 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("title")) {
|
2018-09-11 18:36:30 -04:00
|
|
|
settings.m_title = *response.getUdpSinkSettings()->getTitle();
|
2018-05-25 12:44:24 -04:00
|
|
|
}
|
2019-09-22 19:25:17 -04:00
|
|
|
if (channelSettingsKeys.contains("streamIndex")) {
|
|
|
|
settings.m_streamIndex = response.getUdpSinkSettings()->getStreamIndex();
|
|
|
|
}
|
2019-04-20 13:53:16 -04:00
|
|
|
if (channelSettingsKeys.contains("useReverseAPI")) {
|
|
|
|
settings.m_useReverseAPI = response.getUdpSinkSettings()->getUseReverseApi() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIAddress")) {
|
|
|
|
settings.m_reverseAPIAddress = *response.getUdpSinkSettings()->getReverseApiAddress();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIPort")) {
|
|
|
|
settings.m_reverseAPIPort = response.getUdpSinkSettings()->getReverseApiPort();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
|
|
|
|
settings.m_reverseAPIDeviceIndex = response.getUdpSinkSettings()->getReverseApiDeviceIndex();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
|
|
|
|
settings.m_reverseAPIChannelIndex = response.getUdpSinkSettings()->getReverseApiChannelIndex();
|
|
|
|
}
|
2021-11-30 18:20:14 -05:00
|
|
|
if (settings.m_spectrumGUI && channelSettingsKeys.contains("spectrumConfig")) {
|
|
|
|
settings.m_spectrumGUI->updateFrom(channelSettingsKeys, response.getUdpSinkSettings()->getSpectrumConfig());
|
|
|
|
}
|
2021-12-02 17:54:39 -05:00
|
|
|
if (settings.m_channelMarker && channelSettingsKeys.contains("channelMarker")) {
|
|
|
|
settings.m_channelMarker->updateFrom(channelSettingsKeys, response.getUdpSinkSettings()->getChannelMarker());
|
|
|
|
}
|
2022-01-08 23:27:12 -05:00
|
|
|
if (settings.m_rollupState && channelSettingsKeys.contains("rollupState")) {
|
|
|
|
settings.m_rollupState->updateFrom(channelSettingsKeys, response.getUdpSinkSettings()->getRollupState());
|
|
|
|
}
|
2018-05-25 12:44:24 -04:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
int UDPSink::webapiReportGet(
|
2018-05-25 12:44:24 -04:00
|
|
|
SWGSDRangel::SWGChannelReport& response,
|
2018-11-12 18:45:03 -05:00
|
|
|
QString& errorMessage)
|
2018-05-25 12:44:24 -04:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) errorMessage;
|
2018-09-11 18:36:30 -04:00
|
|
|
response.setUdpSinkReport(new SWGSDRangel::SWGUDPSinkReport());
|
|
|
|
response.getUdpSinkReport()->init();
|
2018-05-25 12:44:24 -04:00
|
|
|
webapiFormatChannelReport(response);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSink::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const UDPSinkSettings& settings)
|
2018-05-25 04:45:40 -04:00
|
|
|
{
|
2018-09-11 18:36:30 -04:00
|
|
|
response.getUdpSinkSettings()->setOutputSampleRate(settings.m_outputSampleRate);
|
|
|
|
response.getUdpSinkSettings()->setSampleFormat((int) settings.m_sampleFormat);
|
|
|
|
response.getUdpSinkSettings()->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
|
|
|
|
response.getUdpSinkSettings()->setRfBandwidth(settings.m_rfBandwidth);
|
|
|
|
response.getUdpSinkSettings()->setFmDeviation(settings.m_fmDeviation);
|
|
|
|
response.getUdpSinkSettings()->setChannelMute(settings.m_channelMute ? 1 : 0);
|
|
|
|
response.getUdpSinkSettings()->setGain(settings.m_gain);
|
|
|
|
response.getUdpSinkSettings()->setSquelchDb(settings.m_squelchdB);
|
|
|
|
response.getUdpSinkSettings()->setSquelchGate(settings.m_squelchGate);
|
|
|
|
response.getUdpSinkSettings()->setSquelchEnabled(settings.m_squelchEnabled ? 1 : 0);
|
|
|
|
response.getUdpSinkSettings()->setAgc(settings.m_agc ? 1 : 0);
|
|
|
|
response.getUdpSinkSettings()->setAudioActive(settings.m_audioActive ? 1 : 0);
|
|
|
|
response.getUdpSinkSettings()->setAudioStereo(settings.m_audioStereo ? 1 : 0);
|
|
|
|
response.getUdpSinkSettings()->setVolume(settings.m_volume);
|
|
|
|
|
|
|
|
if (response.getUdpSinkSettings()->getUdpAddress()) {
|
|
|
|
*response.getUdpSinkSettings()->getUdpAddress() = settings.m_udpAddress;
|
2018-05-25 04:45:40 -04:00
|
|
|
} else {
|
2018-09-11 18:36:30 -04:00
|
|
|
response.getUdpSinkSettings()->setUdpAddress(new QString(settings.m_udpAddress));
|
2018-05-25 04:45:40 -04:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:36:30 -04:00
|
|
|
response.getUdpSinkSettings()->setUdpPort(settings.m_udpPort);
|
|
|
|
response.getUdpSinkSettings()->setAudioPort(settings.m_audioPort);
|
|
|
|
response.getUdpSinkSettings()->setRgbColor(settings.m_rgbColor);
|
2018-05-25 04:45:40 -04:00
|
|
|
|
2018-09-11 18:36:30 -04:00
|
|
|
if (response.getUdpSinkSettings()->getTitle()) {
|
|
|
|
*response.getUdpSinkSettings()->getTitle() = settings.m_title;
|
2018-05-25 04:45:40 -04:00
|
|
|
} else {
|
2018-09-11 18:36:30 -04:00
|
|
|
response.getUdpSinkSettings()->setTitle(new QString(settings.m_title));
|
2018-05-25 04:45:40 -04:00
|
|
|
}
|
2019-04-20 13:53:16 -04:00
|
|
|
|
2019-09-22 19:25:17 -04:00
|
|
|
response.getUdpSinkSettings()->setStreamIndex(settings.m_streamIndex);
|
2019-04-20 13:53:16 -04:00
|
|
|
response.getUdpSinkSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
|
|
|
|
|
|
|
|
if (response.getUdpSinkSettings()->getReverseApiAddress()) {
|
|
|
|
*response.getUdpSinkSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress;
|
|
|
|
} else {
|
|
|
|
response.getUdpSinkSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
|
|
|
|
}
|
|
|
|
|
|
|
|
response.getUdpSinkSettings()->setReverseApiPort(settings.m_reverseAPIPort);
|
|
|
|
response.getUdpSinkSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
|
|
|
|
response.getUdpSinkSettings()->setReverseApiChannelIndex(settings.m_reverseAPIChannelIndex);
|
2021-11-30 18:20:14 -05:00
|
|
|
|
|
|
|
if (settings.m_spectrumGUI)
|
|
|
|
{
|
|
|
|
if (response.getUdpSinkSettings()->getSpectrumConfig())
|
|
|
|
{
|
|
|
|
settings.m_spectrumGUI->formatTo(response.getUdpSinkSettings()->getSpectrumConfig());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGGLSpectrum *swgGLSpectrum = new SWGSDRangel::SWGGLSpectrum();
|
|
|
|
settings.m_spectrumGUI->formatTo(swgGLSpectrum);
|
|
|
|
response.getUdpSinkSettings()->setSpectrumConfig(swgGLSpectrum);
|
|
|
|
}
|
|
|
|
}
|
2021-12-02 17:54:39 -05:00
|
|
|
|
|
|
|
if (settings.m_channelMarker)
|
|
|
|
{
|
|
|
|
if (response.getUdpSinkSettings()->getChannelMarker())
|
|
|
|
{
|
|
|
|
settings.m_channelMarker->formatTo(response.getUdpSinkSettings()->getChannelMarker());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGChannelMarker *swgChannelMarker = new SWGSDRangel::SWGChannelMarker();
|
|
|
|
settings.m_channelMarker->formatTo(swgChannelMarker);
|
|
|
|
response.getUdpSinkSettings()->setChannelMarker(swgChannelMarker);
|
|
|
|
}
|
|
|
|
}
|
2022-01-08 23:27:12 -05:00
|
|
|
|
|
|
|
if (settings.m_rollupState)
|
|
|
|
{
|
|
|
|
if (response.getUdpSinkSettings()->getRollupState())
|
|
|
|
{
|
|
|
|
settings.m_rollupState->formatTo(response.getUdpSinkSettings()->getRollupState());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGRollupState *swgRollupState = new SWGSDRangel::SWGRollupState();
|
|
|
|
settings.m_rollupState->formatTo(swgRollupState);
|
|
|
|
response.getUdpSinkSettings()->setRollupState(swgRollupState);
|
|
|
|
}
|
|
|
|
}
|
2018-05-25 04:45:40 -04:00
|
|
|
}
|
|
|
|
|
2018-09-11 18:08:47 -04:00
|
|
|
void UDPSink::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response)
|
2018-05-25 04:45:40 -04:00
|
|
|
{
|
2018-09-11 18:36:30 -04:00
|
|
|
response.getUdpSinkReport()->setChannelPowerDb(CalcDb::dbPower(getInMagSq()));
|
|
|
|
response.getUdpSinkReport()->setOutputPowerDb(CalcDb::dbPower(getMagSq()));
|
2019-12-08 04:09:24 -05:00
|
|
|
response.getUdpSinkReport()->setSquelch(getSquelchOpen() ? 1 : 0);
|
|
|
|
response.getUdpSinkReport()->setInputSampleRate(m_channelSampleRate);
|
2018-05-25 04:45:40 -04:00
|
|
|
}
|
2018-12-24 04:27:35 -05:00
|
|
|
|
|
|
|
void UDPSink::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const UDPSinkSettings& 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;
|
|
|
|
}
|
|
|
|
|
2020-12-13 07:04:36 -05:00
|
|
|
void UDPSink::sendChannelSettings(
|
2022-03-02 17:07:15 -05:00
|
|
|
const QList<ObjectPipe*>& pipes,
|
2020-12-13 07:04:36 -05:00
|
|
|
QList<QString>& channelSettingsKeys,
|
|
|
|
const UDPSinkSettings& settings,
|
|
|
|
bool force)
|
2020-10-22 18:11:18 -04:00
|
|
|
{
|
2022-03-02 17:07:15 -05:00
|
|
|
for (const auto& pipe : pipes)
|
2020-10-22 18:11:18 -04:00
|
|
|
{
|
2022-03-02 17:07:15 -05:00
|
|
|
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
|
|
|
|
|
|
|
|
if (messageQueue)
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
|
|
|
|
webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force);
|
|
|
|
MainCore::MsgChannelSettings *msg = MainCore::MsgChannelSettings::create(
|
|
|
|
this,
|
|
|
|
channelSettingsKeys,
|
|
|
|
swgChannelSettings,
|
|
|
|
force
|
|
|
|
);
|
|
|
|
messageQueue->push(msg);
|
|
|
|
}
|
2020-10-22 18:11:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSink::webapiFormatChannelSettings(
|
|
|
|
QList<QString>& channelSettingsKeys,
|
|
|
|
SWGSDRangel::SWGChannelSettings *swgChannelSettings,
|
|
|
|
const UDPSinkSettings& settings,
|
|
|
|
bool force
|
|
|
|
)
|
|
|
|
{
|
|
|
|
swgChannelSettings->setDirection(0); // Single sink (Rx)
|
2019-03-25 08:53:48 -04:00
|
|
|
swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet());
|
|
|
|
swgChannelSettings->setOriginatorDeviceSetIndex(getDeviceSetIndex());
|
2020-10-22 18:11:18 -04:00
|
|
|
swgChannelSettings->setChannelType(new QString(m_channelId));
|
2018-12-24 04:27:35 -05:00
|
|
|
swgChannelSettings->setUdpSinkSettings(new SWGSDRangel::SWGUDPSinkSettings());
|
|
|
|
SWGSDRangel::SWGUDPSinkSettings *swgUDPSinkSettings = swgChannelSettings->getUdpSinkSettings();
|
|
|
|
|
|
|
|
// transfer data that has been modified. When force is on transfer all data except reverse API data
|
|
|
|
|
|
|
|
if (channelSettingsKeys.contains("outputSampleRate") || force) {
|
|
|
|
swgUDPSinkSettings->setOutputSampleRate(settings.m_outputSampleRate);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("sampleFormat") || force) {
|
|
|
|
swgUDPSinkSettings->setSampleFormat((int) settings.m_sampleFormat);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("inputFrequencyOffset") || force) {
|
|
|
|
swgUDPSinkSettings->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("rfBandwidth") || force) {
|
|
|
|
swgUDPSinkSettings->setRfBandwidth(settings.m_rfBandwidth);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("fmDeviation") || force) {
|
|
|
|
swgUDPSinkSettings->setFmDeviation(settings.m_fmDeviation);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("channelMute") || force) {
|
|
|
|
swgUDPSinkSettings->setChannelMute(settings.m_channelMute ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("gain") || force) {
|
|
|
|
swgUDPSinkSettings->setGain(settings.m_gain);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("squelchDB") || force) {
|
|
|
|
swgUDPSinkSettings->setSquelchDb(settings.m_squelchdB);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("squelchGate") || force) {
|
|
|
|
swgUDPSinkSettings->setSquelchGate(settings.m_squelchGate);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("squelchEnabled") || force) {
|
|
|
|
swgUDPSinkSettings->setSquelchEnabled(settings.m_squelchEnabled ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("agc") || force) {
|
|
|
|
swgUDPSinkSettings->setAgc(settings.m_agc ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioActive") || force) {
|
|
|
|
swgUDPSinkSettings->setAudioActive(settings.m_audioActive ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioStereo") || force) {
|
|
|
|
swgUDPSinkSettings->setAudioStereo(settings.m_audioStereo ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("volume") || force) {
|
|
|
|
swgUDPSinkSettings->setVolume(settings.m_volume);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("udpAddress") || force) {
|
|
|
|
swgUDPSinkSettings->setUdpAddress(new QString(settings.m_udpAddress));
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("udpPort") || force) {
|
|
|
|
swgUDPSinkSettings->setUdpPort(settings.m_udpPort);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("audioPort") || force) {
|
|
|
|
swgUDPSinkSettings->setAudioPort(settings.m_audioPort);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("rgbColor") || force) {
|
|
|
|
swgUDPSinkSettings->setRgbColor(settings.m_rgbColor);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("title") || force) {
|
|
|
|
swgUDPSinkSettings->setTitle(new QString(settings.m_title));
|
|
|
|
}
|
2019-09-22 19:25:17 -04:00
|
|
|
if (channelSettingsKeys.contains("streamIndex") || force) {
|
|
|
|
swgUDPSinkSettings->setStreamIndex(settings.m_streamIndex);
|
|
|
|
}
|
2021-12-02 17:54:39 -05:00
|
|
|
|
2021-11-30 18:20:14 -05:00
|
|
|
if (settings.m_spectrumGUI && (channelSettingsKeys.contains("spectrunConfig") || force))
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGGLSpectrum *swgGLSpectrum = new SWGSDRangel::SWGGLSpectrum();
|
|
|
|
settings.m_spectrumGUI->formatTo(swgGLSpectrum);
|
|
|
|
swgUDPSinkSettings->setSpectrumConfig(swgGLSpectrum);
|
|
|
|
}
|
2021-12-02 17:54:39 -05:00
|
|
|
|
|
|
|
if (settings.m_channelMarker && (channelSettingsKeys.contains("channelMarker") || force))
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGChannelMarker *swgChannelMarker = new SWGSDRangel::SWGChannelMarker();
|
|
|
|
settings.m_channelMarker->formatTo(swgChannelMarker);
|
|
|
|
swgUDPSinkSettings->setChannelMarker(swgChannelMarker);
|
|
|
|
}
|
2022-01-08 23:27:12 -05:00
|
|
|
|
|
|
|
if (settings.m_rollupState && (channelSettingsKeys.contains("rollupState") || force))
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGRollupState *swgRollupState = new SWGSDRangel::SWGRollupState();
|
|
|
|
settings.m_rollupState->formatTo(swgRollupState);
|
|
|
|
swgUDPSinkSettings->setRollupState(swgRollupState);
|
|
|
|
}
|
2018-12-24 04:27:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSink::networkManagerFinished(QNetworkReply *reply)
|
|
|
|
{
|
|
|
|
QNetworkReply::NetworkError replyError = reply->error();
|
|
|
|
|
|
|
|
if (replyError)
|
|
|
|
{
|
|
|
|
qWarning() << "UDPSink::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("UDPSink::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
|
2018-12-24 04:27:35 -05:00
|
|
|
}
|
|
|
|
|
2019-11-12 12:46:21 -05:00
|
|
|
reply->deleteLater();
|
2018-12-24 04:27:35 -05:00
|
|
|
}
|
2019-12-08 04:09:24 -05:00
|
|
|
|
|
|
|
void UDPSink::enableSpectrum(bool enable)
|
|
|
|
{
|
|
|
|
UDPSinkBaseband::MsgEnableSpectrum *msg = UDPSinkBaseband::MsgEnableSpectrum::create(enable);
|
|
|
|
m_basebandSink->getInputMessageQueue()->push(msg);
|
2020-10-22 18:11:18 -04:00
|
|
|
}
|
2022-03-18 12:08:04 -04:00
|
|
|
|
|
|
|
void UDPSink::handleIndexInDeviceSetChanged(int index)
|
|
|
|
{
|
|
|
|
if (index < 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString fifoLabel = QString("%1 [%2:%3]")
|
|
|
|
.arg(m_channelId)
|
|
|
|
.arg(m_deviceAPI->getDeviceSetIndex())
|
|
|
|
.arg(index);
|
|
|
|
m_basebandSink->setFifoLabel(fifoLabel);
|
|
|
|
m_basebandSink->setAudioFifoLabel(fifoLabel);
|
|
|
|
}
|