2020-09-18 11:36:27 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
|
|
|
|
// Copyright (C) 2020 Jon Beniston, M7RCE //
|
|
|
|
// //
|
|
|
|
// 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 //
|
|
|
|
// (at your option) any later version. //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <QTime>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QMutexLocker>
|
|
|
|
#include <QNetworkAccessManager>
|
2021-04-07 16:06:00 -04:00
|
|
|
#include <QNetworkDatagram>
|
2020-09-18 11:36:27 -04:00
|
|
|
#include <QNetworkReply>
|
|
|
|
#include <QBuffer>
|
2021-04-07 16:06:00 -04:00
|
|
|
#include <QUdpSocket>
|
2020-09-18 11:36:27 -04:00
|
|
|
#include <QThread>
|
|
|
|
|
|
|
|
#include "SWGChannelSettings.h"
|
2022-05-13 16:24:48 -04:00
|
|
|
#include "SWGWorkspaceInfo.h"
|
2020-09-18 11:36:27 -04:00
|
|
|
#include "SWGChannelReport.h"
|
|
|
|
#include "SWGChannelActions.h"
|
|
|
|
#include "SWGPacketModReport.h"
|
|
|
|
#include "SWGPacketModActions.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <complex.h>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "dsp/dspcommands.h"
|
|
|
|
#include "device/deviceapi.h"
|
2020-10-22 18:11:18 -04:00
|
|
|
#include "feature/feature.h"
|
2020-09-18 11:36:27 -04:00
|
|
|
#include "util/db.h"
|
|
|
|
#include "util/crc.h"
|
2020-10-22 18:11:18 -04:00
|
|
|
#include "maincore.h"
|
2020-09-18 11:36:27 -04:00
|
|
|
|
|
|
|
#include "packetmodbaseband.h"
|
|
|
|
#include "packetmod.h"
|
|
|
|
|
|
|
|
MESSAGE_CLASS_DEFINITION(PacketMod::MsgConfigurePacketMod, Message)
|
2021-11-14 16:26:02 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(PacketMod::MsgTx, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(PacketMod::MsgReportTx, Message)
|
2021-04-07 16:06:00 -04:00
|
|
|
MESSAGE_CLASS_DEFINITION(PacketMod::MsgTXPacketBytes, Message)
|
2021-11-21 01:48:39 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(PacketMod::MsgTXPacketData, Message)
|
2020-09-18 11:36:27 -04:00
|
|
|
|
2020-11-21 14:24:18 -05:00
|
|
|
const char* const PacketMod::m_channelIdURI = "sdrangel.channeltx.modpacket";
|
|
|
|
const char* const PacketMod::m_channelId = "PacketMod";
|
2020-09-18 11:36:27 -04:00
|
|
|
|
|
|
|
PacketMod::PacketMod(DeviceAPI *deviceAPI) :
|
|
|
|
ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSource),
|
|
|
|
m_deviceAPI(deviceAPI),
|
|
|
|
m_spectrumVis(SDR_TX_SCALEF),
|
|
|
|
m_settingsMutex(QMutex::Recursive),
|
2021-04-07 16:06:00 -04:00
|
|
|
m_sampleRate(48000),
|
|
|
|
m_udpSocket(nullptr)
|
2020-09-18 11:36:27 -04:00
|
|
|
{
|
|
|
|
setObjectName(m_channelId);
|
|
|
|
|
|
|
|
m_thread = new QThread(this);
|
|
|
|
m_basebandSource = new PacketModBaseband();
|
|
|
|
m_basebandSource->setSpectrumSampleSink(&m_spectrumVis);
|
2020-12-20 20:30:29 -05:00
|
|
|
m_basebandSource->setChannel(this);
|
2020-09-18 11:36:27 -04:00
|
|
|
m_basebandSource->moveToThread(m_thread);
|
|
|
|
|
|
|
|
applySettings(m_settings, true);
|
|
|
|
|
|
|
|
m_deviceAPI->addChannelSource(this);
|
|
|
|
m_deviceAPI->addChannelSourceAPI(this);
|
|
|
|
|
|
|
|
m_networkManager = new QNetworkAccessManager();
|
2022-03-23 17:32:23 -04:00
|
|
|
QObject::connect(
|
|
|
|
m_networkManager,
|
|
|
|
&QNetworkAccessManager::finished,
|
|
|
|
this,
|
|
|
|
&PacketMod::networkManagerFinished
|
|
|
|
);
|
2020-09-18 11:36:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
PacketMod::~PacketMod()
|
|
|
|
{
|
2021-04-07 16:06:00 -04:00
|
|
|
closeUDP();
|
2022-03-23 17:32:23 -04:00
|
|
|
QObject::connect(
|
|
|
|
m_networkManager,
|
|
|
|
&QNetworkAccessManager::finished,
|
|
|
|
this,
|
|
|
|
&PacketMod::networkManagerFinished
|
|
|
|
);
|
2020-09-18 11:36:27 -04:00
|
|
|
delete m_networkManager;
|
|
|
|
m_deviceAPI->removeChannelSourceAPI(this);
|
|
|
|
m_deviceAPI->removeChannelSource(this);
|
|
|
|
delete m_basebandSource;
|
|
|
|
delete m_thread;
|
|
|
|
}
|
|
|
|
|
2022-04-16 10:45:53 -04:00
|
|
|
void PacketMod::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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-18 11:36:27 -04:00
|
|
|
void PacketMod::start()
|
|
|
|
{
|
|
|
|
qDebug("PacketMod::start");
|
|
|
|
m_basebandSource->reset();
|
|
|
|
m_thread->start();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketMod::stop()
|
|
|
|
{
|
|
|
|
qDebug("PacketMod::stop");
|
|
|
|
m_thread->exit();
|
|
|
|
m_thread->wait();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketMod::pull(SampleVector::iterator& begin, unsigned int nbSamples)
|
|
|
|
{
|
|
|
|
m_basebandSource->pull(begin, nbSamples);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PacketMod::handleMessage(const Message& cmd)
|
|
|
|
{
|
|
|
|
if (MsgConfigurePacketMod::match(cmd))
|
|
|
|
{
|
|
|
|
MsgConfigurePacketMod& cfg = (MsgConfigurePacketMod&) cmd;
|
|
|
|
qDebug() << "PacketMod::handleMessage: MsgConfigurePacketMod";
|
|
|
|
|
|
|
|
applySettings(cfg.getSettings(), cfg.getForce());
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2021-11-14 16:26:02 -05:00
|
|
|
if (MsgTx::match(cmd))
|
2020-09-18 11:36:27 -04:00
|
|
|
{
|
2021-11-14 16:26:02 -05:00
|
|
|
MsgTx *msg = new MsgTx((const MsgTx&) cmd);
|
|
|
|
m_basebandSource->getInputMessageQueue()->push(msg);
|
2020-09-18 11:36:27 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (DSPSignalNotification::match(cmd))
|
|
|
|
{
|
|
|
|
// Forward to the source
|
|
|
|
DSPSignalNotification& notif = (DSPSignalNotification&) cmd;
|
|
|
|
DSPSignalNotification* rep = new DSPSignalNotification(notif); // make a copy
|
|
|
|
qDebug() << "PacketMod::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));
|
|
|
|
}
|
2020-09-18 11:36:27 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2021-06-29 15:47:27 -04:00
|
|
|
else if (MainCore::MsgChannelDemodQuery::match(cmd))
|
|
|
|
{
|
|
|
|
qDebug() << "PacketMod::handleMessage: MsgChannelDemodQuery";
|
|
|
|
sendSampleRateToDemodAnalyzer();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2020-09-18 11:36:27 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-06 16:47:41 -05:00
|
|
|
void PacketMod::setCenterFrequency(qint64 frequency)
|
|
|
|
{
|
|
|
|
PacketModSettings settings = m_settings;
|
|
|
|
settings.m_inputFrequencyOffset = frequency;
|
|
|
|
applySettings(settings, false);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue) // forward to GUI if any
|
|
|
|
{
|
|
|
|
MsgConfigurePacketMod *msgToGUI = MsgConfigurePacketMod::create(settings, false);
|
|
|
|
m_guiMessageQueue->push(msgToGUI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-18 11:36:27 -04:00
|
|
|
void PacketMod::applySettings(const PacketModSettings& settings, bool force)
|
|
|
|
{
|
|
|
|
qDebug() << "PacketMod::applySettings:"
|
|
|
|
<< " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset
|
2021-11-14 16:26:02 -05:00
|
|
|
<< " m_modulation: " << settings.m_modulation
|
|
|
|
<< " m_baud: " << settings.m_baud
|
2020-09-18 11:36:27 -04:00
|
|
|
<< " m_rfBandwidth: " << settings.m_rfBandwidth
|
|
|
|
<< " m_fmDeviation: " << settings.m_fmDeviation
|
|
|
|
<< " m_gain: " << settings.m_gain
|
|
|
|
<< " m_channelMute: " << settings.m_channelMute
|
|
|
|
<< " m_repeat: " << settings.m_repeat
|
|
|
|
<< " m_repeatDelay: " << settings.m_repeatDelay
|
|
|
|
<< " m_repeatCount: " << settings.m_repeatCount
|
|
|
|
<< " m_ax25PreFlags: " << settings.m_ax25PreFlags
|
|
|
|
<< " m_ax25PostFlags: " << settings.m_ax25PostFlags
|
|
|
|
<< " m_preEmphasis: " << settings.m_preEmphasis
|
|
|
|
<< " m_preEmphasisTau: " << settings.m_preEmphasisTau
|
|
|
|
<< " m_preEmphasisHighFreq: " << settings.m_preEmphasisHighFreq
|
2020-09-23 08:42:29 -04:00
|
|
|
<< " m_bpf: " << settings.m_bpf
|
|
|
|
<< " m_bpfLowCutoff: " << settings.m_bpfLowCutoff
|
|
|
|
<< " m_bpfHighCutoff: " << settings.m_bpfHighCutoff
|
2020-09-18 11:36:27 -04:00
|
|
|
<< " m_useReverseAPI: " << settings.m_useReverseAPI
|
|
|
|
<< " m_reverseAPIAddress: " << settings.m_reverseAPIAddress
|
|
|
|
<< " m_reverseAPIAddress: " << settings.m_reverseAPIPort
|
|
|
|
<< " m_reverseAPIDeviceIndex: " << settings.m_reverseAPIDeviceIndex
|
|
|
|
<< " m_reverseAPIChannelIndex: " << settings.m_reverseAPIChannelIndex
|
|
|
|
<< " force: " << force;
|
|
|
|
|
|
|
|
QList<QString> reverseAPIKeys;
|
|
|
|
|
|
|
|
if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force) {
|
|
|
|
reverseAPIKeys.append("inputFrequencyOffset");
|
|
|
|
}
|
|
|
|
|
2021-11-14 16:26:02 -05:00
|
|
|
if ((settings.m_modulation != m_settings.m_modulation) || force) {
|
|
|
|
reverseAPIKeys.append("modulation");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_baud != m_settings.m_baud) || force) {
|
|
|
|
reverseAPIKeys.append("baud");
|
|
|
|
}
|
|
|
|
|
2020-09-18 11:36:27 -04:00
|
|
|
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_gain != m_settings.m_gain) || force) {
|
|
|
|
reverseAPIKeys.append("gain");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_channelMute != m_settings.m_channelMute) || force) {
|
|
|
|
reverseAPIKeys.append("channelMute");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_repeat != m_settings.m_repeat) || force) {
|
|
|
|
reverseAPIKeys.append("repeat");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_repeatDelay != m_settings.m_repeatDelay) || force) {
|
|
|
|
reverseAPIKeys.append("repeatDelay");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_repeatCount != m_settings.m_repeatCount) || force) {
|
|
|
|
reverseAPIKeys.append("repeatCount");
|
|
|
|
}
|
|
|
|
|
2020-09-24 16:39:39 -04:00
|
|
|
if ((settings.m_rampUpBits != m_settings.m_rampUpBits) || force) {
|
|
|
|
reverseAPIKeys.append("rampUpBits");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_rampDownBits != m_settings.m_rampDownBits) || force) {
|
|
|
|
reverseAPIKeys.append("rampDownBits");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_rampRange != m_settings.m_rampRange) || force) {
|
|
|
|
reverseAPIKeys.append("rampRange");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_modulateWhileRamping != m_settings.m_modulateWhileRamping) || force) {
|
|
|
|
reverseAPIKeys.append("modulateWhileRamping");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_markFrequency != m_settings.m_markFrequency) || force) {
|
|
|
|
reverseAPIKeys.append("markFrequency");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_spaceFrequency != m_settings.m_spaceFrequency) || force) {
|
|
|
|
reverseAPIKeys.append("spaceFrequency");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_ax25PreFlags != m_settings.m_ax25PreFlags) || force) {
|
2020-09-18 11:36:27 -04:00
|
|
|
reverseAPIKeys.append("ax25PreFlags");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_ax25PostFlags != m_settings.m_ax25PostFlags) || force) {
|
2020-09-18 11:36:27 -04:00
|
|
|
reverseAPIKeys.append("ax25PostFlags");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_ax25Control != m_settings.m_ax25Control) || force) {
|
2020-09-24 16:39:39 -04:00
|
|
|
reverseAPIKeys.append("ax25Control");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_ax25PID != m_settings.m_ax25PID) || force) {
|
2020-09-24 16:39:39 -04:00
|
|
|
reverseAPIKeys.append("ax25PID");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_preEmphasis != m_settings.m_preEmphasis) || force) {
|
2020-09-18 11:36:27 -04:00
|
|
|
reverseAPIKeys.append("preEmphasis");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_preEmphasisTau != m_settings.m_preEmphasisTau) || force) {
|
2020-09-18 11:36:27 -04:00
|
|
|
reverseAPIKeys.append("preEmphasisTau");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_preEmphasisHighFreq != m_settings.m_preEmphasisHighFreq) || force) {
|
2020-09-18 11:36:27 -04:00
|
|
|
reverseAPIKeys.append("preEmphasisHighFreq");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_lpfTaps != m_settings.m_lpfTaps) || force) {
|
2020-09-24 16:39:39 -04:00
|
|
|
reverseAPIKeys.append("lpfTaps");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_bbNoise != m_settings.m_bbNoise) || force) {
|
2020-09-24 16:39:39 -04:00
|
|
|
reverseAPIKeys.append("bbNoise");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_rfNoise != m_settings.m_rfNoise) || force) {
|
2020-09-24 16:39:39 -04:00
|
|
|
reverseAPIKeys.append("rfNoise");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_writeToFile != m_settings.m_writeToFile) || force) {
|
2020-09-24 16:39:39 -04:00
|
|
|
reverseAPIKeys.append("writeToFile");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_spectrumRate != m_settings.m_spectrumRate) || force) {
|
2020-09-24 16:39:39 -04:00
|
|
|
reverseAPIKeys.append("spectrumRate");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_callsign != m_settings.m_callsign) || force) {
|
2020-09-24 16:39:39 -04:00
|
|
|
reverseAPIKeys.append("callsign");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_to != m_settings.m_to) || force) {
|
2020-09-24 16:39:39 -04:00
|
|
|
reverseAPIKeys.append("to");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_via != m_settings.m_via) || force) {
|
2020-09-24 16:39:39 -04:00
|
|
|
reverseAPIKeys.append("via");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_data != m_settings.m_data) || force) {
|
2020-09-24 16:39:39 -04:00
|
|
|
reverseAPIKeys.append("data");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_bpf != m_settings.m_bpf) || force) {
|
2020-09-23 08:42:29 -04:00
|
|
|
reverseAPIKeys.append("bpf");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_bpfLowCutoff != m_settings.m_bpfLowCutoff) || force) {
|
2020-09-23 08:42:29 -04:00
|
|
|
reverseAPIKeys.append("bpfLowCutoff");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_bpfHighCutoff != m_settings.m_bpfHighCutoff) || force) {
|
2020-09-23 08:42:29 -04:00
|
|
|
reverseAPIKeys.append("bpfHighCutoff");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_bpfTaps != m_settings.m_bpfTaps) || force) {
|
2020-09-24 16:39:39 -04:00
|
|
|
reverseAPIKeys.append("bpfTaps");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_scramble != m_settings.m_scramble) || force) {
|
2020-09-24 16:39:39 -04:00
|
|
|
reverseAPIKeys.append("scramble");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_polynomial != m_settings.m_polynomial) || force) {
|
2020-09-24 16:39:39 -04:00
|
|
|
reverseAPIKeys.append("polynomial");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_beta != m_settings.m_beta) || force) {
|
2020-09-24 16:39:39 -04:00
|
|
|
reverseAPIKeys.append("beta");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_symbolSpan != m_settings.m_symbolSpan) || force) {
|
2020-09-24 16:39:39 -04:00
|
|
|
reverseAPIKeys.append("symbolSpan");
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
if ((settings.m_udpEnabled != m_settings.m_udpEnabled) || force) {
|
|
|
|
reverseAPIKeys.append("udpEnabled");
|
|
|
|
}
|
|
|
|
|
|
|
|
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_udpEnabled != m_settings.m_udpEnabled)
|
|
|
|
|| (settings.m_udpAddress != m_settings.m_udpAddress)
|
|
|
|
|| (settings.m_udpPort != m_settings.m_udpPort)
|
|
|
|
|| force)
|
|
|
|
{
|
|
|
|
if (settings.m_udpEnabled)
|
|
|
|
openUDP(settings);
|
|
|
|
else
|
|
|
|
closeUDP();
|
|
|
|
}
|
|
|
|
|
2020-09-18 11:36:27 -04:00
|
|
|
if (m_settings.m_streamIndex != settings.m_streamIndex)
|
|
|
|
{
|
|
|
|
if (m_deviceAPI->getSampleMIMO()) // change of stream is possible for MIMO devices only
|
|
|
|
{
|
|
|
|
m_deviceAPI->removeChannelSourceAPI(this);
|
|
|
|
m_deviceAPI->removeChannelSource(this, m_settings.m_streamIndex);
|
|
|
|
m_deviceAPI->addChannelSource(this, settings.m_streamIndex);
|
|
|
|
m_deviceAPI->addChannelSourceAPI(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
reverseAPIKeys.append("streamIndex");
|
|
|
|
}
|
|
|
|
|
|
|
|
PacketModBaseband::MsgConfigurePacketModBaseband *msg = PacketModBaseband::MsgConfigurePacketModBaseband::create(settings, force);
|
|
|
|
m_basebandSource->getInputMessageQueue()->push(msg);
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-09-18 11:36:27 -04:00
|
|
|
m_settings = settings;
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray PacketMod::serialize() const
|
|
|
|
{
|
|
|
|
return m_settings.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PacketMod::deserialize(const QByteArray& data)
|
|
|
|
{
|
|
|
|
bool success = true;
|
|
|
|
|
|
|
|
if (!m_settings.deserialize(data))
|
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
MsgConfigurePacketMod *msg = MsgConfigurePacketMod::create(m_settings, true);
|
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2021-06-29 15:47:27 -04:00
|
|
|
void PacketMod::sendSampleRateToDemodAnalyzer()
|
|
|
|
{
|
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
|
|
|
|
2022-02-25 17:43:50 -05:00
|
|
|
if (pipes.size() > 0)
|
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,
|
|
|
|
getSourceChannelSampleRate()
|
|
|
|
);
|
2022-02-25 17:43:50 -05:00
|
|
|
messageQueue->push(msg);
|
2021-06-29 15:47:27 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-18 11:36:27 -04:00
|
|
|
int PacketMod::webapiSettingsGet(
|
|
|
|
SWGSDRangel::SWGChannelSettings& response,
|
|
|
|
QString& errorMessage)
|
|
|
|
{
|
|
|
|
(void) errorMessage;
|
|
|
|
response.setPacketModSettings(new SWGSDRangel::SWGPacketModSettings());
|
|
|
|
response.getPacketModSettings()->init();
|
|
|
|
webapiFormatChannelSettings(response, m_settings);
|
|
|
|
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
2022-05-13 16:24:48 -04:00
|
|
|
int PacketMod::webapiWorkspaceGet(
|
|
|
|
SWGSDRangel::SWGWorkspaceInfo& response,
|
|
|
|
QString& errorMessage)
|
|
|
|
{
|
|
|
|
(void) errorMessage;
|
|
|
|
response.setIndex(m_settings.m_workspaceIndex);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
2020-09-18 11:36:27 -04:00
|
|
|
int PacketMod::webapiSettingsPutPatch(
|
|
|
|
bool force,
|
|
|
|
const QStringList& channelSettingsKeys,
|
|
|
|
SWGSDRangel::SWGChannelSettings& response,
|
|
|
|
QString& errorMessage)
|
|
|
|
{
|
|
|
|
(void) errorMessage;
|
|
|
|
PacketModSettings settings = m_settings;
|
|
|
|
webapiUpdateChannelSettings(settings, channelSettingsKeys, response);
|
|
|
|
|
|
|
|
MsgConfigurePacketMod *msg = MsgConfigurePacketMod::create(settings, force);
|
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue) // forward to GUI if any
|
|
|
|
{
|
|
|
|
MsgConfigurePacketMod *msgToGUI = MsgConfigurePacketMod::create(settings, force);
|
|
|
|
m_guiMessageQueue->push(msgToGUI);
|
|
|
|
}
|
|
|
|
|
|
|
|
webapiFormatChannelSettings(response, settings);
|
|
|
|
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketMod::webapiUpdateChannelSettings(
|
|
|
|
PacketModSettings& settings,
|
|
|
|
const QStringList& channelSettingsKeys,
|
|
|
|
SWGSDRangel::SWGChannelSettings& response)
|
|
|
|
{
|
|
|
|
if (channelSettingsKeys.contains("inputFrequencyOffset")) {
|
|
|
|
settings.m_inputFrequencyOffset = response.getPacketModSettings()->getInputFrequencyOffset();
|
|
|
|
}
|
2021-11-14 16:26:02 -05:00
|
|
|
if (channelSettingsKeys.contains("modulation")) {
|
|
|
|
settings.m_modulation = (PacketModSettings::Modulation) response.getPacketModSettings()->getModulation();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("baud")) {
|
|
|
|
settings.m_baud = response.getPacketModSettings()->getBaud();
|
2020-09-23 08:42:29 -04:00
|
|
|
}
|
2020-09-18 11:36:27 -04:00
|
|
|
if (channelSettingsKeys.contains("rfBandwidth")) {
|
|
|
|
settings.m_rfBandwidth = response.getPacketModSettings()->getRfBandwidth();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("fmDeviation")) {
|
|
|
|
settings.m_fmDeviation = response.getPacketModSettings()->getFmDeviation();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("gain")) {
|
|
|
|
settings.m_gain = response.getPacketModSettings()->getGain();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("channelMute")) {
|
|
|
|
settings.m_channelMute = response.getPacketModSettings()->getChannelMute() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("repeat")) {
|
|
|
|
settings.m_repeat = response.getPacketModSettings()->getRepeat() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("repeatDelay")) {
|
|
|
|
settings.m_repeatDelay = response.getPacketModSettings()->getRepeatDelay();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("repeatCount")) {
|
|
|
|
settings.m_repeatCount = response.getPacketModSettings()->getRepeatCount();
|
|
|
|
}
|
2020-09-24 16:39:39 -04:00
|
|
|
if (channelSettingsKeys.contains("rampUpBits")) {
|
|
|
|
settings.m_rampUpBits = response.getPacketModSettings()->getRampUpBits();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("rampDownBits")) {
|
|
|
|
settings.m_rampDownBits = response.getPacketModSettings()->getRampDownBits();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("rampRange")) {
|
|
|
|
settings.m_rampRange = response.getPacketModSettings()->getRampRange();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("modulateWhileRamping")) {
|
|
|
|
settings.m_modulateWhileRamping = response.getPacketModSettings()->getModulateWhileRamping() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("markFrequency")) {
|
|
|
|
settings.m_markFrequency = response.getPacketModSettings()->getMarkFrequency();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("spaceFrequency")) {
|
|
|
|
settings.m_spaceFrequency = response.getPacketModSettings()->getSpaceFrequency();
|
|
|
|
}
|
2020-09-18 11:36:27 -04:00
|
|
|
if (channelSettingsKeys.contains("ax25PreFlags")) {
|
|
|
|
settings.m_ax25PreFlags = response.getPacketModSettings()->getAx25PreFlags();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("ax25PostFlags")) {
|
|
|
|
settings.m_ax25PostFlags = response.getPacketModSettings()->getAx25PostFlags();
|
|
|
|
}
|
2020-09-24 16:39:39 -04:00
|
|
|
if (channelSettingsKeys.contains("ax25Control")) {
|
|
|
|
settings.m_ax25Control = response.getPacketModSettings()->getAx25Control();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("ax25PID")) {
|
|
|
|
settings.m_ax25PID = response.getPacketModSettings()->getAx25Pid();
|
|
|
|
}
|
2020-09-18 11:36:27 -04:00
|
|
|
if (channelSettingsKeys.contains("preEmphasis")) {
|
|
|
|
settings.m_preEmphasis = response.getPacketModSettings()->getPreEmphasis() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("preEmphasisTau")) {
|
|
|
|
settings.m_preEmphasisTau = response.getPacketModSettings()->getPreEmphasisTau();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("preEmphasisHighFreq")) {
|
|
|
|
settings.m_preEmphasisHighFreq = response.getPacketModSettings()->getPreEmphasisHighFreq();
|
|
|
|
}
|
2020-09-24 16:39:39 -04:00
|
|
|
if (channelSettingsKeys.contains("lpfTaps")) {
|
|
|
|
settings.m_lpfTaps = response.getPacketModSettings()->getLpfTaps();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("bbNoise")) {
|
|
|
|
settings.m_bbNoise = response.getPacketModSettings()->getBbNoise() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("rfNoise")) {
|
|
|
|
settings.m_rfNoise = response.getPacketModSettings()->getRfNoise() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("writeToFile")) {
|
|
|
|
settings.m_writeToFile = response.getPacketModSettings()->getWriteToFile() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("spectrumRate")) {
|
|
|
|
settings.m_spectrumRate = response.getPacketModSettings()->getSpectrumRate();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("callsign")) {
|
|
|
|
settings.m_callsign = *response.getPacketModSettings()->getCallsign();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("to")) {
|
|
|
|
settings.m_to = *response.getPacketModSettings()->getTo();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("via")) {
|
|
|
|
settings.m_via = *response.getPacketModSettings()->getVia();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("data")) {
|
|
|
|
settings.m_data = *response.getPacketModSettings()->getData();
|
|
|
|
}
|
2020-09-23 08:42:29 -04:00
|
|
|
if (channelSettingsKeys.contains("bpf")) {
|
|
|
|
settings.m_bpf = response.getPacketModSettings()->getBpf() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("bpfLowCutoff")) {
|
|
|
|
settings.m_bpfLowCutoff = response.getPacketModSettings()->getBpfLowCutoff();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("bpfHighCutoff")) {
|
|
|
|
settings.m_bpfHighCutoff = response.getPacketModSettings()->getBpfHighCutoff();
|
|
|
|
}
|
2020-09-24 16:39:39 -04:00
|
|
|
if (channelSettingsKeys.contains("bpfTaps")) {
|
|
|
|
settings.m_bpfTaps = response.getPacketModSettings()->getBpfTaps();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("scramble")) {
|
|
|
|
settings.m_scramble = response.getPacketModSettings()->getScramble() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("polynomial")) {
|
|
|
|
settings.m_polynomial = response.getPacketModSettings()->getPolynomial();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("beta")) {
|
|
|
|
settings.m_beta = response.getPacketModSettings()->getBeta();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("symbolSpan")) {
|
|
|
|
settings.m_symbolSpan = response.getPacketModSettings()->getSymbolSpan();
|
|
|
|
}
|
2020-09-18 11:36:27 -04:00
|
|
|
if (channelSettingsKeys.contains("rgbColor")) {
|
|
|
|
settings.m_rgbColor = response.getPacketModSettings()->getRgbColor();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("title")) {
|
|
|
|
settings.m_title = *response.getPacketModSettings()->getTitle();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("streamIndex")) {
|
|
|
|
settings.m_streamIndex = response.getPacketModSettings()->getStreamIndex();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("useReverseAPI")) {
|
|
|
|
settings.m_useReverseAPI = response.getPacketModSettings()->getUseReverseApi() != 0;
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIAddress")) {
|
|
|
|
settings.m_reverseAPIAddress = *response.getPacketModSettings()->getReverseApiAddress();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIPort")) {
|
|
|
|
settings.m_reverseAPIPort = response.getPacketModSettings()->getReverseApiPort();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
|
|
|
|
settings.m_reverseAPIDeviceIndex = response.getPacketModSettings()->getReverseApiDeviceIndex();
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
|
|
|
|
settings.m_reverseAPIChannelIndex = response.getPacketModSettings()->getReverseApiChannelIndex();
|
|
|
|
}
|
2021-04-07 16:06:00 -04:00
|
|
|
if (channelSettingsKeys.contains("udpEnabled")) {
|
2021-07-15 07:03:26 -04:00
|
|
|
settings.m_udpEnabled = response.getPacketModSettings()->getUdpEnabled();
|
2021-04-07 16:06:00 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("udpAddress")) {
|
2021-07-15 07:03:26 -04:00
|
|
|
settings.m_udpAddress = *response.getPacketModSettings()->getUdpAddress();
|
2021-04-07 16:06:00 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("udpPort")) {
|
2021-07-15 07:03:26 -04:00
|
|
|
settings.m_udpPort = response.getPacketModSettings()->getUdpPort();
|
2021-04-07 16:06:00 -04:00
|
|
|
}
|
2021-12-03 16:32:54 -05:00
|
|
|
if (settings.m_channelMarker && channelSettingsKeys.contains("channelMarker")) {
|
|
|
|
settings.m_channelMarker->updateFrom(channelSettingsKeys, response.getPacketModSettings()->getChannelMarker());
|
|
|
|
}
|
2022-01-08 23:27:12 -05:00
|
|
|
if (settings.m_rollupState && channelSettingsKeys.contains("rollupState")) {
|
|
|
|
settings.m_rollupState->updateFrom(channelSettingsKeys, response.getPacketModSettings()->getRollupState());
|
|
|
|
}
|
2020-09-18 11:36:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int PacketMod::webapiReportGet(
|
|
|
|
SWGSDRangel::SWGChannelReport& response,
|
|
|
|
QString& errorMessage)
|
|
|
|
{
|
|
|
|
(void) errorMessage;
|
|
|
|
response.setPacketModReport(new SWGSDRangel::SWGPacketModReport());
|
|
|
|
response.getPacketModReport()->init();
|
|
|
|
webapiFormatChannelReport(response);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
int PacketMod::webapiActionsPost(
|
|
|
|
const QStringList& channelActionsKeys,
|
|
|
|
SWGSDRangel::SWGChannelActions& query,
|
|
|
|
QString& errorMessage)
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGPacketModActions *swgPacketModActions = query.getPacketModActions();
|
|
|
|
|
|
|
|
if (swgPacketModActions)
|
|
|
|
{
|
|
|
|
if (channelActionsKeys.contains("tx"))
|
|
|
|
{
|
2021-11-14 16:26:02 -05:00
|
|
|
if (swgPacketModActions->getTx() != 0)
|
2020-10-09 15:05:44 -04:00
|
|
|
{
|
2021-11-21 01:48:39 -05:00
|
|
|
if (channelActionsKeys.contains("payload")
|
|
|
|
&& (swgPacketModActions->getPayload()->getCallsign())
|
|
|
|
&& (swgPacketModActions->getPayload()->getTo())
|
|
|
|
&& (swgPacketModActions->getPayload()->getVia())
|
|
|
|
&& (swgPacketModActions->getPayload()->getData()))
|
|
|
|
{
|
|
|
|
MsgTXPacketData *msg = MsgTXPacketData::create(
|
|
|
|
*swgPacketModActions->getPayload()->getCallsign(),
|
|
|
|
*swgPacketModActions->getPayload()->getTo(),
|
|
|
|
*swgPacketModActions->getPayload()->getVia(),
|
|
|
|
*swgPacketModActions->getPayload()->getData()
|
|
|
|
);
|
|
|
|
m_basebandSource->getInputMessageQueue()->push(msg);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MsgTx *msg = MsgTx::create();
|
|
|
|
m_basebandSource->getInputMessageQueue()->push(msg);
|
|
|
|
}
|
2021-11-14 16:26:02 -05:00
|
|
|
|
|
|
|
if (getMessageQueueToGUI())
|
|
|
|
{
|
|
|
|
MsgReportTx *msg = MsgReportTx::create();
|
|
|
|
getMessageQueueToGUI()->push(msg);
|
|
|
|
}
|
|
|
|
|
2020-10-09 15:05:44 -04:00
|
|
|
return 202;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-14 16:26:02 -05:00
|
|
|
errorMessage = "Packet must contain tx action";
|
2020-10-09 15:05:44 -04:00
|
|
|
return 400;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
errorMessage = "Unknown action";
|
|
|
|
return 400;
|
2020-09-18 11:36:27 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
errorMessage = "Missing PacketModActions in query";
|
|
|
|
return 400;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketMod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const PacketModSettings& settings)
|
|
|
|
{
|
|
|
|
response.getPacketModSettings()->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
|
2021-11-14 16:26:02 -05:00
|
|
|
response.getPacketModSettings()->setModulation((int) settings.m_modulation);
|
|
|
|
response.getPacketModSettings()->setBaud(settings.m_baud);
|
2020-09-18 11:36:27 -04:00
|
|
|
response.getPacketModSettings()->setRfBandwidth(settings.m_rfBandwidth);
|
|
|
|
response.getPacketModSettings()->setFmDeviation(settings.m_fmDeviation);
|
|
|
|
response.getPacketModSettings()->setGain(settings.m_gain);
|
|
|
|
response.getPacketModSettings()->setChannelMute(settings.m_channelMute ? 1 : 0);
|
|
|
|
response.getPacketModSettings()->setRepeat(settings.m_repeat ? 1 : 0);
|
|
|
|
response.getPacketModSettings()->setRepeatDelay(settings.m_repeatDelay);
|
|
|
|
response.getPacketModSettings()->setRepeatCount(settings.m_repeatCount);
|
2020-09-24 16:39:39 -04:00
|
|
|
response.getPacketModSettings()->setRampUpBits(settings.m_rampUpBits);
|
|
|
|
response.getPacketModSettings()->setRampDownBits(settings.m_rampDownBits);
|
|
|
|
response.getPacketModSettings()->setRampRange(settings.m_rampRange);
|
|
|
|
response.getPacketModSettings()->setModulateWhileRamping(settings.m_modulateWhileRamping ? 1 : 0);
|
|
|
|
response.getPacketModSettings()->setMarkFrequency(settings.m_markFrequency);
|
|
|
|
response.getPacketModSettings()->setSpaceFrequency(settings.m_spaceFrequency);
|
2020-09-18 11:36:27 -04:00
|
|
|
response.getPacketModSettings()->setAx25PreFlags(settings.m_ax25PreFlags);
|
|
|
|
response.getPacketModSettings()->setAx25PostFlags(settings.m_ax25PostFlags);
|
2020-09-24 16:39:39 -04:00
|
|
|
response.getPacketModSettings()->setAx25Control(settings.m_ax25Control);
|
|
|
|
response.getPacketModSettings()->setAx25Pid(settings.m_ax25PID);
|
2020-09-18 11:36:27 -04:00
|
|
|
response.getPacketModSettings()->setPreEmphasis(settings.m_preEmphasis ? 1 : 0);
|
|
|
|
response.getPacketModSettings()->setPreEmphasisTau(settings.m_preEmphasisTau);
|
|
|
|
response.getPacketModSettings()->setPreEmphasisHighFreq(settings.m_preEmphasisHighFreq);
|
2020-09-24 16:39:39 -04:00
|
|
|
response.getPacketModSettings()->setLpfTaps(settings.m_lpfTaps);
|
|
|
|
response.getPacketModSettings()->setBbNoise(settings.m_bbNoise ? 1 : 0);
|
|
|
|
response.getPacketModSettings()->setRfNoise(settings.m_rfNoise ? 1 : 0);
|
|
|
|
response.getPacketModSettings()->setWriteToFile(settings.m_writeToFile ? 1 : 0);
|
|
|
|
response.getPacketModSettings()->setSpectrumRate(settings.m_spectrumRate);
|
|
|
|
|
|
|
|
if (response.getPacketModSettings()->getCallsign()) {
|
|
|
|
*response.getPacketModSettings()->getCallsign() = settings.m_callsign;
|
|
|
|
} else {
|
|
|
|
response.getPacketModSettings()->setCallsign(new QString(settings.m_callsign));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (response.getPacketModSettings()->getTo()) {
|
|
|
|
*response.getPacketModSettings()->getTo() = settings.m_to;
|
|
|
|
} else {
|
|
|
|
response.getPacketModSettings()->setTo(new QString(settings.m_to));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (response.getPacketModSettings()->getVia()) {
|
|
|
|
*response.getPacketModSettings()->getVia() = settings.m_via;
|
|
|
|
} else {
|
|
|
|
response.getPacketModSettings()->setVia(new QString(settings.m_via));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (response.getPacketModSettings()->getData()) {
|
|
|
|
*response.getPacketModSettings()->getData() = settings.m_data;
|
|
|
|
} else {
|
|
|
|
response.getPacketModSettings()->setData(new QString(settings.m_data));
|
|
|
|
}
|
|
|
|
|
2020-09-23 08:42:29 -04:00
|
|
|
response.getPacketModSettings()->setBpf(settings.m_bpf ? 1 : 0);
|
|
|
|
response.getPacketModSettings()->setBpfLowCutoff(settings.m_bpfLowCutoff);
|
|
|
|
response.getPacketModSettings()->setBpfHighCutoff(settings.m_bpfHighCutoff);
|
2020-09-24 16:39:39 -04:00
|
|
|
response.getPacketModSettings()->setBpfTaps(settings.m_bpfTaps);
|
|
|
|
response.getPacketModSettings()->setScramble(settings.m_scramble ? 1 : 0);
|
|
|
|
response.getPacketModSettings()->setPolynomial(settings.m_polynomial);
|
|
|
|
response.getPacketModSettings()->setPulseShaping(settings.m_pulseShaping ? 1 : 0);
|
|
|
|
response.getPacketModSettings()->setBeta(settings.m_beta);
|
|
|
|
response.getPacketModSettings()->setSymbolSpan(settings.m_symbolSpan);
|
2021-04-07 16:06:00 -04:00
|
|
|
response.getPacketModSettings()->setUdpEnabled(settings.m_udpEnabled);
|
|
|
|
response.getPacketModSettings()->setUdpAddress(new QString(settings.m_udpAddress));
|
|
|
|
response.getPacketModSettings()->setUdpPort(settings.m_udpPort);
|
2020-09-24 16:39:39 -04:00
|
|
|
|
2020-09-18 11:36:27 -04:00
|
|
|
response.getPacketModSettings()->setRgbColor(settings.m_rgbColor);
|
|
|
|
|
|
|
|
if (response.getPacketModSettings()->getTitle()) {
|
|
|
|
*response.getPacketModSettings()->getTitle() = settings.m_title;
|
|
|
|
} else {
|
|
|
|
response.getPacketModSettings()->setTitle(new QString(settings.m_title));
|
|
|
|
}
|
|
|
|
|
|
|
|
response.getPacketModSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
|
|
|
|
|
|
|
|
if (response.getPacketModSettings()->getReverseApiAddress()) {
|
|
|
|
*response.getPacketModSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress;
|
|
|
|
} else {
|
|
|
|
response.getPacketModSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
|
|
|
|
}
|
|
|
|
|
|
|
|
response.getPacketModSettings()->setReverseApiPort(settings.m_reverseAPIPort);
|
|
|
|
response.getPacketModSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
|
|
|
|
response.getPacketModSettings()->setReverseApiChannelIndex(settings.m_reverseAPIChannelIndex);
|
2021-12-03 16:32:54 -05:00
|
|
|
|
|
|
|
if (settings.m_channelMarker)
|
|
|
|
{
|
|
|
|
if (response.getPacketModSettings()->getChannelMarker())
|
|
|
|
{
|
|
|
|
settings.m_channelMarker->formatTo(response.getPacketModSettings()->getChannelMarker());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGChannelMarker *swgChannelMarker = new SWGSDRangel::SWGChannelMarker();
|
|
|
|
settings.m_channelMarker->formatTo(swgChannelMarker);
|
|
|
|
response.getPacketModSettings()->setChannelMarker(swgChannelMarker);
|
|
|
|
}
|
|
|
|
}
|
2022-01-08 23:27:12 -05:00
|
|
|
|
|
|
|
if (settings.m_rollupState)
|
|
|
|
{
|
|
|
|
if (response.getPacketModSettings()->getRollupState())
|
|
|
|
{
|
|
|
|
settings.m_rollupState->formatTo(response.getPacketModSettings()->getRollupState());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGRollupState *swgRollupState = new SWGSDRangel::SWGRollupState();
|
|
|
|
settings.m_rollupState->formatTo(swgRollupState);
|
|
|
|
response.getPacketModSettings()->setRollupState(swgRollupState);
|
|
|
|
}
|
|
|
|
}
|
2020-09-18 11:36:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void PacketMod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response)
|
|
|
|
{
|
|
|
|
response.getPacketModReport()->setChannelPowerDb(CalcDb::dbPower(getMagSq()));
|
|
|
|
response.getPacketModReport()->setChannelSampleRate(m_basebandSource->getChannelSampleRate());
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketMod::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const PacketModSettings& 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 PacketMod::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 PacketModSettings& 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 PacketMod::webapiFormatChannelSettings(
|
|
|
|
QList<QString>& channelSettingsKeys,
|
|
|
|
SWGSDRangel::SWGChannelSettings *swgChannelSettings,
|
|
|
|
const PacketModSettings& settings,
|
|
|
|
bool force
|
|
|
|
)
|
|
|
|
{
|
2020-09-18 11:36:27 -04:00
|
|
|
swgChannelSettings->setDirection(1); // single source (Tx)
|
|
|
|
swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet());
|
|
|
|
swgChannelSettings->setOriginatorDeviceSetIndex(getDeviceSetIndex());
|
2020-10-22 18:11:18 -04:00
|
|
|
swgChannelSettings->setChannelType(new QString(m_channelId));
|
2020-09-18 11:36:27 -04:00
|
|
|
swgChannelSettings->setPacketModSettings(new SWGSDRangel::SWGPacketModSettings());
|
|
|
|
SWGSDRangel::SWGPacketModSettings *swgPacketModSettings = swgChannelSettings->getPacketModSettings();
|
|
|
|
|
|
|
|
// transfer data that has been modified. When force is on transfer all data except reverse API data
|
|
|
|
|
|
|
|
if (channelSettingsKeys.contains("inputFrequencyOffset") || force) {
|
|
|
|
swgPacketModSettings->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
|
|
|
|
}
|
2021-11-14 16:26:02 -05:00
|
|
|
if (channelSettingsKeys.contains("modulation") || force) {
|
|
|
|
swgPacketModSettings->setModulation((int) settings.m_modulation);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("baud") || force) {
|
|
|
|
swgPacketModSettings->setBaud((int) settings.m_baud);
|
|
|
|
}
|
2020-09-18 11:36:27 -04:00
|
|
|
if (channelSettingsKeys.contains("rfBandwidth") || force) {
|
|
|
|
swgPacketModSettings->setRfBandwidth(settings.m_rfBandwidth);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("fmDeviation") || force) {
|
|
|
|
swgPacketModSettings->setFmDeviation(settings.m_fmDeviation);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("gain") || force) {
|
|
|
|
swgPacketModSettings->setGain(settings.m_gain);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("channelMute") || force) {
|
|
|
|
swgPacketModSettings->setChannelMute(settings.m_channelMute ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("repeat") || force) {
|
|
|
|
swgPacketModSettings->setRepeat(settings.m_repeat ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("repeatDelay") || force) {
|
|
|
|
swgPacketModSettings->setRepeatDelay(settings.m_repeatDelay);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("repeatCount") || force) {
|
|
|
|
swgPacketModSettings->setRepeatCount(settings.m_repeatCount);
|
|
|
|
}
|
2020-09-24 16:39:39 -04:00
|
|
|
if (channelSettingsKeys.contains("rampUpBits")) {
|
|
|
|
swgPacketModSettings->setRampUpBits(settings.m_rampUpBits);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("rampDownBits")) {
|
|
|
|
swgPacketModSettings->setRampDownBits(settings.m_rampDownBits);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("rampRange")) {
|
|
|
|
swgPacketModSettings->setRampRange(settings.m_rampRange);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("modulateWhileRamping")) {
|
|
|
|
swgPacketModSettings->setRampRange(settings.m_modulateWhileRamping ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("markFrequency")) {
|
|
|
|
swgPacketModSettings->setMarkFrequency(settings.m_markFrequency);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("spaceFrequency")) {
|
|
|
|
swgPacketModSettings->setSpaceFrequency(settings.m_spaceFrequency);
|
|
|
|
}
|
2020-09-18 11:36:27 -04:00
|
|
|
if (channelSettingsKeys.contains("ax25PreFlags") || force) {
|
|
|
|
swgPacketModSettings->setAx25PreFlags(settings.m_ax25PreFlags);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("ax25PostFlags") || force) {
|
|
|
|
swgPacketModSettings->setAx25PostFlags(settings.m_ax25PostFlags);
|
|
|
|
}
|
2020-09-24 16:39:39 -04:00
|
|
|
if (channelSettingsKeys.contains("ax25Control")) {
|
|
|
|
swgPacketModSettings->setAx25Control(settings.m_ax25Control);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("ax25PID")) {
|
|
|
|
swgPacketModSettings->setAx25Pid(settings.m_ax25PID);
|
|
|
|
}
|
2020-09-18 11:36:27 -04:00
|
|
|
if (channelSettingsKeys.contains("preEmphasis") || force) {
|
2020-09-24 16:39:39 -04:00
|
|
|
swgPacketModSettings->setPreEmphasis(settings.m_preEmphasis ? 1 : 0);
|
2020-09-18 11:36:27 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("preEmphasisTau") || force) {
|
|
|
|
swgPacketModSettings->setPreEmphasisTau(settings.m_preEmphasisTau);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("preEmphasisHighFreq") || force) {
|
|
|
|
swgPacketModSettings->setPreEmphasisHighFreq(settings.m_preEmphasisHighFreq);
|
|
|
|
}
|
2020-09-24 16:39:39 -04:00
|
|
|
if (channelSettingsKeys.contains("lpfTaps")) {
|
|
|
|
swgPacketModSettings->setLpfTaps(settings.m_lpfTaps);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("bbNoise")) {
|
|
|
|
swgPacketModSettings->setBbNoise(settings.m_bbNoise ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("rfNoise")) {
|
|
|
|
swgPacketModSettings->setRfNoise(settings.m_rfNoise ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("writeToFile")) {
|
|
|
|
swgPacketModSettings->setWriteToFile(settings.m_writeToFile ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("spectrumRate")) {
|
|
|
|
swgPacketModSettings->setSpectrumRate(settings.m_spectrumRate);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("callsign")) {
|
|
|
|
swgPacketModSettings->setCallsign(new QString(settings.m_callsign));
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("to")) {
|
|
|
|
swgPacketModSettings->setTo(new QString(settings.m_to));
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("via")) {
|
|
|
|
swgPacketModSettings->setVia(new QString(settings.m_via));
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("data")) {
|
|
|
|
swgPacketModSettings->setData(new QString(settings.m_data));
|
|
|
|
}
|
2020-09-23 08:42:29 -04:00
|
|
|
if (channelSettingsKeys.contains("bpf") || force) {
|
2021-07-15 07:03:26 -04:00
|
|
|
swgPacketModSettings->setBpf(settings.m_bpf ? 1 : 0);
|
2020-09-23 08:42:29 -04:00
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("bpfLowCutoff") || force) {
|
|
|
|
swgPacketModSettings->setBpfLowCutoff(settings.m_bpfLowCutoff);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("bpfHighCutoff") || force) {
|
|
|
|
swgPacketModSettings->setBpfHighCutoff(settings.m_bpfHighCutoff);
|
|
|
|
}
|
2020-09-24 16:39:39 -04:00
|
|
|
if (channelSettingsKeys.contains("bpfTaps")) {
|
|
|
|
swgPacketModSettings->setBpfTaps(settings.m_bpfTaps);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("scramble")) {
|
|
|
|
swgPacketModSettings->setScramble(settings.m_scramble ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("polynomial")) {
|
|
|
|
swgPacketModSettings->setPolynomial(settings.m_polynomial);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("beta")) {
|
|
|
|
swgPacketModSettings->setBeta(settings.m_beta);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("symbolSpan")) {
|
|
|
|
swgPacketModSettings->setSymbolSpan(settings.m_symbolSpan);
|
|
|
|
}
|
2020-09-18 11:36:27 -04:00
|
|
|
if (channelSettingsKeys.contains("rgbColor") || force) {
|
|
|
|
swgPacketModSettings->setRgbColor(settings.m_rgbColor);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("title") || force) {
|
|
|
|
swgPacketModSettings->setTitle(new QString(settings.m_title));
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("streamIndex") || force) {
|
|
|
|
swgPacketModSettings->setStreamIndex(settings.m_streamIndex);
|
|
|
|
}
|
2021-04-07 16:06:00 -04:00
|
|
|
if (channelSettingsKeys.contains("udpEnabled") || force) {
|
|
|
|
swgPacketModSettings->setUdpEnabled(settings.m_udpEnabled);
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("udpAddress") || force) {
|
|
|
|
swgPacketModSettings->setUdpAddress(new QString(settings.m_udpAddress));
|
|
|
|
}
|
|
|
|
if (channelSettingsKeys.contains("udpPort") || force) {
|
|
|
|
swgPacketModSettings->setUdpPort(settings.m_udpPort);
|
|
|
|
}
|
2021-12-03 16:32:54 -05:00
|
|
|
|
|
|
|
if (settings.m_channelMarker && (channelSettingsKeys.contains("channelMarker") || force))
|
|
|
|
{
|
|
|
|
SWGSDRangel::SWGChannelMarker *swgChannelMarker = new SWGSDRangel::SWGChannelMarker();
|
|
|
|
settings.m_channelMarker->formatTo(swgChannelMarker);
|
|
|
|
swgPacketModSettings->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);
|
|
|
|
swgPacketModSettings->setRollupState(swgRollupState);
|
|
|
|
}
|
2020-09-18 11:36:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void PacketMod::networkManagerFinished(QNetworkReply *reply)
|
|
|
|
{
|
|
|
|
QNetworkReply::NetworkError replyError = reply->error();
|
|
|
|
|
|
|
|
if (replyError)
|
|
|
|
{
|
|
|
|
qWarning() << "PacketMod::networkManagerFinished:"
|
|
|
|
<< " error(" << (int) replyError
|
|
|
|
<< "): " << replyError
|
|
|
|
<< ": " << reply->errorString();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QString answer = reply->readAll();
|
|
|
|
answer.chop(1); // remove last \n
|
|
|
|
qDebug("PacketMod::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
reply->deleteLater();
|
|
|
|
}
|
|
|
|
|
|
|
|
double PacketMod::getMagSq() const
|
|
|
|
{
|
|
|
|
return m_basebandSource->getMagSq();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketMod::setLevelMeter(QObject *levelMeter)
|
|
|
|
{
|
|
|
|
connect(m_basebandSource, SIGNAL(levelChanged(qreal, qreal, int)), levelMeter, SLOT(levelChanged(qreal, qreal, int)));
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t PacketMod::getNumberOfDeviceStreams() const
|
|
|
|
{
|
|
|
|
return m_deviceAPI->getNbSinkStreams();
|
|
|
|
}
|
2021-04-07 16:06:00 -04:00
|
|
|
|
2021-06-29 15:47:27 -04:00
|
|
|
int PacketMod::getSourceChannelSampleRate() const
|
|
|
|
{
|
|
|
|
return m_basebandSource->getSourceChannelSampleRate();
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
void PacketMod::openUDP(const PacketModSettings& settings)
|
|
|
|
{
|
|
|
|
closeUDP();
|
|
|
|
m_udpSocket = new QUdpSocket();
|
|
|
|
if (!m_udpSocket->bind(QHostAddress(settings.m_udpAddress), settings.m_udpPort))
|
|
|
|
qCritical() << "PacketMod::openUDP: Failed to bind to port " << settings.m_udpAddress << ":" << settings.m_udpPort << ". Error: " << m_udpSocket->error();
|
|
|
|
else
|
|
|
|
qDebug() << "PacketMod::openUDP: Listening for packets on " << settings.m_udpAddress << ":" << settings.m_udpPort;
|
|
|
|
connect(m_udpSocket, &QUdpSocket::readyRead, this, &PacketMod::udpRx);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketMod::closeUDP()
|
|
|
|
{
|
|
|
|
if (m_udpSocket != nullptr)
|
|
|
|
{
|
|
|
|
disconnect(m_udpSocket, &QUdpSocket::readyRead, this, &PacketMod::udpRx);
|
|
|
|
delete m_udpSocket;
|
|
|
|
m_udpSocket = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketMod::udpRx()
|
|
|
|
{
|
|
|
|
while (m_udpSocket->hasPendingDatagrams())
|
|
|
|
{
|
|
|
|
QNetworkDatagram datagram = m_udpSocket->receiveDatagram();
|
|
|
|
MsgTXPacketBytes *msg = MsgTXPacketBytes::create(datagram.data());
|
|
|
|
m_basebandSource->getInputMessageQueue()->push(msg);
|
|
|
|
}
|
|
|
|
}
|