2023-03-18 07:48:21 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
2023-11-18 04:07:41 -05:00
|
|
|
// Copyright (C) 2023 Daniele Forsi <iu5hkx@gmail.com> //
|
|
|
|
// Copyright (C) 2023 Frank Werner <mail@hb9fxq.ch> //
|
|
|
|
// Copyright (C) 2023 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
|
2023-03-18 07:48:21 -04: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 //
|
|
|
|
// (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 <boost/endian/conversion.hpp>
|
2023-03-19 08:25:06 -04:00
|
|
|
|
2023-03-22 20:30:12 -04:00
|
|
|
#include <QJsonObject>
|
|
|
|
#include <QJsonArray>
|
|
|
|
#include <QJsonValue>
|
|
|
|
|
2023-03-18 07:48:21 -04:00
|
|
|
#include "util/messagequeue.h"
|
2023-03-19 08:25:06 -04:00
|
|
|
#include "dsp/dspcommands.h"
|
|
|
|
|
2023-03-24 13:26:26 -04:00
|
|
|
#include "aaroniartsainputsettings.h"
|
|
|
|
#include "aaroniartsainputworker.h"
|
2023-03-18 07:48:21 -04:00
|
|
|
|
2023-03-24 13:26:26 -04:00
|
|
|
MESSAGE_CLASS_DEFINITION(AaroniaRTSAInputWorker::MsgReportSampleRateAndFrequency, Message)
|
2023-03-18 07:48:21 -04:00
|
|
|
|
2023-03-24 13:26:26 -04:00
|
|
|
AaroniaRTSAInputWorker::AaroniaRTSAInputWorker(SampleSinkFifo* sampleFifo) :
|
2023-03-18 07:48:21 -04:00
|
|
|
QObject(),
|
|
|
|
m_timer(this),
|
|
|
|
m_samplesBuf(),
|
|
|
|
m_sampleFifo(sampleFifo),
|
2023-03-22 12:57:21 -04:00
|
|
|
m_centerFrequency(0),
|
|
|
|
m_sampleRate(1),
|
2023-03-18 07:48:21 -04:00
|
|
|
m_inputMessageQueue(nullptr),
|
2023-03-24 13:26:26 -04:00
|
|
|
m_status(AaroniaRTSAInputSettings::ConnectionIdle),
|
2023-03-22 12:57:21 -04:00
|
|
|
mReply(nullptr),
|
2023-03-18 07:48:21 -04:00
|
|
|
m_convertBuffer(64e6)
|
|
|
|
{
|
2023-03-22 12:57:21 -04:00
|
|
|
// Initialize network managers
|
2023-03-22 20:30:12 -04:00
|
|
|
m_networkAccessManager = new QNetworkAccessManager(this);
|
|
|
|
m_networkAccessManagerConfig = new QNetworkAccessManager(this);
|
|
|
|
QObject::connect(
|
|
|
|
m_networkAccessManagerConfig,
|
|
|
|
&QNetworkAccessManager::finished,
|
|
|
|
this,
|
2023-03-24 13:26:26 -04:00
|
|
|
&AaroniaRTSAInputWorker::handleConfigReply
|
2023-03-22 20:30:12 -04:00
|
|
|
);
|
2023-03-18 07:48:21 -04:00
|
|
|
|
|
|
|
// Request 16bit raw samples
|
2023-03-22 12:57:21 -04:00
|
|
|
// m_serverAddress = "localhost:55123";
|
|
|
|
// QUrl url(tr("http://%1/stream?format=float32").arg(m_serverAddress));
|
2023-03-18 07:48:21 -04:00
|
|
|
|
2023-03-22 12:57:21 -04:00
|
|
|
// QNetworkRequest req(url);
|
2023-03-22 20:30:12 -04:00
|
|
|
// mReply = m_networkAccessManager->get(req);
|
2023-03-18 07:48:21 -04:00
|
|
|
|
2023-03-22 12:57:21 -04:00
|
|
|
// // Connect Qt slots to network events
|
|
|
|
// connect(mReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onError(QNetworkReply::NetworkError)));
|
|
|
|
// connect(mReply, SIGNAL(finished()), this, SLOT(onFinished()));
|
|
|
|
// connect(mReply, SIGNAL(readyRead()), this, SLOT(onReadyRead()));
|
2023-03-18 07:48:21 -04:00
|
|
|
|
|
|
|
mPrevTime = 0;
|
|
|
|
mPacketSamples = 0;
|
|
|
|
}
|
|
|
|
|
2023-03-24 13:26:26 -04:00
|
|
|
AaroniaRTSAInputWorker::~AaroniaRTSAInputWorker()
|
2023-03-22 12:57:21 -04:00
|
|
|
{
|
|
|
|
if (mReply)
|
|
|
|
{
|
|
|
|
// disconnect previous sugnals
|
|
|
|
disconnect(mReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onError(QNetworkReply::NetworkError)));
|
|
|
|
disconnect(mReply, SIGNAL(finished()), this, SLOT(onFinished()));
|
|
|
|
disconnect(mReply, SIGNAL(readyRead()), this, SLOT(onReadyRead()));
|
|
|
|
|
|
|
|
mReply->abort();
|
|
|
|
mReply->deleteLater();
|
|
|
|
}
|
|
|
|
|
2023-03-22 20:30:12 -04:00
|
|
|
m_networkAccessManager->deleteLater();
|
|
|
|
|
|
|
|
QObject::disconnect(
|
|
|
|
m_networkAccessManagerConfig,
|
|
|
|
&QNetworkAccessManager::finished,
|
|
|
|
this,
|
2023-03-24 13:26:26 -04:00
|
|
|
&AaroniaRTSAInputWorker::handleConfigReply
|
2023-03-22 20:30:12 -04:00
|
|
|
);
|
|
|
|
m_networkAccessManagerConfig->deleteLater();
|
2023-03-22 12:57:21 -04:00
|
|
|
}
|
|
|
|
|
2023-03-24 13:26:26 -04:00
|
|
|
void AaroniaRTSAInputWorker::onSocketError(QAbstractSocket::SocketError error)
|
2023-03-18 07:48:21 -04:00
|
|
|
{
|
|
|
|
(void) error;
|
2023-03-24 13:26:26 -04:00
|
|
|
m_status = AaroniaRTSAInputSettings::ConnectionError;
|
2023-03-22 12:57:21 -04:00
|
|
|
emit updateStatus(m_status);
|
2023-03-18 07:48:21 -04:00
|
|
|
}
|
|
|
|
|
2023-03-24 13:26:26 -04:00
|
|
|
void AaroniaRTSAInputWorker::sendCenterFrequencyAndSampleRate()
|
2023-03-18 07:48:21 -04:00
|
|
|
{
|
2023-03-22 20:30:12 -04:00
|
|
|
if (m_iqDemodName.size() == 0) {
|
|
|
|
return;
|
|
|
|
}
|
2023-03-18 07:48:21 -04:00
|
|
|
|
2023-03-24 13:26:26 -04:00
|
|
|
qDebug("AaroniaRTSAInputWorker::sendCenterFrequencyAndSampleRate: %llu samplerate: %d", m_centerFrequency, m_sampleRate);
|
2023-03-22 20:30:12 -04:00
|
|
|
|
|
|
|
QJsonObject object {
|
|
|
|
{"receiverName", m_iqDemodName},
|
|
|
|
{"simpleconfig", QJsonObject({
|
|
|
|
{"main", QJsonObject({
|
|
|
|
{"centerfreq", QJsonValue((qint64) m_centerFrequency)},
|
|
|
|
{"samplerate", QJsonValue(m_sampleRate)},
|
|
|
|
{"spanfreq", QJsonValue(m_sampleRate)},
|
|
|
|
})}
|
|
|
|
})}
|
|
|
|
};
|
|
|
|
|
|
|
|
QJsonDocument document;
|
|
|
|
document.setObject(object);
|
|
|
|
QUrl url(tr("http://%1/remoteconfig").arg(m_serverAddress));
|
|
|
|
QNetworkRequest request(url);
|
|
|
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
|
|
|
m_networkAccessManagerConfig->put(request, document.toJson());
|
|
|
|
}
|
2023-03-18 07:48:21 -04:00
|
|
|
|
2023-03-24 13:26:26 -04:00
|
|
|
void AaroniaRTSAInputWorker::getConfig()
|
2023-03-22 20:30:12 -04:00
|
|
|
{
|
|
|
|
QUrl url(tr("http://%1/remoteconfig").arg(m_serverAddress));
|
|
|
|
QNetworkRequest request(url);
|
|
|
|
m_networkAccessManagerConfig->get(request);
|
2023-03-18 07:48:21 -04:00
|
|
|
}
|
|
|
|
|
2023-03-24 13:26:26 -04:00
|
|
|
void AaroniaRTSAInputWorker::onCenterFrequencyChanged(quint64 centerFrequency)
|
2023-03-18 07:48:21 -04:00
|
|
|
{
|
2023-03-24 02:57:09 -04:00
|
|
|
if (m_centerFrequency == centerFrequency) {
|
2023-03-18 07:48:21 -04:00
|
|
|
return;
|
2023-03-24 02:57:09 -04:00
|
|
|
}
|
2023-03-18 07:48:21 -04:00
|
|
|
|
|
|
|
m_centerFrequency = centerFrequency;
|
2023-03-22 20:30:12 -04:00
|
|
|
sendCenterFrequencyAndSampleRate();
|
2023-03-18 07:48:21 -04:00
|
|
|
}
|
|
|
|
|
2023-03-24 13:26:26 -04:00
|
|
|
void AaroniaRTSAInputWorker::onSampleRateChanged(int sampleRate)
|
2023-03-24 02:57:09 -04:00
|
|
|
{
|
|
|
|
if (m_sampleRate == sampleRate) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_sampleRate = sampleRate;
|
|
|
|
sendCenterFrequencyAndSampleRate();
|
|
|
|
}
|
|
|
|
|
2023-03-24 13:26:26 -04:00
|
|
|
void AaroniaRTSAInputWorker::onServerAddressChanged(QString serverAddress)
|
2023-03-18 07:48:21 -04:00
|
|
|
{
|
2023-03-24 13:26:26 -04:00
|
|
|
m_status = AaroniaRTSAInputSettings::ConnectionDisconnected;
|
2023-03-22 12:57:21 -04:00
|
|
|
updateStatus(m_status);
|
|
|
|
|
|
|
|
if (mReply)
|
|
|
|
{
|
|
|
|
// disconnect previous sugnals
|
|
|
|
disconnect(mReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onError(QNetworkReply::NetworkError)));
|
|
|
|
disconnect(mReply, SIGNAL(finished()), this, SLOT(onFinished()));
|
|
|
|
disconnect(mReply, SIGNAL(readyRead()), this, SLOT(onReadyRead()));
|
|
|
|
|
|
|
|
mReply->abort();
|
|
|
|
mReply->deleteLater();
|
2023-03-18 07:48:21 -04:00
|
|
|
}
|
|
|
|
|
2023-03-22 12:57:21 -04:00
|
|
|
QUrl url(tr("http://%1/stream?format=float32").arg(serverAddress));
|
|
|
|
QNetworkRequest req(url);
|
2023-03-22 20:30:12 -04:00
|
|
|
mReply = m_networkAccessManager->get(req);
|
2023-03-18 07:48:21 -04:00
|
|
|
|
2023-03-22 12:57:21 -04:00
|
|
|
// Connect Qt slots to network events
|
|
|
|
connect(mReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onError(QNetworkReply::NetworkError)));
|
|
|
|
connect(mReply, SIGNAL(finished()), this, SLOT(onFinished()));
|
|
|
|
connect(mReply, SIGNAL(readyRead()), this, SLOT(onReadyRead()));
|
2023-03-18 07:48:21 -04:00
|
|
|
|
2023-03-22 12:57:21 -04:00
|
|
|
mPrevTime = 0;
|
|
|
|
mPacketSamples = 0;
|
|
|
|
m_serverAddress = serverAddress;
|
2023-03-22 20:30:12 -04:00
|
|
|
|
|
|
|
getConfig();
|
2023-03-18 07:48:21 -04:00
|
|
|
}
|
|
|
|
|
2023-03-24 13:26:26 -04:00
|
|
|
void AaroniaRTSAInputWorker::tick()
|
2023-03-18 07:48:21 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************CPY ********************************* */
|
|
|
|
|
2023-03-24 13:26:26 -04:00
|
|
|
void AaroniaRTSAInputWorker::onError(QNetworkReply::NetworkError code)
|
2023-03-18 07:48:21 -04:00
|
|
|
{
|
2023-03-22 12:57:21 -04:00
|
|
|
(void) code;
|
2023-03-24 13:26:26 -04:00
|
|
|
qWarning() << "AaroniaRTSAInputWorker::onError: network Error: " << mReply->errorString();
|
2023-03-22 12:57:21 -04:00
|
|
|
m_status = 3;
|
|
|
|
emit updateStatus(3);
|
2023-03-18 07:48:21 -04:00
|
|
|
}
|
|
|
|
|
2023-03-24 13:26:26 -04:00
|
|
|
void AaroniaRTSAInputWorker::onFinished()
|
2023-03-18 07:48:21 -04:00
|
|
|
{
|
2023-03-24 13:26:26 -04:00
|
|
|
qDebug() << "AaroniaRTSAInputWorker::onFinished(: finished: " << mReply->errorString();
|
2023-03-18 07:48:21 -04:00
|
|
|
mBuffer.append(mReply->readAll());
|
|
|
|
mReply->deleteLater();
|
|
|
|
mReply = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// bytes received from the socket
|
2023-03-24 13:26:26 -04:00
|
|
|
void AaroniaRTSAInputWorker::onReadyRead()
|
2023-03-18 07:48:21 -04:00
|
|
|
{
|
2023-03-24 13:26:26 -04:00
|
|
|
if (m_status != AaroniaRTSAInputSettings::ConnectionOK)
|
2023-03-22 12:57:21 -04:00
|
|
|
{
|
2023-03-24 13:26:26 -04:00
|
|
|
m_status = AaroniaRTSAInputSettings::ConnectionOK;
|
2023-03-22 12:57:21 -04:00
|
|
|
emit updateStatus(m_status);
|
|
|
|
}
|
|
|
|
|
2023-03-18 07:48:21 -04:00
|
|
|
// read as many bytes as possible into input buffer
|
2023-03-19 08:25:06 -04:00
|
|
|
qint64 n = mReply->bytesAvailable();
|
|
|
|
qint64 bs = mBuffer.size();
|
2023-03-18 07:48:21 -04:00
|
|
|
mBuffer.resize(bs + n);
|
2023-03-19 08:25:06 -04:00
|
|
|
qint64 done = mReply->read(mBuffer.data() + bs, n);
|
2023-03-18 07:48:21 -04:00
|
|
|
mBuffer.resize(bs + done);
|
|
|
|
|
|
|
|
// intialize parsing
|
|
|
|
int offset = 0;
|
|
|
|
int avail = mBuffer.size();
|
|
|
|
|
2023-03-19 05:49:18 -04:00
|
|
|
// consume all input data if possible
|
2023-03-18 07:48:21 -04:00
|
|
|
while (offset < avail)
|
|
|
|
{
|
|
|
|
// any samples so far (not looking for meta data)
|
|
|
|
if (mPacketSamples)
|
|
|
|
{
|
|
|
|
// enough samples
|
2023-03-19 08:25:06 -04:00
|
|
|
if (offset + mPacketSamples * 2 * sizeof(float) <= (unsigned long) avail)
|
2023-03-18 07:48:21 -04:00
|
|
|
{
|
|
|
|
// do something with the IQ data
|
2023-03-19 08:25:06 -04:00
|
|
|
const float *sp = (const float *)(mBuffer.constData() + offset);
|
2023-03-18 07:48:21 -04:00
|
|
|
|
|
|
|
SampleVector::iterator it = m_convertBuffer.begin();
|
|
|
|
|
|
|
|
m_decimatorsFloatIQ.decimate1(&it, sp, 2*mPacketSamples);
|
|
|
|
|
|
|
|
/*m_samplesBuf.clear();
|
|
|
|
for (int i = 0; i < mPacketSamples*2; i+=2)
|
|
|
|
{
|
|
|
|
m_samplesBuf.push_back(Sample(
|
|
|
|
sp[i] << (SDR_RX_SAMP_SZ - 8),
|
|
|
|
sp[i+1] << (SDR_RX_SAMP_SZ - 8)
|
|
|
|
));
|
|
|
|
}*/
|
|
|
|
|
|
|
|
//m_sampleFifo->write(m_samplesBuf.begin(), m_samplesBuf.end());
|
|
|
|
m_sampleFifo->write(m_convertBuffer.begin(), it);
|
|
|
|
|
2023-03-22 20:30:12 -04:00
|
|
|
//qDebug() << "IQ " << sp[0] << ", " << sp[1];
|
2023-03-18 07:48:21 -04:00
|
|
|
//m_sampleFifo->write()
|
|
|
|
|
|
|
|
// consume all samples from the input buffer
|
|
|
|
offset += mPacketSamples * 2 * sizeof(float);
|
|
|
|
mPacketSamples = 0;
|
|
|
|
}
|
|
|
|
else
|
2023-03-19 08:25:06 -04:00
|
|
|
{
|
2023-03-18 07:48:21 -04:00
|
|
|
break;
|
2023-03-19 08:25:06 -04:00
|
|
|
}
|
2023-03-18 07:48:21 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// is there a complete JSON metadata object in the buffer
|
|
|
|
int split = mBuffer.indexOf('\x1e', offset);
|
2023-03-19 08:25:06 -04:00
|
|
|
|
|
|
|
if (split != -1)
|
2023-03-18 07:48:21 -04:00
|
|
|
{
|
|
|
|
// Extract it
|
2023-03-19 08:25:06 -04:00
|
|
|
QByteArray data = mBuffer.mid(offset, split - offset);
|
2023-03-18 07:48:21 -04:00
|
|
|
offset = split + 1;
|
|
|
|
|
|
|
|
// Parse the JSON data
|
|
|
|
|
|
|
|
QJsonParseError error;
|
2023-03-19 08:25:06 -04:00
|
|
|
QJsonDocument jdoc = QJsonDocument::fromJson(data, &error);
|
2023-03-18 07:48:21 -04:00
|
|
|
|
|
|
|
if (error.error == QJsonParseError::NoError)
|
|
|
|
{
|
|
|
|
// Extract fields of interest
|
2023-03-24 02:57:09 -04:00
|
|
|
// double startTime = jdoc["startTime"].toDouble(), endTime = jdoc["endTime"].toDouble();
|
2023-03-19 08:25:06 -04:00
|
|
|
int samples = jdoc["samples"].toInt();
|
2023-03-18 07:48:21 -04:00
|
|
|
|
|
|
|
// Dump packet loss
|
2023-03-24 02:57:09 -04:00
|
|
|
// if (startTime != mPrevTime)
|
|
|
|
// {
|
2023-03-24 13:26:26 -04:00
|
|
|
// qDebug() << "AaroniaRTSAInputWorker::onReadyRead: packet loss: "
|
2023-03-24 02:57:09 -04:00
|
|
|
// << QDateTime::fromMSecsSinceEpoch(startTime * 1000).toString()
|
|
|
|
// << " D " << endTime - startTime
|
|
|
|
// << " O " << startTime - mPrevTime
|
|
|
|
// << " S " << samples
|
|
|
|
// << " L " << QDateTime::currentMSecsSinceEpoch() / 1000.0 - startTime;
|
|
|
|
|
2023-03-24 13:26:26 -04:00
|
|
|
// if (m_status != AaroniaRTSAInputSettings::ConnectionUnstable)
|
2023-03-24 02:57:09 -04:00
|
|
|
// {
|
2023-03-24 13:26:26 -04:00
|
|
|
// m_status = AaroniaRTSAInputSettings::ConnectionUnstable;
|
2023-03-24 02:57:09 -04:00
|
|
|
// emit updateStatus(m_status);
|
|
|
|
// }
|
|
|
|
// }
|
2023-03-18 07:48:21 -04:00
|
|
|
|
|
|
|
// Switch to data phase
|
2023-03-24 02:57:09 -04:00
|
|
|
// mPrevTime = endTime;
|
2023-03-18 07:48:21 -04:00
|
|
|
mPacketSamples = samples;
|
2023-03-19 08:25:06 -04:00
|
|
|
// qDebug() << jdoc.toJson();
|
|
|
|
quint64 endFreq = jdoc["endFrequency"].toDouble();
|
|
|
|
quint64 startFreq = jdoc["startFrequency"].toDouble();
|
2023-04-19 05:42:54 -04:00
|
|
|
int bw = jdoc["sampleFrequency"].toInt();
|
2023-03-19 08:25:06 -04:00
|
|
|
quint64 midFreq = (endFreq + startFreq) / 2;
|
|
|
|
|
|
|
|
if ((bw != m_sampleRate) || (midFreq != m_centerFrequency))
|
|
|
|
{
|
|
|
|
if (m_inputMessageQueue)
|
|
|
|
{
|
|
|
|
MsgReportSampleRateAndFrequency *msg = MsgReportSampleRateAndFrequency::create(bw, midFreq);
|
|
|
|
m_inputMessageQueue->push(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2023-03-22 20:30:12 -04:00
|
|
|
|
|
|
|
m_sampleRate = bw;
|
|
|
|
m_centerFrequency = midFreq;
|
2023-03-18 07:48:21 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QTextStream qerr(stderr);
|
|
|
|
qerr << "Json Parse Error: " + error.errorString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2023-03-19 08:25:06 -04:00
|
|
|
{
|
2023-03-18 07:48:21 -04:00
|
|
|
break;
|
2023-03-19 08:25:06 -04:00
|
|
|
}
|
2023-03-18 07:48:21 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove consumed data from the buffer
|
|
|
|
mBuffer.remove(0, offset);
|
|
|
|
}
|
|
|
|
|
2023-03-24 13:26:26 -04:00
|
|
|
void AaroniaRTSAInputWorker::handleConfigReply(QNetworkReply* reply)
|
2023-03-22 20:30:12 -04:00
|
|
|
{
|
|
|
|
if (reply->operation() == QNetworkAccessManager::GetOperation) // return from GET to /remoteconfig
|
|
|
|
{
|
|
|
|
parseConfig(reply->readAll());
|
|
|
|
}
|
|
|
|
else if (reply->operation() == QNetworkAccessManager::PutOperation) // return from PUT to /remoteconfig
|
|
|
|
{
|
|
|
|
int httpStatusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
|
|
|
|
|
|
|
if ((httpStatusCode / 100) == 2) {
|
2023-03-24 13:26:26 -04:00
|
|
|
qDebug("AaroniaRTSAInputWorker::handleConfigReply: remoteconfig OK (%d)", httpStatusCode);
|
2023-03-22 20:30:12 -04:00
|
|
|
} else {
|
2023-03-24 13:26:26 -04:00
|
|
|
qWarning("AaroniaRTSAInputWorker::handleConfigReply: remoteconfig ended with error (%d)", httpStatusCode);
|
2023-03-22 20:30:12 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
reply->deleteLater();
|
|
|
|
}
|
2023-03-18 07:48:21 -04:00
|
|
|
|
2023-03-24 13:26:26 -04:00
|
|
|
void AaroniaRTSAInputWorker::parseConfig(QByteArray bytes)
|
2023-03-22 20:30:12 -04:00
|
|
|
{
|
|
|
|
QJsonDocument document = QJsonDocument::fromJson(bytes);
|
|
|
|
m_iqDemodName = "";
|
|
|
|
|
|
|
|
if (document.isObject())
|
|
|
|
{
|
|
|
|
QJsonObject documentObject = document.object();
|
|
|
|
|
|
|
|
if (documentObject.contains(QStringLiteral("config")))
|
|
|
|
{
|
|
|
|
QJsonObject config = documentObject.value(QStringLiteral("config")).toObject();
|
|
|
|
|
|
|
|
if (config.contains(QStringLiteral("items")))
|
|
|
|
{
|
|
|
|
QJsonArray configItems = config.value(QStringLiteral("items")).toArray();
|
|
|
|
|
|
|
|
for (const auto& configIem : configItems)
|
|
|
|
{
|
|
|
|
QJsonObject configIemObject = configIem.toObject();
|
|
|
|
|
|
|
|
if (configIemObject.contains(QStringLiteral("name")))
|
|
|
|
{
|
|
|
|
QString nameItem = configIemObject.value(QStringLiteral("name")).toString();
|
|
|
|
|
|
|
|
if (nameItem.startsWith("Block_IQDemodulator"))
|
|
|
|
{
|
|
|
|
m_iqDemodName = nameItem;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-03-24 13:26:26 -04:00
|
|
|
qDebug() << "AaroniaRTSAInputWorker::parseConfig: config has no items: " << config;
|
2023-03-22 20:30:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-07-23 10:44:42 -04:00
|
|
|
qDebug() << "AaroniaRTSAInputWorker::parseConfig: document has no config object: " << documentObject;
|
2023-03-22 20:30:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-07-23 10:44:42 -04:00
|
|
|
qDebug() << "AaroniaRTSAInputWorker::parseConfig: document is not an object: " << document;
|
2023-03-22 20:30:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_iqDemodName == "") {
|
2023-03-24 13:26:26 -04:00
|
|
|
qWarning("AaroniaRTSAInputWorker.parseConfig: could not find IQ demdulator");
|
2023-03-22 20:30:12 -04:00
|
|
|
} else {
|
2023-03-24 13:26:26 -04:00
|
|
|
qDebug("AaroniaRTSAInputWorker::parseConfig: IQ demdulator name: %s", qPrintable(m_iqDemodName));
|
2023-03-22 20:30:12 -04:00
|
|
|
}
|
|
|
|
}
|