2016-11-12 20:59:31 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
2019-04-11 00:57:41 -04:00
|
|
|
// (at your option) any later version. //
|
2016-11-12 20:59:31 -05:00
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
2018-12-26 11:35:55 -05:00
|
|
|
|
2016-11-12 20:59:31 -05:00
|
|
|
#include <QDebug>
|
2018-12-26 11:35:55 -05:00
|
|
|
#include <QNetworkReply>
|
|
|
|
#include <QBuffer>
|
2016-11-12 20:59:31 -05:00
|
|
|
|
2017-12-09 06:41:42 -05:00
|
|
|
#include "SWGDeviceSettings.h"
|
|
|
|
#include "SWGDeviceState.h"
|
2018-05-27 05:57:23 -04:00
|
|
|
#include "SWGDeviceReport.h"
|
|
|
|
#include "SWGSDRPlayReport.h"
|
2017-12-09 06:41:42 -05:00
|
|
|
|
2016-11-12 20:59:31 -05:00
|
|
|
#include "util/simpleserializer.h"
|
|
|
|
#include "dsp/dspcommands.h"
|
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "sdrplayinput.h"
|
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
#include <device/deviceapi.h>
|
2016-11-12 20:59:31 -05:00
|
|
|
|
|
|
|
#include "sdrplaythread.h"
|
|
|
|
|
|
|
|
MESSAGE_CLASS_DEFINITION(SDRPlayInput::MsgConfigureSDRPlay, Message)
|
2016-11-17 20:46:35 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(SDRPlayInput::MsgReportSDRPlayGains, Message)
|
2017-12-13 18:19:59 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(SDRPlayInput::MsgStartStop, Message)
|
2016-11-12 20:59:31 -05:00
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
SDRPlayInput::SDRPlayInput(DeviceAPI *deviceAPI) :
|
2016-11-12 20:59:31 -05:00
|
|
|
m_deviceAPI(deviceAPI),
|
2017-12-19 16:46:17 -05:00
|
|
|
m_variant(SDRPlayUndef),
|
2016-11-12 20:59:31 -05:00
|
|
|
m_settings(),
|
2016-11-15 12:58:17 -05:00
|
|
|
m_dev(0),
|
2020-06-21 05:46:08 -04:00
|
|
|
m_sdrPlayThread(nullptr),
|
2016-11-18 22:11:19 -05:00
|
|
|
m_deviceDescription("SDRPlay"),
|
2017-04-13 20:49:41 -04:00
|
|
|
m_devNumber(0),
|
|
|
|
m_running(false)
|
2016-11-12 20:59:31 -05:00
|
|
|
{
|
2022-03-17 16:10:30 -04:00
|
|
|
m_sampleFifo.setLabel(m_deviceDescription);
|
2017-04-13 21:17:04 -04:00
|
|
|
openDevice();
|
2019-05-20 18:27:08 -04:00
|
|
|
m_deviceAPI->setNbSourceStreams(1);
|
2018-12-26 11:35:55 -05:00
|
|
|
|
|
|
|
m_networkManager = new QNetworkAccessManager();
|
2022-03-23 17:32:23 -04:00
|
|
|
QObject::connect(
|
|
|
|
m_networkManager,
|
|
|
|
&QNetworkAccessManager::finished,
|
|
|
|
this,
|
|
|
|
&SDRPlayInput::networkManagerFinished
|
|
|
|
);
|
2016-11-12 20:59:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
SDRPlayInput::~SDRPlayInput()
|
|
|
|
{
|
2022-03-23 17:32:23 -04:00
|
|
|
QObject::disconnect(
|
|
|
|
m_networkManager,
|
|
|
|
&QNetworkAccessManager::finished,
|
|
|
|
this,
|
|
|
|
&SDRPlayInput::networkManagerFinished
|
|
|
|
);
|
2018-12-26 11:35:55 -05:00
|
|
|
delete m_networkManager;
|
|
|
|
|
|
|
|
if (m_running) {
|
|
|
|
stop();
|
|
|
|
}
|
|
|
|
|
2017-04-13 21:17:04 -04:00
|
|
|
closeDevice();
|
2016-11-12 20:59:31 -05:00
|
|
|
}
|
|
|
|
|
2017-09-14 20:32:30 -04:00
|
|
|
void SDRPlayInput::destroy()
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
2017-04-13 21:17:04 -04:00
|
|
|
bool SDRPlayInput::openDevice()
|
2017-04-13 20:49:41 -04:00
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
m_devNumber = m_deviceAPI->getSamplingDeviceSequence();
|
2017-04-13 20:49:41 -04:00
|
|
|
|
2017-04-13 21:17:04 -04:00
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
|
|
|
closeDevice();
|
|
|
|
}
|
2017-04-13 20:49:41 -04:00
|
|
|
|
2017-04-13 21:17:04 -04:00
|
|
|
int res;
|
|
|
|
//int numberOfGains;
|
2017-04-13 20:49:41 -04:00
|
|
|
|
2017-04-13 21:17:04 -04:00
|
|
|
if (!m_sampleFifo.setSize(96000 * 4))
|
|
|
|
{
|
2017-12-19 16:46:17 -05:00
|
|
|
qCritical("SDRPlayInput::openDevice: could not allocate SampleFifo");
|
2017-04-13 21:17:04 -04:00
|
|
|
return false;
|
|
|
|
}
|
2016-11-12 20:59:31 -05:00
|
|
|
|
2022-07-18 09:52:40 -04:00
|
|
|
if ((res = mirisdr_open(&m_dev, m_devNumber)) < 0)
|
2017-04-13 21:17:04 -04:00
|
|
|
{
|
2017-12-19 16:46:17 -05:00
|
|
|
qCritical("SDRPlayInput::openDevice: could not open SDRPlay #%d: %s", m_devNumber, strerror(errno));
|
2017-04-13 21:17:04 -04:00
|
|
|
return false;
|
|
|
|
}
|
2022-10-27 16:22:36 -04:00
|
|
|
|
2022-07-18 09:52:40 -04:00
|
|
|
if ((res = mirisdr_set_hw_flavour(m_dev, MIRISDR_HW_SDRPLAY)) < 0)
|
|
|
|
{
|
|
|
|
qCritical("SDRPlayInput::openDevice: failed to set HW flavour: %s", strerror(errno));
|
|
|
|
return false;
|
|
|
|
}
|
2016-11-18 22:11:19 -05:00
|
|
|
|
2017-04-13 21:17:04 -04:00
|
|
|
char vendor[256];
|
|
|
|
char product[256];
|
|
|
|
char serial[256];
|
2016-11-15 12:58:17 -05:00
|
|
|
|
2017-04-13 21:17:04 -04:00
|
|
|
vendor[0] = '\0';
|
|
|
|
product[0] = '\0';
|
|
|
|
serial[0] = '\0';
|
2016-11-15 12:58:17 -05:00
|
|
|
|
2017-04-13 21:17:04 -04:00
|
|
|
if ((res = mirisdr_get_device_usb_strings(m_devNumber, vendor, product, serial)) < 0)
|
2016-11-12 20:59:31 -05:00
|
|
|
{
|
2017-12-19 16:46:17 -05:00
|
|
|
qCritical("SDRPlayInput::openDevice: error accessing USB device");
|
2017-04-13 21:17:04 -04:00
|
|
|
stop();
|
2016-11-12 20:59:31 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-12-19 16:46:17 -05:00
|
|
|
qWarning("SDRPlayInput::openDevice: %s %s, SN: %s", vendor, product, serial);
|
2017-04-13 21:17:04 -04:00
|
|
|
m_deviceDescription = QString("%1 (SN %2)").arg(product).arg(serial);
|
2016-11-15 12:58:17 -05:00
|
|
|
|
2017-12-19 16:46:17 -05:00
|
|
|
if (QString(product) == "RSP1A") {
|
|
|
|
m_variant = SDRPlayRSP1A;
|
2017-12-20 15:38:56 -05:00
|
|
|
} else if (QString(product) == "RSP2") {
|
|
|
|
m_variant = SDRPlayRSP2;
|
2017-12-19 16:46:17 -05:00
|
|
|
} else {
|
|
|
|
m_variant = SDRPlayRSP1;
|
|
|
|
}
|
|
|
|
|
|
|
|
qDebug("SDRPlayInput::openDevice: m_variant: %d", (int) m_variant);
|
|
|
|
|
2017-04-13 21:17:04 -04:00
|
|
|
return true;
|
|
|
|
}
|
2016-11-15 12:58:17 -05:00
|
|
|
|
2017-04-13 21:40:45 -04:00
|
|
|
bool SDRPlayInput::start()
|
2017-04-13 21:17:04 -04:00
|
|
|
{
|
|
|
|
// QMutexLocker mutexLocker(&m_mutex);
|
|
|
|
int res;
|
2016-11-15 12:58:17 -05:00
|
|
|
|
2017-04-13 21:17:04 -04:00
|
|
|
if (!m_dev) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_running) stop();
|
2016-11-15 12:58:17 -05:00
|
|
|
|
2016-11-15 20:38:21 -05:00
|
|
|
char s12FormatString[] = "336_S16";
|
|
|
|
|
|
|
|
if ((res = mirisdr_set_sample_format(m_dev, s12FormatString))) // sample format S12
|
2016-11-15 12:58:17 -05:00
|
|
|
{
|
|
|
|
qCritical("SDRPlayInput::start: could not set sample format: rc: %d", res);
|
|
|
|
stop();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-11-18 22:11:19 -05:00
|
|
|
int sampleRate = SDRPlaySampleRates::getRate(m_settings.m_devSampleRateIndex);
|
|
|
|
|
|
|
|
if ((res = mirisdr_set_sample_rate(m_dev, sampleRate)))
|
|
|
|
{
|
|
|
|
qCritical("SDRPlayInput::start: could not set sample rate to %d: rc: %d", sampleRate, res);
|
|
|
|
stop();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-11-15 20:38:21 -05:00
|
|
|
char bulkFormatString[] = "BULK";
|
|
|
|
|
|
|
|
if ((res = mirisdr_set_transfer(m_dev, bulkFormatString)) < 0)
|
2016-11-15 12:58:17 -05:00
|
|
|
{
|
|
|
|
qCritical("SDRPlayInput::start: could not set USB Bulk mode: rc: %d", res);
|
|
|
|
stop();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((res = mirisdr_reset_buffer(m_dev)) < 0)
|
|
|
|
{
|
|
|
|
qCritical("SDRPlayInput::start: could not reset USB EP buffers: %s", strerror(errno));
|
|
|
|
stop();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-02-24 04:29:27 -05:00
|
|
|
m_sdrPlayThread = new SDRPlayThread(m_dev, &m_sampleFifo);
|
2017-04-13 20:46:52 -04:00
|
|
|
m_sdrPlayThread->setLog2Decimation(m_settings.m_log2Decim);
|
|
|
|
m_sdrPlayThread->setFcPos((int) m_settings.m_fcPos);
|
2020-06-21 05:46:08 -04:00
|
|
|
m_sdrPlayThread->setIQOrder(m_settings.m_iqOrder);
|
2016-11-15 12:58:17 -05:00
|
|
|
m_sdrPlayThread->startWork();
|
2016-11-12 20:59:31 -05:00
|
|
|
|
2017-04-13 21:17:04 -04:00
|
|
|
// mutexLocker.unlock();
|
2016-11-13 21:23:41 -05:00
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
applySettings(m_settings, QList<QString>(), true, true);
|
2017-04-13 21:17:04 -04:00
|
|
|
m_running = true;
|
2016-11-15 20:38:21 -05:00
|
|
|
|
|
|
|
return true;
|
2016-11-12 20:59:31 -05:00
|
|
|
}
|
|
|
|
|
2017-04-13 21:17:04 -04:00
|
|
|
void SDRPlayInput::closeDevice()
|
|
|
|
{
|
|
|
|
if (m_dev != 0)
|
|
|
|
{
|
|
|
|
mirisdr_close(m_dev);
|
|
|
|
m_dev = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_deviceDescription.clear();
|
|
|
|
}
|
|
|
|
|
2017-12-25 03:10:19 -05:00
|
|
|
void SDRPlayInput::init()
|
|
|
|
{
|
2022-10-27 16:22:36 -04:00
|
|
|
applySettings(m_settings, QList<QString>(), true, true);
|
2017-12-25 03:10:19 -05:00
|
|
|
}
|
|
|
|
|
2016-11-12 20:59:31 -05:00
|
|
|
void SDRPlayInput::stop()
|
|
|
|
{
|
2017-04-13 21:17:04 -04:00
|
|
|
// QMutexLocker mutexLocker(&m_mutex);
|
2016-11-12 20:59:31 -05:00
|
|
|
|
2020-06-21 05:46:08 -04:00
|
|
|
if(m_sdrPlayThread)
|
2016-11-12 20:59:31 -05:00
|
|
|
{
|
|
|
|
m_sdrPlayThread->stopWork();
|
|
|
|
delete m_sdrPlayThread;
|
2020-06-21 05:46:08 -04:00
|
|
|
m_sdrPlayThread = nullptr;
|
2016-11-12 20:59:31 -05:00
|
|
|
}
|
2016-11-15 20:38:21 -05:00
|
|
|
|
2017-04-13 21:17:04 -04:00
|
|
|
m_running = false;
|
2016-11-12 20:59:31 -05:00
|
|
|
}
|
|
|
|
|
2017-12-27 21:21:48 -05:00
|
|
|
QByteArray SDRPlayInput::serialize() const
|
|
|
|
{
|
|
|
|
return m_settings.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SDRPlayInput::deserialize(const QByteArray& data)
|
|
|
|
{
|
|
|
|
bool success = true;
|
|
|
|
|
|
|
|
if (!m_settings.deserialize(data))
|
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
MsgConfigureSDRPlay* message = MsgConfigureSDRPlay::create(m_settings, QList<QString>(), true);
|
2017-12-27 21:21:48 -05:00
|
|
|
m_inputMessageQueue.push(message);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue)
|
|
|
|
{
|
2022-10-27 16:22:36 -04:00
|
|
|
MsgConfigureSDRPlay* messageToGUI = MsgConfigureSDRPlay::create(m_settings, QList<QString>(), true);
|
2017-12-27 21:21:48 -05:00
|
|
|
m_guiMessageQueue->push(messageToGUI);
|
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2016-11-12 20:59:31 -05:00
|
|
|
const QString& SDRPlayInput::getDeviceDescription() const
|
|
|
|
{
|
|
|
|
return m_deviceDescription;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SDRPlayInput::getSampleRate() const
|
|
|
|
{
|
|
|
|
int rate = SDRPlaySampleRates::getRate(m_settings.m_devSampleRateIndex);
|
2016-11-15 20:38:21 -05:00
|
|
|
return rate / (1<<m_settings.m_log2Decim);
|
2016-11-12 20:59:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
quint64 SDRPlayInput::getCenterFrequency() const
|
|
|
|
{
|
|
|
|
return m_settings.m_centerFrequency;
|
|
|
|
}
|
|
|
|
|
2017-12-27 21:21:48 -05:00
|
|
|
void SDRPlayInput::setCenterFrequency(qint64 centerFrequency)
|
|
|
|
{
|
|
|
|
SDRPlaySettings settings = m_settings;
|
|
|
|
settings.m_centerFrequency = centerFrequency;
|
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
MsgConfigureSDRPlay* message = MsgConfigureSDRPlay::create(settings, QList<QString>{"centerFrequency"}, false);
|
2017-12-27 21:21:48 -05:00
|
|
|
m_inputMessageQueue.push(message);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue)
|
|
|
|
{
|
2022-10-27 16:22:36 -04:00
|
|
|
MsgConfigureSDRPlay* messageToGUI = MsgConfigureSDRPlay::create(settings, QList<QString>{"centerFrequency"}, false);
|
2017-12-27 21:21:48 -05:00
|
|
|
m_guiMessageQueue->push(messageToGUI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-12 20:59:31 -05:00
|
|
|
bool SDRPlayInput::handleMessage(const Message& message)
|
|
|
|
{
|
|
|
|
if (MsgConfigureSDRPlay::match(message))
|
|
|
|
{
|
|
|
|
MsgConfigureSDRPlay& conf = (MsgConfigureSDRPlay&) message;
|
|
|
|
qDebug() << "SDRPlayInput::handleMessage: MsgConfigureSDRPlay";
|
|
|
|
|
2016-11-18 22:11:19 -05:00
|
|
|
// change of sample rate needs full stop / start sequence that includes the standard apply settings
|
2016-11-20 05:34:32 -05:00
|
|
|
// only if in started state (iff m_dev != 0)
|
2022-10-27 16:22:36 -04:00
|
|
|
if ((m_dev != 0) && conf.getSettingsKeys().contains("devSampleRateIndex"))
|
2016-11-12 20:59:31 -05:00
|
|
|
{
|
2022-10-27 16:22:36 -04:00
|
|
|
if (conf.getForce()) {
|
|
|
|
m_settings = conf.getSettings();
|
|
|
|
} else {
|
|
|
|
m_settings.applySettings(conf.getSettingsKeys(), conf.getSettings());
|
|
|
|
}
|
|
|
|
|
2016-11-18 22:11:19 -05:00
|
|
|
stop();
|
2017-04-13 21:40:45 -04:00
|
|
|
start();
|
2016-11-18 22:11:19 -05:00
|
|
|
}
|
|
|
|
// standard changes
|
|
|
|
else
|
|
|
|
{
|
2022-10-27 16:22:36 -04:00
|
|
|
if (!applySettings(conf.getSettings(), conf.getSettingsKeys(), false, conf.getForce())) {
|
2016-11-18 22:11:19 -05:00
|
|
|
qDebug("SDRPlayInput::handleMessage: config error");
|
|
|
|
}
|
2016-11-12 20:59:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2017-12-13 18:19:59 -05:00
|
|
|
else if (MsgStartStop::match(message))
|
|
|
|
{
|
|
|
|
MsgStartStop& cmd = (MsgStartStop&) message;
|
|
|
|
qDebug() << "SDRPlayInput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
|
|
|
|
|
|
|
|
if (cmd.getStartStop())
|
|
|
|
{
|
2022-10-27 16:22:36 -04:00
|
|
|
if (m_deviceAPI->initDeviceEngine()) {
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceAPI->startDeviceEngine();
|
2017-12-13 18:19:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceAPI->stopDeviceEngine();
|
2017-12-13 18:19:59 -05:00
|
|
|
}
|
|
|
|
|
2018-12-26 11:35:55 -05:00
|
|
|
if (m_settings.m_useReverseAPI) {
|
|
|
|
webapiReverseSendStartStop(cmd.getStartStop());
|
|
|
|
}
|
|
|
|
|
2017-12-13 18:19:59 -05:00
|
|
|
return true;
|
|
|
|
}
|
2016-11-12 20:59:31 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, const QList<QString>& settingsKeys, bool forwardChange, bool force)
|
2016-11-12 20:59:31 -05:00
|
|
|
{
|
2022-10-27 16:22:36 -04:00
|
|
|
qDebug() << "SDRPlayInput::applySettings: forwardChange: " << forwardChange << " force: " << force << settings.getDebugString(settingsKeys, force);
|
2016-11-17 20:46:35 -05:00
|
|
|
bool forceGainSetting = false;
|
2016-11-12 20:59:31 -05:00
|
|
|
QMutexLocker mutexLocker(&m_mutex);
|
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
if (settingsKeys.contains("dcBlock") || settingsKeys.contains("iqCorrection") || force) {
|
2018-12-26 11:35:55 -05:00
|
|
|
m_deviceAPI->configureCorrections(settings.m_dcBlock, settings.m_iqCorrection);
|
2016-11-12 20:59:31 -05:00
|
|
|
}
|
|
|
|
|
2016-11-17 22:36:12 -05:00
|
|
|
// gains processing
|
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
if (settingsKeys.contains("tunerGainMode") || force) {
|
2016-11-17 20:46:35 -05:00
|
|
|
forceGainSetting = true;
|
|
|
|
}
|
2016-11-12 20:59:31 -05:00
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
bool tunerGainMode = settingsKeys.contains("tunerGainMode") ?
|
|
|
|
settings.m_tunerGainMode :
|
|
|
|
m_settings.m_tunerGainMode;
|
|
|
|
uint32_t frequencyBandIndex = settingsKeys.contains("frequencyBandIndex") ?
|
|
|
|
settings.m_frequencyBandIndex :
|
|
|
|
m_settings.m_frequencyBandIndex;
|
2018-12-26 11:35:55 -05:00
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
if (tunerGainMode) // auto
|
2016-11-17 20:46:35 -05:00
|
|
|
{
|
2022-10-27 16:22:36 -04:00
|
|
|
if (settingsKeys.contains("tunerGain") || forceGainSetting)
|
2016-11-17 20:46:35 -05:00
|
|
|
{
|
2022-10-27 16:22:36 -04:00
|
|
|
if (m_dev != 0)
|
2016-11-17 20:46:35 -05:00
|
|
|
{
|
2018-12-26 11:35:55 -05:00
|
|
|
int r = mirisdr_set_tuner_gain(m_dev, settings.m_tunerGain);
|
2016-11-17 20:46:35 -05:00
|
|
|
|
|
|
|
if (r < 0)
|
|
|
|
{
|
|
|
|
qDebug("SDRPlayInput::applySettings: could not set tuner gain");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-11-19 17:25:57 -05:00
|
|
|
int lnaGain;
|
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
if (frequencyBandIndex < 3) { // bands using AM mode
|
2016-11-19 17:25:57 -05:00
|
|
|
lnaGain = mirisdr_get_mixbuffer_gain(m_dev);
|
2022-10-27 16:22:36 -04:00
|
|
|
} else {
|
2016-11-19 17:25:57 -05:00
|
|
|
lnaGain = mirisdr_get_lna_gain(m_dev);
|
|
|
|
}
|
|
|
|
|
2016-11-17 20:46:35 -05:00
|
|
|
MsgReportSDRPlayGains *message = MsgReportSDRPlayGains::create(
|
2016-11-19 17:25:57 -05:00
|
|
|
lnaGain,
|
2016-11-17 20:46:35 -05:00
|
|
|
mirisdr_get_mixer_gain(m_dev),
|
|
|
|
mirisdr_get_baseband_gain(m_dev),
|
|
|
|
mirisdr_get_tuner_gain(m_dev)
|
|
|
|
);
|
2016-11-19 17:25:57 -05:00
|
|
|
|
2017-09-16 19:23:54 -04:00
|
|
|
if (getMessageQueueToGUI()) {
|
|
|
|
getMessageQueueToGUI()->push(message);
|
|
|
|
}
|
2016-11-17 20:46:35 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-11-19 17:25:57 -05:00
|
|
|
else // manual
|
2016-11-17 20:46:35 -05:00
|
|
|
{
|
|
|
|
bool anyChange = false;
|
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
if (settingsKeys.contains("lnaOn") || forceGainSetting)
|
2016-11-12 20:59:31 -05:00
|
|
|
{
|
2018-12-26 11:35:55 -05:00
|
|
|
if (m_dev != 0)
|
2016-11-17 20:46:35 -05:00
|
|
|
{
|
2022-10-27 16:22:36 -04:00
|
|
|
if (frequencyBandIndex < 3) // bands using AM mode
|
2016-11-17 20:46:35 -05:00
|
|
|
{
|
2016-11-19 17:25:57 -05:00
|
|
|
int r = mirisdr_set_mixbuffer_gain(m_dev, settings.m_lnaOn ? 0 : 1); // mirisdr_set_mixbuffer_gain takes gain reduction
|
|
|
|
|
2018-12-26 11:35:55 -05:00
|
|
|
if (r != 0) {
|
2016-11-19 17:25:57 -05:00
|
|
|
qDebug("SDRPlayInput::applySettings: could not set mixer buffer gain");
|
2018-12-26 11:35:55 -05:00
|
|
|
} else {
|
2016-11-19 17:25:57 -05:00
|
|
|
anyChange = true;
|
|
|
|
}
|
2016-11-17 20:46:35 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-11-19 17:25:57 -05:00
|
|
|
int r = mirisdr_set_lna_gain(m_dev, settings.m_lnaOn ? 0 : 1); // mirisdr_set_lna_gain takes gain reduction
|
|
|
|
|
2018-12-26 11:35:55 -05:00
|
|
|
if (r != 0) {
|
2016-11-19 17:25:57 -05:00
|
|
|
qDebug("SDRPlayInput::applySettings: could not set LNA gain");
|
2018-12-26 11:35:55 -05:00
|
|
|
} else {
|
2016-11-19 17:25:57 -05:00
|
|
|
anyChange = true;
|
|
|
|
}
|
2016-11-17 20:46:35 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-11-15 20:38:21 -05:00
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
if (settingsKeys.contains("mixerAmpOn") || forceGainSetting)
|
2016-11-17 20:46:35 -05:00
|
|
|
{
|
2018-12-26 11:35:55 -05:00
|
|
|
if (m_dev != 0)
|
2016-11-15 20:38:21 -05:00
|
|
|
{
|
2016-11-17 20:46:35 -05:00
|
|
|
int r = mirisdr_set_mixer_gain(m_dev, settings.m_mixerAmpOn ? 0 : 1); // mirisdr_set_lna_gain takes gain reduction
|
|
|
|
|
2018-12-26 11:35:55 -05:00
|
|
|
if (r != 0) {
|
2016-11-17 20:46:35 -05:00
|
|
|
qDebug("SDRPlayInput::applySettings: could not set mixer gain");
|
2018-12-26 11:35:55 -05:00
|
|
|
} else {
|
2016-11-17 20:46:35 -05:00
|
|
|
anyChange = true;
|
|
|
|
}
|
2016-11-15 20:38:21 -05:00
|
|
|
}
|
2016-11-12 20:59:31 -05:00
|
|
|
}
|
2016-11-17 20:46:35 -05:00
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
if (settingsKeys.contains("basebandGain") || forceGainSetting)
|
2016-11-17 20:46:35 -05:00
|
|
|
{
|
2018-12-26 11:35:55 -05:00
|
|
|
if (m_dev != 0)
|
2016-11-17 20:46:35 -05:00
|
|
|
{
|
|
|
|
int r = mirisdr_set_baseband_gain(m_dev, settings.m_basebandGain);
|
|
|
|
|
2018-12-26 11:35:55 -05:00
|
|
|
if (r != 0) {
|
2016-11-17 20:46:35 -05:00
|
|
|
qDebug("SDRPlayInput::applySettings: could not set mixer gain");
|
2018-12-26 11:35:55 -05:00
|
|
|
} else {
|
2016-11-17 20:46:35 -05:00
|
|
|
anyChange = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (anyChange)
|
|
|
|
{
|
2016-11-19 17:25:57 -05:00
|
|
|
int lnaGain;
|
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
if (frequencyBandIndex < 3) { // bands using AM mode
|
2016-11-19 17:25:57 -05:00
|
|
|
lnaGain = mirisdr_get_mixbuffer_gain(m_dev);
|
2018-12-26 11:35:55 -05:00
|
|
|
} else {
|
2017-05-25 14:13:34 -04:00
|
|
|
lnaGain = mirisdr_get_lna_gain(m_dev);
|
2016-11-19 17:25:57 -05:00
|
|
|
}
|
|
|
|
|
2016-11-17 20:46:35 -05:00
|
|
|
MsgReportSDRPlayGains *message = MsgReportSDRPlayGains::create(
|
2016-11-19 17:25:57 -05:00
|
|
|
lnaGain,
|
2016-11-17 20:46:35 -05:00
|
|
|
mirisdr_get_mixer_gain(m_dev),
|
|
|
|
mirisdr_get_baseband_gain(m_dev),
|
|
|
|
mirisdr_get_tuner_gain(m_dev)
|
|
|
|
);
|
2017-09-16 19:23:54 -04:00
|
|
|
|
|
|
|
if (getMessageQueueToGUI()) {
|
|
|
|
getMessageQueueToGUI()->push(message);
|
|
|
|
}
|
2016-11-17 20:46:35 -05:00
|
|
|
}
|
2016-11-12 20:59:31 -05:00
|
|
|
}
|
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
if (settingsKeys.contains("log2Decim") || force)
|
2016-11-13 18:38:43 -05:00
|
|
|
{
|
2020-06-21 05:46:08 -04:00
|
|
|
if (m_sdrPlayThread)
|
2016-11-13 18:38:43 -05:00
|
|
|
{
|
2018-12-26 11:35:55 -05:00
|
|
|
m_sdrPlayThread->setLog2Decimation(settings.m_log2Decim);
|
2018-01-19 21:28:30 -05:00
|
|
|
qDebug() << "SDRPlayInput::applySettings: set decimation to " << (1<<settings.m_log2Decim);
|
2016-11-13 18:38:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
if (settingsKeys.contains("fcPos") || force)
|
2016-11-13 18:38:43 -05:00
|
|
|
{
|
2020-06-21 05:46:08 -04:00
|
|
|
if (m_sdrPlayThread)
|
2018-01-19 21:28:30 -05:00
|
|
|
{
|
2018-12-26 11:35:55 -05:00
|
|
|
m_sdrPlayThread->setFcPos((int) settings.m_fcPos);
|
2018-01-19 21:28:30 -05:00
|
|
|
qDebug() << "SDRPlayInput: set fc pos (enum) to " << (int) settings.m_fcPos;
|
|
|
|
}
|
2016-11-13 18:38:43 -05:00
|
|
|
}
|
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
if (settingsKeys.contains("iqOrder") || force)
|
2020-06-21 05:46:08 -04:00
|
|
|
{
|
|
|
|
if (m_sdrPlayThread)
|
|
|
|
{
|
|
|
|
m_sdrPlayThread->setIQOrder((int) settings.m_iqOrder);
|
|
|
|
qDebug() << "SDRPlayInput: set IQ order to " << (settings.m_iqOrder ? "IQ" : "QI");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
if (settingsKeys.contains("centerFrequency")
|
|
|
|
|| settingsKeys.contains("LOppmTenths")
|
|
|
|
|| settingsKeys.contains("fcPos")
|
|
|
|
|| settingsKeys.contains("log2Decim") || force)
|
2016-11-13 18:38:43 -05:00
|
|
|
{
|
2018-05-10 09:14:43 -04:00
|
|
|
qint64 deviceCenterFrequency = DeviceSampleSource::calculateDeviceCenterFrequency(
|
|
|
|
settings.m_centerFrequency,
|
|
|
|
0,
|
|
|
|
settings.m_log2Decim,
|
|
|
|
(DeviceSampleSource::fcPos_t) settings.m_fcPos,
|
2019-04-01 19:10:03 -04:00
|
|
|
SDRPlaySampleRates::getRate(settings.m_devSampleRateIndex),
|
|
|
|
DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD,
|
|
|
|
false);
|
2018-01-19 21:28:30 -05:00
|
|
|
|
|
|
|
forwardChange = true;
|
2016-11-13 18:38:43 -05:00
|
|
|
|
2016-11-15 20:38:21 -05:00
|
|
|
if(m_dev != 0)
|
|
|
|
{
|
2018-05-10 09:14:43 -04:00
|
|
|
if (setDeviceCenterFrequency(deviceCenterFrequency)) {
|
2018-12-26 11:35:55 -05:00
|
|
|
qDebug() << "SDRPlayInput::applySettings: center freq: " << settings.m_centerFrequency << " Hz";
|
2016-11-13 18:38:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
if (settingsKeys.contains("bandwidthIndex") || force)
|
2016-11-15 20:38:21 -05:00
|
|
|
{
|
|
|
|
int bandwidth = SDRPlayBandwidths::getBandwidth(settings.m_bandwidthIndex);
|
|
|
|
int r = mirisdr_set_bandwidth(m_dev, bandwidth);
|
2016-11-13 18:38:43 -05:00
|
|
|
|
2018-12-26 11:35:55 -05:00
|
|
|
if (r < 0) {
|
2016-11-15 20:38:21 -05:00
|
|
|
qCritical("SDRPlayInput::applySettings: set bandwidth %d failed: rc: %d", bandwidth, r);
|
2018-12-26 11:35:55 -05:00
|
|
|
} else {
|
2016-11-15 20:38:21 -05:00
|
|
|
qDebug("SDRPlayInput::applySettings: bandwidth set to %d", bandwidth);
|
2016-11-13 18:38:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
if (settingsKeys.contains("ifFrequencyIndex") || force)
|
2016-11-13 18:38:43 -05:00
|
|
|
{
|
2016-11-15 20:38:21 -05:00
|
|
|
int iFFrequency = SDRPlayIF::getIF(settings.m_ifFrequencyIndex);
|
|
|
|
int r = mirisdr_set_if_freq(m_dev, iFFrequency);
|
2016-11-13 18:38:43 -05:00
|
|
|
|
2018-12-26 11:35:55 -05:00
|
|
|
if (r < 0) {
|
2016-11-15 20:38:21 -05:00
|
|
|
qCritical("SDRPlayInput::applySettings: set IF frequency to %d failed: rc: %d", iFFrequency, r);
|
2018-12-26 11:35:55 -05:00
|
|
|
} else {
|
2016-11-15 20:38:21 -05:00
|
|
|
qDebug("SDRPlayInput::applySettings: IF frequency set to %d", iFFrequency);
|
2016-11-13 18:38:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
if (settingsKeys.contains("useReverseAPI"))
|
2018-12-26 11:35:55 -05:00
|
|
|
{
|
2022-10-27 16:22:36 -04:00
|
|
|
bool fullUpdate = (settingsKeys.contains("useReverseAPI") && settings.m_useReverseAPI) ||
|
|
|
|
settingsKeys.contains("reverseAPIAddress") ||
|
|
|
|
settingsKeys.contains("reverseAPIPort") ||
|
|
|
|
settingsKeys.contains("reverseAPIDeviceIndex");
|
|
|
|
webapiReverseSendSettings(settingsKeys, settings, fullUpdate || force);
|
2018-12-26 11:35:55 -05:00
|
|
|
}
|
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
if (force) {
|
|
|
|
m_settings = settings;
|
|
|
|
} else {
|
|
|
|
m_settings.applySettings(settingsKeys, settings);
|
|
|
|
}
|
2018-12-26 11:35:55 -05:00
|
|
|
|
2016-11-12 20:59:31 -05:00
|
|
|
if (forwardChange)
|
|
|
|
{
|
|
|
|
int sampleRate = getSampleRate();
|
|
|
|
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, m_settings.m_centerFrequency);
|
2017-09-13 17:40:06 -04:00
|
|
|
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
2016-11-12 20:59:31 -05:00
|
|
|
}
|
2016-11-13 18:38:43 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-12-27 21:21:48 -05:00
|
|
|
bool SDRPlayInput::setDeviceCenterFrequency(quint64 freq_hz)
|
2016-11-13 18:38:43 -05:00
|
|
|
{
|
2016-11-15 20:38:21 -05:00
|
|
|
qint64 df = ((qint64)freq_hz * m_settings.m_LOppmTenths) / 10000000LL;
|
|
|
|
freq_hz += df;
|
|
|
|
|
|
|
|
int r = mirisdr_set_center_freq(m_dev, static_cast<uint32_t>(freq_hz));
|
|
|
|
|
|
|
|
if (r != 0)
|
2016-11-13 18:38:43 -05:00
|
|
|
{
|
2017-12-27 21:21:48 -05:00
|
|
|
qWarning("SDRPlayInput::setDeviceCenterFrequency: could not frequency to %llu Hz", freq_hz);
|
2016-11-15 20:38:21 -05:00
|
|
|
return false;
|
2016-11-13 18:38:43 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-27 21:21:48 -05:00
|
|
|
qWarning("SDRPlayInput::setDeviceCenterFrequency: frequency set to %llu Hz", freq_hz);
|
2016-11-15 20:38:21 -05:00
|
|
|
return true;
|
2016-11-13 18:38:43 -05:00
|
|
|
}
|
2016-11-12 20:59:31 -05:00
|
|
|
}
|
|
|
|
|
2017-12-09 06:41:42 -05:00
|
|
|
int SDRPlayInput::webapiRunGet(
|
|
|
|
SWGSDRangel::SWGDeviceState& response,
|
2018-11-13 02:51:14 -05:00
|
|
|
QString& errorMessage)
|
2017-12-09 06:41:42 -05:00
|
|
|
{
|
2018-11-13 02:51:14 -05:00
|
|
|
(void) errorMessage;
|
2017-12-09 06:41:42 -05:00
|
|
|
m_deviceAPI->getDeviceEngineStateStr(*response.getState());
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SDRPlayInput::webapiRun(
|
|
|
|
bool run,
|
|
|
|
SWGSDRangel::SWGDeviceState& response,
|
2018-11-13 02:51:14 -05:00
|
|
|
QString& errorMessage)
|
2017-12-09 06:41:42 -05:00
|
|
|
{
|
2018-11-13 02:51:14 -05:00
|
|
|
(void) errorMessage;
|
2017-12-14 17:29:12 -05:00
|
|
|
m_deviceAPI->getDeviceEngineStateStr(*response.getState());
|
2017-12-13 18:19:59 -05:00
|
|
|
MsgStartStop *message = MsgStartStop::create(run);
|
|
|
|
m_inputMessageQueue.push(message);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue) // forward to GUI if any
|
2017-12-09 06:41:42 -05:00
|
|
|
{
|
2017-12-13 18:19:59 -05:00
|
|
|
MsgStartStop *msgToGUI = MsgStartStop::create(run);
|
|
|
|
m_guiMessageQueue->push(msgToGUI);
|
2017-12-09 06:41:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return 200;
|
|
|
|
}
|
2016-11-15 20:38:21 -05:00
|
|
|
|
2018-05-27 14:15:55 -04:00
|
|
|
int SDRPlayInput::webapiSettingsGet(
|
|
|
|
SWGSDRangel::SWGDeviceSettings& response,
|
2018-11-13 02:51:14 -05:00
|
|
|
QString& errorMessage)
|
2018-05-27 14:15:55 -04:00
|
|
|
{
|
2018-11-13 02:51:14 -05:00
|
|
|
(void) errorMessage;
|
2018-05-27 14:15:55 -04:00
|
|
|
response.setSdrPlaySettings(new SWGSDRangel::SWGSDRPlaySettings());
|
|
|
|
response.getSdrPlaySettings()->init();
|
|
|
|
webapiFormatDeviceSettings(response, m_settings);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SDRPlayInput::webapiSettingsPutPatch(
|
|
|
|
bool force,
|
|
|
|
const QStringList& deviceSettingsKeys,
|
|
|
|
SWGSDRangel::SWGDeviceSettings& response, // query + response
|
2018-11-13 02:51:14 -05:00
|
|
|
QString& errorMessage)
|
2018-05-27 14:15:55 -04:00
|
|
|
{
|
2018-11-13 02:51:14 -05:00
|
|
|
(void) errorMessage;
|
2018-05-27 14:15:55 -04:00
|
|
|
SDRPlaySettings settings = m_settings;
|
2019-08-04 14:24:44 -04:00
|
|
|
webapiUpdateDeviceSettings(settings, deviceSettingsKeys, response);
|
2018-05-27 14:15:55 -04:00
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
MsgConfigureSDRPlay *msg = MsgConfigureSDRPlay::create(settings, deviceSettingsKeys, force);
|
2019-08-04 14:24:44 -04:00
|
|
|
m_inputMessageQueue.push(msg);
|
|
|
|
|
|
|
|
if (m_guiMessageQueue) // forward to GUI if any
|
|
|
|
{
|
2022-10-27 16:22:36 -04:00
|
|
|
MsgConfigureSDRPlay *msgToGUI = MsgConfigureSDRPlay::create(settings, deviceSettingsKeys, force);
|
2019-08-04 14:24:44 -04:00
|
|
|
m_guiMessageQueue->push(msgToGUI);
|
|
|
|
}
|
|
|
|
|
|
|
|
webapiFormatDeviceSettings(response, settings);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SDRPlayInput::webapiUpdateDeviceSettings(
|
|
|
|
SDRPlaySettings& settings,
|
|
|
|
const QStringList& deviceSettingsKeys,
|
|
|
|
SWGSDRangel::SWGDeviceSettings& response)
|
|
|
|
{
|
2018-05-27 14:15:55 -04:00
|
|
|
if (deviceSettingsKeys.contains("centerFrequency")) {
|
|
|
|
settings.m_centerFrequency = response.getSdrPlaySettings()->getCenterFrequency();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("tunerGain")) {
|
|
|
|
settings.m_tunerGain = response.getSdrPlaySettings()->getTunerGain();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("LOppmTenths")) {
|
|
|
|
settings.m_LOppmTenths = response.getSdrPlaySettings()->getLOppmTenths();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("frequencyBandIndex")) {
|
|
|
|
settings.m_frequencyBandIndex = response.getSdrPlaySettings()->getFrequencyBandIndex();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("ifFrequencyIndex")) {
|
|
|
|
settings.m_ifFrequencyIndex = response.getSdrPlaySettings()->getIfFrequencyIndex();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("bandwidthIndex")) {
|
|
|
|
settings.m_bandwidthIndex = response.getSdrPlaySettings()->getBandwidthIndex();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("devSampleRateIndex")) {
|
|
|
|
settings.m_devSampleRateIndex = response.getSdrPlaySettings()->getDevSampleRateIndex();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("log2Decim")) {
|
|
|
|
settings.m_log2Decim = response.getSdrPlaySettings()->getLog2Decim();
|
|
|
|
}
|
2020-06-21 20:10:35 -04:00
|
|
|
if (deviceSettingsKeys.contains("iqOrder")) {
|
|
|
|
settings.m_iqOrder = response.getSdrPlaySettings()->getIqOrder() != 0;
|
|
|
|
}
|
2018-05-27 14:15:55 -04:00
|
|
|
if (deviceSettingsKeys.contains("fcPos"))
|
|
|
|
{
|
|
|
|
int fcPos = response.getSdrPlaySettings()->getFcPos();
|
|
|
|
fcPos = fcPos < 0 ? 0 : fcPos > 2 ? 2 : fcPos;
|
|
|
|
settings.m_fcPos = (SDRPlaySettings::fcPos_t) fcPos;
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("dcBlock")) {
|
|
|
|
settings.m_dcBlock = response.getSdrPlaySettings()->getDcBlock() != 0;
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("iqCorrection")) {
|
|
|
|
settings.m_iqCorrection = response.getSdrPlaySettings()->getIqCorrection() != 0;
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("tunerGainMode")) {
|
|
|
|
settings.m_tunerGainMode = response.getSdrPlaySettings()->getTunerGainMode() != 0;
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("lnaOn")) {
|
|
|
|
settings.m_lnaOn = response.getSdrPlaySettings()->getLnaOn() != 0;
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("mixerAmpOn")) {
|
|
|
|
settings.m_mixerAmpOn = response.getSdrPlaySettings()->getMixerAmpOn() != 0;
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("basebandGain")) {
|
|
|
|
settings.m_basebandGain = response.getSdrPlaySettings()->getBasebandGain();
|
|
|
|
}
|
2019-01-11 08:45:00 -05:00
|
|
|
if (deviceSettingsKeys.contains("useReverseAPI")) {
|
|
|
|
settings.m_useReverseAPI = response.getSdrPlaySettings()->getUseReverseApi() != 0;
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("reverseAPIAddress")) {
|
|
|
|
settings.m_reverseAPIAddress = *response.getSdrPlaySettings()->getReverseApiAddress();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("reverseAPIPort")) {
|
|
|
|
settings.m_reverseAPIPort = response.getSdrPlaySettings()->getReverseApiPort();
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
|
|
|
|
settings.m_reverseAPIDeviceIndex = response.getSdrPlaySettings()->getReverseApiDeviceIndex();
|
2018-05-27 14:15:55 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SDRPlayInput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const SDRPlaySettings& settings)
|
|
|
|
{
|
|
|
|
response.getSdrPlaySettings()->setCenterFrequency(settings.m_centerFrequency);
|
|
|
|
response.getSdrPlaySettings()->setTunerGain(settings.m_tunerGain);
|
|
|
|
response.getSdrPlaySettings()->setLOppmTenths(settings.m_LOppmTenths);
|
|
|
|
response.getSdrPlaySettings()->setFrequencyBandIndex(settings.m_frequencyBandIndex);
|
|
|
|
response.getSdrPlaySettings()->setIfFrequencyIndex(settings.m_ifFrequencyIndex);
|
|
|
|
response.getSdrPlaySettings()->setBandwidthIndex(settings.m_bandwidthIndex);
|
|
|
|
response.getSdrPlaySettings()->setDevSampleRateIndex(settings.m_devSampleRateIndex);
|
|
|
|
response.getSdrPlaySettings()->setLog2Decim(settings.m_log2Decim);
|
2020-06-21 20:10:35 -04:00
|
|
|
response.getSdrPlaySettings()->setIqOrder(settings.m_iqOrder ? 1 : 0);
|
2018-05-27 14:15:55 -04:00
|
|
|
response.getSdrPlaySettings()->setFcPos((int) settings.m_fcPos);
|
|
|
|
response.getSdrPlaySettings()->setDcBlock(settings.m_dcBlock ? 1 : 0);
|
|
|
|
response.getSdrPlaySettings()->setIqCorrection(settings.m_iqCorrection ? 1 : 0);
|
|
|
|
response.getSdrPlaySettings()->setTunerGainMode((int) settings.m_tunerGainMode);
|
|
|
|
response.getSdrPlaySettings()->setLnaOn(settings.m_lnaOn ? 1 : 0);
|
|
|
|
response.getSdrPlaySettings()->setMixerAmpOn(settings.m_mixerAmpOn ? 1 : 0);
|
|
|
|
response.getSdrPlaySettings()->setBasebandGain(settings.m_basebandGain);
|
|
|
|
|
2019-01-11 08:45:00 -05:00
|
|
|
response.getSdrPlaySettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
|
|
|
|
|
|
|
|
if (response.getSdrPlaySettings()->getReverseApiAddress()) {
|
|
|
|
*response.getSdrPlaySettings()->getReverseApiAddress() = settings.m_reverseAPIAddress;
|
|
|
|
} else {
|
|
|
|
response.getSdrPlaySettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
|
|
|
|
}
|
|
|
|
|
|
|
|
response.getSdrPlaySettings()->setReverseApiPort(settings.m_reverseAPIPort);
|
|
|
|
response.getSdrPlaySettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
|
2018-05-27 14:15:55 -04:00
|
|
|
}
|
|
|
|
|
2018-05-27 05:57:23 -04:00
|
|
|
int SDRPlayInput::webapiReportGet(
|
|
|
|
SWGSDRangel::SWGDeviceReport& response,
|
2018-11-13 02:51:14 -05:00
|
|
|
QString& errorMessage)
|
2018-05-27 05:57:23 -04:00
|
|
|
{
|
2018-11-13 02:51:14 -05:00
|
|
|
(void) errorMessage;
|
2018-05-27 05:57:23 -04:00
|
|
|
response.setSdrPlayReport(new SWGSDRangel::SWGSDRPlayReport());
|
|
|
|
response.getSdrPlayReport()->init();
|
|
|
|
webapiFormatDeviceReport(response);
|
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SDRPlayInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response)
|
|
|
|
{
|
2018-05-27 13:54:33 -04:00
|
|
|
response.getSdrPlayReport()->setSampleRates(new QList<SWGSDRangel::SWGSampleRate*>);
|
2018-05-27 05:57:23 -04:00
|
|
|
|
|
|
|
for (unsigned int i = 0; i < SDRPlaySampleRates::getNbRates(); i++)
|
|
|
|
{
|
2018-05-27 13:54:33 -04:00
|
|
|
response.getSdrPlayReport()->getSampleRates()->append(new SWGSDRangel::SWGSampleRate);
|
|
|
|
response.getSdrPlayReport()->getSampleRates()->back()->setRate(SDRPlaySampleRates::getRate(i));
|
2018-05-27 05:57:23 -04:00
|
|
|
}
|
|
|
|
|
2018-05-27 13:54:33 -04:00
|
|
|
response.getSdrPlayReport()->setIntermediateFrequencies(new QList<SWGSDRangel::SWGFrequency*>);
|
2018-05-27 05:57:23 -04:00
|
|
|
|
|
|
|
for (unsigned int i = 0; i < SDRPlayIF::getNbIFs(); i++)
|
|
|
|
{
|
2018-05-27 13:54:33 -04:00
|
|
|
response.getSdrPlayReport()->getIntermediateFrequencies()->append(new SWGSDRangel::SWGFrequency);
|
|
|
|
response.getSdrPlayReport()->getIntermediateFrequencies()->back()->setFrequency(SDRPlayIF::getIF(i));
|
2018-05-27 05:57:23 -04:00
|
|
|
}
|
|
|
|
|
2018-05-27 13:54:33 -04:00
|
|
|
response.getSdrPlayReport()->setBandwidths(new QList<SWGSDRangel::SWGBandwidth*>);
|
2018-05-27 05:57:23 -04:00
|
|
|
|
|
|
|
for (unsigned int i = 0; i < SDRPlayBandwidths::getNbBandwidths(); i++)
|
|
|
|
{
|
2018-05-27 13:54:33 -04:00
|
|
|
response.getSdrPlayReport()->getBandwidths()->append(new SWGSDRangel::SWGBandwidth);
|
2018-05-27 05:57:23 -04:00
|
|
|
response.getSdrPlayReport()->getBandwidths()->back()->setBandwidth(SDRPlayBandwidths::getBandwidth(i));
|
|
|
|
}
|
|
|
|
|
2018-05-27 13:54:33 -04:00
|
|
|
response.getSdrPlayReport()->setFrequencyBands(new QList<SWGSDRangel::SWGFrequencyBand*>);
|
2018-05-27 05:57:23 -04:00
|
|
|
|
|
|
|
for (unsigned int i = 0; i < SDRPlayBands::getNbBands(); i++)
|
|
|
|
{
|
2018-05-27 13:54:33 -04:00
|
|
|
response.getSdrPlayReport()->getFrequencyBands()->append(new SWGSDRangel::SWGFrequencyBand);
|
|
|
|
response.getSdrPlayReport()->getFrequencyBands()->back()->setName(new QString(SDRPlayBands::getBandName(i)));
|
2021-11-27 06:10:44 -05:00
|
|
|
response.getSdrPlayReport()->getFrequencyBands()->back()->setLowerBound(SDRPlayBands::getBandLow(i) * 1000);
|
|
|
|
response.getSdrPlayReport()->getFrequencyBands()->back()->setHigherBound(SDRPlayBands::getBandHigh(i) * 1000);
|
2018-05-27 05:57:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-27 16:22:36 -04:00
|
|
|
void SDRPlayInput::webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const SDRPlaySettings& settings, bool force)
|
2018-12-26 11:35:55 -05:00
|
|
|
{
|
|
|
|
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
2019-05-07 08:43:38 -04:00
|
|
|
swgDeviceSettings->setDirection(0); // single Rx
|
2019-03-25 08:41:38 -04:00
|
|
|
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
|
2018-12-26 11:35:55 -05:00
|
|
|
swgDeviceSettings->setDeviceHwType(new QString("SDRplay1"));
|
|
|
|
swgDeviceSettings->setSdrPlaySettings(new SWGSDRangel::SWGSDRPlaySettings());
|
|
|
|
SWGSDRangel::SWGSDRPlaySettings *swgSDRPlaySettings = swgDeviceSettings->getSdrPlaySettings();
|
|
|
|
|
|
|
|
// transfer data that has been modified. When force is on transfer all data except reverse API data
|
|
|
|
|
|
|
|
if (deviceSettingsKeys.contains("centerFrequency") || force) {
|
|
|
|
swgSDRPlaySettings->setCenterFrequency(settings.m_centerFrequency);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("tunerGain") || force) {
|
|
|
|
swgSDRPlaySettings->setTunerGain(settings.m_tunerGain);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("LOppmTenths") || force) {
|
|
|
|
swgSDRPlaySettings->setLOppmTenths(settings.m_LOppmTenths);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("frequencyBandIndex") || force) {
|
|
|
|
swgSDRPlaySettings->setFrequencyBandIndex(settings.m_frequencyBandIndex);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("ifFrequencyIndex") || force) {
|
|
|
|
swgSDRPlaySettings->setIfFrequencyIndex(settings.m_ifFrequencyIndex);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("bandwidthIndex") || force) {
|
|
|
|
swgSDRPlaySettings->setBandwidthIndex(settings.m_bandwidthIndex);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("devSampleRateIndex") || force) {
|
|
|
|
swgSDRPlaySettings->setDevSampleRateIndex(settings.m_devSampleRateIndex);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("log2Decim") || force) {
|
|
|
|
swgSDRPlaySettings->setLog2Decim(settings.m_log2Decim);
|
|
|
|
}
|
2020-06-21 20:10:35 -04:00
|
|
|
if (deviceSettingsKeys.contains("iqOrder") || force) {
|
|
|
|
swgSDRPlaySettings->setIqOrder(settings.m_iqOrder);
|
|
|
|
}
|
2018-12-26 11:35:55 -05:00
|
|
|
if (deviceSettingsKeys.contains("fcPos") || force) {
|
|
|
|
swgSDRPlaySettings->setFcPos((int) settings.m_fcPos);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("dcBlock") || force) {
|
|
|
|
swgSDRPlaySettings->setDcBlock(settings.m_dcBlock ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("iqCorrection") || force) {
|
|
|
|
swgSDRPlaySettings->setIqCorrection(settings.m_iqCorrection ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("tunerGainMode") || force) {
|
|
|
|
swgSDRPlaySettings->setTunerGainMode(settings.m_tunerGainMode ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("lnaOn") || force) {
|
|
|
|
swgSDRPlaySettings->setLnaOn(settings.m_lnaOn ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("mixerAmpOn") || force) {
|
|
|
|
swgSDRPlaySettings->setMixerAmpOn(settings.m_mixerAmpOn ? 1 : 0);
|
|
|
|
}
|
|
|
|
if (deviceSettingsKeys.contains("basebandGain") || force) {
|
|
|
|
swgSDRPlaySettings->setBasebandGain(settings.m_basebandGain);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/settings")
|
|
|
|
.arg(settings.m_reverseAPIAddress)
|
|
|
|
.arg(settings.m_reverseAPIPort)
|
|
|
|
.arg(settings.m_reverseAPIDeviceIndex);
|
|
|
|
m_networkRequest.setUrl(QUrl(deviceSettingsURL));
|
|
|
|
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
|
|
|
|
2019-11-12 12:46:21 -05:00
|
|
|
QBuffer *buffer = new QBuffer();
|
2018-12-26 11:35:55 -05:00
|
|
|
buffer->open((QBuffer::ReadWrite));
|
|
|
|
buffer->write(swgDeviceSettings->asJson().toUtf8());
|
|
|
|
buffer->seek(0);
|
|
|
|
|
|
|
|
// Always use PATCH to avoid passing reverse API settings
|
2019-11-12 12:46:21 -05:00
|
|
|
QNetworkReply *reply = m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
|
|
|
|
buffer->setParent(reply);
|
2018-12-26 11:35:55 -05:00
|
|
|
|
|
|
|
delete swgDeviceSettings;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SDRPlayInput::webapiReverseSendStartStop(bool start)
|
|
|
|
{
|
2019-03-25 10:21:17 -04:00
|
|
|
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
2019-05-07 08:43:38 -04:00
|
|
|
swgDeviceSettings->setDirection(0); // single Rx
|
2019-03-25 10:21:17 -04:00
|
|
|
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
|
|
|
|
swgDeviceSettings->setDeviceHwType(new QString("SDRplay1"));
|
|
|
|
|
2018-12-26 11:35:55 -05:00
|
|
|
QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
|
|
|
|
.arg(m_settings.m_reverseAPIAddress)
|
|
|
|
.arg(m_settings.m_reverseAPIPort)
|
|
|
|
.arg(m_settings.m_reverseAPIDeviceIndex);
|
|
|
|
m_networkRequest.setUrl(QUrl(deviceSettingsURL));
|
2019-03-25 10:21:17 -04:00
|
|
|
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
|
|
|
|
2019-11-12 12:46:21 -05:00
|
|
|
QBuffer *buffer = new QBuffer();
|
2019-03-25 10:21:17 -04:00
|
|
|
buffer->open((QBuffer::ReadWrite));
|
|
|
|
buffer->write(swgDeviceSettings->asJson().toUtf8());
|
|
|
|
buffer->seek(0);
|
2019-11-12 12:46:21 -05:00
|
|
|
QNetworkReply *reply;
|
2018-12-26 11:35:55 -05:00
|
|
|
|
|
|
|
if (start) {
|
2019-11-12 12:46:21 -05:00
|
|
|
reply = m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
|
2018-12-26 11:35:55 -05:00
|
|
|
} else {
|
2019-11-12 12:46:21 -05:00
|
|
|
reply = m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
|
2018-12-26 11:35:55 -05:00
|
|
|
}
|
2019-06-14 10:58:09 -04:00
|
|
|
|
2019-11-12 12:46:21 -05:00
|
|
|
buffer->setParent(reply);
|
2019-06-14 10:58:09 -04:00
|
|
|
delete swgDeviceSettings;
|
2018-12-26 11:35:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void SDRPlayInput::networkManagerFinished(QNetworkReply *reply)
|
|
|
|
{
|
|
|
|
QNetworkReply::NetworkError replyError = reply->error();
|
|
|
|
|
|
|
|
if (replyError)
|
|
|
|
{
|
|
|
|
qWarning() << "SDRPlayInput::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("SDRPlayInput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
|
2018-12-26 11:35:55 -05:00
|
|
|
}
|
|
|
|
|
2019-11-12 12:46:21 -05:00
|
|
|
reply->deleteLater();
|
2018-12-26 11:35:55 -05:00
|
|
|
}
|
|
|
|
|
2018-05-27 05:57:23 -04:00
|
|
|
// ====================================================================
|
|
|
|
|
|
|
|
unsigned int SDRPlaySampleRates::m_rates[m_nb_rates] = {
|
|
|
|
1536000, // 0
|
|
|
|
1792000, // 1
|
|
|
|
2000000, // 2
|
|
|
|
2048000, // 3
|
|
|
|
2304000, // 4
|
|
|
|
2400000, // 5
|
|
|
|
3072000, // 6
|
|
|
|
3200000, // 7
|
|
|
|
4000000, // 8
|
|
|
|
4096000, // 9
|
|
|
|
4608000, // 10
|
|
|
|
4800000, // 11
|
|
|
|
5000000, // 12
|
|
|
|
6000000, // 13
|
|
|
|
6144000, // 14
|
|
|
|
6400000, // 15
|
|
|
|
8000000, // 16
|
|
|
|
8192000, // 17
|
|
|
|
};
|
|
|
|
|
|
|
|
unsigned int SDRPlaySampleRates::getRate(unsigned int rate_index)
|
|
|
|
{
|
|
|
|
if (rate_index < m_nb_rates)
|
|
|
|
{
|
|
|
|
return m_rates[rate_index];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return m_rates[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int SDRPlaySampleRates::getRateIndex(unsigned int rate)
|
|
|
|
{
|
|
|
|
for (unsigned int i=0; i < m_nb_rates; i++)
|
|
|
|
{
|
|
|
|
if (rate == m_rates[i])
|
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int SDRPlaySampleRates::getNbRates()
|
|
|
|
{
|
|
|
|
return SDRPlaySampleRates::m_nb_rates;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ====================================================================
|
|
|
|
|
|
|
|
unsigned int SDRPlayBandwidths::m_bw[m_nb_bw] = {
|
|
|
|
200000, // 0
|
|
|
|
300000, // 1
|
|
|
|
600000, // 2
|
|
|
|
1536000, // 3
|
|
|
|
5000000, // 4
|
|
|
|
6000000, // 5
|
|
|
|
7000000, // 6
|
|
|
|
8000000, // 7
|
|
|
|
};
|
|
|
|
|
|
|
|
unsigned int SDRPlayBandwidths::getBandwidth(unsigned int bandwidth_index)
|
|
|
|
{
|
|
|
|
if (bandwidth_index < m_nb_bw)
|
|
|
|
{
|
|
|
|
return m_bw[bandwidth_index];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return m_bw[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int SDRPlayBandwidths::getBandwidthIndex(unsigned int bandwidth)
|
|
|
|
{
|
|
|
|
for (unsigned int i=0; i < m_nb_bw; i++)
|
|
|
|
{
|
|
|
|
if (bandwidth == m_bw[i])
|
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int SDRPlayBandwidths::getNbBandwidths()
|
|
|
|
{
|
|
|
|
return SDRPlayBandwidths::m_nb_bw;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ====================================================================
|
|
|
|
|
|
|
|
unsigned int SDRPlayIF::m_if[m_nb_if] = {
|
|
|
|
0, // 0
|
|
|
|
450000, // 1
|
|
|
|
1620000, // 2
|
|
|
|
2048000, // 3
|
|
|
|
};
|
|
|
|
|
|
|
|
unsigned int SDRPlayIF::getIF(unsigned int if_index)
|
|
|
|
{
|
|
|
|
if (if_index < m_nb_if)
|
|
|
|
{
|
|
|
|
return m_if[if_index];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return m_if[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int SDRPlayIF::getIFIndex(unsigned int iff)
|
|
|
|
{
|
|
|
|
for (unsigned int i=0; i < m_nb_if; i++)
|
|
|
|
{
|
|
|
|
if (iff == m_if[i])
|
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int SDRPlayIF::getNbIFs()
|
|
|
|
{
|
|
|
|
return SDRPlayIF::m_nb_if;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ====================================================================
|
|
|
|
|
|
|
|
/** Lower frequency bound in kHz inclusive */
|
|
|
|
unsigned int SDRPlayBands::m_bandLow[m_nb_bands] = {
|
|
|
|
10, // 0
|
|
|
|
12000, // 1
|
|
|
|
30000, // 2
|
|
|
|
50000, // 3
|
|
|
|
120000, // 4
|
|
|
|
250000, // 5
|
|
|
|
380000, // 6
|
|
|
|
1000000, // 7
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Lower frequency bound in kHz exclusive */
|
|
|
|
unsigned int SDRPlayBands::m_bandHigh[m_nb_bands] = {
|
|
|
|
12000, // 0
|
|
|
|
30000, // 1
|
|
|
|
50000, // 2
|
|
|
|
120000, // 3
|
|
|
|
250000, // 4
|
|
|
|
380000, // 5
|
|
|
|
1000000, // 6
|
|
|
|
2000000, // 7
|
|
|
|
};
|
|
|
|
|
|
|
|
const char* SDRPlayBands::m_bandName[m_nb_bands] = {
|
|
|
|
"10k-12M", // 0
|
|
|
|
"12-30M", // 1
|
|
|
|
"30-50M", // 2
|
|
|
|
"50-120M", // 3
|
|
|
|
"120-250M", // 4
|
|
|
|
"250-380M", // 5
|
|
|
|
"380M-1G", // 6
|
|
|
|
"1-2G", // 7
|
|
|
|
};
|
|
|
|
|
|
|
|
QString SDRPlayBands::getBandName(unsigned int band_index)
|
|
|
|
{
|
|
|
|
if (band_index < m_nb_bands)
|
|
|
|
{
|
|
|
|
return QString(m_bandName[band_index]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return QString(m_bandName[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int SDRPlayBands::getBandLow(unsigned int band_index)
|
|
|
|
{
|
|
|
|
if (band_index < m_nb_bands)
|
|
|
|
{
|
|
|
|
return m_bandLow[band_index];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return m_bandLow[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int SDRPlayBands::getBandHigh(unsigned int band_index)
|
|
|
|
{
|
|
|
|
if (band_index < m_nb_bands)
|
|
|
|
{
|
|
|
|
return m_bandHigh[band_index];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return m_bandHigh[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int SDRPlayBands::getNbBands()
|
|
|
|
{
|
|
|
|
return SDRPlayBands::m_nb_bands;
|
|
|
|
}
|
|
|
|
|