1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-12-01 04:13:36 -05:00

LoRa modulator: basic modulator

This commit is contained in:
f4exb 2020-02-10 08:45:55 +01:00
parent e9174178a2
commit c264b0913e
35 changed files with 3937 additions and 2 deletions

View File

@ -1,6 +1,7 @@
project(mod)
add_subdirectory(modam)
add_subdirectory(modlora)
add_subdirectory(modnfm)
add_subdirectory(modssb)
add_subdirectory(modwfm)

View File

@ -0,0 +1,59 @@
project(modlora)
set(modlora_SOURCES
loramod.cpp
loramodsettings.cpp
loramodsource.cpp
loramodbaseband.cpp
loramodplugin.cpp
loramodwebapiadapter.cpp
)
set(modlora_HEADERS
loramod.h
loramodsettings.h
loramodsource.h
loramodbaseband.h
loramodplugin.h
loramodwebapiadapter.h
)
include_directories(
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
)
if(NOT SERVER_MODE)
set(modlora_SOURCES
${modlora_SOURCES}
loramodgui.cpp
loramodgui.ui
)
set(modlora_HEADERS
${modlora_HEADERS}
loramodgui.h
)
set(TARGET_NAME modlora)
set(TARGET_LIB "Qt5::Widgets")
set(TARGET_LIB_GUI "sdrgui")
set(INSTALL_FOLDER ${INSTALL_PLUGINS_DIR})
else()
set(TARGET_NAME modlorasrv)
set(TARGET_LIB "")
set(TARGET_LIB_GUI "")
set(INSTALL_FOLDER ${INSTALL_PLUGINSSRV_DIR})
endif()
add_library(${TARGET_NAME} SHARED
${modlora_SOURCES}
)
target_link_libraries(${TARGET_NAME}
Qt5::Core
${TARGET_LIB}
sdrbase
${TARGET_LIB_GUI}
swagger
)
install(TARGETS ${TARGET_NAME} DESTINATION ${INSTALL_FOLDER})

View File

@ -0,0 +1,408 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 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 //
// (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>
#include <QNetworkReply>
#include <QBuffer>
#include <QThread>
#include "SWGChannelSettings.h"
#include "SWGChannelReport.h"
#include "SWGLoRaModReport.h"
#include <stdio.h>
#include <complex.h>
#include <algorithm>
#include "dsp/dspengine.h"
#include "dsp/dspcommands.h"
#include "device/deviceapi.h"
#include "util/db.h"
#include "loramodbaseband.h"
#include "loramod.h"
MESSAGE_CLASS_DEFINITION(LoRaMod::MsgConfigureLoRaMod, Message)
const QString LoRaMod::m_channelIdURI = "sdrangel.channeltx.modlora";
const QString LoRaMod::m_channelId = "LoRaMod";
LoRaMod::LoRaMod(DeviceAPI *deviceAPI) :
ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSource),
m_deviceAPI(deviceAPI),
m_settingsMutex(QMutex::Recursive),
m_sampleRate(48000)
{
setObjectName(m_channelId);
m_thread = new QThread(this);
m_basebandSource = new LoRaModBaseband();
m_basebandSource->moveToThread(m_thread);
applySettings(m_settings, true);
m_deviceAPI->addChannelSource(this);
m_deviceAPI->addChannelSourceAPI(this);
m_networkManager = new QNetworkAccessManager();
connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
}
LoRaMod::~LoRaMod()
{
disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
delete m_networkManager;
m_deviceAPI->removeChannelSourceAPI(this);
m_deviceAPI->removeChannelSource(this);
delete m_basebandSource;
delete m_thread;
}
void LoRaMod::start()
{
qDebug("LoRaMod::start");
m_basebandSource->reset();
m_thread->start();
}
void LoRaMod::stop()
{
qDebug("LoRaMod::stop");
m_thread->exit();
m_thread->wait();
}
void LoRaMod::pull(SampleVector::iterator& begin, unsigned int nbSamples)
{
m_basebandSource->pull(begin, nbSamples);
}
bool LoRaMod::handleMessage(const Message& cmd)
{
if (MsgConfigureLoRaMod::match(cmd))
{
MsgConfigureLoRaMod& cfg = (MsgConfigureLoRaMod&) cmd;
qDebug() << "LoRaMod::handleMessage: MsgConfigureLoRaMod";
applySettings(cfg.getSettings(), cfg.getForce());
return true;
}
else if (DSPSignalNotification::match(cmd))
{
// Forward to the source
DSPSignalNotification& notif = (DSPSignalNotification&) cmd;
DSPSignalNotification* rep = new DSPSignalNotification(notif); // make a copy
qDebug() << "LoRaMod::handleMessage: DSPSignalNotification";
m_basebandSource->getInputMessageQueue()->push(rep);
// Forward to the GUI
if (getMessageQueueToGUI())
{
DSPSignalNotification* repToGUI = new DSPSignalNotification(notif); // make a copy
getMessageQueueToGUI()->push(repToGUI);
}
return true;
}
else
{
return false;
}
}
void LoRaMod::applySettings(const LoRaModSettings& settings, bool force)
{
qDebug() << "NFMMod::applySettings:"
<< " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset
<< " m_rfBandwidth: " << settings.m_bandwidthIndex
<< " bandwidth: " << LoRaModSettings::bandwidths[settings.m_bandwidthIndex]
<< " m_channelMute: " << settings.m_channelMute
<< " 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");
}
if ((settings.m_bandwidthIndex != m_settings.m_bandwidthIndex) || force) {
reverseAPIKeys.append("bandwidthIndex");
}
if ((settings.m_channelMute != m_settings.m_channelMute) || force) {
reverseAPIKeys.append("channelMute");
}
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");
}
LoRaModBaseband::MsgConfigureLoRaModBaseband *msg = LoRaModBaseband::MsgConfigureLoRaModBaseband::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);
}
m_settings = settings;
}
QByteArray LoRaMod::serialize() const
{
return m_settings.serialize();
}
bool LoRaMod::deserialize(const QByteArray& data)
{
bool success = true;
if (!m_settings.deserialize(data))
{
m_settings.resetToDefaults();
success = false;
}
MsgConfigureLoRaMod *msg = MsgConfigureLoRaMod::create(m_settings, true);
m_inputMessageQueue.push(msg);
return success;
}
int LoRaMod::webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage)
{
(void) errorMessage;
response.setLoRaModSettings(new SWGSDRangel::SWGLoRaModSettings());
response.getLoRaModSettings()->init();
webapiFormatChannelSettings(response, m_settings);
return 200;
}
int LoRaMod::webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage)
{
(void) errorMessage;
LoRaModSettings settings = m_settings;
webapiUpdateChannelSettings(settings, channelSettingsKeys, response);
MsgConfigureLoRaMod *msg = MsgConfigureLoRaMod::create(settings, force);
m_inputMessageQueue.push(msg);
if (m_guiMessageQueue) // forward to GUI if any
{
MsgConfigureLoRaMod *msgToGUI = MsgConfigureLoRaMod::create(settings, force);
m_guiMessageQueue->push(msgToGUI);
}
webapiFormatChannelSettings(response, settings);
return 200;
}
void LoRaMod::webapiUpdateChannelSettings(
LoRaModSettings& settings,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response)
{
if (channelSettingsKeys.contains("channelMute")) {
settings.m_channelMute = response.getLoRaModSettings()->getChannelMute() != 0;
}
if (channelSettingsKeys.contains("inputFrequencyOffset")) {
settings.m_inputFrequencyOffset = response.getLoRaModSettings()->getInputFrequencyOffset();
}
if (channelSettingsKeys.contains("bandwidthIndex")) {
settings.m_bandwidthIndex = response.getLoRaModSettings()->getBandwidthIndex();
}
if (channelSettingsKeys.contains("rgbColor")) {
settings.m_rgbColor = response.getLoRaModSettings()->getRgbColor();
}
if (channelSettingsKeys.contains("title")) {
settings.m_title = *response.getLoRaModSettings()->getTitle();
}
if (channelSettingsKeys.contains("streamIndex")) {
settings.m_streamIndex = response.getLoRaModSettings()->getStreamIndex();
}
if (channelSettingsKeys.contains("useReverseAPI")) {
settings.m_useReverseAPI = response.getLoRaModSettings()->getUseReverseApi() != 0;
}
if (channelSettingsKeys.contains("reverseAPIAddress")) {
settings.m_reverseAPIAddress = *response.getLoRaModSettings()->getReverseApiAddress();
}
if (channelSettingsKeys.contains("reverseAPIPort")) {
settings.m_reverseAPIPort = response.getLoRaModSettings()->getReverseApiPort();
}
if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
settings.m_reverseAPIDeviceIndex = response.getLoRaModSettings()->getReverseApiDeviceIndex();
}
if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
settings.m_reverseAPIChannelIndex = response.getLoRaModSettings()->getReverseApiChannelIndex();
}
}
int LoRaMod::webapiReportGet(
SWGSDRangel::SWGChannelReport& response,
QString& errorMessage)
{
(void) errorMessage;
response.setLoRaModReport(new SWGSDRangel::SWGLoRaModReport());
response.getLoRaModReport()->init();
webapiFormatChannelReport(response);
return 200;
}
void LoRaMod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const LoRaModSettings& settings)
{
response.getLoRaModSettings()->setChannelMute(settings.m_channelMute ? 1 : 0);
response.getLoRaModSettings()->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
response.getLoRaModSettings()->setBandwidthIndex(settings.m_bandwidthIndex);
response.getLoRaModSettings()->setRgbColor(settings.m_rgbColor);
if (response.getLoRaModSettings()->getTitle()) {
*response.getLoRaModSettings()->getTitle() = settings.m_title;
} else {
response.getLoRaModSettings()->setTitle(new QString(settings.m_title));
}
response.getLoRaModSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
if (response.getLoRaModSettings()->getReverseApiAddress()) {
*response.getLoRaModSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress;
} else {
response.getLoRaModSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
}
response.getLoRaModSettings()->setReverseApiPort(settings.m_reverseAPIPort);
response.getLoRaModSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
response.getLoRaModSettings()->setReverseApiChannelIndex(settings.m_reverseAPIChannelIndex);
}
void LoRaMod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response)
{
response.getLoRaModReport()->setChannelPowerDb(CalcDb::dbPower(getMagSq()));
response.getLoRaModReport()->setChannelSampleRate(m_basebandSource->getChannelSampleRate());
}
void LoRaMod::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const LoRaModSettings& settings, bool force)
{
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
swgChannelSettings->setDirection(1); // single source (Tx)
swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet());
swgChannelSettings->setOriginatorDeviceSetIndex(getDeviceSetIndex());
swgChannelSettings->setChannelType(new QString("NFMMod"));
swgChannelSettings->setLoRaModSettings(new SWGSDRangel::SWGLoRaModSettings());
SWGSDRangel::SWGLoRaModSettings *swgLoRaModSettings = swgChannelSettings->getLoRaModSettings();
// transfer data that has been modified. When force is on transfer all data except reverse API data
if (channelSettingsKeys.contains("channelMute") || force) {
swgLoRaModSettings->setChannelMute(settings.m_channelMute ? 1 : 0);
}
if (channelSettingsKeys.contains("inputFrequencyOffset") || force) {
swgLoRaModSettings->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
}
if (channelSettingsKeys.contains("bandwidthIndex") || force) {
swgLoRaModSettings->setBandwidthIndex(settings.m_bandwidthIndex);
}
if (channelSettingsKeys.contains("rgbColor") || force) {
swgLoRaModSettings->setRgbColor(settings.m_rgbColor);
}
if (channelSettingsKeys.contains("title") || force) {
swgLoRaModSettings->setTitle(new QString(settings.m_title));
}
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;
}
void LoRaMod::networkManagerFinished(QNetworkReply *reply)
{
QNetworkReply::NetworkError replyError = reply->error();
if (replyError)
{
qWarning() << "LoRaMod::networkManagerFinished:"
<< " error(" << (int) replyError
<< "): " << replyError
<< ": " << reply->errorString();
}
else
{
QString answer = reply->readAll();
answer.chop(1); // remove last \n
qDebug("LoRaMod::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
}
reply->deleteLater();
}
double LoRaMod::getMagSq() const
{
return m_basebandSource->getMagSq();
}
void LoRaMod::setLevelMeter(QObject *levelMeter)
{
connect(m_basebandSource, SIGNAL(levelChanged(qreal, qreal, int)), levelMeter, SLOT(levelChanged(qreal, qreal, int)));
}
uint32_t LoRaMod::getNumberOfDeviceStreams() const
{
return m_deviceAPI->getNbSinkStreams();
}

View File

@ -0,0 +1,150 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 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 //
// (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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef PLUGINS_CHANNELTX_MODLORA_LORAMOD_H_
#define PLUGINS_CHANNELTX_MODLORA_LORAMOD_H_
#include <vector>
#include <iostream>
#include <fstream>
#include <QMutex>
#include <QNetworkRequest>
#include "dsp/basebandsamplesource.h"
#include "channel/channelapi.h"
#include "util/message.h"
#include "loramodsettings.h"
class QNetworkAccessManager;
class QNetworkReply;
class QThread;
class DeviceAPI;
class CWKeyer;
class LoRaModBaseband;
class LoRaMod : public BasebandSampleSource, public ChannelAPI {
Q_OBJECT
public:
class MsgConfigureLoRaMod : public Message {
MESSAGE_CLASS_DECLARATION
public:
const LoRaModSettings& getSettings() const { return m_settings; }
bool getForce() const { return m_force; }
static MsgConfigureLoRaMod* create(const LoRaModSettings& settings, bool force)
{
return new MsgConfigureLoRaMod(settings, force);
}
private:
LoRaModSettings m_settings;
bool m_force;
MsgConfigureLoRaMod(const LoRaModSettings& settings, bool force) :
Message(),
m_settings(settings),
m_force(force)
{ }
};
//=================================================================
LoRaMod(DeviceAPI *deviceAPI);
~LoRaMod();
virtual void destroy() { delete this; }
virtual void start();
virtual void stop();
virtual void pull(SampleVector::iterator& begin, unsigned int nbSamples);
virtual bool handleMessage(const Message& cmd);
virtual void getIdentifier(QString& id) { id = objectName(); }
virtual void getTitle(QString& title) { title = m_settings.m_title; }
virtual qint64 getCenterFrequency() const { return m_settings.m_inputFrequencyOffset; }
virtual QByteArray serialize() const;
virtual bool deserialize(const QByteArray& data);
virtual int getNbSinkStreams() const { return 1; }
virtual int getNbSourceStreams() const { return 0; }
virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const
{
(void) streamIndex;
(void) sinkElseSource;
return m_settings.m_inputFrequencyOffset;
}
virtual int webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
virtual int webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
virtual int webapiReportGet(
SWGSDRangel::SWGChannelReport& response,
QString& errorMessage);
static void webapiFormatChannelSettings(
SWGSDRangel::SWGChannelSettings& response,
const LoRaModSettings& settings);
static void webapiUpdateChannelSettings(
LoRaModSettings& settings,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response);
double getMagSq() const;
CWKeyer *getCWKeyer();
void setLevelMeter(QObject *levelMeter);
uint32_t getNumberOfDeviceStreams() const;
static const QString m_channelIdURI;
static const QString m_channelId;
private:
DeviceAPI* m_deviceAPI;
QThread *m_thread;
LoRaModBaseband* m_basebandSource;
LoRaModSettings m_settings;
SampleVector m_sampleBuffer;
QMutex m_settingsMutex;
int m_sampleRate;
QNetworkAccessManager *m_networkManager;
QNetworkRequest m_networkRequest;
void applySettings(const LoRaModSettings& settings, bool force = false);
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response);
void webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const LoRaModSettings& settings, bool force);
private slots:
void networkManagerFinished(QNetworkReply *reply);
};
#endif /* PLUGINS_CHANNELTX_MODLORA_LORAMOD_H_ */

View File

@ -0,0 +1,191 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 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 //
// (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 <QDebug>
#include "dsp/upchannelizer.h"
#include "dsp/dspengine.h"
#include "dsp/dspcommands.h"
#include "loramodbaseband.h"
MESSAGE_CLASS_DEFINITION(LoRaModBaseband::MsgConfigureLoRaModBaseband, Message)
LoRaModBaseband::LoRaModBaseband() :
m_mutex(QMutex::Recursive)
{
m_sampleFifo.resize(SampleSourceFifo::getSizePolicy(48000));
m_channelizer = new UpChannelizer(&m_source);
qDebug("LoRaModBaseband::LoRaModBaseband");
QObject::connect(
&m_sampleFifo,
&SampleSourceFifo::dataRead,
this,
&LoRaModBaseband::handleData,
Qt::QueuedConnection
);
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
}
LoRaModBaseband::~LoRaModBaseband()
{
delete m_channelizer;
}
void LoRaModBaseband::reset()
{
QMutexLocker mutexLocker(&m_mutex);
m_sampleFifo.reset();
}
void LoRaModBaseband::pull(const SampleVector::iterator& begin, unsigned int nbSamples)
{
unsigned int part1Begin, part1End, part2Begin, part2End;
m_sampleFifo.read(nbSamples, part1Begin, part1End, part2Begin, part2End);
SampleVector& data = m_sampleFifo.getData();
if (part1Begin != part1End)
{
std::copy(
data.begin() + part1Begin,
data.begin() + part1End,
begin
);
}
unsigned int shift = part1End - part1Begin;
if (part2Begin != part2End)
{
std::copy(
data.begin() + part2Begin,
data.begin() + part2End,
begin + shift
);
}
}
void LoRaModBaseband::handleData()
{
QMutexLocker mutexLocker(&m_mutex);
SampleVector& data = m_sampleFifo.getData();
unsigned int ipart1begin;
unsigned int ipart1end;
unsigned int ipart2begin;
unsigned int ipart2end;
qreal rmsLevel, peakLevel;
int numSamples;
unsigned int remainder = m_sampleFifo.remainder();
while ((remainder > 0) && (m_inputMessageQueue.size() == 0))
{
m_sampleFifo.write(remainder, ipart1begin, ipart1end, ipart2begin, ipart2end);
if (ipart1begin != ipart1end) { // first part of FIFO data
processFifo(data, ipart1begin, ipart1end);
}
if (ipart2begin != ipart2end) { // second part of FIFO data (used when block wraps around)
processFifo(data, ipart2begin, ipart2end);
}
remainder = m_sampleFifo.remainder();
}
m_source.getLevels(rmsLevel, peakLevel, numSamples);
emit levelChanged(rmsLevel, peakLevel, numSamples);
}
void LoRaModBaseband::processFifo(SampleVector& data, unsigned int iBegin, unsigned int iEnd)
{
m_channelizer->pull(data.begin() + iBegin, iEnd - iBegin);
}
void LoRaModBaseband::handleInputMessages()
{
Message* message;
while ((message = m_inputMessageQueue.pop()) != nullptr)
{
if (handleMessage(*message)) {
delete message;
}
}
}
bool LoRaModBaseband::handleMessage(const Message& cmd)
{
if (MsgConfigureLoRaModBaseband::match(cmd))
{
QMutexLocker mutexLocker(&m_mutex);
MsgConfigureLoRaModBaseband& cfg = (MsgConfigureLoRaModBaseband&) cmd;
qDebug() << "LoRaModBaseband::handleMessage: MsgConfigureLoRaModBaseband";
applySettings(cfg.getSettings(), cfg.getForce());
return true;
}
else if (DSPSignalNotification::match(cmd))
{
QMutexLocker mutexLocker(&m_mutex);
DSPSignalNotification& notif = (DSPSignalNotification&) cmd;
qDebug() << "LoRaModBaseband::handleMessage: DSPSignalNotification: basebandSampleRate: " << notif.getSampleRate();
m_sampleFifo.resize(SampleSourceFifo::getSizePolicy(notif.getSampleRate()));
m_channelizer->setBasebandSampleRate(notif.getSampleRate());
m_source.applyChannelSettings(
m_channelizer->getChannelSampleRate(),
LoRaModSettings::bandwidths[m_settings.m_bandwidthIndex],
m_channelizer->getChannelFrequencyOffset()
);
return true;
}
else
{
return false;
}
}
void LoRaModBaseband::applySettings(const LoRaModSettings& settings, bool force)
{
if ((settings.m_bandwidthIndex != m_settings.m_bandwidthIndex)
|| (settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force)
{
int thisBW = LoRaModSettings::bandwidths[settings.m_bandwidthIndex];
m_channelizer->setChannelization(
thisBW * LoRaModSettings::oversampling,
settings.m_inputFrequencyOffset
);
m_source.applyChannelSettings(
m_channelizer->getChannelSampleRate(),
thisBW,
m_channelizer->getChannelFrequencyOffset()
);
}
m_source.applySettings(settings, force);
m_settings = settings;
}
int LoRaModBaseband::getChannelSampleRate() const
{
return m_channelizer->getChannelSampleRate();
}

View File

@ -0,0 +1,94 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 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 //
// (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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_LORAMODBASEBAND_H
#define INCLUDE_LORAMODBASEBAND_H
#include <QObject>
#include <QMutex>
#include "dsp/samplesourcefifo.h"
#include "util/message.h"
#include "util/messagequeue.h"
#include "loramodsource.h"
class UpChannelizer;
class LoRaModBaseband : public QObject
{
Q_OBJECT
public:
class MsgConfigureLoRaModBaseband : public Message {
MESSAGE_CLASS_DECLARATION
public:
const LoRaModSettings& getSettings() const { return m_settings; }
bool getForce() const { return m_force; }
static MsgConfigureLoRaModBaseband* create(const LoRaModSettings& settings, bool force)
{
return new MsgConfigureLoRaModBaseband(settings, force);
}
private:
LoRaModSettings m_settings;
bool m_force;
MsgConfigureLoRaModBaseband(const LoRaModSettings& settings, bool force) :
Message(),
m_settings(settings),
m_force(force)
{ }
};
LoRaModBaseband();
~LoRaModBaseband();
void reset();
void pull(const SampleVector::iterator& begin, unsigned int nbSamples);
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication
double getMagSq() const { return m_source.getMagSq(); }
int getChannelSampleRate() const;
signals:
/**
* Level changed
* \param rmsLevel RMS level in range 0.0 - 1.0
* \param peakLevel Peak level in range 0.0 - 1.0
* \param numSamples Number of audio samples analyzed
*/
void levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples);
private:
SampleSourceFifo m_sampleFifo;
UpChannelizer *m_channelizer;
LoRaModSource m_source;
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
LoRaModSettings m_settings;
QMutex m_mutex;
void processFifo(SampleVector& data, unsigned int iBegin, unsigned int iEnd);
bool handleMessage(const Message& cmd);
void applySettings(const LoRaModSettings& settings, bool force = false);
private slots:
void handleInputMessages();
void handleData(); //!< Handle data when samples have to be processed
};
#endif // INCLUDE_NFMMODBASEBAND_H

View File

@ -0,0 +1,413 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 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 //
// (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 <QDockWidget>
#include <QMainWindow>
#include <QFileDialog>
#include <QTime>
#include <QDebug>
#include "device/deviceuiset.h"
#include "plugin/pluginapi.h"
#include "util/simpleserializer.h"
#include "util/db.h"
#include "dsp/dspengine.h"
#include "dsp/dspcommands.h"
#include "gui/crightclickenabler.h"
#include "gui/basicchannelsettingsdialog.h"
#include "gui/devicestreamselectiondialog.h"
#include "mainwindow.h"
#include "ui_loramodgui.h"
#include "loramodgui.h"
LoRaModGUI* LoRaModGUI::create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx)
{
LoRaModGUI* gui = new LoRaModGUI(pluginAPI, deviceUISet, channelTx);
return gui;
}
void LoRaModGUI::destroy()
{
delete this;
}
void LoRaModGUI::setName(const QString& name)
{
setObjectName(name);
}
QString LoRaModGUI::getName() const
{
return objectName();
}
qint64 LoRaModGUI::getCenterFrequency() const {
return m_channelMarker.getCenterFrequency();
}
void LoRaModGUI::setCenterFrequency(qint64 centerFrequency)
{
m_channelMarker.setCenterFrequency(centerFrequency);
applySettings();
}
void LoRaModGUI::resetToDefaults()
{
m_settings.resetToDefaults();
displaySettings();
applySettings(true);
}
QByteArray LoRaModGUI::serialize() const
{
return m_settings.serialize();
}
bool LoRaModGUI::deserialize(const QByteArray& data)
{
if (m_settings.deserialize(data))
{
displaySettings();
applySettings(true);
return true;
}
else
{
resetToDefaults();
return false;
}
}
bool LoRaModGUI::handleMessage(const Message& message)
{
if (LoRaMod::MsgConfigureLoRaMod::match(message))
{
const LoRaMod::MsgConfigureLoRaMod& cfg = (LoRaMod::MsgConfigureLoRaMod&) message;
m_settings = cfg.getSettings();
blockApplySettings(true);
displaySettings();
blockApplySettings(false);
return true;
}
else if (DSPSignalNotification::match(message))
{
DSPSignalNotification& notif = (DSPSignalNotification&) message;
int basebandSampleRate = notif.getSampleRate();
qDebug() << "LoRaModGUI::handleMessage: DSPSignalNotification: m_basebandSampleRate: " << basebandSampleRate;
if (basebandSampleRate != m_basebandSampleRate)
{
m_basebandSampleRate = basebandSampleRate;
setBandwidths();
}
return true;
}
else
{
return false;
}
}
void LoRaModGUI::channelMarkerChangedByCursor()
{
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
applySettings();
}
void LoRaModGUI::handleSourceMessages()
{
Message* message;
while ((message = getInputMessageQueue()->pop()) != 0)
{
if (handleMessage(*message))
{
delete message;
}
}
}
void LoRaModGUI::on_deltaFrequency_changed(qint64 value)
{
m_channelMarker.setCenterFrequency(value);
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
applySettings();
}
void LoRaModGUI::on_bw_valueChanged(int value)
{
if (value < 0) {
m_settings.m_bandwidthIndex = 0;
} else if (value < LoRaModSettings::nbBandwidths) {
m_settings.m_bandwidthIndex = value;
} else {
m_settings.m_bandwidthIndex = LoRaModSettings::nbBandwidths - 1;
}
int thisBW = LoRaModSettings::bandwidths[value];
ui->bwText->setText(QString("%1 Hz").arg(thisBW));
m_channelMarker.setBandwidth(thisBW);
applySettings();
}
void LoRaModGUI::on_channelMute_toggled(bool checked)
{
m_settings.m_channelMute = checked;
applySettings();
}
void LoRaModGUI::on_spread_valueChanged(int value)
{
m_settings.m_spreadFactor = value;
ui->spreadText->setText(tr("%1").arg(value));
applySettings();
}
void LoRaModGUI::on_deBits_valueChanged(int value)
{
m_settings.m_deBits = value;
ui->deBitsText->setText(tr("%1").arg(m_settings.m_deBits));
applySettings();
}
void LoRaModGUI::on_preambleChirps_valueChanged(int value)
{
m_settings.m_preambleChirps = value;
ui->preambleChirpsText->setText(tr("%1").arg(m_settings.m_preambleChirps));
applySettings();
}
void LoRaModGUI::on_idleTime_valueChanged(int value)
{
m_settings.m_quietMillis = value * 100;
ui->idleTimeText->setText(tr("%1").arg(m_settings.m_quietMillis / 1000.0, 0, 'f', 1));
applySettings();
}
void LoRaModGUI::on_syncWord_editingFinished()
{
bool ok;
unsigned int syncWord = ui->syncWord->text().toUInt(&ok, 16);
if (ok)
{
m_settings.m_syncWord = syncWord > 255 ? 0 : syncWord;
applySettings();
}
}
void LoRaModGUI::onWidgetRolled(QWidget* widget, bool rollDown)
{
(void) widget;
(void) rollDown;
}
void LoRaModGUI::onMenuDialogCalled(const QPoint &p)
{
if (m_contextMenuType == ContextMenuChannelSettings)
{
BasicChannelSettingsDialog dialog(&m_channelMarker, this);
dialog.setUseReverseAPI(m_settings.m_useReverseAPI);
dialog.setReverseAPIAddress(m_settings.m_reverseAPIAddress);
dialog.setReverseAPIPort(m_settings.m_reverseAPIPort);
dialog.setReverseAPIDeviceIndex(m_settings.m_reverseAPIDeviceIndex);
dialog.setReverseAPIChannelIndex(m_settings.m_reverseAPIChannelIndex);
dialog.move(p);
dialog.exec();
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
m_settings.m_rgbColor = m_channelMarker.getColor().rgb();
m_settings.m_title = m_channelMarker.getTitle();
m_settings.m_useReverseAPI = dialog.useReverseAPI();
m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress();
m_settings.m_reverseAPIPort = dialog.getReverseAPIPort();
m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex();
m_settings.m_reverseAPIChannelIndex = dialog.getReverseAPIChannelIndex();
setWindowTitle(m_settings.m_title);
setTitleColor(m_settings.m_rgbColor);
applySettings();
}
else if ((m_contextMenuType == ContextMenuStreamSettings) && (m_deviceUISet->m_deviceMIMOEngine))
{
DeviceStreamSelectionDialog dialog(this);
dialog.setNumberOfStreams(m_loRaMod->getNumberOfDeviceStreams());
dialog.setStreamIndex(m_settings.m_streamIndex);
dialog.move(p);
dialog.exec();
m_settings.m_streamIndex = dialog.getSelectedStreamIndex();
m_channelMarker.clearStreamIndexes();
m_channelMarker.addStreamIndex(m_settings.m_streamIndex);
displayStreamIndex();
applySettings();
}
resetContextMenuType();
}
LoRaModGUI::LoRaModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx, QWidget* parent) :
RollupWidget(parent),
ui(new Ui::LoRaModGUI),
m_pluginAPI(pluginAPI),
m_deviceUISet(deviceUISet),
m_channelMarker(this),
m_basebandSampleRate(125000),
m_doApplySettings(true),
m_tickCount(0)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
m_loRaMod = (LoRaMod*) channelTx;
m_loRaMod->setMessageQueueToGUI(getInputMessageQueue());
connect(&MainWindow::getInstance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
m_channelMarker.blockSignals(true);
m_channelMarker.setColor(Qt::red);
m_channelMarker.setBandwidth(12500);
m_channelMarker.setCenterFrequency(0);
m_channelMarker.setTitle("LoRa Modulator");
m_channelMarker.setSourceOrSinkStream(false);
m_channelMarker.blockSignals(false);
m_channelMarker.setVisible(true); // activate signal on the last setting only
m_deviceUISet->registerTxChannelInstance(LoRaMod::m_channelIdURI, this);
m_deviceUISet->addChannelMarker(&m_channelMarker);
m_deviceUISet->addRollupWidget(this);
connect(&m_channelMarker, SIGNAL(changedByCursor()), this, SLOT(channelMarkerChangedByCursor()));
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
m_settings.setChannelMarker(&m_channelMarker);
setBandwidths();
displaySettings();
applySettings();
}
LoRaModGUI::~LoRaModGUI()
{
m_deviceUISet->removeTxChannelInstance(this);
delete m_loRaMod; // TODO: check this: when the GUI closes it has to delete the modulator
delete ui;
}
void LoRaModGUI::blockApplySettings(bool block)
{
m_doApplySettings = !block;
}
void LoRaModGUI::applySettings(bool force)
{
if (m_doApplySettings)
{
LoRaMod::MsgConfigureLoRaMod *msg = LoRaMod::MsgConfigureLoRaMod::create(m_settings, force);
m_loRaMod->getInputMessageQueue()->push(msg);
}
}
void LoRaModGUI::displaySettings()
{
int thisBW = LoRaModSettings::bandwidths[m_settings.m_bandwidthIndex];
m_channelMarker.blockSignals(true);
m_channelMarker.setTitle(m_settings.m_title);
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
m_channelMarker.setBandwidth(thisBW);
m_channelMarker.blockSignals(false);
m_channelMarker.setColor(m_settings.m_rgbColor);
setTitleColor(m_settings.m_rgbColor);
setWindowTitle(m_channelMarker.getTitle());
displayStreamIndex();
blockApplySettings(true);
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
ui->bwText->setText(QString("%1 Hz").arg(thisBW));
ui->bw->setValue(m_settings.m_bandwidthIndex);
ui->spread->setValue(m_settings.m_spreadFactor);
ui->spreadText->setText(tr("%1").arg(m_settings.m_spreadFactor));
ui->deBits->setValue(m_settings.m_deBits);
ui->deBitsText->setText(tr("%1").arg(m_settings.m_deBits));
ui->preambleChirps->setValue(m_settings.m_preambleChirps);
ui->preambleChirpsText->setText(tr("%1").arg(m_settings.m_preambleChirps));
ui->idleTime->setValue(m_settings.m_quietMillis / 100);
ui->idleTimeText->setText(tr("%1").arg(m_settings.m_quietMillis / 1000.0, 0, 'f', 1));
ui->syncWord->setText((tr("%1").arg(m_settings.m_syncWord, 2, 16)));
ui->channelMute->setChecked(m_settings.m_channelMute);
blockApplySettings(false);
}
void LoRaModGUI::displayStreamIndex()
{
if (m_deviceUISet->m_deviceMIMOEngine) {
setStreamIndicator(tr("%1").arg(m_settings.m_streamIndex));
} else {
setStreamIndicator("S"); // single channel indicator
}
}
void LoRaModGUI::setBandwidths()
{
int maxBandwidth = m_basebandSampleRate / LoRaModSettings::oversampling;
int maxIndex = 0;
for (; (maxIndex < LoRaModSettings::nbBandwidths) && (LoRaModSettings::bandwidths[maxIndex] <= maxBandwidth); maxIndex++)
{}
if (maxIndex != 0)
{
qDebug("LoRaModGUI::setBandwidths: avl: %d max: %d", maxBandwidth, LoRaModSettings::bandwidths[maxIndex-1]);
ui->bw->setMaximum(maxIndex - 1);
int index = ui->bw->value();
ui->bwText->setText(QString("%1 Hz").arg(LoRaModSettings::bandwidths[index]));
}
}
void LoRaModGUI::leaveEvent(QEvent*)
{
m_channelMarker.setHighlighted(false);
}
void LoRaModGUI::enterEvent(QEvent*)
{
m_channelMarker.setHighlighted(true);
}
void LoRaModGUI::tick()
{
double powDb = CalcDb::dbPower(m_loRaMod->getMagSq());
m_channelPowerDbAvg(powDb);
ui->channelPower->setText(tr("%1 dB").arg(m_channelPowerDbAvg.asDouble(), 0, 'f', 1));
}

View File

@ -0,0 +1,101 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 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 //
// (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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef PLUGINS_CHANNELTX_MODLORA_LORAMODGUI_H_
#define PLUGINS_CHANNELTX_MODLORA_LORAMODGUI_H_
#include <plugin/plugininstancegui.h>
#include "gui/rollupwidget.h"
#include "dsp/channelmarker.h"
#include "util/movingaverage.h"
#include "util/messagequeue.h"
#include "loramod.h"
#include "loramodsettings.h"
class PluginAPI;
class DeviceUISet;
class BasebandSampleSource;
namespace Ui {
class LoRaModGUI;
}
class LoRaModGUI : public RollupWidget, public PluginInstanceGUI {
Q_OBJECT
public:
static LoRaModGUI* create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx);
virtual void destroy();
void setName(const QString& name);
QString getName() const;
virtual qint64 getCenterFrequency() const;
virtual void setCenterFrequency(qint64 centerFrequency);
void resetToDefaults();
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
virtual MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
virtual bool handleMessage(const Message& message);
public slots:
void channelMarkerChangedByCursor();
private:
Ui::LoRaModGUI* ui;
PluginAPI* m_pluginAPI;
DeviceUISet* m_deviceUISet;
ChannelMarker m_channelMarker;
LoRaModSettings m_settings;
int m_basebandSampleRate;
bool m_doApplySettings;
LoRaMod* m_loRaMod;
MovingAverageUtil<double, double, 20> m_channelPowerDbAvg;
std::size_t m_tickCount;
MessageQueue m_inputMessageQueue;
explicit LoRaModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx, QWidget* parent = nullptr);
virtual ~LoRaModGUI();
void blockApplySettings(bool block);
void applySettings(bool force = false);
void displaySettings();
void displayStreamIndex();
void setBandwidths();
void leaveEvent(QEvent*);
void enterEvent(QEvent*);
private slots:
void handleSourceMessages();
void on_deltaFrequency_changed(qint64 value);
void on_bw_valueChanged(int value);
void on_spread_valueChanged(int value);
void on_deBits_valueChanged(int value);
void on_preambleChirps_valueChanged(int value);
void on_idleTime_valueChanged(int value);
void on_syncWord_editingFinished();
void on_channelMute_toggled(bool checked);
void onWidgetRolled(QWidget* widget, bool rollDown);
void onMenuDialogCalled(const QPoint& p);
void tick();
};
#endif /* PLUGINS_CHANNELTX_MODLORA_LORAMODGUI_H_ */

View File

@ -0,0 +1,551 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LoRaModGUI</class>
<widget class="RollupWidget" name="LoRaModGUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>220</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>180</height>
</size>
</property>
<property name="font">
<font>
<family>Liberation Sans</family>
<pointsize>9</pointsize>
</font>
</property>
<property name="windowTitle">
<string>LoRa Modulator</string>
</property>
<widget class="QWidget" name="settingsContainer" native="true">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>331</width>
<height>150</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>150</height>
</size>
</property>
<property name="windowTitle">
<string>RF/demod Settings</string>
</property>
<widget class="QLabel" name="bwLabel">
<property name="geometry">
<rect>
<x>2</x>
<y>50</y>
<width>32</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>BW</string>
</property>
</widget>
<widget class="QLabel" name="spreadLabel">
<property name="geometry">
<rect>
<x>2</x>
<y>70</y>
<width>32</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>SF</string>
</property>
</widget>
<widget class="QSlider" name="bw">
<property name="geometry">
<rect>
<x>40</x>
<y>50</y>
<width>170</width>
<height>16</height>
</rect>
</property>
<property name="toolTip">
<string>Bandwidth</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>5</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QSlider" name="spread">
<property name="geometry">
<rect>
<x>40</x>
<y>70</y>
<width>70</width>
<height>16</height>
</rect>
</property>
<property name="toolTip">
<string>Spreading factor</string>
</property>
<property name="minimum">
<number>7</number>
</property>
<property name="maximum">
<number>12</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>10</number>
</property>
<property name="sliderPosition">
<number>10</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QLabel" name="spreadText">
<property name="geometry">
<rect>
<x>120</x>
<y>70</y>
<width>30</width>
<height>16</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>10</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="bwText">
<property name="geometry">
<rect>
<x>240</x>
<y>50</y>
<width>80</width>
<height>16</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>7813 Hz</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="deBitsLabel">
<property name="geometry">
<rect>
<x>170</x>
<y>70</y>
<width>32</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>DE</string>
</property>
</widget>
<widget class="QLabel" name="deBitsText">
<property name="geometry">
<rect>
<x>290</x>
<y>70</y>
<width>30</width>
<height>16</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QSlider" name="deBits">
<property name="geometry">
<rect>
<x>210</x>
<y>70</y>
<width>70</width>
<height>16</height>
</rect>
</property>
<property name="toolTip">
<string>Low data rate optimize (DE) bits</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>2</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="sliderPosition">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>311</width>
<height>26</height>
</rect>
</property>
<layout class="QHBoxLayout" name="deltaFrequencyLayout">
<item>
<widget class="QLabel" name="deltaFrequencyLabel">
<property name="minimumSize">
<size>
<width>16</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Df</string>
</property>
</widget>
</item>
<item>
<widget class="ValueDialZ" name="deltaFrequency" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>32</width>
<height>16</height>
</size>
</property>
<property name="font">
<font>
<family>Liberation Mono</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>Demod shift frequency from center in Hz</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="deltaUnits">
<property name="text">
<string>Hz </string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="channelPower">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Channel power</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>-100.0 dB</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="channelMute">
<property name="toolTip">
<string>Mute/Unmute channel</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../sdrgui/resources/res.qrc">
<normaloff>:/txon.png</normaloff>
<normalon>:/txoff.png</normalon>:/txon.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QSlider" name="preambleChirps">
<property name="geometry">
<rect>
<x>40</x>
<y>90</y>
<width>70</width>
<height>16</height>
</rect>
</property>
<property name="toolTip">
<string>Number of preamble chirps</string>
</property>
<property name="minimum">
<number>4</number>
</property>
<property name="maximum">
<number>20</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>8</number>
</property>
<property name="sliderPosition">
<number>8</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QLabel" name="preambleChirpsLabel">
<property name="geometry">
<rect>
<x>2</x>
<y>90</y>
<width>32</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Pre</string>
</property>
</widget>
<widget class="QLabel" name="preambleChirpsText">
<property name="geometry">
<rect>
<x>120</x>
<y>90</y>
<width>30</width>
<height>16</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>8</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="idleTimeLabel">
<property name="geometry">
<rect>
<x>170</x>
<y>90</y>
<width>32</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Idle</string>
</property>
</widget>
<widget class="QSlider" name="idleTime">
<property name="geometry">
<rect>
<x>210</x>
<y>90</y>
<width>70</width>
<height>16</height>
</rect>
</property>
<property name="toolTip">
<string>Idle time beween packets (s)</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>600</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>10</number>
</property>
<property name="sliderPosition">
<number>10</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QLabel" name="idleTimeText">
<property name="geometry">
<rect>
<x>290</x>
<y>90</y>
<width>30</width>
<height>16</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>60.0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="syncLabel">
<property name="geometry">
<rect>
<x>2</x>
<y>110</y>
<width>32</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Sync</string>
</property>
</widget>
<widget class="QLineEdit" name="syncWord">
<property name="geometry">
<rect>
<x>40</x>
<y>110</y>
<width>30</width>
<height>16</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
<property name="toolTip">
<string>Sync word (1 byte hex)</string>
</property>
<property name="inputMask">
<string>HH</string>
</property>
<property name="text">
<string>00</string>
</property>
</widget>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>RollupWidget</class>
<extends>QWidget</extends>
<header>gui/rollupwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ValueDialZ</class>
<extends>QWidget</extends>
<header>gui/valuedialz.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../../sdrgui/resources/res.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -0,0 +1,84 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 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 //
// (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 <QtPlugin>
#include "plugin/pluginapi.h"
#ifndef SERVER_MODE
#include "loramodgui.h"
#endif
#include "loramod.h"
#include "loramodwebapiadapter.h"
#include "loramodplugin.h"
const PluginDescriptor LoRaModPlugin::m_pluginDescriptor = {
LoRaMod::m_channelId,
QString("LoRa Modulator"),
QString("5.2.0"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,
QString("https://github.com/f4exb/sdrangel")
};
LoRaModPlugin::LoRaModPlugin(QObject* parent) :
QObject(parent),
m_pluginAPI(0)
{
}
const PluginDescriptor& LoRaModPlugin::getPluginDescriptor() const
{
return m_pluginDescriptor;
}
void LoRaModPlugin::initPlugin(PluginAPI* pluginAPI)
{
m_pluginAPI = pluginAPI;
// register LoRa modulator
m_pluginAPI->registerTxChannel(LoRaMod::m_channelIdURI, LoRaMod::m_channelId, this);
}
#ifdef SERVER_MODE
PluginInstanceGUI* LoRaModPlugin::createTxChannelGUI(
DeviceUISet *deviceUISet,
BasebandSampleSource *txChannel) const
{
return 0;
}
#else
PluginInstanceGUI* LoRaModPlugin::createTxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSource *txChannel) const
{
return LoRaModGUI::create(m_pluginAPI, deviceUISet, txChannel);
}
#endif
BasebandSampleSource* LoRaModPlugin::createTxChannelBS(DeviceAPI *deviceAPI) const
{
return new LoRaMod(deviceAPI);
}
ChannelAPI* LoRaModPlugin::createTxChannelCS(DeviceAPI *deviceAPI) const
{
return new LoRaMod(deviceAPI);
}
ChannelWebAPIAdapter* LoRaModPlugin::createChannelWebAPIAdapter() const
{
return new LoRaModWebAPIAdapter();
}

View File

@ -0,0 +1,49 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 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 //
// (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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_LORAMODPLUGIN_H
#define INCLUDE_LORAMODPLUGIN_H
#include <QObject>
#include "plugin/plugininterface.h"
class DeviceUISet;
class BasebandSampleSource;
class LoRaModPlugin : public QObject, PluginInterface {
Q_OBJECT
Q_INTERFACES(PluginInterface)
Q_PLUGIN_METADATA(IID "sdrangel.channeltx.loramod")
public:
explicit LoRaModPlugin(QObject* parent = nullptr);
const PluginDescriptor& getPluginDescriptor() const;
void initPlugin(PluginAPI* pluginAPI);
virtual PluginInstanceGUI* createTxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSource *rxChannel) const;
virtual BasebandSampleSource* createTxChannelBS(DeviceAPI *deviceAPI) const;
virtual ChannelAPI* createTxChannelCS(DeviceAPI *deviceAPI) const;
virtual ChannelWebAPIAdapter* createChannelWebAPIAdapter() const;
private:
static const PluginDescriptor m_pluginDescriptor;
PluginAPI* m_pluginAPI;
};
#endif // INCLUDE_LORAMODPLUGIN_H

View File

@ -0,0 +1,141 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019-2020 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 //
// (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 "loramodsettings.h"
#include <QColor>
#include "dsp/dspengine.h"
#include "util/simpleserializer.h"
#include "settings/serializable.h"
#include "loramodsettings.h"
const int LoRaModSettings::bandwidths[] = {7813, 10417, 15625, 20833, 31250, 41667, 62500, 125000, 250000, 500000};
const int LoRaModSettings::nbBandwidths = 10;
const int LoRaModSettings::oversampling = 4;
LoRaModSettings::LoRaModSettings() :
m_inputFrequencyOffset(0),
m_channelMarker(0)
{
resetToDefaults();
}
void LoRaModSettings::resetToDefaults()
{
m_bandwidthIndex = 5;
m_spreadFactor = 7;
m_deBits = 0;
m_preambleChirps = 8;
m_quietMillis = 1000;
m_message = "LoRa beacon";
m_syncWord = 0x34;
m_channelMute = false;
m_rgbColor = QColor(255, 0, 255).rgb();
m_title = "LoRa Modulator";
m_streamIndex = 0;
m_useReverseAPI = false;
m_reverseAPIAddress = "127.0.0.1";
m_reverseAPIPort = 8888;
m_reverseAPIDeviceIndex = 0;
m_reverseAPIChannelIndex = 0;
}
QByteArray LoRaModSettings::serialize() const
{
SimpleSerializer s(1);
s.writeS32(1, m_inputFrequencyOffset);
s.writeS32(2, m_bandwidthIndex);
s.writeS32(3, m_spreadFactor);
s.writeString(4, m_message);
if (m_channelMarker) {
s.writeBlob(5, m_channelMarker->serialize());
}
s.writeString(6, m_title);
s.writeS32(7, m_deBits);
s.writeBool(8, m_channelMute);
s.writeU32(9, m_syncWord);
s.writeS32(10, m_preambleChirps);
s.writeS32(11, m_quietMillis);
s.writeBool(12, m_useReverseAPI);
s.writeString(13, m_reverseAPIAddress);
s.writeU32(14, m_reverseAPIPort);
s.writeU32(15, m_reverseAPIDeviceIndex);
s.writeU32(16, m_reverseAPIChannelIndex);
return s.final();
}
bool LoRaModSettings::deserialize(const QByteArray& data)
{
SimpleDeserializer d(data);
if(!d.isValid())
{
resetToDefaults();
return false;
}
if(d.getVersion() == 1)
{
QByteArray bytetmp;
unsigned int utmp;
d.readS32(1, &m_inputFrequencyOffset, 0);
d.readS32(2, &m_bandwidthIndex, 0);
d.readS32(3, &m_spreadFactor, 0);
d.readString(4, &m_message, "LoRa beacon");
if (m_channelMarker)
{
d.readBlob(5, &bytetmp);
m_channelMarker->deserialize(bytetmp);
}
d.readString(6, &m_title, "LoRa Demodulator");
d.readS32(7, &m_deBits, 0);
d.readBool(8, &m_channelMute, false);
d.readU32(9, &utmp, 0x34);
m_syncWord = utmp > 255 ? 0 : utmp;
d.readS32(10, &m_preambleChirps, 8);
d.readS32(11, &m_quietMillis, 1000);
d.readBool(11, &m_useReverseAPI, false);
d.readString(12, &m_reverseAPIAddress, "127.0.0.1");
d.readU32(13, &utmp, 0);
if ((utmp > 1023) && (utmp < 65535)) {
m_reverseAPIPort = utmp;
} else {
m_reverseAPIPort = 8888;
}
d.readU32(14, &utmp, 0);
m_reverseAPIDeviceIndex = utmp > 99 ? 99 : utmp;
d.readU32(15, &utmp, 0);
m_reverseAPIChannelIndex = utmp > 99 ? 99 : utmp;
return true;
}
else
{
resetToDefaults();
return false;
}
}

View File

@ -0,0 +1,63 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 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 //
// (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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef PLUGINS_CHANNELTX_MODLORA_LORAMODSETTINGS_H_
#define PLUGINS_CHANNELTX_MODLORA_LORAMODSETTINGS_H_
#include <QByteArray>
#include <QString>
#include <stdint.h>
class Serializable;
struct LoRaModSettings
{
int m_inputFrequencyOffset;
int m_bandwidthIndex;
int m_spreadFactor;
int m_deBits; //!< Low data rate optmize (DE) bits
int m_preambleChirps; //!< Number of preamble chirps
int m_quietMillis; //!< Number of milliseconds to pause between transmissions
unsigned char m_syncWord;
bool m_channelMute;
QString m_message;
uint32_t m_rgbColor;
QString m_title;
int m_streamIndex;
bool m_useReverseAPI;
QString m_reverseAPIAddress;
uint16_t m_reverseAPIPort;
uint16_t m_reverseAPIDeviceIndex;
uint16_t m_reverseAPIChannelIndex;
Serializable *m_channelMarker;
static const int bandwidths[];
static const int nbBandwidths;
static const int oversampling;
LoRaModSettings();
void resetToDefaults();
void setChannelMarker(Serializable *channelMarker) { m_channelMarker = channelMarker; }
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
};
#endif /* PLUGINS_CHANNELTX_MODLORA_LORAMODSETTINGS_H_ */

View File

@ -0,0 +1,360 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 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 //
// (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 <QDebug>
#include "loramodsource.h"
const int LoRaModSource::m_levelNbSamples = 480; // every 10ms
LoRaModSource::LoRaModSource() :
m_channelSampleRate(48000),
m_channelFrequencyOffset(0),
m_downChirps(nullptr),
m_upChirps(nullptr),
m_phaseIncrements(nullptr),
m_modPhasor(0.0f),
m_levelCalcCount(0),
m_peakLevel(0.0f),
m_levelSum(0.0f)
{
m_magsq = 0.0;
initSF(m_settings.m_spreadFactor);
reset();
applySettings(m_settings, true);
applyChannelSettings(m_channelSampleRate, m_channelFrequencyOffset, true);
}
LoRaModSource::~LoRaModSource()
{
delete[] m_downChirps;
delete[] m_upChirps;
delete[] m_phaseIncrements;
}
void LoRaModSource::initSF(unsigned int sf)
{
if (m_downChirps) {
delete[] m_downChirps;
}
if (m_upChirps) {
delete[] m_upChirps;
}
m_fftLength = 1 << sf;
m_state = LoRaStateIdle;
m_quarterSamples = (m_fftLength/4)*LoRaModSettings::oversampling;
m_downChirps = new Complex[2*m_fftLength*LoRaModSettings::oversampling]; // Each table is 2 chirps long to allow use from arbitrary offsets.
m_upChirps = new Complex[2*m_fftLength*LoRaModSettings::oversampling];
m_symbols.clear();
for (unsigned int symbol = m_fftLength/4; symbol < m_fftLength; symbol += m_fftLength/4)
{
m_symbols.push_back(symbol);
m_symbols.push_back(symbol+1);
}
float halfAngle = M_PI/LoRaModSettings::oversampling;
float phase = -halfAngle;
double accumulator = 0;
for (int i = 0; i < 2*m_fftLength*LoRaModSettings::oversampling; i++)
{
accumulator = fmod(accumulator + phase, 2*M_PI);
m_downChirps[i] = Complex(std::conj(std::polar(0.891235351562 * SDR_TX_SCALED, accumulator))); // -1 dB
m_upChirps[i] = Complex(std::polar(0.891235351562 * SDR_TX_SCALED, accumulator));
phase += (2*halfAngle) / (m_fftLength*LoRaModSettings::oversampling);
phase = phase > halfAngle ? phase - 2.0*halfAngle : phase;
}
if (m_phaseIncrements) {
delete[] m_phaseIncrements;
}
m_phaseIncrements = new double[2*m_fftLength*LoRaModSettings::oversampling];
phase = -halfAngle;
for (int i = 0; i < 2*m_fftLength*LoRaModSettings::oversampling; i++)
{
m_phaseIncrements[i] = phase;
phase += (2*halfAngle) / (m_fftLength*LoRaModSettings::oversampling);
phase = phase > halfAngle ? -halfAngle : phase;
}
}
void LoRaModSource::reset()
{
m_chirp = 0;
m_chirp0 = 0;
m_sampleCounter = 0;
m_fftCounter = 0;
m_chirpCount = 0;
}
void LoRaModSource::pull(SampleVector::iterator begin, unsigned int nbSamples)
{
std::for_each(
begin,
begin + nbSamples,
[this](Sample& s) {
pullOne(s);
}
);
}
void LoRaModSource::pullOne(Sample& sample)
{
if (m_settings.m_channelMute)
{
sample.m_real = 0.0f;
sample.m_imag = 0.0f;
m_magsq = 0.0;
return;
}
Complex ci;
if (m_interpolatorDistance > 1.0f) // decimate
{
modulateSample();
while (!m_interpolator.decimate(&m_interpolatorDistanceRemain, m_modSample, &ci))
{
modulateSample();
}
}
else
{
if (m_interpolator.interpolate(&m_interpolatorDistanceRemain, m_modSample, &ci))
{
modulateSample();
}
}
m_interpolatorDistanceRemain += m_interpolatorDistance;
ci *= m_carrierNco.nextIQ(); // shift to carrier frequency
if (!(m_state == LoRaStateIdle))
{
double magsq = std::norm(ci);
magsq /= (SDR_TX_SCALED*SDR_TX_SCALED);
m_movingAverage(magsq);
m_magsq = m_movingAverage.asDouble();
}
sample.m_real = (FixReal) ci.real();
sample.m_imag = (FixReal) ci.imag();
}
void LoRaModSource::modulateSample()
{
if (m_state == LoRaStateIdle)
{
m_modSample = Complex{0.0, 0.0};
m_sampleCounter++;
if (m_sampleCounter == m_quietSamples*LoRaModSettings::oversampling)
{
m_chirp0 = 0;
m_chirp = m_fftLength*LoRaModSettings::oversampling - 1;
m_state = LoRaStatePreamble;
}
}
else if (m_state == LoRaStatePreamble)
{
// m_modSample = m_upChirps[m_chirp];
m_modSample = Complex(std::polar(0.891235351562 * SDR_TX_SCALED, m_modPhasor));
m_modPhasor += m_phaseIncrements[m_chirp];
m_fftCounter++;
if (m_fftCounter == m_fftLength*LoRaModSettings::oversampling)
{
m_chirpCount++;
m_fftCounter = 0;
if (m_chirpCount == m_settings.m_preambleChirps)
{
m_chirpCount = 0;
m_chirp0 = ((m_settings.m_syncWord >> ((1-m_chirpCount)*4)) & 0xf)*8;
m_chirp = (m_chirp0 + m_fftLength)*LoRaModSettings::oversampling - 1;
m_fftCounter = 0;
m_state = LoRaStateSyncWord;
}
}
}
else if (m_state == LoRaStateSyncWord)
{
// m_modSample = m_upChirps[m_chirp];
m_modSample = Complex(std::polar(0.891235351562 * SDR_TX_SCALED, m_modPhasor));
m_modPhasor += m_phaseIncrements[m_chirp];
m_fftCounter++;
if (m_fftCounter == m_fftLength*LoRaModSettings::oversampling)
{
m_chirpCount++;
m_chirp0 = ((m_settings.m_syncWord >> ((1-m_chirpCount)*4)) & 0xf)*8;
m_chirp = (m_chirp0 + m_fftLength)*LoRaModSettings::oversampling - 1;
m_fftCounter = 0;
if (m_chirpCount == 2)
{
m_sampleCounter = 0;
m_chirpCount = 0;
m_chirp0 = 0;
m_chirp = m_fftLength*LoRaModSettings::oversampling - 1;
m_state = LoRaStateSFD;
}
}
}
else if (m_state == LoRaStateSFD)
{
// m_modSample = m_downChirps[m_chirp];
m_modSample = Complex(std::conj(std::polar(0.891235351562 * SDR_TX_SCALED, m_modPhasor)));
m_modPhasor += m_phaseIncrements[m_chirp];
m_fftCounter++;
m_sampleCounter++;
if (m_fftCounter == m_fftLength*LoRaModSettings::oversampling)
{
m_chirp0 = 0;
m_chirp = m_fftLength*LoRaModSettings::oversampling - 1;
m_fftCounter = 0;
}
if (m_sampleCounter == m_quarterSamples)
{
m_chirpCount++;
m_sampleCounter = 0;
}
if (m_chirpCount == 9)
{
m_fftCounter = 0;
m_chirpCount = 0;
m_chirp0 = m_symbols[m_chirpCount];
m_chirp = (m_chirp0 + m_fftLength)*LoRaModSettings::oversampling - 1;
m_state = LoRaStatePayload;
}
}
else if (m_state == LoRaStatePayload)
{
// m_modSample = m_upChirps[m_chirp];
m_modSample = Complex(std::polar(0.891235351562 * SDR_TX_SCALED, m_modPhasor));
m_modPhasor += m_phaseIncrements[m_chirp];
m_fftCounter++;
if (m_fftCounter == m_fftLength*LoRaModSettings::oversampling)
{
m_chirpCount++;
if (m_chirpCount == m_symbols.size())
{
reset();
m_state = LoRaStateIdle;
}
else
{
m_chirp0 = m_symbols[m_chirpCount];
m_chirp = (m_chirp0 + m_fftLength)*LoRaModSettings::oversampling - 1;
m_fftCounter = 0;
}
}
}
// limit phasor range to ]-pi,pi]
if (m_modPhasor > M_PI) {
m_modPhasor -= (2.0f * M_PI);
}
m_chirp++;
if (m_chirp >= (m_chirp0 + m_fftLength)*LoRaModSettings::oversampling) {
m_chirp = m_chirp0*LoRaModSettings::oversampling;
}
}
void LoRaModSource::processOneSample(Complex& ci)
{
}
void LoRaModSource::calculateLevel(Real& sample)
{
if (m_levelCalcCount < m_levelNbSamples)
{
m_peakLevel = std::max(std::fabs(m_peakLevel), sample);
m_levelSum += sample * sample;
m_levelCalcCount++;
}
else
{
m_rmsLevel = sqrt(m_levelSum / m_levelNbSamples);
m_peakLevelOut = m_peakLevel;
m_peakLevel = 0.0f;
m_levelSum = 0.0f;
m_levelCalcCount = 0;
}
}
void LoRaModSource::applySettings(const LoRaModSettings& settings, bool force)
{
if ((settings.m_spreadFactor != m_settings.m_spreadFactor) || force)
{
initSF(settings.m_spreadFactor);
reset();
}
if ((settings.m_quietMillis != m_settings.m_quietMillis) || force)
{
m_quietSamples = (m_bandwidth*settings.m_quietMillis) / 1000;
reset();
}
m_settings = settings;
}
void LoRaModSource::applyChannelSettings(int channelSampleRate, int bandwidth, int channelFrequencyOffset, bool force)
{
qDebug() << "LoRaModSource::applyChannelSettings:"
<< " channelSampleRate: " << channelSampleRate
<< " channelFrequencyOffset: " << channelFrequencyOffset
<< " bandwidth: " << bandwidth
<< " SR: " << bandwidth * LoRaModSettings::oversampling;
if ((channelFrequencyOffset != m_channelFrequencyOffset)
|| (channelSampleRate != m_channelSampleRate) || force)
{
m_carrierNco.setFreq(channelFrequencyOffset, channelSampleRate);
}
if ((channelSampleRate != m_channelSampleRate)
|| (bandwidth != m_bandwidth) || force)
{
m_interpolatorDistanceRemain = 0;
m_interpolatorConsumed = false;
m_interpolatorDistance = (Real) (bandwidth*LoRaModSettings::oversampling) / (Real) channelSampleRate;
m_interpolator.create(16, bandwidth, bandwidth / 2.2);
}
m_channelSampleRate = channelSampleRate;
m_channelFrequencyOffset = channelFrequencyOffset;
m_bandwidth = bandwidth;
m_quietSamples = (bandwidth*m_settings.m_quietMillis) / 1000;
m_state = LoRaStateIdle;
reset();
}

View File

@ -0,0 +1,116 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 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 //
// (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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_LORAMODSOURCE_H
#define INCLUDE_LORAMODSOURCE_H
#include <QMutex>
#include "dsp/channelsamplesource.h"
#include "dsp/nco.h"
#include "dsp/interpolator.h"
#include "dsp/bandpass.h"
#include "util/movingaverage.h"
#include "loramodsettings.h"
class LoRaModSource : public ChannelSampleSource
{
public:
LoRaModSource();
virtual ~LoRaModSource();
virtual void pull(SampleVector::iterator begin, unsigned int nbSamples);
virtual void pullOne(Sample& sample);
virtual void prefetch(unsigned int nbSamples) {}
double getMagSq() const { return m_magsq; }
void getLevels(qreal& rmsLevel, qreal& peakLevel, int& numSamples) const
{
rmsLevel = m_rmsLevel;
peakLevel = m_peakLevelOut;
numSamples = m_levelNbSamples;
}
void applySettings(const LoRaModSettings& settings, bool force = false);
void applyChannelSettings(int channelSampleRate, int bandwidth, int channelFrequencyOffset, bool force = false);
private:
enum LoRaMode
{
LoRaStandard, //!< Classic
LoRaTTY //!< Special TTY (SF=7, DE=2)
};
enum LoRaState
{
LoRaStateIdle, //!< Quiet time
LoRaStatePreamble, //!< Transmit preamble
LoRaStateSyncWord, //!< Tramsmit sync word
LoRaStateSFD, //!< Transmit SFD
LoRaStatePayload, //!< Tramsmoit payload
LoRaStateTest
};
int m_channelSampleRate;
int m_channelFrequencyOffset;
int m_bandwidth;
LoRaModSettings m_settings;
LoRaState m_state;
Complex *m_downChirps;
Complex *m_upChirps;
double *m_phaseIncrements;
std::vector<unsigned int> m_symbols;
unsigned int m_fftLength; //!< chirp length in samples
unsigned int m_chirp; //!< actual chirp index in chirps table
unsigned int m_chirp0; //!< half index of chirp start in chirps table
unsigned int m_sampleCounter; //!< actual sample counter
unsigned int m_fftCounter; //!< chirp sample counter
unsigned int m_chirpCount; //!< chirp or quarter chirp counter
unsigned int m_quietSamples; //!< number of samples during quiet period
unsigned int m_quarterSamples; //!< number of samples in a quarter chirp
NCO m_carrierNco;
double m_modPhasor; //!< baseband modulator phasor
Complex m_modSample;
Interpolator m_interpolator;
Real m_interpolatorDistance;
Real m_interpolatorDistanceRemain;
bool m_interpolatorConsumed;
Bandpass<Real> m_bandpass;
double m_magsq;
MovingAverageUtil<double, double, 16> m_movingAverage;
quint32 m_levelCalcCount;
qreal m_rmsLevel;
qreal m_peakLevelOut;
Real m_peakLevel;
Real m_levelSum;
static const int m_levelNbSamples;
void initSF(unsigned int sf); //!< Init tables, FFTs, depending on spread factor
void reset();
void processOneSample(Complex& ci);
void calculateLevel(Real& sample);
void modulateSample();
};
#endif // INCLUDE_LORAMODSOURCE_H

View File

@ -0,0 +1,49 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 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 //
// (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 "SWGChannelSettings.h"
#include "loramod.h"
#include "loramodwebapiadapter.h"
LoRaModWebAPIAdapter::LoRaModWebAPIAdapter()
{}
LoRaModWebAPIAdapter::~LoRaModWebAPIAdapter()
{}
int LoRaModWebAPIAdapter::webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage)
{
(void) errorMessage;
response.setLoRaModSettings(new SWGSDRangel::SWGLoRaModSettings());
response.getLoRaModSettings()->init();
LoRaMod::webapiFormatChannelSettings(response, m_settings);
return 200;
}
int LoRaModWebAPIAdapter::webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage)
{
(void) errorMessage;
LoRaMod::webapiUpdateChannelSettings(m_settings, channelSettingsKeys, response);
LoRaMod::webapiFormatChannelSettings(response, m_settings);
return 200;
}

View File

@ -0,0 +1,49 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2020 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 //
// (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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_LORAMOD_WEBAPIADAPTER_H
#define INCLUDE_LORAMOD_WEBAPIADAPTER_H
#include "channel/channelwebapiadapter.h"
#include "loramodsettings.h"
/**
* Standalone API adapter only for the settings
*/
class LoRaModWebAPIAdapter : public ChannelWebAPIAdapter {
public:
LoRaModWebAPIAdapter();
virtual ~LoRaModWebAPIAdapter();
virtual QByteArray serialize() const { return m_settings.serialize(); }
virtual bool deserialize(const QByteArray& data) { return m_settings.deserialize(data); }
virtual int webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
virtual int webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
private:
LoRaModSettings m_settings;
};
#endif // INCLUDE_LORAMOD_WEBAPIADAPTER_H

View File

@ -33,6 +33,7 @@
<file>webapi/doc/swagger/include/Interferometer.yaml</file>
<file>webapi/doc/swagger/include/LimeRFE.yaml</file>
<file>webapi/doc/swagger/include/LimeSdr.yaml</file>
<file>webapi/doc/swagger/include/LoRaMod.yaml</file>
<file>webapi/doc/swagger/include/KiwiSDR.yaml</file>
<file>webapi/doc/swagger/include/LocalInput.yaml</file>
<file>webapi/doc/swagger/include/LocalOutput.yaml</file>

View File

@ -2184,6 +2184,9 @@ margin-bottom: 20px;
"FreqTrackerReport" : {
"$ref" : "#/definitions/FreqTrackerReport"
},
"LoRaModReport" : {
"$ref" : "#/definitions/LoRaModReport"
},
"NFMDemodReport" : {
"$ref" : "#/definitions/NFMDemodReport"
},
@ -2276,6 +2279,9 @@ margin-bottom: 20px;
"InterferometerSettings" : {
"$ref" : "#/definitions/InterferometerSettings"
},
"LoRaModSettings" : {
"$ref" : "#/definitions/LoRaModSettings"
},
"NFMDemodSettings" : {
"$ref" : "#/definitions/NFMDemodSettings"
},
@ -4373,6 +4379,70 @@ margin-bottom: 20px;
}
},
"description" : "LimeSDR"
};
defs.LoRaModReport = {
"properties" : {
"channelPowerDB" : {
"type" : "number",
"format" : "float",
"description" : "power transmitted in channel (dB)"
},
"channelSampleRate" : {
"type" : "integer"
}
},
"description" : "LoRaMod"
};
defs.LoRaModSettings = {
"properties" : {
"inputFrequencyOffset" : {
"type" : "integer",
"format" : "int64"
},
"bandwidthIndex" : {
"type" : "integer"
},
"spreadFactor" : {
"type" : "integer"
},
"deBits" : {
"type" : "integer"
},
"message" : {
"type" : "string"
},
"channelMute" : {
"type" : "integer",
"description" : "boolean"
},
"rgbColor" : {
"type" : "integer"
},
"title" : {
"type" : "string"
},
"streamIndex" : {
"type" : "integer",
"description" : "MIMO channel. Not relevant when connected to SI (single Rx)."
},
"useReverseAPI" : {
"type" : "integer",
"description" : "Synchronize with reverse API (1 for yes, 0 for no)"
},
"reverseAPIAddress" : {
"type" : "string"
},
"reverseAPIPort" : {
"type" : "integer"
},
"reverseAPIDeviceIndex" : {
"type" : "integer"
},
"reverseAPIChannelIndex" : {
"type" : "integer"
}
},
"description" : "LoRaMod"
};
defs.LocalInputReport = {
"properties" : {
@ -32252,7 +32322,7 @@ except ApiException as e:
</div>
<div id="generator">
<div class="content">
Generated 2020-01-23T00:38:38.303+01:00
Generated 2020-02-08T20:41:49.295+01:00
</div>
</div>
</div>

View File

@ -45,6 +45,8 @@ ChannelSettings:
$ref: "/doc/swagger/include/FreqTracker.yaml#/FreqTrackerSettings"
InterferometerSettings:
$ref: "/doc/swagger/include/Interferometer.yaml#/InterferometerSettings"
LoRaModSettings:
$ref: "/doc/swagger/include/LoRaMod.yaml#/LoRaModSettings"
NFMDemodSettings:
$ref: "/doc/swagger/include/NFMDemod.yaml#/NFMDemodSettings"
NFMModSettings:

View File

@ -0,0 +1,45 @@
LoRaModSettings:
description: LoRaMod
properties:
inputFrequencyOffset:
type: integer
format: int64
bandwidthIndex:
type: integer
spreadFactor:
type: integer
deBits:
type: integer
message:
type: string
channelMute:
description: boolean
type: integer
rgbColor:
type: integer
title:
type: string
streamIndex:
description: MIMO channel. Not relevant when connected to SI (single Rx).
type: integer
useReverseAPI:
description: Synchronize with reverse API (1 for yes, 0 for no)
type: integer
reverseAPIAddress:
type: string
reverseAPIPort:
type: integer
reverseAPIDeviceIndex:
type: integer
reverseAPIChannelIndex:
type: integer
LoRaModReport:
description: LoRaMod
properties:
channelPowerDB:
description: power transmitted in channel (dB)
type: number
format: float
channelSampleRate:
type: integer

View File

@ -2272,6 +2272,8 @@ definitions:
$ref: "/doc/swagger/include/FreeDVMod.yaml#/FreeDVModReport"
FreqTrackerReport:
$ref: "/doc/swagger/include/FreqTracker.yaml#/FreqTrackerReport"
LoRaModReport:
$ref: "/doc/swagger/include/LoRaMod.yaml#/LoRaModReport"
NFMDemodReport:
$ref: "/doc/swagger/include/NFMDemod.yaml#/NFMDemodReport"
NFMModReport:

View File

@ -45,6 +45,8 @@ ChannelSettings:
$ref: "http://localhost:8081/api/swagger/include/FreqTracker.yaml#/FreqTrackerSettings"
InterferometerSettings:
$ref: "http://localhost:8081/api/swagger/include/Interferometer.yaml#/InterferometerSettings"
LoRaModSettings:
$ref: "http://localhost:8081/api/swagger/include/LoRaMod.yaml#/LoRaModSettings"
NFMDemodSettings:
$ref: "http://localhost:8081/api/swagger/include/NFMDemod.yaml#/NFMDemodSettings"
NFMModSettings:

View File

@ -0,0 +1,45 @@
LoRaModSettings:
description: LoRaMod
properties:
inputFrequencyOffset:
type: integer
format: int64
bandwidthIndex:
type: integer
spreadFactor:
type: integer
deBits:
type: integer
message:
type: string
channelMute:
description: boolean
type: integer
rgbColor:
type: integer
title:
type: string
streamIndex:
description: MIMO channel. Not relevant when connected to SI (single Rx).
type: integer
useReverseAPI:
description: Synchronize with reverse API (1 for yes, 0 for no)
type: integer
reverseAPIAddress:
type: string
reverseAPIPort:
type: integer
reverseAPIDeviceIndex:
type: integer
reverseAPIChannelIndex:
type: integer
LoRaModReport:
description: LoRaMod
properties:
channelPowerDB:
description: power transmitted in channel (dB)
type: number
format: float
channelSampleRate:
type: integer

View File

@ -2272,6 +2272,8 @@ definitions:
$ref: "http://localhost:8081/api/swagger/include/FreeDVMod.yaml#/FreeDVModReport"
FreqTrackerReport:
$ref: "http://localhost:8081/api/swagger/include/FreqTracker.yaml#/FreqTrackerReport"
LoRaModReport:
$ref: "http://localhost:8081/api/swagger/include/LoRaMod.yaml#/LoRaModReport"
NFMDemodReport:
$ref: "http://localhost:8081/api/swagger/include/NFMDemod.yaml#/NFMDemodReport"
NFMModReport:

View File

@ -2184,6 +2184,9 @@ margin-bottom: 20px;
"FreqTrackerReport" : {
"$ref" : "#/definitions/FreqTrackerReport"
},
"LoRaModReport" : {
"$ref" : "#/definitions/LoRaModReport"
},
"NFMDemodReport" : {
"$ref" : "#/definitions/NFMDemodReport"
},
@ -2276,6 +2279,9 @@ margin-bottom: 20px;
"InterferometerSettings" : {
"$ref" : "#/definitions/InterferometerSettings"
},
"LoRaModSettings" : {
"$ref" : "#/definitions/LoRaModSettings"
},
"NFMDemodSettings" : {
"$ref" : "#/definitions/NFMDemodSettings"
},
@ -4373,6 +4379,70 @@ margin-bottom: 20px;
}
},
"description" : "LimeSDR"
};
defs.LoRaModReport = {
"properties" : {
"channelPowerDB" : {
"type" : "number",
"format" : "float",
"description" : "power transmitted in channel (dB)"
},
"channelSampleRate" : {
"type" : "integer"
}
},
"description" : "LoRaMod"
};
defs.LoRaModSettings = {
"properties" : {
"inputFrequencyOffset" : {
"type" : "integer",
"format" : "int64"
},
"bandwidthIndex" : {
"type" : "integer"
},
"spreadFactor" : {
"type" : "integer"
},
"deBits" : {
"type" : "integer"
},
"message" : {
"type" : "string"
},
"channelMute" : {
"type" : "integer",
"description" : "boolean"
},
"rgbColor" : {
"type" : "integer"
},
"title" : {
"type" : "string"
},
"streamIndex" : {
"type" : "integer",
"description" : "MIMO channel. Not relevant when connected to SI (single Rx)."
},
"useReverseAPI" : {
"type" : "integer",
"description" : "Synchronize with reverse API (1 for yes, 0 for no)"
},
"reverseAPIAddress" : {
"type" : "string"
},
"reverseAPIPort" : {
"type" : "integer"
},
"reverseAPIDeviceIndex" : {
"type" : "integer"
},
"reverseAPIChannelIndex" : {
"type" : "integer"
}
},
"description" : "LoRaMod"
};
defs.LocalInputReport = {
"properties" : {
@ -32252,7 +32322,7 @@ except ApiException as e:
</div>
<div id="generator">
<div class="content">
Generated 2020-01-23T00:38:38.303+01:00
Generated 2020-02-08T20:41:49.295+01:00
</div>
</div>
</div>

View File

@ -50,6 +50,8 @@ SWGChannelReport::SWGChannelReport() {
m_free_dv_mod_report_isSet = false;
freq_tracker_report = nullptr;
m_freq_tracker_report_isSet = false;
lo_ra_mod_report = nullptr;
m_lo_ra_mod_report_isSet = false;
nfm_demod_report = nullptr;
m_nfm_demod_report_isSet = false;
nfm_mod_report = nullptr;
@ -98,6 +100,8 @@ SWGChannelReport::init() {
m_free_dv_mod_report_isSet = false;
freq_tracker_report = new SWGFreqTrackerReport();
m_freq_tracker_report_isSet = false;
lo_ra_mod_report = new SWGLoRaModReport();
m_lo_ra_mod_report_isSet = false;
nfm_demod_report = new SWGNFMDemodReport();
m_nfm_demod_report_isSet = false;
nfm_mod_report = new SWGNFMModReport();
@ -151,6 +155,9 @@ SWGChannelReport::cleanup() {
if(freq_tracker_report != nullptr) {
delete freq_tracker_report;
}
if(lo_ra_mod_report != nullptr) {
delete lo_ra_mod_report;
}
if(nfm_demod_report != nullptr) {
delete nfm_demod_report;
}
@ -213,6 +220,8 @@ SWGChannelReport::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&freq_tracker_report, pJson["FreqTrackerReport"], "SWGFreqTrackerReport", "SWGFreqTrackerReport");
::SWGSDRangel::setValue(&lo_ra_mod_report, pJson["LoRaModReport"], "SWGLoRaModReport", "SWGLoRaModReport");
::SWGSDRangel::setValue(&nfm_demod_report, pJson["NFMDemodReport"], "SWGNFMDemodReport", "SWGNFMDemodReport");
::SWGSDRangel::setValue(&nfm_mod_report, pJson["NFMModReport"], "SWGNFMModReport", "SWGNFMModReport");
@ -280,6 +289,9 @@ SWGChannelReport::asJsonObject() {
if((freq_tracker_report != nullptr) && (freq_tracker_report->isSet())){
toJsonValue(QString("FreqTrackerReport"), freq_tracker_report, obj, QString("SWGFreqTrackerReport"));
}
if((lo_ra_mod_report != nullptr) && (lo_ra_mod_report->isSet())){
toJsonValue(QString("LoRaModReport"), lo_ra_mod_report, obj, QString("SWGLoRaModReport"));
}
if((nfm_demod_report != nullptr) && (nfm_demod_report->isSet())){
toJsonValue(QString("NFMDemodReport"), nfm_demod_report, obj, QString("SWGNFMDemodReport"));
}
@ -421,6 +433,16 @@ SWGChannelReport::setFreqTrackerReport(SWGFreqTrackerReport* freq_tracker_report
this->m_freq_tracker_report_isSet = true;
}
SWGLoRaModReport*
SWGChannelReport::getLoRaModReport() {
return lo_ra_mod_report;
}
void
SWGChannelReport::setLoRaModReport(SWGLoRaModReport* lo_ra_mod_report) {
this->lo_ra_mod_report = lo_ra_mod_report;
this->m_lo_ra_mod_report_isSet = true;
}
SWGNFMDemodReport*
SWGChannelReport::getNfmDemodReport() {
return nfm_demod_report;
@ -549,6 +571,9 @@ SWGChannelReport::isSet(){
if(freq_tracker_report && freq_tracker_report->isSet()){
isObjectUpdated = true; break;
}
if(lo_ra_mod_report && lo_ra_mod_report->isSet()){
isObjectUpdated = true; break;
}
if(nfm_demod_report && nfm_demod_report->isSet()){
isObjectUpdated = true; break;
}

View File

@ -31,6 +31,7 @@
#include "SWGFreeDVDemodReport.h"
#include "SWGFreeDVModReport.h"
#include "SWGFreqTrackerReport.h"
#include "SWGLoRaModReport.h"
#include "SWGNFMDemodReport.h"
#include "SWGNFMModReport.h"
#include "SWGRemoteSourceReport.h"
@ -93,6 +94,9 @@ public:
SWGFreqTrackerReport* getFreqTrackerReport();
void setFreqTrackerReport(SWGFreqTrackerReport* freq_tracker_report);
SWGLoRaModReport* getLoRaModReport();
void setLoRaModReport(SWGLoRaModReport* lo_ra_mod_report);
SWGNFMDemodReport* getNfmDemodReport();
void setNfmDemodReport(SWGNFMDemodReport* nfm_demod_report);
@ -157,6 +161,9 @@ private:
SWGFreqTrackerReport* freq_tracker_report;
bool m_freq_tracker_report_isSet;
SWGLoRaModReport* lo_ra_mod_report;
bool m_lo_ra_mod_report_isSet;
SWGNFMDemodReport* nfm_demod_report;
bool m_nfm_demod_report_isSet;

View File

@ -64,6 +64,8 @@ SWGChannelSettings::SWGChannelSettings() {
m_freq_tracker_settings_isSet = false;
interferometer_settings = nullptr;
m_interferometer_settings_isSet = false;
lo_ra_mod_settings = nullptr;
m_lo_ra_mod_settings_isSet = false;
nfm_demod_settings = nullptr;
m_nfm_demod_settings_isSet = false;
nfm_mod_settings = nullptr;
@ -132,6 +134,8 @@ SWGChannelSettings::init() {
m_freq_tracker_settings_isSet = false;
interferometer_settings = new SWGInterferometerSettings();
m_interferometer_settings_isSet = false;
lo_ra_mod_settings = new SWGLoRaModSettings();
m_lo_ra_mod_settings_isSet = false;
nfm_demod_settings = new SWGNFMDemodSettings();
m_nfm_demod_settings_isSet = false;
nfm_mod_settings = new SWGNFMModSettings();
@ -208,6 +212,9 @@ SWGChannelSettings::cleanup() {
if(interferometer_settings != nullptr) {
delete interferometer_settings;
}
if(lo_ra_mod_settings != nullptr) {
delete lo_ra_mod_settings;
}
if(nfm_demod_settings != nullptr) {
delete nfm_demod_settings;
}
@ -293,6 +300,8 @@ SWGChannelSettings::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&interferometer_settings, pJson["InterferometerSettings"], "SWGInterferometerSettings", "SWGInterferometerSettings");
::SWGSDRangel::setValue(&lo_ra_mod_settings, pJson["LoRaModSettings"], "SWGLoRaModSettings", "SWGLoRaModSettings");
::SWGSDRangel::setValue(&nfm_demod_settings, pJson["NFMDemodSettings"], "SWGNFMDemodSettings", "SWGNFMDemodSettings");
::SWGSDRangel::setValue(&nfm_mod_settings, pJson["NFMModSettings"], "SWGNFMModSettings", "SWGNFMModSettings");
@ -387,6 +396,9 @@ SWGChannelSettings::asJsonObject() {
if((interferometer_settings != nullptr) && (interferometer_settings->isSet())){
toJsonValue(QString("InterferometerSettings"), interferometer_settings, obj, QString("SWGInterferometerSettings"));
}
if((lo_ra_mod_settings != nullptr) && (lo_ra_mod_settings->isSet())){
toJsonValue(QString("LoRaModSettings"), lo_ra_mod_settings, obj, QString("SWGLoRaModSettings"));
}
if((nfm_demod_settings != nullptr) && (nfm_demod_settings->isSet())){
toJsonValue(QString("NFMDemodSettings"), nfm_demod_settings, obj, QString("SWGNFMDemodSettings"));
}
@ -607,6 +619,16 @@ SWGChannelSettings::setInterferometerSettings(SWGInterferometerSettings* interfe
this->m_interferometer_settings_isSet = true;
}
SWGLoRaModSettings*
SWGChannelSettings::getLoRaModSettings() {
return lo_ra_mod_settings;
}
void
SWGChannelSettings::setLoRaModSettings(SWGLoRaModSettings* lo_ra_mod_settings) {
this->lo_ra_mod_settings = lo_ra_mod_settings;
this->m_lo_ra_mod_settings_isSet = true;
}
SWGNFMDemodSettings*
SWGChannelSettings::getNfmDemodSettings() {
return nfm_demod_settings;
@ -786,6 +808,9 @@ SWGChannelSettings::isSet(){
if(interferometer_settings && interferometer_settings->isSet()){
isObjectUpdated = true; break;
}
if(lo_ra_mod_settings && lo_ra_mod_settings->isSet()){
isObjectUpdated = true; break;
}
if(nfm_demod_settings && nfm_demod_settings->isSet()){
isObjectUpdated = true; break;
}

View File

@ -36,6 +36,7 @@
#include "SWGFreeDVModSettings.h"
#include "SWGFreqTrackerSettings.h"
#include "SWGInterferometerSettings.h"
#include "SWGLoRaModSettings.h"
#include "SWGLocalSinkSettings.h"
#include "SWGLocalSourceSettings.h"
#include "SWGNFMDemodSettings.h"
@ -122,6 +123,9 @@ public:
SWGInterferometerSettings* getInterferometerSettings();
void setInterferometerSettings(SWGInterferometerSettings* interferometer_settings);
SWGLoRaModSettings* getLoRaModSettings();
void setLoRaModSettings(SWGLoRaModSettings* lo_ra_mod_settings);
SWGNFMDemodSettings* getNfmDemodSettings();
void setNfmDemodSettings(SWGNFMDemodSettings* nfm_demod_settings);
@ -216,6 +220,9 @@ private:
SWGInterferometerSettings* interferometer_settings;
bool m_interferometer_settings_isSet;
SWGLoRaModSettings* lo_ra_mod_settings;
bool m_lo_ra_mod_settings_isSet;
SWGNFMDemodSettings* nfm_demod_settings;
bool m_nfm_demod_settings_isSet;

View File

@ -0,0 +1,131 @@
/**
* SDRangel
* This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time ---
*
* OpenAPI spec version: 5.1.0
* Contact: f4exb06@gmail.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
#include "SWGLoRaModReport.h"
#include "SWGHelpers.h"
#include <QJsonDocument>
#include <QJsonArray>
#include <QObject>
#include <QDebug>
namespace SWGSDRangel {
SWGLoRaModReport::SWGLoRaModReport(QString* json) {
init();
this->fromJson(*json);
}
SWGLoRaModReport::SWGLoRaModReport() {
channel_power_db = 0.0f;
m_channel_power_db_isSet = false;
channel_sample_rate = 0;
m_channel_sample_rate_isSet = false;
}
SWGLoRaModReport::~SWGLoRaModReport() {
this->cleanup();
}
void
SWGLoRaModReport::init() {
channel_power_db = 0.0f;
m_channel_power_db_isSet = false;
channel_sample_rate = 0;
m_channel_sample_rate_isSet = false;
}
void
SWGLoRaModReport::cleanup() {
}
SWGLoRaModReport*
SWGLoRaModReport::fromJson(QString &json) {
QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject jsonObject = doc.object();
this->fromJsonObject(jsonObject);
return this;
}
void
SWGLoRaModReport::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&channel_power_db, pJson["channelPowerDB"], "float", "");
::SWGSDRangel::setValue(&channel_sample_rate, pJson["channelSampleRate"], "qint32", "");
}
QString
SWGLoRaModReport::asJson ()
{
QJsonObject* obj = this->asJsonObject();
QJsonDocument doc(*obj);
QByteArray bytes = doc.toJson();
delete obj;
return QString(bytes);
}
QJsonObject*
SWGLoRaModReport::asJsonObject() {
QJsonObject* obj = new QJsonObject();
if(m_channel_power_db_isSet){
obj->insert("channelPowerDB", QJsonValue(channel_power_db));
}
if(m_channel_sample_rate_isSet){
obj->insert("channelSampleRate", QJsonValue(channel_sample_rate));
}
return obj;
}
float
SWGLoRaModReport::getChannelPowerDb() {
return channel_power_db;
}
void
SWGLoRaModReport::setChannelPowerDb(float channel_power_db) {
this->channel_power_db = channel_power_db;
this->m_channel_power_db_isSet = true;
}
qint32
SWGLoRaModReport::getChannelSampleRate() {
return channel_sample_rate;
}
void
SWGLoRaModReport::setChannelSampleRate(qint32 channel_sample_rate) {
this->channel_sample_rate = channel_sample_rate;
this->m_channel_sample_rate_isSet = true;
}
bool
SWGLoRaModReport::isSet(){
bool isObjectUpdated = false;
do{
if(m_channel_power_db_isSet){
isObjectUpdated = true; break;
}
if(m_channel_sample_rate_isSet){
isObjectUpdated = true; break;
}
}while(false);
return isObjectUpdated;
}
}

View File

@ -0,0 +1,64 @@
/**
* SDRangel
* This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time ---
*
* OpenAPI spec version: 5.1.0
* Contact: f4exb06@gmail.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
/*
* SWGLoRaModReport.h
*
* LoRaMod
*/
#ifndef SWGLoRaModReport_H_
#define SWGLoRaModReport_H_
#include <QJsonObject>
#include "SWGObject.h"
#include "export.h"
namespace SWGSDRangel {
class SWG_API SWGLoRaModReport: public SWGObject {
public:
SWGLoRaModReport();
SWGLoRaModReport(QString* json);
virtual ~SWGLoRaModReport();
void init();
void cleanup();
virtual QString asJson () override;
virtual QJsonObject* asJsonObject() override;
virtual void fromJsonObject(QJsonObject &json) override;
virtual SWGLoRaModReport* fromJson(QString &jsonString) override;
float getChannelPowerDb();
void setChannelPowerDb(float channel_power_db);
qint32 getChannelSampleRate();
void setChannelSampleRate(qint32 channel_sample_rate);
virtual bool isSet() override;
private:
float channel_power_db;
bool m_channel_power_db_isSet;
qint32 channel_sample_rate;
bool m_channel_sample_rate_isSet;
};
}
#endif /* SWGLoRaModReport_H_ */

View File

@ -0,0 +1,413 @@
/**
* SDRangel
* This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time ---
*
* OpenAPI spec version: 5.1.0
* Contact: f4exb06@gmail.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
#include "SWGLoRaModSettings.h"
#include "SWGHelpers.h"
#include <QJsonDocument>
#include <QJsonArray>
#include <QObject>
#include <QDebug>
namespace SWGSDRangel {
SWGLoRaModSettings::SWGLoRaModSettings(QString* json) {
init();
this->fromJson(*json);
}
SWGLoRaModSettings::SWGLoRaModSettings() {
input_frequency_offset = 0L;
m_input_frequency_offset_isSet = false;
bandwidth_index = 0;
m_bandwidth_index_isSet = false;
spread_factor = 0;
m_spread_factor_isSet = false;
de_bits = 0;
m_de_bits_isSet = false;
message = nullptr;
m_message_isSet = false;
channel_mute = 0;
m_channel_mute_isSet = false;
rgb_color = 0;
m_rgb_color_isSet = false;
title = nullptr;
m_title_isSet = false;
stream_index = 0;
m_stream_index_isSet = false;
use_reverse_api = 0;
m_use_reverse_api_isSet = false;
reverse_api_address = nullptr;
m_reverse_api_address_isSet = false;
reverse_api_port = 0;
m_reverse_api_port_isSet = false;
reverse_api_device_index = 0;
m_reverse_api_device_index_isSet = false;
reverse_api_channel_index = 0;
m_reverse_api_channel_index_isSet = false;
}
SWGLoRaModSettings::~SWGLoRaModSettings() {
this->cleanup();
}
void
SWGLoRaModSettings::init() {
input_frequency_offset = 0L;
m_input_frequency_offset_isSet = false;
bandwidth_index = 0;
m_bandwidth_index_isSet = false;
spread_factor = 0;
m_spread_factor_isSet = false;
de_bits = 0;
m_de_bits_isSet = false;
message = new QString("");
m_message_isSet = false;
channel_mute = 0;
m_channel_mute_isSet = false;
rgb_color = 0;
m_rgb_color_isSet = false;
title = new QString("");
m_title_isSet = false;
stream_index = 0;
m_stream_index_isSet = false;
use_reverse_api = 0;
m_use_reverse_api_isSet = false;
reverse_api_address = new QString("");
m_reverse_api_address_isSet = false;
reverse_api_port = 0;
m_reverse_api_port_isSet = false;
reverse_api_device_index = 0;
m_reverse_api_device_index_isSet = false;
reverse_api_channel_index = 0;
m_reverse_api_channel_index_isSet = false;
}
void
SWGLoRaModSettings::cleanup() {
if(message != nullptr) {
delete message;
}
if(title != nullptr) {
delete title;
}
if(reverse_api_address != nullptr) {
delete reverse_api_address;
}
}
SWGLoRaModSettings*
SWGLoRaModSettings::fromJson(QString &json) {
QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject jsonObject = doc.object();
this->fromJsonObject(jsonObject);
return this;
}
void
SWGLoRaModSettings::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&input_frequency_offset, pJson["inputFrequencyOffset"], "qint64", "");
::SWGSDRangel::setValue(&bandwidth_index, pJson["bandwidthIndex"], "qint32", "");
::SWGSDRangel::setValue(&spread_factor, pJson["spreadFactor"], "qint32", "");
::SWGSDRangel::setValue(&de_bits, pJson["deBits"], "qint32", "");
::SWGSDRangel::setValue(&message, pJson["message"], "QString", "QString");
::SWGSDRangel::setValue(&channel_mute, pJson["channelMute"], "qint32", "");
::SWGSDRangel::setValue(&rgb_color, pJson["rgbColor"], "qint32", "");
::SWGSDRangel::setValue(&title, pJson["title"], "QString", "QString");
::SWGSDRangel::setValue(&stream_index, pJson["streamIndex"], "qint32", "");
::SWGSDRangel::setValue(&use_reverse_api, pJson["useReverseAPI"], "qint32", "");
::SWGSDRangel::setValue(&reverse_api_address, pJson["reverseAPIAddress"], "QString", "QString");
::SWGSDRangel::setValue(&reverse_api_port, pJson["reverseAPIPort"], "qint32", "");
::SWGSDRangel::setValue(&reverse_api_device_index, pJson["reverseAPIDeviceIndex"], "qint32", "");
::SWGSDRangel::setValue(&reverse_api_channel_index, pJson["reverseAPIChannelIndex"], "qint32", "");
}
QString
SWGLoRaModSettings::asJson ()
{
QJsonObject* obj = this->asJsonObject();
QJsonDocument doc(*obj);
QByteArray bytes = doc.toJson();
delete obj;
return QString(bytes);
}
QJsonObject*
SWGLoRaModSettings::asJsonObject() {
QJsonObject* obj = new QJsonObject();
if(m_input_frequency_offset_isSet){
obj->insert("inputFrequencyOffset", QJsonValue(input_frequency_offset));
}
if(m_bandwidth_index_isSet){
obj->insert("bandwidthIndex", QJsonValue(bandwidth_index));
}
if(m_spread_factor_isSet){
obj->insert("spreadFactor", QJsonValue(spread_factor));
}
if(m_de_bits_isSet){
obj->insert("deBits", QJsonValue(de_bits));
}
if(message != nullptr && *message != QString("")){
toJsonValue(QString("message"), message, obj, QString("QString"));
}
if(m_channel_mute_isSet){
obj->insert("channelMute", QJsonValue(channel_mute));
}
if(m_rgb_color_isSet){
obj->insert("rgbColor", QJsonValue(rgb_color));
}
if(title != nullptr && *title != QString("")){
toJsonValue(QString("title"), title, obj, QString("QString"));
}
if(m_stream_index_isSet){
obj->insert("streamIndex", QJsonValue(stream_index));
}
if(m_use_reverse_api_isSet){
obj->insert("useReverseAPI", QJsonValue(use_reverse_api));
}
if(reverse_api_address != nullptr && *reverse_api_address != QString("")){
toJsonValue(QString("reverseAPIAddress"), reverse_api_address, obj, QString("QString"));
}
if(m_reverse_api_port_isSet){
obj->insert("reverseAPIPort", QJsonValue(reverse_api_port));
}
if(m_reverse_api_device_index_isSet){
obj->insert("reverseAPIDeviceIndex", QJsonValue(reverse_api_device_index));
}
if(m_reverse_api_channel_index_isSet){
obj->insert("reverseAPIChannelIndex", QJsonValue(reverse_api_channel_index));
}
return obj;
}
qint64
SWGLoRaModSettings::getInputFrequencyOffset() {
return input_frequency_offset;
}
void
SWGLoRaModSettings::setInputFrequencyOffset(qint64 input_frequency_offset) {
this->input_frequency_offset = input_frequency_offset;
this->m_input_frequency_offset_isSet = true;
}
qint32
SWGLoRaModSettings::getBandwidthIndex() {
return bandwidth_index;
}
void
SWGLoRaModSettings::setBandwidthIndex(qint32 bandwidth_index) {
this->bandwidth_index = bandwidth_index;
this->m_bandwidth_index_isSet = true;
}
qint32
SWGLoRaModSettings::getSpreadFactor() {
return spread_factor;
}
void
SWGLoRaModSettings::setSpreadFactor(qint32 spread_factor) {
this->spread_factor = spread_factor;
this->m_spread_factor_isSet = true;
}
qint32
SWGLoRaModSettings::getDeBits() {
return de_bits;
}
void
SWGLoRaModSettings::setDeBits(qint32 de_bits) {
this->de_bits = de_bits;
this->m_de_bits_isSet = true;
}
QString*
SWGLoRaModSettings::getMessage() {
return message;
}
void
SWGLoRaModSettings::setMessage(QString* message) {
this->message = message;
this->m_message_isSet = true;
}
qint32
SWGLoRaModSettings::getChannelMute() {
return channel_mute;
}
void
SWGLoRaModSettings::setChannelMute(qint32 channel_mute) {
this->channel_mute = channel_mute;
this->m_channel_mute_isSet = true;
}
qint32
SWGLoRaModSettings::getRgbColor() {
return rgb_color;
}
void
SWGLoRaModSettings::setRgbColor(qint32 rgb_color) {
this->rgb_color = rgb_color;
this->m_rgb_color_isSet = true;
}
QString*
SWGLoRaModSettings::getTitle() {
return title;
}
void
SWGLoRaModSettings::setTitle(QString* title) {
this->title = title;
this->m_title_isSet = true;
}
qint32
SWGLoRaModSettings::getStreamIndex() {
return stream_index;
}
void
SWGLoRaModSettings::setStreamIndex(qint32 stream_index) {
this->stream_index = stream_index;
this->m_stream_index_isSet = true;
}
qint32
SWGLoRaModSettings::getUseReverseApi() {
return use_reverse_api;
}
void
SWGLoRaModSettings::setUseReverseApi(qint32 use_reverse_api) {
this->use_reverse_api = use_reverse_api;
this->m_use_reverse_api_isSet = true;
}
QString*
SWGLoRaModSettings::getReverseApiAddress() {
return reverse_api_address;
}
void
SWGLoRaModSettings::setReverseApiAddress(QString* reverse_api_address) {
this->reverse_api_address = reverse_api_address;
this->m_reverse_api_address_isSet = true;
}
qint32
SWGLoRaModSettings::getReverseApiPort() {
return reverse_api_port;
}
void
SWGLoRaModSettings::setReverseApiPort(qint32 reverse_api_port) {
this->reverse_api_port = reverse_api_port;
this->m_reverse_api_port_isSet = true;
}
qint32
SWGLoRaModSettings::getReverseApiDeviceIndex() {
return reverse_api_device_index;
}
void
SWGLoRaModSettings::setReverseApiDeviceIndex(qint32 reverse_api_device_index) {
this->reverse_api_device_index = reverse_api_device_index;
this->m_reverse_api_device_index_isSet = true;
}
qint32
SWGLoRaModSettings::getReverseApiChannelIndex() {
return reverse_api_channel_index;
}
void
SWGLoRaModSettings::setReverseApiChannelIndex(qint32 reverse_api_channel_index) {
this->reverse_api_channel_index = reverse_api_channel_index;
this->m_reverse_api_channel_index_isSet = true;
}
bool
SWGLoRaModSettings::isSet(){
bool isObjectUpdated = false;
do{
if(m_input_frequency_offset_isSet){
isObjectUpdated = true; break;
}
if(m_bandwidth_index_isSet){
isObjectUpdated = true; break;
}
if(m_spread_factor_isSet){
isObjectUpdated = true; break;
}
if(m_de_bits_isSet){
isObjectUpdated = true; break;
}
if(message && *message != QString("")){
isObjectUpdated = true; break;
}
if(m_channel_mute_isSet){
isObjectUpdated = true; break;
}
if(m_rgb_color_isSet){
isObjectUpdated = true; break;
}
if(title && *title != QString("")){
isObjectUpdated = true; break;
}
if(m_stream_index_isSet){
isObjectUpdated = true; break;
}
if(m_use_reverse_api_isSet){
isObjectUpdated = true; break;
}
if(reverse_api_address && *reverse_api_address != QString("")){
isObjectUpdated = true; break;
}
if(m_reverse_api_port_isSet){
isObjectUpdated = true; break;
}
if(m_reverse_api_device_index_isSet){
isObjectUpdated = true; break;
}
if(m_reverse_api_channel_index_isSet){
isObjectUpdated = true; break;
}
}while(false);
return isObjectUpdated;
}
}

View File

@ -0,0 +1,137 @@
/**
* SDRangel
* This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time ---
*
* OpenAPI spec version: 5.1.0
* Contact: f4exb06@gmail.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
/*
* SWGLoRaModSettings.h
*
* LoRaMod
*/
#ifndef SWGLoRaModSettings_H_
#define SWGLoRaModSettings_H_
#include <QJsonObject>
#include <QString>
#include "SWGObject.h"
#include "export.h"
namespace SWGSDRangel {
class SWG_API SWGLoRaModSettings: public SWGObject {
public:
SWGLoRaModSettings();
SWGLoRaModSettings(QString* json);
virtual ~SWGLoRaModSettings();
void init();
void cleanup();
virtual QString asJson () override;
virtual QJsonObject* asJsonObject() override;
virtual void fromJsonObject(QJsonObject &json) override;
virtual SWGLoRaModSettings* fromJson(QString &jsonString) override;
qint64 getInputFrequencyOffset();
void setInputFrequencyOffset(qint64 input_frequency_offset);
qint32 getBandwidthIndex();
void setBandwidthIndex(qint32 bandwidth_index);
qint32 getSpreadFactor();
void setSpreadFactor(qint32 spread_factor);
qint32 getDeBits();
void setDeBits(qint32 de_bits);
QString* getMessage();
void setMessage(QString* message);
qint32 getChannelMute();
void setChannelMute(qint32 channel_mute);
qint32 getRgbColor();
void setRgbColor(qint32 rgb_color);
QString* getTitle();
void setTitle(QString* title);
qint32 getStreamIndex();
void setStreamIndex(qint32 stream_index);
qint32 getUseReverseApi();
void setUseReverseApi(qint32 use_reverse_api);
QString* getReverseApiAddress();
void setReverseApiAddress(QString* reverse_api_address);
qint32 getReverseApiPort();
void setReverseApiPort(qint32 reverse_api_port);
qint32 getReverseApiDeviceIndex();
void setReverseApiDeviceIndex(qint32 reverse_api_device_index);
qint32 getReverseApiChannelIndex();
void setReverseApiChannelIndex(qint32 reverse_api_channel_index);
virtual bool isSet() override;
private:
qint64 input_frequency_offset;
bool m_input_frequency_offset_isSet;
qint32 bandwidth_index;
bool m_bandwidth_index_isSet;
qint32 spread_factor;
bool m_spread_factor_isSet;
qint32 de_bits;
bool m_de_bits_isSet;
QString* message;
bool m_message_isSet;
qint32 channel_mute;
bool m_channel_mute_isSet;
qint32 rgb_color;
bool m_rgb_color_isSet;
QString* title;
bool m_title_isSet;
qint32 stream_index;
bool m_stream_index_isSet;
qint32 use_reverse_api;
bool m_use_reverse_api_isSet;
QString* reverse_api_address;
bool m_reverse_api_address_isSet;
qint32 reverse_api_port;
bool m_reverse_api_port_isSet;
qint32 reverse_api_device_index;
bool m_reverse_api_device_index_isSet;
qint32 reverse_api_channel_index;
bool m_reverse_api_channel_index_isSet;
};
}
#endif /* SWGLoRaModSettings_H_ */

View File

@ -101,6 +101,8 @@
#include "SWGLimeSdrInputSettings.h"
#include "SWGLimeSdrOutputReport.h"
#include "SWGLimeSdrOutputSettings.h"
#include "SWGLoRaModReport.h"
#include "SWGLoRaModSettings.h"
#include "SWGLocalInputReport.h"
#include "SWGLocalInputSettings.h"
#include "SWGLocalOutputReport.h"
@ -439,6 +441,12 @@ namespace SWGSDRangel {
if(QString("SWGLimeSdrOutputSettings").compare(type) == 0) {
return new SWGLimeSdrOutputSettings();
}
if(QString("SWGLoRaModReport").compare(type) == 0) {
return new SWGLoRaModReport();
}
if(QString("SWGLoRaModSettings").compare(type) == 0) {
return new SWGLoRaModSettings();
}
if(QString("SWGLocalInputReport").compare(type) == 0) {
return new SWGLocalInputReport();
}