Browse Source

Add ChirpModem demodulator channel plugin (libchirpmodem Rx)

New channel Rx plugin demodchirpmodem, built on libchirpmodem (format v1),
modelled on demodselcal: plugin, settings, baseband, sink, GUI, web API
adapter, readme. Rx only.

- The channel is decimated to at least 2 x BW; the library is given the
  delivered rate and the signal's residual offset in it (if_offset).
- The chirpmodem_rx handle lives in the sink and is used only on the
  baseband thread under the baseband mutex. Settings changes mark it stale;
  it is rebuilt once per message, never during chirpmodem_rx_push().
- Frames are copied in the callback and posted to the channel, which
  forwards them to the GUI and publishes OK frames (whole MAC frame) on the
  "packets" pipe.
- GUI: SF, BW, effort, auto effort, report failures, max bytes; frames table
  (UTC, status, profile, src, dst, SNR, offset Hz/ppm, mode, length, text,
  hex) with licensed-profile policy flag; channel spectrum.
- libchirpmodem found with find_package(chirpmodem 0.1 REQUIRED), hint
  CHIRPMODEM_DIR or ~/.local; linked statically. Builds in SERVER_MODE.

Web API / MCP support:
- ChirpModemDemod.yaml (settings and report), SWG model classes, entries
  in SWGChannelSettings/SWGChannelReport/SWGModelFactory, webapiutils,
  webapirequestmapper and webapi.qrc.
- MCP data feed: listen to sdrangel.channel.chirpmodemdemod and decode the
  MAC frame (flags, base-40 callsigns, body) for get_packets.

Verified on the 2026-10-23 OTA capture (ota.cu8 -> .sdriq, FileInput):
49/49 frames, identical to cm_rx in order, source and body; last-frame SNR
and offset match (-10.1 dB, -2651.5 Hz, -11.86 ppm).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chirpmodem-v8.1.0
Daniel Peter Chokola 2 weeks ago
parent
commit
693cfacd2e
  1. 1
      CMakeLists.txt
  2. 6
      plugins/channelrx/CMakeLists.txt
  3. 84
      plugins/channelrx/demodchirpmodem/CMakeLists.txt
  4. 600
      plugins/channelrx/demodchirpmodem/chirpmodemdemod.cpp
  5. 154
      plugins/channelrx/demodchirpmodem/chirpmodemdemod.h
  6. 178
      plugins/channelrx/demodchirpmodem/chirpmodemdemodbaseband.cpp
  7. 101
      plugins/channelrx/demodchirpmodem/chirpmodemdemodbaseband.h
  8. 597
      plugins/channelrx/demodchirpmodem/chirpmodemdemodgui.cpp
  9. 127
      plugins/channelrx/demodchirpmodem/chirpmodemdemodgui.h
  10. 575
      plugins/channelrx/demodchirpmodem/chirpmodemdemodgui.ui
  11. 91
      plugins/channelrx/demodchirpmodem/chirpmodemdemodplugin.cpp
  12. 50
      plugins/channelrx/demodchirpmodem/chirpmodemdemodplugin.h
  13. 314
      plugins/channelrx/demodchirpmodem/chirpmodemdemodsettings.cpp
  14. 77
      plugins/channelrx/demodchirpmodem/chirpmodemdemodsettings.h
  15. 312
      plugins/channelrx/demodchirpmodem/chirpmodemdemodsink.cpp
  16. 88
      plugins/channelrx/demodchirpmodem/chirpmodemdemodsink.h
  17. 49
      plugins/channelrx/demodchirpmodem/chirpmodemdemodwebapiadapter.cpp
  18. 43
      plugins/channelrx/demodchirpmodem/chirpmodemdemodwebapiadapter.h
  19. 48
      plugins/channelrx/demodchirpmodem/chirpmodemmessages.cpp
  20. 105
      plugins/channelrx/demodchirpmodem/chirpmodemmessages.h
  21. 88
      plugins/channelrx/demodchirpmodem/readme.md
  22. 71
      plugins/feature/mcpserver/mcpdatafeed.cpp
  23. 1
      sdrbase/resources/webapi.qrc
  24. 2
      sdrbase/resources/webapi/doc/swagger/include/ChannelReport.yaml
  25. 2
      sdrbase/resources/webapi/doc/swagger/include/ChannelSettings.yaml
  26. 162
      sdrbase/resources/webapi/doc/swagger/include/ChirpModemDemod.yaml
  27. 6
      sdrbase/webapi/webapirequestmapper.cpp
  28. 2
      sdrbase/webapi/webapiutils.cpp
  29. 2
      swagger/sdrangel/api/swagger/include/ChannelReport.yaml
  30. 2
      swagger/sdrangel/api/swagger/include/ChannelSettings.yaml
  31. 162
      swagger/sdrangel/api/swagger/include/ChirpModemDemod.yaml
  32. 26
      swagger/sdrangel/code/qt5/client/SWGChannelReport.cpp
  33. 5
      swagger/sdrangel/code/qt5/client/SWGChannelReport.h
  34. 26
      swagger/sdrangel/code/qt5/client/SWGChannelSettings.cpp
  35. 5
      swagger/sdrangel/code/qt5/client/SWGChannelSettings.h
  36. 177
      swagger/sdrangel/code/qt5/client/SWGChirpModemDemodReport.cpp
  37. 130
      swagger/sdrangel/code/qt5/client/SWGChirpModemDemodReport.h
  38. 138
      swagger/sdrangel/code/qt5/client/SWGChirpModemDemodSettings.cpp
  39. 104
      swagger/sdrangel/code/qt5/client/SWGChirpModemDemodSettings.h
  40. 12
      swagger/sdrangel/code/qt5/client/SWGModelFactory.h

1
CMakeLists.txt

@ -177,6 +177,7 @@ option(ENABLE_CHANNELRX_DEMODRTTY "Enable channelrx demodrtty plugin" ON) @@ -177,6 +177,7 @@ option(ENABLE_CHANNELRX_DEMODRTTY "Enable channelrx demodrtty plugin" ON)
option(ENABLE_CHANNELRX_DEMODPSK31 "Enable channelrx demodpsk31 plugin" ON)
option(ENABLE_CHANNELRX_DEMODILS "Enable channelrx demodils plugin" ON)
option(ENABLE_CHANNELRX_DEMODSELCAL "Enable channelrx demodselcal plugin" ON)
option(ENABLE_CHANNELRX_DEMODCHIRPMODEM "Enable channelrx demodchirpmodem plugin (needs libchirpmodem)" ON)
option(ENABLE_CHANNELRX_DEMOD802.15.4 "Enable channelrx demod802.15.4 plugin" ON)
option(ENABLE_CHANNELRX_DEMODDSC "Enable channelrx demoddsc plugin" ON)
option(ENABLE_CHANNELRX_HEATMAP "Enable channelrx heatmap plugin" ON)

6
plugins/channelrx/CMakeLists.txt

@ -323,6 +323,12 @@ else() @@ -323,6 +323,12 @@ else()
message(STATUS "Not building demodselcal (ENABLE_CHANNELRX_DEMODSELCAL=${ENABLE_CHANNELRX_DEMODSELCAL})")
endif()
if(ENABLE_CHANNELRX_DEMODCHIRPMODEM)
add_subdirectory(demodchirpmodem)
else()
message(STATUS "Not building demodchirpmodem (ENABLE_CHANNELRX_DEMODCHIRPMODEM=${ENABLE_CHANNELRX_DEMODCHIRPMODEM})")
endif()
if (ENABLE_CHANNELRX_DEMOD802.15.4)
add_subdirectory(demod802.15.4)
else()

84
plugins/channelrx/demodchirpmodem/CMakeLists.txt

@ -0,0 +1,84 @@ @@ -0,0 +1,84 @@
project(demodchirpmodem)
# libchirpmodem: found through its CMake package. A local install (for example
# cmake --install build --prefix ~/.local) is found through CHIRPMODEM_DIR,
# the CMake prefix path, or the default hint below.
set(CHIRPMODEM_DIR "" CACHE PATH "Install prefix of libchirpmodem")
find_package(chirpmodem 0.1 REQUIRED
HINTS ${CHIRPMODEM_DIR} $ENV{HOME}/.local
)
set(demodchirpmodem_SOURCES
chirpmodemdemod.cpp
chirpmodemdemodsettings.cpp
chirpmodemdemodbaseband.cpp
chirpmodemdemodsink.cpp
chirpmodemmessages.cpp
chirpmodemdemodplugin.cpp
chirpmodemdemodwebapiadapter.cpp
)
set(demodchirpmodem_HEADERS
chirpmodemdemod.h
chirpmodemdemodsettings.h
chirpmodemdemodbaseband.h
chirpmodemdemodsink.h
chirpmodemmessages.h
chirpmodemdemodplugin.h
chirpmodemdemodwebapiadapter.h
)
include_directories(
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
)
if(NOT SERVER_MODE)
set(demodchirpmodem_SOURCES
${demodchirpmodem_SOURCES}
chirpmodemdemodgui.cpp
chirpmodemdemodgui.ui
)
set(demodchirpmodem_HEADERS
${demodchirpmodem_HEADERS}
chirpmodemdemodgui.h
)
set(TARGET_NAME ${PLUGINS_PREFIX}demodchirpmodem)
set(TARGET_LIB "Qt::Widgets")
set(TARGET_LIB_GUI "sdrgui")
set(INSTALL_FOLDER ${INSTALL_PLUGINS_DIR})
else()
set(TARGET_NAME ${PLUGINSSRV_PREFIX}demodchirpmodemsrv)
set(TARGET_LIB "")
set(TARGET_LIB_GUI "")
set(INSTALL_FOLDER ${INSTALL_PLUGINSSRV_DIR})
endif()
if(NOT Qt6_FOUND)
add_library(${TARGET_NAME} ${demodchirpmodem_SOURCES})
else()
qt_add_plugin(${TARGET_NAME} CLASS_NAME ChirpModemDemodPlugin)
target_sources(${TARGET_NAME} PRIVATE ${demodchirpmodem_SOURCES})
endif()
if(NOT BUILD_SHARED_LIBS)
set_property(GLOBAL APPEND PROPERTY STATIC_PLUGINS_PROPERTY ${TARGET_NAME})
endif()
# The static library is position independent, so the plugin carries the modem
# and needs no library path at run time.
target_link_libraries(${TARGET_NAME} PRIVATE
Qt::Core
${TARGET_LIB}
sdrbase
${TARGET_LIB_GUI}
chirpmodem::chirpmodem_static
)
install(TARGETS ${TARGET_NAME} DESTINATION ${INSTALL_FOLDER})
# Install debug symbols
if (WIN32)
install(FILES $<TARGET_PROPERTY:${TARGET_NAME},RUNTIME_OUTPUT_DIRECTORY>/${TARGET_NAME}stripped.pdb CONFIGURATIONS Release DESTINATION ${INSTALL_FOLDER} RENAME ${TARGET_NAME}.pdb )
install(FILES $<TARGET_PDB_FILE:${TARGET_NAME}> CONFIGURATIONS Debug RelWithDebInfo DESTINATION ${INSTALL_FOLDER} )
endif()

600
plugins/channelrx/demodchirpmodem/chirpmodemdemod.cpp

@ -0,0 +1,600 @@ @@ -0,0 +1,600 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Dan Chokola, KD2HSG //
// Based on the SELCAL demodulator plugin: //
// Copyright (C) 2021-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// //
// 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 <QBuffer>
#include <QDebug>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <algorithm>
#include "SWGChannelSettings.h"
#include "SWGWorkspaceInfo.h"
#include "SWGChirpModemDemodSettings.h"
#include "SWGChannelReport.h"
#include "dsp/dspcommands.h"
#include "device/deviceapi.h"
#include "settings/serializable.h"
#include "util/db.h"
#include "maincore.h"
#include "chirpmodemdemod.h"
MESSAGE_CLASS_DEFINITION(ChirpModemDemod::MsgConfigureChirpModemDemod, Message)
const char *const ChirpModemDemod::m_channelIdURI = "sdrangel.channel.chirpmodemdemod";
const char *const ChirpModemDemod::m_channelId = "ChirpModemDemod";
static QString printable(const QByteArray& bytes)
{
QString s;
for (char c : bytes) {
s.append(((c >= 0x20) && (c < 0x7f)) ? QChar(c) : QChar('.'));
}
return s;
}
ChirpModemDemod::ChirpModemDemod(DeviceAPI *deviceAPI) :
ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSink),
m_deviceAPI(deviceAPI),
m_spectrumVis(SDR_RX_SCALEF),
m_basebandSampleRate(0),
m_centerFrequency(0)
{
setObjectName(m_channelId);
m_thread.setObjectName("ChirpModemBB");
m_basebandSink = new ChirpModemDemodBaseband();
m_basebandSink->setMessageQueueToChannel(getInputMessageQueue());
m_basebandSink->setSpectrumSink(&m_spectrumVis);
m_basebandSink->moveToThread(&m_thread);
applySettings(QStringList(), m_settings, true);
m_deviceAPI->addChannelSink(this);
m_deviceAPI->addChannelSinkAPI(this);
m_networkManager = new QNetworkAccessManager();
QObject::connect(m_networkManager, &QNetworkAccessManager::finished, this, &ChirpModemDemod::networkManagerFinished);
QObject::connect(this, &ChannelAPI::indexInDeviceSetChanged, this, &ChirpModemDemod::handleIndexInDeviceSetChanged);
}
ChirpModemDemod::~ChirpModemDemod()
{
qDebug("ChirpModemDemod::~ChirpModemDemod");
QObject::disconnect(m_networkManager, &QNetworkAccessManager::finished, this, &ChirpModemDemod::networkManagerFinished);
delete m_networkManager;
m_deviceAPI->removeChannelSinkAPI(this);
m_deviceAPI->removeChannelSink(this, true, m_settings.m_streamIndex);
if (m_basebandSink->isRunning()) {
stop();
}
delete m_basebandSink;
}
void ChirpModemDemod::setDeviceAPI(DeviceAPI *deviceAPI)
{
if (deviceAPI != m_deviceAPI)
{
m_deviceAPI->removeChannelSinkAPI(this);
m_deviceAPI->removeChannelSink(this, false, m_settings.m_streamIndex);
m_deviceAPI = deviceAPI;
m_deviceAPI->addChannelSink(this, m_settings.m_streamIndex);
m_deviceAPI->addChannelSinkAPI(this);
}
}
uint32_t ChirpModemDemod::getNumberOfDeviceStreams() const
{
return m_deviceAPI->getNbSourceStreams();
}
void ChirpModemDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly)
{
(void) positiveOnly;
m_basebandSink->feed(begin, end);
}
void ChirpModemDemod::start()
{
qDebug("ChirpModemDemod::start");
{
QMutexLocker lock(&m_reportMutex);
m_frameCount = 0;
m_okCount = 0;
m_failCount = 0;
m_policyCount = 0;
}
m_basebandSink->reset();
m_basebandSink->startWork();
m_thread.start();
DSPSignalNotification *dspMsg = new DSPSignalNotification(m_basebandSampleRate, m_centerFrequency);
m_basebandSink->getInputMessageQueue()->push(dspMsg);
ChirpModemDemodBaseband::MsgConfigureChirpModemDemodBaseband *msg =
ChirpModemDemodBaseband::MsgConfigureChirpModemDemodBaseband::create(QStringList(), m_settings, true);
m_basebandSink->getInputMessageQueue()->push(msg);
}
void ChirpModemDemod::stop()
{
qDebug("ChirpModemDemod::stop");
m_basebandSink->stopWork();
m_thread.quit();
m_thread.wait();
}
bool ChirpModemDemod::handleMessage(const Message& cmd)
{
if (MsgConfigureChirpModemDemod::match(cmd))
{
const auto& cfg = static_cast<const MsgConfigureChirpModemDemod&>(cmd);
qDebug() << "ChirpModemDemod::handleMessage: MsgConfigureChirpModemDemod";
applySettings(cfg.getSettingsKeys(), cfg.getSettings(), cfg.getForce());
return true;
}
else if (DSPSignalNotification::match(cmd))
{
const auto& notif = static_cast<const DSPSignalNotification&>(cmd);
m_basebandSampleRate = notif.getSampleRate();
m_centerFrequency = notif.getCenterFrequency();
qDebug() << "ChirpModemDemod::handleMessage: DSPSignalNotification";
m_basebandSink->getInputMessageQueue()->push(new DSPSignalNotification(notif));
if (m_guiMessageQueue) {
m_guiMessageQueue->push(new DSPSignalNotification(notif));
}
return true;
}
else if (ChirpModemMessages::MsgFrame::match(cmd))
{
frameReceived(static_cast<const ChirpModemMessages::MsgFrame&>(cmd).getFrame());
return true;
}
else if (ChirpModemMessages::MsgStatus::match(cmd))
{
const auto& status = static_cast<const ChirpModemMessages::MsgStatus&>(cmd).getStatus();
{
QMutexLocker lock(&m_reportMutex);
m_status = status;
}
if (getMessageQueueToGUI()) {
getMessageQueueToGUI()->push(ChirpModemMessages::MsgStatus::create(status));
}
return true;
}
else
{
return false;
}
}
void ChirpModemDemod::frameReceived(const ChirpModemMessages::Frame& frame)
{
{
QMutexLocker lock(&m_reportMutex);
m_lastFrame = frame;
m_frameCount++;
if (frame.m_status == ChirpModemMessages::StatusOK) {
m_okCount++;
} else {
m_failCount++;
}
if (frame.m_status == ChirpModemMessages::StatusOK && !frame.m_policyOk) {
m_policyCount++;
}
}
if (getMessageQueueToGUI()) {
getMessageQueueToGUI()->push(ChirpModemMessages::MsgFrame::create(frame));
}
// Decoded frames go to packet consumers (the MCP server's get_packets,
// and any feature listening on this channel's "packets" pipe) as the raw
// MAC frame
if ((frame.m_status == ChirpModemMessages::StatusOK) && !frame.m_mac.isEmpty())
{
QList<ObjectPipe *> packetsPipes;
MainCore::instance()->getMessagePipes().getMessagePipes(this, "packets", packetsPipes);
for (const auto& pipe : packetsPipes)
{
MessageQueue *messageQueue = qobject_cast<MessageQueue *>(pipe->m_element);
messageQueue->push(MainCore::MsgPacket::create(this, frame.m_mac, frame.m_dateTime.toLocalTime()));
}
}
}
void ChirpModemDemod::setCenterFrequency(qint64 frequency)
{
ChirpModemDemodSettings settings = m_settings;
settings.m_inputFrequencyOffset = frequency;
applySettings(QStringList("inputFrequencyOffset"), settings, false);
if (m_guiMessageQueue) {
m_guiMessageQueue->push(MsgConfigureChirpModemDemod::create(QStringList("inputFrequencyOffset"), settings, false));
}
}
void ChirpModemDemod::applySettings(const QStringList& settingsKeys, const ChirpModemDemodSettings& incomingSettings, bool force)
{
ChirpModemDemodSettings settings = incomingSettings;
settings.normalize();
settings.m_streamIndex = std::min(settings.m_streamIndex, std::max(0, static_cast<int>(getNumberOfDeviceStreams()) - 1));
qDebug() << "ChirpModemDemod::applySettings:" << settings.getDebugString(settingsKeys, force);
if ((settingsKeys.contains("streamIndex") || force) && (settings.m_streamIndex != m_settings.m_streamIndex))
{
if (m_deviceAPI->getSampleMIMO()) // change of stream is possible for MIMO devices only
{
m_deviceAPI->removeChannelSinkAPI(this);
m_deviceAPI->removeChannelSink(this, false, m_settings.m_streamIndex);
m_deviceAPI->addChannelSink(this, settings.m_streamIndex);
m_deviceAPI->addChannelSinkAPI(this);
m_settings.m_streamIndex = settings.m_streamIndex; // make sure ChannelAPI::getStreamIndex() is consistent
emit streamIndexChanged(settings.m_streamIndex);
}
}
m_basebandSink->getInputMessageQueue()->push(
ChirpModemDemodBaseband::MsgConfigureChirpModemDemodBaseband::create(settingsKeys, settings, force));
if (settings.m_useReverseAPI)
{
bool fullUpdate =
((settingsKeys.contains("useReverseAPI") && (settings.m_useReverseAPI != m_settings.m_useReverseAPI)) && settings.m_useReverseAPI) ||
(settingsKeys.contains("reverseAPIAddress") && (settings.m_reverseAPIAddress != m_settings.m_reverseAPIAddress)) ||
(settingsKeys.contains("reverseAPIPort") && (settings.m_reverseAPIPort != m_settings.m_reverseAPIPort)) ||
(settingsKeys.contains("reverseAPIDeviceIndex") && (settings.m_reverseAPIDeviceIndex != m_settings.m_reverseAPIDeviceIndex)) ||
(settingsKeys.contains("reverseAPIChannelIndex") && (settings.m_reverseAPIChannelIndex != m_settings.m_reverseAPIChannelIndex));
webapiReverseSendSettings(settingsKeys, settings, fullUpdate || force);
}
if (force) {
m_settings = settings;
} else {
m_settings.applySettings(settingsKeys, settings);
}
}
QByteArray ChirpModemDemod::serialize() const
{
return m_settings.serialize();
}
bool ChirpModemDemod::deserialize(const QByteArray& data)
{
bool valid = m_settings.deserialize(data);
if (!valid) {
m_settings.resetToDefaults();
}
m_inputMessageQueue.push(MsgConfigureChirpModemDemod::create(QStringList(), m_settings, true));
return valid;
}
int ChirpModemDemod::getChannelSampleRate() const
{
return m_basebandSink ? m_basebandSink->getChannelSampleRate() : 0;
}
int ChirpModemDemod::webapiSettingsGet(SWGSDRangel::SWGChannelSettings& response, QString& errorMessage)
{
(void) errorMessage;
response.setChirpModemDemodSettings(new SWGSDRangel::SWGChirpModemDemodSettings());
response.getChirpModemDemodSettings()->init();
webapiFormatChannelSettings(response, m_settings);
return 200;
}
int ChirpModemDemod::webapiWorkspaceGet(SWGSDRangel::SWGWorkspaceInfo& response, QString& errorMessage)
{
(void) errorMessage;
response.setIndex(m_settings.m_workspaceIndex);
return 200;
}
int ChirpModemDemod::webapiSettingsPutPatch(bool force, const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response, QString& errorMessage)
{
(void) errorMessage;
ChirpModemDemodSettings settings = m_settings;
webapiUpdateChannelSettings(settings, channelSettingsKeys, response);
settings.m_streamIndex = std::min(settings.m_streamIndex, std::max(0, static_cast<int>(getNumberOfDeviceStreams()) - 1));
m_inputMessageQueue.push(MsgConfigureChirpModemDemod::create(channelSettingsKeys, settings, force));
if (m_guiMessageQueue) {
m_guiMessageQueue->push(MsgConfigureChirpModemDemod::create(channelSettingsKeys, settings, force));
}
webapiFormatChannelSettings(response, settings);
return 200;
}
int ChirpModemDemod::webapiReportGet(SWGSDRangel::SWGChannelReport& response, QString& errorMessage)
{
(void) errorMessage;
response.setChirpModemDemodReport(new SWGSDRangel::SWGChirpModemDemodReport());
response.getChirpModemDemodReport()->init();
webapiFormatChannelReport(response);
return 200;
}
void ChirpModemDemod::webapiUpdateChannelSettings(ChirpModemDemodSettings& settings, const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response)
{
auto *model = response.getChirpModemDemodSettings();
if (!model) {
return;
}
if (channelSettingsKeys.contains("inputFrequencyOffset")) {
settings.m_inputFrequencyOffset = model->getInputFrequencyOffset();
}
if (channelSettingsKeys.contains("spreadFactor")) {
settings.m_spreadFactor = model->getSpreadFactor();
}
if (channelSettingsKeys.contains("bandwidth")) {
settings.m_bandwidth = model->getBandwidth();
}
if (channelSettingsKeys.contains("effort")) {
settings.m_effort = model->getEffort();
}
if (channelSettingsKeys.contains("autoEffort")) {
settings.m_autoEffort = model->getAutoEffort() != 0;
}
if (channelSettingsKeys.contains("reportFailures")) {
settings.m_reportFailures = model->getReportFailures() != 0;
}
if (channelSettingsKeys.contains("maxBytes")) {
settings.m_maxBytes = model->getMaxBytes();
}
if (channelSettingsKeys.contains("rgbColor")) {
settings.m_rgbColor = model->getRgbColor();
}
if (channelSettingsKeys.contains("title") && model->getTitle()) {
settings.m_title = *model->getTitle();
}
if (channelSettingsKeys.contains("streamIndex")) {
settings.m_streamIndex = model->getStreamIndex();
}
if (channelSettingsKeys.contains("useReverseAPI")) {
settings.m_useReverseAPI = model->getUseReverseApi() != 0;
}
if (channelSettingsKeys.contains("reverseAPIAddress") && model->getReverseApiAddress()) {
settings.m_reverseAPIAddress = *model->getReverseApiAddress();
}
if (channelSettingsKeys.contains("reverseAPIPort")) {
settings.m_reverseAPIPort = model->getReverseApiPort();
}
if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
settings.m_reverseAPIDeviceIndex = model->getReverseApiDeviceIndex();
}
if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
settings.m_reverseAPIChannelIndex = model->getReverseApiChannelIndex();
}
if (settings.m_channelMarker && channelSettingsKeys.contains("channelMarker") && model->getChannelMarker()) {
settings.m_channelMarker->updateFrom(channelSettingsKeys, model->getChannelMarker());
}
if (settings.m_rollupState && channelSettingsKeys.contains("rollupState") && model->getRollupState()) {
settings.m_rollupState->updateFrom(channelSettingsKeys, model->getRollupState());
}
settings.normalize();
}
void ChirpModemDemod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const ChirpModemDemodSettings& settings)
{
auto *model = response.getChirpModemDemodSettings();
model->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
model->setSpreadFactor(settings.m_spreadFactor);
model->setBandwidth(settings.m_bandwidth);
model->setEffort(settings.m_effort);
model->setAutoEffort(settings.m_autoEffort ? 1 : 0);
model->setReportFailures(settings.m_reportFailures ? 1 : 0);
model->setMaxBytes(settings.m_maxBytes);
model->setRgbColor(settings.m_rgbColor);
model->setTitle(new QString(settings.m_title));
model->setStreamIndex(settings.m_streamIndex);
model->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
model->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
model->setReverseApiPort(settings.m_reverseAPIPort);
model->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
model->setReverseApiChannelIndex(settings.m_reverseAPIChannelIndex);
if (settings.m_channelMarker)
{
auto *item = new SWGSDRangel::SWGChannelMarker();
settings.m_channelMarker->formatTo(item);
model->setChannelMarker(item);
}
if (settings.m_rollupState)
{
auto *item = new SWGSDRangel::SWGRollupState();
settings.m_rollupState->formatTo(item);
model->setRollupState(item);
}
}
void ChirpModemDemod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response)
{
double avg, peak;
int count;
getMagSqLevels(avg, peak, count);
auto *model = response.getChirpModemDemodReport();
model->setChannelPowerDb(CalcDb::dbPower(avg));
QMutexLocker lock(&m_reportMutex);
model->setChannelSampleRate(m_status.m_channelSampleRate);
model->setIfOffset(m_status.m_ifOffset);
model->setFrequency(m_status.m_frequency);
model->setReceiverValid(m_status.m_valid ? 1 : 0);
model->setReceiverError(new QString(m_status.m_error));
model->setEffort(m_status.m_effort);
model->setLoad(m_status.m_load);
model->setOkCount(m_okCount);
model->setFailCount(m_failCount);
model->setPolicyFailCount(m_policyCount);
if (m_frameCount > 0)
{
model->setLastTimestamp(new QString(m_lastFrame.m_dateTime.toString(Qt::ISODateWithMs)));
model->setLastStatus(new QString(ChirpModemMessages::statusName(m_lastFrame.m_status)));
model->setLastProfile(new QString(ChirpModemMessages::profileName(m_lastFrame.m_profile)));
model->setLastPolicyOk(m_lastFrame.m_policyOk ? 1 : 0);
model->setLastCoherent(m_lastFrame.m_coherent ? 1 : 0);
model->setLastEncrypted(m_lastFrame.m_encrypted ? 1 : 0);
model->setLastSrc(new QString(m_lastFrame.m_src));
model->setLastDst(new QString(m_lastFrame.m_dst));
model->setLastSnr(m_lastFrame.m_snr);
model->setLastOffsetHz(m_lastFrame.m_offsetHz);
model->setLastOffsetPpm(m_lastFrame.m_offsetPpm);
model->setLastBodyText(new QString(printable(m_lastFrame.m_body)));
model->setLastBodyHex(new QString(QString::fromLatin1(m_lastFrame.m_body.toHex())));
}
}
void ChirpModemDemod::webapiReverseSendSettings(const QList<QString>& channelSettingsKeys, const ChirpModemDemodSettings& settings, bool force)
{
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force);
QString channelSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
.arg(settings.m_reverseAPIAddress)
.arg(settings.m_reverseAPIPort)
.arg(settings.m_reverseAPIDeviceIndex)
.arg(settings.m_reverseAPIChannelIndex);
m_networkRequest.setUrl(QUrl(channelSettingsURL));
m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QBuffer *buffer = new QBuffer();
buffer->open((QBuffer::ReadWrite));
buffer->write(swgChannelSettings->asJson().toUtf8());
buffer->seek(0);
// Always use PATCH to avoid passing reverse API settings
QNetworkReply *reply = m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
buffer->setParent(reply);
delete swgChannelSettings;
}
void ChirpModemDemod::webapiFormatChannelSettings(const QList<QString>& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings *swgChannelSettings,
const ChirpModemDemodSettings& settings, bool force)
{
swgChannelSettings->setDirection(0);
swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet());
swgChannelSettings->setOriginatorDeviceSetIndex(getDeviceSetIndex());
swgChannelSettings->setChannelType(new QString(m_channelId));
auto *model = new SWGSDRangel::SWGChirpModemDemodSettings();
swgChannelSettings->setChirpModemDemodSettings(model);
if (force || channelSettingsKeys.contains("inputFrequencyOffset")) {
model->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
}
if (force || channelSettingsKeys.contains("spreadFactor")) {
model->setSpreadFactor(settings.m_spreadFactor);
}
if (force || channelSettingsKeys.contains("bandwidth")) {
model->setBandwidth(settings.m_bandwidth);
}
if (force || channelSettingsKeys.contains("effort")) {
model->setEffort(settings.m_effort);
}
if (force || channelSettingsKeys.contains("autoEffort")) {
model->setAutoEffort(settings.m_autoEffort ? 1 : 0);
}
if (force || channelSettingsKeys.contains("reportFailures")) {
model->setReportFailures(settings.m_reportFailures ? 1 : 0);
}
if (force || channelSettingsKeys.contains("maxBytes")) {
model->setMaxBytes(settings.m_maxBytes);
}
if (force || channelSettingsKeys.contains("rgbColor")) {
model->setRgbColor(settings.m_rgbColor);
}
if (force || channelSettingsKeys.contains("title")) {
model->setTitle(new QString(settings.m_title));
}
if (force || channelSettingsKeys.contains("streamIndex")) {
model->setStreamIndex(settings.m_streamIndex);
}
if (settings.m_channelMarker && (force || channelSettingsKeys.contains("channelMarker")))
{
auto *item = new SWGSDRangel::SWGChannelMarker();
settings.m_channelMarker->formatTo(item);
model->setChannelMarker(item);
}
if (settings.m_rollupState && (force || channelSettingsKeys.contains("rollupState")))
{
auto *item = new SWGSDRangel::SWGRollupState();
settings.m_rollupState->formatTo(item);
model->setRollupState(item);
}
}
void ChirpModemDemod::networkManagerFinished(QNetworkReply *reply)
{
QNetworkReply::NetworkError replyError = reply->error();
if (replyError)
{
qWarning() << "ChirpModemDemod::networkManagerFinished:"
<< " error(" << (int) replyError << "): " << replyError << ": " << reply->errorString();
}
else
{
QString answer = reply->readAll();
answer.chop(1); // remove last \n
qDebug("ChirpModemDemod::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
}
reply->deleteLater();
}
void ChirpModemDemod::handleIndexInDeviceSetChanged(int index)
{
if (index < 0) {
return;
}
QString fifoLabel = QString("%1 [%2:%3]").arg(m_channelId).arg(m_deviceAPI->getDeviceSetIndex()).arg(index);
m_basebandSink->setFifoLabel(fifoLabel);
}

154
plugins/channelrx/demodchirpmodem/chirpmodemdemod.h

@ -0,0 +1,154 @@ @@ -0,0 +1,154 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Dan Chokola, KD2HSG //
// Based on the SELCAL demodulator plugin: //
// Copyright (C) 2021-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// //
// 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_CHIRPMODEMDEMOD_H
#define INCLUDE_CHIRPMODEMDEMOD_H
#include <QMutex>
#include <QNetworkRequest>
#include <QThread>
#include "dsp/basebandsamplesink.h"
#include "dsp/spectrumvis.h"
#include "channel/channelapi.h"
#include "util/message.h"
#include "chirpmodemdemodbaseband.h"
#include "chirpmodemdemodsettings.h"
#include "chirpmodemmessages.h"
class QNetworkAccessManager;
class QNetworkReply;
class DeviceAPI;
class ChirpModemDemod : public BasebandSampleSink, public ChannelAPI {
public:
class MsgConfigureChirpModemDemod : public Message {
MESSAGE_CLASS_DECLARATION
public:
const ChirpModemDemodSettings& getSettings() const { return m_settings; }
const QStringList& getSettingsKeys() const { return m_settingsKeys; }
bool getForce() const { return m_force; }
static MsgConfigureChirpModemDemod *create(const QStringList& settingsKeys, const ChirpModemDemodSettings& settings, bool force) {
return new MsgConfigureChirpModemDemod(settingsKeys, settings, force);
}
private:
ChirpModemDemodSettings m_settings;
QStringList m_settingsKeys;
bool m_force;
MsgConfigureChirpModemDemod(const QStringList& settingsKeys, const ChirpModemDemodSettings& settings, bool force) :
Message(),
m_settings(settings),
m_settingsKeys(settingsKeys),
m_force(force)
{ }
};
ChirpModemDemod(DeviceAPI *deviceAPI);
virtual ~ChirpModemDemod();
virtual void destroy() { delete this; }
virtual void setDeviceAPI(DeviceAPI *deviceAPI);
virtual DeviceAPI *getDeviceAPI() { return m_deviceAPI; }
using BasebandSampleSink::feed;
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po);
virtual void start();
virtual void stop();
virtual void pushMessage(Message *msg) { m_inputMessageQueue.push(msg); }
virtual QString getSinkName() { return objectName(); }
virtual void getIdentifier(QString& id) { id = objectName(); }
virtual QString getIdentifier() const { return objectName(); }
virtual const QString& getURI() const { return getName(); }
virtual void getTitle(QString& title) { title = m_settings.m_title; }
virtual qint64 getCenterFrequency() const { return m_settings.m_inputFrequencyOffset; }
virtual void setCenterFrequency(qint64 frequency);
int getChannelSampleRate() const override;
virtual QByteArray serialize() const;
virtual bool deserialize(const QByteArray& data);
virtual int getNbSinkStreams() const { return 1; }
virtual int getNbSourceStreams() const { return 0; }
virtual int getStreamIndex() const { return m_settings.m_streamIndex; }
virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const
{
(void) streamIndex;
(void) sinkElseSource;
return 0;
}
virtual int webapiSettingsGet(SWGSDRangel::SWGChannelSettings& response, QString& errorMessage);
virtual int webapiWorkspaceGet(SWGSDRangel::SWGWorkspaceInfo& 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 ChirpModemDemodSettings& settings);
static void webapiUpdateChannelSettings(ChirpModemDemodSettings& settings, const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response);
SpectrumVis *getSpectrumVis() { return &m_spectrumVis; }
double getMagSq() const { return m_basebandSink->getMagSq(); }
void getMagSqLevels(double& avg, double& peak, int& nbSamples) { m_basebandSink->getMagSqLevels(avg, peak, nbSamples); }
uint32_t getNumberOfDeviceStreams() const;
static const char *const m_channelIdURI;
static const char *const m_channelId;
private:
DeviceAPI *m_deviceAPI;
QThread m_thread;
ChirpModemDemodBaseband *m_basebandSink;
SpectrumVis m_spectrumVis;
ChirpModemDemodSettings m_settings;
int m_basebandSampleRate; //!< stored from device message used when starting baseband sink
qint64 m_centerFrequency;
QMutex m_reportMutex; //!< Report state is read from web API threads
ChirpModemMessages::Frame m_lastFrame;
ChirpModemMessages::Status m_status;
qint64 m_frameCount = 0; //!< Frames reported to this channel, all statuses
qint64 m_okCount = 0;
qint64 m_failCount = 0;
qint64 m_policyCount = 0; //!< Licensed frames that failed the policy check
QNetworkAccessManager *m_networkManager;
QNetworkRequest m_networkRequest;
virtual bool handleMessage(const Message& cmd);
void applySettings(const QStringList& settingsKeys, const ChirpModemDemodSettings& settings, bool force = false);
void frameReceived(const ChirpModemMessages::Frame& frame);
void webapiReverseSendSettings(const QList<QString>& channelSettingsKeys, const ChirpModemDemodSettings& settings, bool force);
void webapiFormatChannelSettings(const QList<QString>& channelSettingsKeys, SWGSDRangel::SWGChannelSettings *swgChannelSettings,
const ChirpModemDemodSettings& settings, bool force);
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response);
private slots:
void networkManagerFinished(QNetworkReply *reply);
void handleIndexInDeviceSetChanged(int index);
};
#endif // INCLUDE_CHIRPMODEMDEMOD_H

178
plugins/channelrx/demodchirpmodem/chirpmodemdemodbaseband.cpp

@ -0,0 +1,178 @@ @@ -0,0 +1,178 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Dan Chokola, KD2HSG //
// Based on the SELCAL demodulator plugin: //
// Copyright (C) 2021-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// //
// 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 <algorithm>
#include "dsp/dspcommands.h"
#include "dsp/downchannelizer.h"
#include "chirpmodemdemodbaseband.h"
MESSAGE_CLASS_DEFINITION(ChirpModemDemodBaseband::MsgConfigureChirpModemDemodBaseband, Message)
ChirpModemDemodBaseband::ChirpModemDemodBaseband() :
m_running(false)
{
qDebug("ChirpModemDemodBaseband::ChirpModemDemodBaseband");
m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(1000000));
m_channelizer = new DownChannelizer(&m_sink);
}
ChirpModemDemodBaseband::~ChirpModemDemodBaseband()
{
m_inputMessageQueue.clear();
delete m_channelizer;
}
void ChirpModemDemodBaseband::reset()
{
QMutexLocker mutexLocker(&m_mutex);
m_inputMessageQueue.clear();
m_sampleFifo.reset();
m_sink.reset();
}
void ChirpModemDemodBaseband::startWork()
{
QMutexLocker mutexLocker(&m_mutex);
QObject::connect(&m_sampleFifo, &SampleSinkFifo::dataReady, this, &ChirpModemDemodBaseband::handleData, Qt::QueuedConnection);
QObject::connect(&m_inputMessageQueue, &MessageQueue::messageEnqueued, this, &ChirpModemDemodBaseband::handleInputMessages);
m_running = true;
}
void ChirpModemDemodBaseband::stopWork()
{
QMutexLocker mutexLocker(&m_mutex);
QObject::disconnect(&m_inputMessageQueue, &MessageQueue::messageEnqueued, this, &ChirpModemDemodBaseband::handleInputMessages);
QObject::disconnect(&m_sampleFifo, &SampleSinkFifo::dataReady, this, &ChirpModemDemodBaseband::handleData);
m_running = false;
}
void ChirpModemDemodBaseband::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end)
{
m_sampleFifo.write(begin, end);
}
void ChirpModemDemodBaseband::handleData()
{
QMutexLocker mutexLocker(&m_mutex);
// Stops when a message is queued, so settings take effect between blocks
while ((m_sampleFifo.fill() > 0) && (m_inputMessageQueue.size() == 0) && m_channelizer->getBasebandSampleRate())
{
SampleVector::iterator part1begin;
SampleVector::iterator part1end;
SampleVector::iterator part2begin;
SampleVector::iterator part2end;
std::size_t count = m_sampleFifo.readBegin(m_sampleFifo.fill(), &part1begin, &part1end, &part2begin, &part2end);
if (part1begin != part1end) {
m_channelizer->feed(part1begin, part1end);
}
if (part2begin != part2end) {
m_channelizer->feed(part2begin, part2end);
}
m_sampleFifo.readCommit((unsigned int) count);
}
}
void ChirpModemDemodBaseband::handleInputMessages()
{
Message *message;
while ((message = m_inputMessageQueue.pop()))
{
if (!handleMessage(*message)) {
qDebug("%s: unhandled message: %s", Q_FUNC_INFO, message->getIdentifier());
}
delete message;
}
}
bool ChirpModemDemodBaseband::handleMessage(const Message& cmd)
{
if (MsgConfigureChirpModemDemodBaseband::match(cmd))
{
QMutexLocker mutexLocker(&m_mutex);
const auto& cfg = static_cast<const MsgConfigureChirpModemDemodBaseband&>(cmd);
qDebug() << "ChirpModemDemodBaseband::handleMessage: MsgConfigureChirpModemDemodBaseband";
applySettings(cfg.getSettingsKeys(), cfg.getSettings(), cfg.getForce());
m_sink.commitConfig();
return true;
}
else if (DSPSignalNotification::match(cmd))
{
QMutexLocker mutexLocker(&m_mutex);
const auto& notif = static_cast<const DSPSignalNotification&>(cmd);
qDebug() << "ChirpModemDemodBaseband::handleMessage: DSPSignalNotification: basebandSampleRate:" << notif.getSampleRate()
<< "centerFrequency:" << notif.getCenterFrequency();
bool changed = (notif.getSampleRate() != m_channelizer->getBasebandSampleRate()) ||
(notif.getCenterFrequency() != m_centerFrequency);
m_centerFrequency = notif.getCenterFrequency();
m_sink.setCenterFrequency(notif.getCenterFrequency());
setBasebandSampleRate(notif.getSampleRate());
if (changed) {
m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(std::max(notif.getSampleRate(), 48000)));
}
m_sink.commitConfig();
return true;
}
else
{
return false;
}
}
void ChirpModemDemodBaseband::applySettings(const QStringList& settingsKeys, const ChirpModemDemodSettings& settings, bool force)
{
if (force ||
(settingsKeys.contains("inputFrequencyOffset") && (settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset)) ||
(settingsKeys.contains("bandwidth") && (settings.m_bandwidth != m_settings.m_bandwidth)))
{
m_channelizer->setChannelization(settings.requestedChannelSampleRate(), settings.m_inputFrequencyOffset);
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
}
m_sink.applySettings(settingsKeys, settings, force);
if (force) {
m_settings = settings;
} else {
m_settings.applySettings(settingsKeys, settings);
}
}
int ChirpModemDemodBaseband::getChannelSampleRate() const
{
return m_channelizer->getChannelSampleRate();
}
void ChirpModemDemodBaseband::setBasebandSampleRate(int sampleRate)
{
m_channelizer->setBasebandSampleRate(sampleRate);
m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset());
}

101
plugins/channelrx/demodchirpmodem/chirpmodemdemodbaseband.h

@ -0,0 +1,101 @@ @@ -0,0 +1,101 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Dan Chokola, KD2HSG //
// Based on the SELCAL demodulator plugin: //
// Copyright (C) 2021-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// //
// 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_CHIRPMODEMDEMODBASEBAND_H
#define INCLUDE_CHIRPMODEMDEMODBASEBAND_H
#include <QObject>
#include <QRecursiveMutex>
#include "dsp/samplesinkfifo.h"
#include "util/message.h"
#include "util/messagequeue.h"
#include "chirpmodemdemodsink.h"
class DownChannelizer;
class SpectrumVis;
class ChirpModemDemodBaseband : public QObject {
Q_OBJECT
public:
class MsgConfigureChirpModemDemodBaseband : public Message {
MESSAGE_CLASS_DECLARATION
public:
const ChirpModemDemodSettings& getSettings() const { return m_settings; }
const QStringList& getSettingsKeys() const { return m_settingsKeys; }
bool getForce() const { return m_force; }
static MsgConfigureChirpModemDemodBaseband *create(const QStringList& settingsKeys, const ChirpModemDemodSettings& settings, bool force) {
return new MsgConfigureChirpModemDemodBaseband(settingsKeys, settings, force);
}
private:
ChirpModemDemodSettings m_settings;
QStringList m_settingsKeys;
bool m_force;
MsgConfigureChirpModemDemodBaseband(const QStringList& settingsKeys, const ChirpModemDemodSettings& settings, bool force) :
Message(),
m_settings(settings),
m_settingsKeys(settingsKeys),
m_force(force)
{ }
};
ChirpModemDemodBaseband();
~ChirpModemDemodBaseband();
void reset();
void startWork();
void stopWork();
void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end);
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
// As in other demodulators, these don't wait for the worker, which holds
// the mutex while processing all queued samples.
void getMagSqLevels(double& avg, double& peak, int& nbSamples) { m_sink.getMagSqLevels(avg, peak, nbSamples); }
double getMagSq() const { return m_sink.getMagSq(); }
void setMessageQueueToChannel(MessageQueue *messageQueue) { m_sink.setMessageQueueToChannel(messageQueue); }
void setSpectrumSink(SpectrumVis *spectrumSink) { m_sink.setSpectrumSink(spectrumSink); }
int getChannelSampleRate() const;
bool isRunning() const { return m_running; }
void setFifoLabel(const QString& label) { m_sampleFifo.setLabel(label); }
private:
SampleSinkFifo m_sampleFifo;
DownChannelizer *m_channelizer;
ChirpModemDemodSink m_sink;
MessageQueue m_inputMessageQueue;
ChirpModemDemodSettings m_settings;
qint64 m_centerFrequency = -1; //!< From the latest DSPSignalNotification
bool m_running;
mutable QRecursiveMutex m_mutex;
bool handleMessage(const Message& cmd);
void applySettings(const QStringList& settingsKeys, const ChirpModemDemodSettings& settings, bool force = false);
void setBasebandSampleRate(int sampleRate);
private slots:
void handleInputMessages();
void handleData();
};
#endif // INCLUDE_CHIRPMODEMDEMODBASEBAND_H

597
plugins/channelrx/demodchirpmodem/chirpmodemdemodgui.cpp

@ -0,0 +1,597 @@ @@ -0,0 +1,597 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Dan Chokola, KD2HSG //
// Based on the SELCAL demodulator plugin: //
// Copyright (C) 2021-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// //
// 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 <QHeaderView>
#include <QScrollBar>
#include <QSignalBlocker>
#include <cmath>
#include "device/deviceuiset.h"
#include "dsp/dspcommands.h"
#include "dsp/spectrumvis.h"
#include "gui/basicchannelsettingsdialog.h"
#include "gui/dialogpositioner.h"
#include "gui/glspectrum.h"
#include "maincore.h"
#include "util/db.h"
#include "chirpmodemdemod.h"
#include "chirpmodemdemodgui.h"
#include "ui_chirpmodemdemodgui.h"
// Bandwidths offered in the combo box. Other values (from the web API) are
// added to it when displayed.
static const int bandwidths[] = {15625, 31250, 62500, 125000, 250000, 500000};
static QString printable(const QByteArray& bytes)
{
QString s;
for (char c : bytes) {
s.append(((c >= 0x20) && (c < 0x7f)) ? QChar(c) : QChar('.'));
}
return s;
}
static QString bandwidthText(int bandwidth)
{
return QString("%1 kHz").arg(bandwidth / 1000.0, 0, 'g', 6);
}
ChirpModemDemodGUI *ChirpModemDemodGUI::create(PluginAPI *pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel)
{
return new ChirpModemDemodGUI(pluginAPI, deviceUISet, rxChannel);
}
void ChirpModemDemodGUI::destroy()
{
delete this;
}
ChirpModemDemodGUI::ChirpModemDemodGUI(PluginAPI *, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel, QWidget *parent) :
ChannelGUI(parent),
ui(new Ui::ChirpModemDemodGUI),
m_deviceUISet(deviceUISet),
m_channelMarker(this),
m_chirpModemDemod(static_cast<ChirpModemDemod *>(rxChannel))
{
setAttribute(Qt::WA_DeleteOnClose, true);
m_helpURL = "plugins/channelrx/demodchirpmodem/readme.md";
ui->setupUi(getRollupContents());
setSizePolicy(getRollupContents()->sizePolicy());
m_chirpModemDemod->setMessageQueueToGUI(getInputMessageQueue());
// Spectrum of the channel fed to the receiver
m_spectrumVis = m_chirpModemDemod->getSpectrumVis();
m_spectrumVis->setGLSpectrum(ui->glSpectrum);
ui->spectrumGUI->setBuddies(m_spectrumVis, ui->glSpectrum);
ui->glSpectrum->setCenterFrequency(0);
ui->glSpectrum->setSampleRate(m_settings.requestedChannelSampleRate());
SpectrumSettings spectrumSettings = m_spectrumVis->getSettings();
spectrumSettings.m_ssb = false;
spectrumSettings.m_fftSize = 512;
spectrumSettings.m_fftWindow = FFTWindow::Hanning;
spectrumSettings.m_averagingMode = SpectrumSettings::AvgModeNone;
spectrumSettings.m_displayWaterfall = true;
spectrumSettings.m_displayCurrent = true;
m_spectrumVis->getInputMessageQueue()->push(SpectrumVis::MsgConfigureSpectrumVis::create(spectrumSettings, false));
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
ui->deltaFrequency->setValueRange(false, 8, -99999999, 99999999);
ui->channelPowerMeter->setColorTheme(LevelMeterSignalDB::ColorGreenAndBlue);
for (int sf = 7; sf <= 12; sf++) {
ui->spreadFactor->addItem(QString::number(sf), sf);
}
for (int bandwidth : bandwidths) {
ui->bandwidth->addItem(bandwidthText(bandwidth), bandwidth);
}
ui->frames->horizontalHeader()->setSectionsMovable(true);
ui->frames->setColumnWidth(COL_UTC, 175);
ui->frames->setColumnWidth(COL_STATUS, 85);
ui->frames->setColumnWidth(COL_PROFILE, 80);
ui->frames->setColumnWidth(COL_SRC, 80);
ui->frames->setColumnWidth(COL_DST, 80);
ui->frames->setColumnWidth(COL_SNR, 60);
ui->frames->setColumnWidth(COL_OFFSET_HZ, 80);
ui->frames->setColumnWidth(COL_OFFSET_PPM, 65);
ui->frames->setColumnWidth(COL_MODE, 50);
ui->frames->setColumnWidth(COL_LENGTH, 45);
ui->frames->setColumnWidth(COL_TEXT, 200);
ui->frames->setColumnWidth(COL_HEX, 300);
ui->frames->setWordWrap(false);
m_settings.setChannelMarker(&m_channelMarker);
m_settings.setRollupState(&m_rollupState);
m_settings.setSpectrumGUI(ui->spectrumGUI);
m_channelMarker.setVisible(true);
m_deviceUISet->addChannelMarker(&m_channelMarker);
connect(&m_channelMarker, &ChannelMarker::changedByCursor, this, &ChirpModemDemodGUI::channelMarkerChangedByCursor);
connect(&m_channelMarker, &ChannelMarker::highlightedByCursor, this, &ChirpModemDemodGUI::channelMarkerHighlightedByCursor);
connect(getInputMessageQueue(), &MessageQueue::messageEnqueued, this, &ChirpModemDemodGUI::handleInputMessages);
connect(&MainCore::instance()->getMasterTimer(), &QTimer::timeout, this, &ChirpModemDemodGUI::tick);
connect(this, &ChirpModemDemodGUI::customContextMenuRequested, this, &ChirpModemDemodGUI::onMenuDialogCalled);
connect(getRollupContents(), &RollupContents::widgetRolled, this, &ChirpModemDemodGUI::onWidgetRolled);
displaySettings();
makeUIConnections();
applySettings({}, true);
getRollupContents()->arrangeRollups();
m_resizer.enableChildMouseTracking();
}
ChirpModemDemodGUI::~ChirpModemDemodGUI()
{
delete ui;
}
void ChirpModemDemodGUI::resetToDefaults()
{
m_settings.resetToDefaults();
displaySettings();
applySettings({}, true);
}
QByteArray ChirpModemDemodGUI::serialize() const
{
return m_settings.serialize();
}
bool ChirpModemDemodGUI::deserialize(const QByteArray& data)
{
bool valid = m_settings.deserialize(data);
displaySettings();
applySettings({}, true);
return valid;
}
void ChirpModemDemodGUI::applySettings(const QStringList& keys, bool force)
{
if (!m_doApplySettings) {
return;
}
m_settings.normalize();
updateChannelMarker();
m_chirpModemDemod->getInputMessageQueue()->push(ChirpModemDemod::MsgConfigureChirpModemDemod::create(keys, m_settings, force));
updateAbsoluteCenterFrequency();
}
void ChirpModemDemodGUI::updateChannelMarker()
{
QSignalBlocker blocker(&m_channelMarker);
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
m_channelMarker.setBandwidth(m_settings.m_bandwidth);
m_channelMarker.setSidebands(ChannelMarker::dsb);
}
void ChirpModemDemodGUI::displayBandwidth()
{
QSignalBlocker blocker(ui->bandwidth);
int index = ui->bandwidth->findData(m_settings.m_bandwidth);
if (index < 0)
{
ui->bandwidth->addItem(bandwidthText(m_settings.m_bandwidth), m_settings.m_bandwidth);
index = ui->bandwidth->count() - 1;
}
ui->bandwidth->setCurrentIndex(index);
}
void ChirpModemDemodGUI::displaySettings()
{
m_doApplySettings = false;
{
QSignalBlocker blocker(&m_channelMarker);
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
m_channelMarker.setBandwidth(m_settings.m_bandwidth);
m_channelMarker.setSidebands(ChannelMarker::dsb);
m_channelMarker.setTitle(m_settings.m_title);
m_channelMarker.setColor(m_settings.m_rgbColor);
m_channelMarker.clearStreamIndexes();
m_channelMarker.addStreamIndex(m_settings.m_streamIndex);
}
setTitle(m_settings.m_title);
setWindowTitle(m_settings.m_title);
setTitleColor(m_settings.m_rgbColor);
QSignalBlocker deltaFrequencyBlocker(ui->deltaFrequency);
QSignalBlocker spreadFactorBlocker(ui->spreadFactor);
QSignalBlocker effortBlocker(ui->effort);
QSignalBlocker autoEffortBlocker(ui->autoEffort);
QSignalBlocker reportFailuresBlocker(ui->reportFailures);
QSignalBlocker maxBytesBlocker(ui->maxBytes);
ui->deltaFrequency->setValue(m_settings.m_inputFrequencyOffset);
ui->spreadFactor->setCurrentIndex(ui->spreadFactor->findData(m_settings.m_spreadFactor));
displayBandwidth();
ui->effort->setCurrentIndex(m_settings.m_effort);
ui->autoEffort->setChecked(m_settings.m_autoEffort);
ui->reportFailures->setChecked(m_settings.m_reportFailures);
ui->maxBytes->setValue(m_settings.m_maxBytes);
getRollupContents()->restoreState(m_rollupState);
// Place columns in visual order, as in the SELCAL demodulator
auto *header = ui->frames->horizontalHeader();
for (int visual = 0; visual < ChirpModemDemodSettings::m_columns; ++visual)
{
for (int logical = 0; logical < ChirpModemDemodSettings::m_columns; ++logical)
{
if (m_settings.m_columnIndexes[logical] == visual)
{
header->moveSection(header->visualIndex(logical), visual);
break;
}
}
}
for (int i = 0; i < ChirpModemDemodSettings::m_columns; ++i)
{
if (m_settings.m_columnSizes[i] > 0) {
header->resizeSection(i, m_settings.m_columnSizes[i]);
}
}
updateIndexLabel();
updateAbsoluteCenterFrequency();
m_doApplySettings = true;
}
void ChirpModemDemodGUI::makeUIConnections()
{
QObject::connect(ui->deltaFrequency, &ValueDialZ::changed, this, &ChirpModemDemodGUI::on_deltaFrequency_changed);
QObject::connect(ui->spreadFactor, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ChirpModemDemodGUI::on_spreadFactor_currentIndexChanged);
QObject::connect(ui->bandwidth, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ChirpModemDemodGUI::on_bandwidth_currentIndexChanged);
QObject::connect(ui->effort, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ChirpModemDemodGUI::on_effort_currentIndexChanged);
QObject::connect(ui->autoEffort, &ButtonSwitch::toggled, this, &ChirpModemDemodGUI::on_autoEffort_toggled);
QObject::connect(ui->reportFailures, &ButtonSwitch::toggled, this, &ChirpModemDemodGUI::on_reportFailures_toggled);
QObject::connect(ui->maxBytes, QOverload<int>::of(&QSpinBox::valueChanged), this, &ChirpModemDemodGUI::on_maxBytes_valueChanged);
QObject::connect(ui->clearTable, &QPushButton::clicked, this, &ChirpModemDemodGUI::on_clearTable_clicked);
QObject::connect(ui->frames->horizontalHeader(), &QHeaderView::sectionMoved, this, &ChirpModemDemodGUI::frames_sectionMoved);
QObject::connect(ui->frames->horizontalHeader(), &QHeaderView::sectionResized, this, &ChirpModemDemodGUI::frames_sectionResized);
}
void ChirpModemDemodGUI::on_deltaFrequency_changed(qint64 value)
{
m_settings.m_inputFrequencyOffset = value;
applySettings({"inputFrequencyOffset"});
}
void ChirpModemDemodGUI::on_spreadFactor_currentIndexChanged(int index)
{
m_settings.m_spreadFactor = ui->spreadFactor->itemData(index).toInt();
applySettings({"spreadFactor"});
}
void ChirpModemDemodGUI::on_bandwidth_currentIndexChanged(int index)
{
m_settings.m_bandwidth = ui->bandwidth->itemData(index).toInt();
applySettings({"bandwidth"});
}
void ChirpModemDemodGUI::on_effort_currentIndexChanged(int index)
{
m_settings.m_effort = index;
applySettings({"effort"});
}
void ChirpModemDemodGUI::on_autoEffort_toggled(bool checked)
{
m_settings.m_autoEffort = checked;
applySettings({"autoEffort"});
}
void ChirpModemDemodGUI::on_reportFailures_toggled(bool checked)
{
m_settings.m_reportFailures = checked;
applySettings({"reportFailures"});
}
void ChirpModemDemodGUI::on_maxBytes_valueChanged(int value)
{
m_settings.m_maxBytes = value;
applySettings({"maxBytes"});
}
void ChirpModemDemodGUI::on_clearTable_clicked()
{
ui->frames->setRowCount(0);
ui->lastFrame->setText("-");
}
void ChirpModemDemodGUI::frames_sectionMoved(int logicalIndex, int oldVisualIndex, int newVisualIndex)
{
(void) logicalIndex;
(void) oldVisualIndex;
(void) newVisualIndex;
if (!m_doApplySettings) {
return;
}
for (int i = 0; i < ChirpModemDemodSettings::m_columns; ++i) {
m_settings.m_columnIndexes[i] = ui->frames->horizontalHeader()->visualIndex(i);
}
}
void ChirpModemDemodGUI::frames_sectionResized(int logicalIndex, int oldSize, int newSize)
{
(void) oldSize;
if (m_doApplySettings) {
m_settings.m_columnSizes[logicalIndex] = newSize;
}
}
void ChirpModemDemodGUI::handleInputMessages()
{
while (auto *message = m_inputMessageQueue.pop())
{
if (ChirpModemDemod::MsgConfigureChirpModemDemod::match(*message))
{
const auto& config = static_cast<const ChirpModemDemod::MsgConfigureChirpModemDemod&>(*message);
if (config.getForce())
{
// The layout of this window isn't sent to the channel when changed
ChirpModemDemodSettings settings = config.getSettings();
settings.m_columnIndexes = m_settings.m_columnIndexes;
settings.m_columnSizes = m_settings.m_columnSizes;
settings.m_workspaceIndex = m_settings.m_workspaceIndex;
settings.m_geometryBytes = m_settings.m_geometryBytes;
settings.m_hidden = m_settings.m_hidden;
m_settings = settings;
}
else
{
m_settings.applySettings(config.getSettingsKeys(), config.getSettings());
}
// Serializable pointers always belong to this GUI
m_settings.setChannelMarker(&m_channelMarker);
m_settings.setRollupState(&m_rollupState);
m_settings.setSpectrumGUI(ui->spectrumGUI);
displaySettings();
}
else if (DSPSignalNotification::match(*message))
{
const auto& notification = static_cast<const DSPSignalNotification&>(*message);
m_deviceCenterFrequency = notification.getCenterFrequency();
m_basebandSampleRate = notification.getSampleRate();
ui->deltaFrequency->setValueRange(false, 8, -m_basebandSampleRate / 2, m_basebandSampleRate / 2);
updateAbsoluteCenterFrequency();
}
else if (ChirpModemMessages::MsgFrame::match(*message))
{
frameReceived(static_cast<const ChirpModemMessages::MsgFrame&>(*message).getFrame());
}
else if (ChirpModemMessages::MsgStatus::match(*message))
{
statusReceived(static_cast<const ChirpModemMessages::MsgStatus&>(*message).getStatus());
}
delete message;
}
}
void ChirpModemDemodGUI::frameReceived(const ChirpModemMessages::Frame& frame)
{
// Keep following new frames only if the table is already scrolled to the end
QScrollBar *scrollBar = ui->frames->verticalScrollBar();
bool atEnd = scrollBar->value() == scrollBar->maximum();
bool ok = frame.m_status == ChirpModemMessages::StatusOK;
bool policyViolation = ok && (frame.m_profile == 0) && !frame.m_policyOk;
int row = ui->frames->rowCount();
ui->frames->setRowCount(row + 1);
auto setCell = [&](int column, const QString& text, Qt::Alignment alignment = Qt::AlignLeft | Qt::AlignVCenter) {
auto *item = new QTableWidgetItem(text);
item->setTextAlignment(alignment);
ui->frames->setItem(row, column, item);
return item;
};
const Qt::Alignment right = Qt::AlignRight | Qt::AlignVCenter;
setCell(COL_UTC, frame.m_dateTime.toString("yyyy-MM-dd HH:mm:ss.zzz"));
QTableWidgetItem *status = setCell(COL_STATUS, policyViolation ? QStringLiteral("OK (policy)") : ChirpModemMessages::statusName(frame.m_status));
if (policyViolation)
{
status->setBackground(QColor(160, 30, 30));
status->setToolTip("Licensed frame without a source callsign, or with encryption (47 CFR 97.113, 97.119)");
}
else if (!ok)
{
status->setForeground(QColor(255, 140, 0));
}
setCell(COL_PROFILE, ok ? ChirpModemMessages::profileName(frame.m_profile) : QString());
setCell(COL_SRC, frame.m_src);
setCell(COL_DST, frame.m_dst);
setCell(COL_SNR, QString::number(frame.m_snr, 'f', 1), right);
setCell(COL_OFFSET_HZ, QString::number(frame.m_offsetHz, 'f', 1), right);
setCell(COL_OFFSET_PPM, QString::number(frame.m_offsetPpm, 'f', 2), right);
if (ok)
{
QTableWidgetItem *mode = setCell(COL_MODE, frame.m_coherent ? QStringLiteral("Coh") : QStringLiteral("Non"));
QStringList details;
details << (frame.m_coherent ? "Coherent payload" : "Non-coherent payload");
details << QString("SF%1, %2").arg(frame.m_spreadFactor).arg(bandwidthText(frame.m_bandwidth));
if (frame.m_rampRetry) {
details << QString("Carrier ramp removed: %1 Hz/s").arg(frame.m_rampHzPerS, 0, 'f', 1);
}
if (frame.m_driftRetry) {
details << QString("Sample clock re-estimated: %1 ppm").arg(frame.m_clockPpm, 0, 'f', 2);
}
if (frame.m_ddPasses > 0) {
details << QString("Decision-directed passes: %1").arg(frame.m_ddPasses);
}
mode->setToolTip(details.join("\n"));
setCell(COL_LENGTH, QString::number(frame.m_body.size()), right);
setCell(COL_TEXT, frame.m_encrypted ? QStringLiteral("(encrypted)") : printable(frame.m_body));
setCell(COL_HEX, QString::fromLatin1(frame.m_body.toHex(' ')));
}
else
{
setCell(COL_MODE, QString());
setCell(COL_LENGTH, QString());
setCell(COL_TEXT, QString());
setCell(COL_HEX, QString());
}
if (ok)
{
ui->lastFrame->setText(QString("%1 > %2 %3 dB %4 Hz %5")
.arg(frame.m_src.isEmpty() ? QStringLiteral("?") : frame.m_src)
.arg(frame.m_dst.isEmpty() ? QStringLiteral("*") : frame.m_dst)
.arg(frame.m_snr, 0, 'f', 1)
.arg(frame.m_offsetHz, 0, 'f', 0)
.arg(frame.m_encrypted ? QStringLiteral("(encrypted)") : printable(frame.m_body).left(40)));
}
if (atEnd) {
ui->frames->scrollToBottom();
}
}
void ChirpModemDemodGUI::statusReceived(const ChirpModemMessages::Status& status)
{
if (status.m_channelSampleRate > 0 && status.m_channelSampleRate != m_spectrumSampleRate)
{
m_spectrumSampleRate = status.m_channelSampleRate;
ui->glSpectrum->setSampleRate(m_spectrumSampleRate);
}
QString text;
if (status.m_valid)
{
text = QString("%1 kS/s IF %2 Hz effort %3 load %4%")
.arg(status.m_channelSampleRate / 1000.0, 0, 'f', 1)
.arg(status.m_ifOffset)
.arg(status.m_effort)
.arg(status.m_load * 100.0, 0, 'f', 0);
}
else
{
text = QStringLiteral("Receiver not running");
}
if (!status.m_error.isEmpty()) {
text += " " + status.m_error;
}
ui->receiverStatus->setText(text);
ui->receiverStatus->setToolTip(status.m_error.isEmpty() ? QStringLiteral("Receiver status") : status.m_error);
}
void ChirpModemDemodGUI::tick()
{
double avg, peak;
int count;
m_chirpModemDemod->getMagSqLevels(avg, peak, count);
double power = CalcDb::dbPower(avg);
ui->channelPower->setText(QString::number(power, 'f', 1) + " dB");
ui->channelPowerMeter->levelChanged((100 + power) / 100, (100 + CalcDb::dbPower(peak)) / 100, count);
}
void ChirpModemDemodGUI::updateAbsoluteCenterFrequency()
{
setStatusFrequency(m_deviceCenterFrequency + m_settings.m_inputFrequencyOffset);
}
void ChirpModemDemodGUI::channelMarkerChangedByCursor()
{
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
ui->deltaFrequency->setValue(m_settings.m_inputFrequencyOffset);
applySettings({"inputFrequencyOffset"});
}
void ChirpModemDemodGUI::channelMarkerHighlightedByCursor()
{
setHighlighted(m_channelMarker.getHighlighted());
}
void ChirpModemDemodGUI::onWidgetRolled(QWidget *widget, bool rollDown)
{
(void) widget;
(void) rollDown;
// Rollups change while the saved state is being restored
if (!m_doApplySettings) {
return;
}
getRollupContents()->saveState(m_rollupState);
applySettings({"rollupState"});
}
void ChirpModemDemodGUI::onMenuDialogCalled(const QPoint& point)
{
if (m_contextMenuType == 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.setDefaultTitle(m_displayedName);
if (m_deviceUISet->m_deviceMIMOEngine)
{
dialog.setNumberOfStreams(m_chirpModemDemod->getNumberOfDeviceStreams());
dialog.setStreamIndex(m_settings.m_streamIndex);
}
dialog.move(point);
new DialogPositioner(&dialog, false);
dialog.exec();
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();
if (m_deviceUISet->m_deviceMIMOEngine) {
m_settings.m_streamIndex = dialog.getSelectedStreamIndex();
}
displaySettings();
applySettings({"rgbColor", "title", "useReverseAPI", "reverseAPIAddress", "reverseAPIPort",
"reverseAPIDeviceIndex", "reverseAPIChannelIndex", "streamIndex"});
}
resetContextMenuType();
}

127
plugins/channelrx/demodchirpmodem/chirpmodemdemodgui.h

@ -0,0 +1,127 @@ @@ -0,0 +1,127 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Dan Chokola, KD2HSG //
// Based on the SELCAL demodulator plugin: //
// Copyright (C) 2021-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// //
// 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_CHIRPMODEMDEMODGUI_H
#define INCLUDE_CHIRPMODEMDEMODGUI_H
#include "channel/channelgui.h"
#include "dsp/channelmarker.h"
#include "settings/rollupstate.h"
#include "util/messagequeue.h"
#include "chirpmodemdemodsettings.h"
#include "chirpmodemmessages.h"
class PluginAPI;
class DeviceUISet;
class BasebandSampleSink;
class ChirpModemDemod;
class SpectrumVis;
namespace Ui {
class ChirpModemDemodGUI;
}
class ChirpModemDemodGUI : public ChannelGUI {
Q_OBJECT
public:
static ChirpModemDemodGUI *create(PluginAPI *pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel);
virtual void destroy();
void resetToDefaults();
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
virtual MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
virtual void setWorkspaceIndex(int index) { m_settings.m_workspaceIndex = index; }
virtual int getWorkspaceIndex() const { return m_settings.m_workspaceIndex; }
virtual void setGeometryBytes(const QByteArray& blob) { m_settings.m_geometryBytes = blob; }
virtual QByteArray getGeometryBytes() const { return m_settings.m_geometryBytes; }
virtual QString getTitle() const { return m_settings.m_title; }
virtual QColor getTitleColor() const { return m_settings.m_rgbColor; }
virtual void zetHidden(bool hidden) { m_settings.m_hidden = hidden; }
virtual bool getHidden() const { return m_settings.m_hidden; }
virtual ChannelMarker& getChannelMarker() { return m_channelMarker; }
virtual int getStreamIndex() const { return m_settings.m_streamIndex; }
virtual void setStreamIndex(int streamIndex) { m_settings.m_streamIndex = streamIndex; }
public slots:
void channelMarkerChangedByCursor();
void channelMarkerHighlightedByCursor();
private:
// Logical columns of the frames table
enum Column {
COL_UTC,
COL_STATUS,
COL_PROFILE,
COL_SRC,
COL_DST,
COL_SNR,
COL_OFFSET_HZ,
COL_OFFSET_PPM,
COL_MODE,
COL_LENGTH,
COL_TEXT,
COL_HEX
};
Ui::ChirpModemDemodGUI *ui;
DeviceUISet *m_deviceUISet;
ChannelMarker m_channelMarker;
RollupState m_rollupState;
ChirpModemDemodSettings m_settings;
ChirpModemDemod *m_chirpModemDemod;
SpectrumVis *m_spectrumVis;
MessageQueue m_inputMessageQueue;
qint64 m_deviceCenterFrequency = 0;
int m_basebandSampleRate = 48000;
int m_spectrumSampleRate = 0;
bool m_doApplySettings = true;
explicit ChirpModemDemodGUI(PluginAPI *pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel, QWidget *parent = nullptr);
~ChirpModemDemodGUI() override;
void applySettings(const QStringList& keys, bool force = false);
void displaySettings();
void displayBandwidth();
void makeUIConnections();
void updateAbsoluteCenterFrequency();
void updateChannelMarker();
void frameReceived(const ChirpModemMessages::Frame& frame);
void statusReceived(const ChirpModemMessages::Status& status);
private slots:
void on_deltaFrequency_changed(qint64 value);
void on_spreadFactor_currentIndexChanged(int index);
void on_bandwidth_currentIndexChanged(int index);
void on_effort_currentIndexChanged(int index);
void on_autoEffort_toggled(bool checked);
void on_reportFailures_toggled(bool checked);
void on_maxBytes_valueChanged(int value);
void on_clearTable_clicked();
void frames_sectionMoved(int logicalIndex, int oldVisualIndex, int newVisualIndex);
void frames_sectionResized(int logicalIndex, int oldSize, int newSize);
void handleInputMessages();
void tick();
void onMenuDialogCalled(const QPoint& point);
void onWidgetRolled(QWidget *widget, bool rollDown);
};
#endif // INCLUDE_CHIRPMODEMDEMODGUI_H

575
plugins/channelrx/demodchirpmodem/chirpmodemdemodgui.ui

@ -0,0 +1,575 @@ @@ -0,0 +1,575 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ChirpModemDemodGUI</class>
<widget class="RollupContents" name="ChirpModemDemodGUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>820</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>500</width>
<height>400</height>
</size>
</property>
<property name="windowTitle">
<string>ChirpModem Demodulator</string>
</property>
<widget class="QWidget" name="settingsContainer">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>130</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>500</width>
<height>120</height>
</size>
</property>
<property name="windowTitle">
<string>Settings</string>
</property>
<layout class="QVBoxLayout" name="settingsContainerLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<layout class="QHBoxLayout" name="frequencyLayout">
<item>
<widget class="QLabel" name="deltaFrequencyLabel">
<property name="text">
<string>Δf</string>
</property>
</widget>
</item>
<item>
<widget class="ValueDialZ" name="deltaFrequency" native="true">
<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="toolTip">
<string>Channel offset from device centre frequency in Hz</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="frequencyUnits">
<property name="text">
<string>Hz</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::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="toolTip">
<string>Channel power</string>
</property>
<property name="text">
<string>-120.0 dB</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="powerLayout">
<item>
<widget class="LevelMeterSignalDB" name="channelPowerMeter" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>170</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>24</height>
</size>
</property>
<property name="font">
<font>
<family>Liberation Mono</family>
<pointsize>8</pointsize>
</font>
</property>
<property name="toolTip">
<string>Level meter (dB) top trace: average, bottom trace: instantaneous peak, tip: peak hold</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="modemLayout">
<item>
<widget class="QLabel" name="spreadFactorLabel">
<property name="text">
<string>SF</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="spreadFactor">
<property name="toolTip">
<string>Spreading factor</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="bandwidthLabel">
<property name="text">
<string>BW</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="bandwidth">
<property name="toolTip">
<string>Chip rate, equal to the occupied bandwidth</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="effortLabel">
<property name="text">
<string>Effort</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="effort">
<property name="toolTip">
<string>Retries per frame: 0 none, 1 some, 2 all (carrier ramp, sample clock drift, decision-directed passes)</string>
</property>
<item>
<property name="text">
<string>0</string>
</property>
</item>
<item>
<property name="text">
<string>1</string>
</property>
</item>
<item>
<property name="text">
<string>2</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="autoEffort">
<property name="toolTip">
<string>Lower the effort while decoding lags real time</string>
</property>
<property name="text">
<string>Auto</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="reportFailures">
<property name="toolTip">
<string>Also list frames whose preamble was found but whose header or payload did not decode</string>
</property>
<property name="text">
<string>Fail</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="maxBytesLabel">
<property name="text">
<string>Max</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="maxBytes">
<property name="toolTip">
<string>Longest MAC frame to wait for, in bytes</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>2047</number>
</property>
<property name="value">
<number>255</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="statusLayout">
<item>
<widget class="QLabel" name="receiverStatus">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Receiver status</string>
</property>
<property name="text">
<string>Receiver not running</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="clearTable">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Clear received frames</string>
</property>
<property name="accessibleName">
<string>Clear received frames</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normaloff>:/bin.png</normaloff>:/bin.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="framesContainer">
<property name="geometry">
<rect>
<x>0</x>
<y>140</y>
<width>640</width>
<height>300</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>500</width>
<height>200</height>
</size>
</property>
<property name="windowTitle">
<string>Received frames</string>
</property>
<layout class="QVBoxLayout" name="framesContainerLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="QLabel" name="lastFrame">
<property name="font">
<font>
<pointsize>12</pointsize>
<bold>true</bold>
</font>
</property>
<property name="toolTip">
<string>Last decoded frame: source &gt; destination, SNR, carrier offset, body</string>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="frames">
<property name="toolTip">
<string>Received frames</string>
</property>
<property name="editTriggers">
<set>QAbstractItemView::EditTrigger::NoEditTriggers</set>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
</property>
<column>
<property name="text">
<string>UTC</string>
</property>
<property name="toolTip">
<string>Date and time of the start of the frame</string>
</property>
</column>
<column>
<property name="text">
<string>Status</string>
</property>
<property name="toolTip">
<string>OK, or where decoding failed</string>
</property>
</column>
<column>
<property name="text">
<string>Profile</string>
</property>
<property name="toolTip">
<string>Licensed (amateur: source callsign required, no encryption) or unlicensed</string>
</property>
</column>
<column>
<property name="text">
<string>Src</string>
</property>
<property name="toolTip">
<string>Source callsign</string>
</property>
</column>
<column>
<property name="text">
<string>Dst</string>
</property>
<property name="toolTip">
<string>Destination callsign</string>
</property>
</column>
<column>
<property name="text">
<string>SNR (dB)</string>
</property>
<property name="toolTip">
<string>Signal to noise ratio in the signal bandwidth</string>
</property>
</column>
<column>
<property name="text">
<string>Offset (Hz)</string>
</property>
<property name="toolTip">
<string>Carrier offset of the frame from the channel frequency</string>
</property>
</column>
<column>
<property name="text">
<string>ppm</string>
</property>
<property name="toolTip">
<string>Carrier offset relative to the channel frequency</string>
</property>
</column>
<column>
<property name="text">
<string>Mode</string>
</property>
<property name="toolTip">
<string>Coherent or non-coherent payload</string>
</property>
</column>
<column>
<property name="text">
<string>Len</string>
</property>
<property name="toolTip">
<string>Body length in bytes</string>
</property>
</column>
<column>
<property name="text">
<string>Text</string>
</property>
<property name="toolTip">
<string>Body, with non-printable bytes shown as dots</string>
</property>
</column>
<column>
<property name="text">
<string>Hex</string>
</property>
<property name="toolTip">
<string>Body in hexadecimal</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="spectrumContainer" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>450</y>
<width>640</width>
<height>360</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>500</width>
<height>250</height>
</size>
</property>
<property name="windowTitle">
<string>Channel spectrum</string>
</property>
<layout class="QVBoxLayout" name="spectrumContainerLayout">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="GLSpectrum" name="glSpectrum" native="true">
<property name="minimumSize">
<size>
<width>200</width>
<height>200</height>
</size>
</property>
<property name="font">
<font>
<family>Liberation Mono</family>
<pointsize>8</pointsize>
</font>
</property>
</widget>
</item>
<item>
<widget class="GLSpectrumGUI" name="spectrumGUI" native="true"/>
</item>
</layout>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>RollupContents</class>
<extends>QWidget</extends>
<header>gui/rollupcontents.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>LevelMeterSignalDB</class>
<extends>QWidget</extends>
<header>gui/levelmeter.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ValueDialZ</class>
<extends>QWidget</extends>
<header>gui/valuedialz.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
<customwidget>
<class>GLSpectrum</class>
<extends>QWidget</extends>
<header>gui/glspectrum.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GLSpectrumGUI</class>
<extends>QWidget</extends>
<header>gui/glspectrumgui.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

91
plugins/channelrx/demodchirpmodem/chirpmodemdemodplugin.cpp

@ -0,0 +1,91 @@ @@ -0,0 +1,91 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Dan Chokola, KD2HSG //
// Based on the SELCAL demodulator plugin: //
// Copyright (C) 2021-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// //
// 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 "chirpmodemdemodgui.h"
#endif
#include "chirpmodemdemod.h"
#include "chirpmodemdemodwebapiadapter.h"
#include "chirpmodemdemodplugin.h"
const PluginDescriptor ChirpModemDemodPlugin::m_pluginDescriptor = {
ChirpModemDemod::m_channelId,
QStringLiteral("ChirpModem Demodulator"),
QStringLiteral("8.0.0"),
QStringLiteral("(c) Dan Chokola, KD2HSG"),
QStringLiteral("https://github.com/f4exb/sdrangel"),
true,
QStringLiteral("https://github.com/f4exb/sdrangel")
};
ChirpModemDemodPlugin::ChirpModemDemodPlugin(QObject *parent) :
QObject(parent),
m_pluginAPI(nullptr)
{
}
const PluginDescriptor& ChirpModemDemodPlugin::getPluginDescriptor() const
{
return m_pluginDescriptor;
}
void ChirpModemDemodPlugin::initPlugin(PluginAPI *pluginAPI)
{
m_pluginAPI = pluginAPI;
m_pluginAPI->registerRxChannel(ChirpModemDemod::m_channelIdURI, ChirpModemDemod::m_channelId, this);
}
void ChirpModemDemodPlugin::createRxChannel(DeviceAPI *deviceAPI, BasebandSampleSink **bs, ChannelAPI **cs) const
{
if (bs || cs)
{
ChirpModemDemod *instance = new ChirpModemDemod(deviceAPI);
if (bs) {
*bs = instance;
}
if (cs) {
*cs = instance;
}
}
}
#ifdef SERVER_MODE
ChannelGUI *ChirpModemDemodPlugin::createRxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel) const
{
(void) deviceUISet;
(void) rxChannel;
return nullptr;
}
#else
ChannelGUI *ChirpModemDemodPlugin::createRxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel) const
{
return ChirpModemDemodGUI::create(m_pluginAPI, deviceUISet, rxChannel);
}
#endif
ChannelWebAPIAdapter *ChirpModemDemodPlugin::createChannelWebAPIAdapter() const
{
return new ChirpModemDemodWebAPIAdapter();
}

50
plugins/channelrx/demodchirpmodem/chirpmodemdemodplugin.h

@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Dan Chokola, KD2HSG //
// Based on the SELCAL demodulator plugin: //
// Copyright (C) 2021-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// //
// 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_CHIRPMODEMDEMODPLUGIN_H
#define INCLUDE_CHIRPMODEMDEMODPLUGIN_H
#include <QObject>
#include "plugin/plugininterface.h"
class DeviceUISet;
class BasebandSampleSink;
class ChirpModemDemodPlugin : public QObject, PluginInterface {
Q_OBJECT
Q_INTERFACES(PluginInterface)
Q_PLUGIN_METADATA(IID "sdrangel.channel.chirpmodemdemod")
public:
explicit ChirpModemDemodPlugin(QObject *parent = nullptr);
const PluginDescriptor& getPluginDescriptor() const;
void initPlugin(PluginAPI *pluginAPI);
virtual void createRxChannel(DeviceAPI *deviceAPI, BasebandSampleSink **bs, ChannelAPI **cs) const;
virtual ChannelGUI *createRxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel) const;
virtual ChannelWebAPIAdapter *createChannelWebAPIAdapter() const;
private:
static const PluginDescriptor m_pluginDescriptor;
PluginAPI *m_pluginAPI;
};
#endif // INCLUDE_CHIRPMODEMDEMODPLUGIN_H

314
plugins/channelrx/demodchirpmodem/chirpmodemdemodsettings.cpp

@ -0,0 +1,314 @@ @@ -0,0 +1,314 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Dan Chokola, KD2HSG //
// Based on the SELCAL demodulator plugin: //
// Copyright (C) 2021-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// //
// 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 <QColor>
#include <algorithm>
#include "settings/serializable.h"
#include "util/simpleserializer.h"
#include "chirpmodemdemodsettings.h"
ChirpModemDemodSettings::ChirpModemDemodSettings()
{
resetToDefaults();
}
void ChirpModemDemodSettings::resetToDefaults()
{
m_inputFrequencyOffset = 0;
m_spreadFactor = 9;
m_bandwidth = 62500;
m_effort = 2;
m_autoEffort = true;
m_reportFailures = false;
m_maxBytes = 255;
m_rgbColor = QColor(255, 140, 0).rgb();
m_title = QStringLiteral("ChirpModem Demodulator");
m_streamIndex = 0;
m_useReverseAPI = false;
m_reverseAPIAddress = QStringLiteral("127.0.0.1");
m_reverseAPIPort = 8888;
m_reverseAPIDeviceIndex = 0;
m_reverseAPIChannelIndex = 0;
m_workspaceIndex = 0;
m_geometryBytes = QByteArray();
m_hidden = false;
m_columnIndexes.clear();
m_columnSizes.clear();
for (int i = 0; i < m_columns; ++i)
{
m_columnIndexes.append(i);
m_columnSizes.append(-1);
}
}
void ChirpModemDemodSettings::normalize()
{
m_spreadFactor = std::clamp(m_spreadFactor, 7, 12);
m_bandwidth = std::clamp(m_bandwidth, 1000, 2000000);
m_effort = std::clamp(m_effort, 0, 2);
m_maxBytes = std::clamp(m_maxBytes, 1, 2047);
m_streamIndex = std::max(0, m_streamIndex);
if (!m_reverseAPIPort || m_reverseAPIPort > 65535) {
m_reverseAPIPort = 8888;
}
m_reverseAPIDeviceIndex = std::min(m_reverseAPIDeviceIndex, 99u);
m_reverseAPIChannelIndex = std::min(m_reverseAPIChannelIndex, 99u);
if (m_columnIndexes.size() != m_columns || m_columnSizes.size() != m_columns)
{
m_columnIndexes.clear();
m_columnSizes.clear();
for (int i = 0; i < m_columns; ++i)
{
m_columnIndexes.append(i);
m_columnSizes.append(-1);
}
}
bool used[m_columns] = {};
bool valid = true;
for (int i = 0; i < m_columns; ++i)
{
int index = m_columnIndexes[i];
if (index < 0 || index >= m_columns || used[index]) {
valid = false;
} else {
used[index] = true;
}
m_columnSizes[i] = std::clamp(m_columnSizes[i], -1, 10000);
}
if (!valid)
{
for (int i = 0; i < m_columns; ++i) {
m_columnIndexes[i] = i;
}
}
}
QByteArray ChirpModemDemodSettings::serialize() const
{
SimpleSerializer s(1);
s.writeS32(1, m_inputFrequencyOffset);
s.writeS32(2, m_spreadFactor);
s.writeS32(3, m_bandwidth);
s.writeS32(4, m_effort);
s.writeBool(5, m_autoEffort);
s.writeBool(6, m_reportFailures);
s.writeS32(7, m_maxBytes);
s.writeU32(15, m_rgbColor);
s.writeString(16, m_title);
s.writeS32(17, m_streamIndex);
s.writeBool(18, m_useReverseAPI);
s.writeString(19, m_reverseAPIAddress);
s.writeU32(20, m_reverseAPIPort);
s.writeU32(21, m_reverseAPIDeviceIndex);
s.writeU32(22, m_reverseAPIChannelIndex);
s.writeS32(23, m_workspaceIndex);
s.writeBlob(24, m_geometryBytes);
s.writeBool(25, m_hidden);
s.writeList(28, m_columnIndexes);
s.writeList(29, m_columnSizes);
if (m_channelMarker) {
s.writeBlob(40, m_channelMarker->serialize());
}
if (m_rollupState) {
s.writeBlob(41, m_rollupState->serialize());
}
if (m_spectrumGUI) {
s.writeBlob(42, m_spectrumGUI->serialize());
}
return s.final();
}
bool ChirpModemDemodSettings::deserialize(const QByteArray& data)
{
SimpleDeserializer d(data);
resetToDefaults();
if (!d.isValid() || d.getVersion() != 1) {
return false;
}
d.readS32(1, &m_inputFrequencyOffset, 0);
d.readS32(2, &m_spreadFactor, 9);
d.readS32(3, &m_bandwidth, 62500);
d.readS32(4, &m_effort, 2);
d.readBool(5, &m_autoEffort, true);
d.readBool(6, &m_reportFailures, false);
d.readS32(7, &m_maxBytes, 255);
d.readU32(15, &m_rgbColor, QColor(255, 140, 0).rgb());
d.readString(16, &m_title, QStringLiteral("ChirpModem Demodulator"));
d.readS32(17, &m_streamIndex, 0);
d.readBool(18, &m_useReverseAPI, false);
d.readString(19, &m_reverseAPIAddress, QStringLiteral("127.0.0.1"));
d.readU32(20, &m_reverseAPIPort, 8888);
d.readU32(21, &m_reverseAPIDeviceIndex, 0);
d.readU32(22, &m_reverseAPIChannelIndex, 0);
d.readS32(23, &m_workspaceIndex, 0);
d.readBlob(24, &m_geometryBytes);
d.readBool(25, &m_hidden, false);
d.readList(28, &m_columnIndexes);
d.readList(29, &m_columnSizes);
QByteArray blob;
if (m_channelMarker && d.readBlob(40, &blob)) {
m_channelMarker->deserialize(blob);
}
if (m_rollupState && d.readBlob(41, &blob)) {
m_rollupState->deserialize(blob);
}
if (m_spectrumGUI && d.readBlob(42, &blob)) {
m_spectrumGUI->deserialize(blob);
}
normalize();
return true;
}
void ChirpModemDemodSettings::applySettings(const QStringList& keys, const ChirpModemDemodSettings& settings)
{
if (keys.contains("inputFrequencyOffset")) {
m_inputFrequencyOffset = settings.m_inputFrequencyOffset;
}
if (keys.contains("spreadFactor")) {
m_spreadFactor = settings.m_spreadFactor;
}
if (keys.contains("bandwidth")) {
m_bandwidth = settings.m_bandwidth;
}
if (keys.contains("effort")) {
m_effort = settings.m_effort;
}
if (keys.contains("autoEffort")) {
m_autoEffort = settings.m_autoEffort;
}
if (keys.contains("reportFailures")) {
m_reportFailures = settings.m_reportFailures;
}
if (keys.contains("maxBytes")) {
m_maxBytes = settings.m_maxBytes;
}
if (keys.contains("rgbColor")) {
m_rgbColor = settings.m_rgbColor;
}
if (keys.contains("title")) {
m_title = settings.m_title;
}
if (keys.contains("streamIndex")) {
m_streamIndex = settings.m_streamIndex;
}
if (keys.contains("useReverseAPI")) {
m_useReverseAPI = settings.m_useReverseAPI;
}
if (keys.contains("reverseAPIAddress")) {
m_reverseAPIAddress = settings.m_reverseAPIAddress;
}
if (keys.contains("reverseAPIPort")) {
m_reverseAPIPort = settings.m_reverseAPIPort;
}
if (keys.contains("reverseAPIDeviceIndex")) {
m_reverseAPIDeviceIndex = settings.m_reverseAPIDeviceIndex;
}
if (keys.contains("reverseAPIChannelIndex")) {
m_reverseAPIChannelIndex = settings.m_reverseAPIChannelIndex;
}
if (keys.contains("workspaceIndex")) {
m_workspaceIndex = settings.m_workspaceIndex;
}
if (keys.contains("geometryBytes")) {
m_geometryBytes = settings.m_geometryBytes;
}
if (keys.contains("hidden")) {
m_hidden = settings.m_hidden;
}
normalize();
}
QString ChirpModemDemodSettings::getDebugString(const QStringList& keys, bool force) const
{
QStringList result;
if (force || keys.contains("inputFrequencyOffset")) {
result << QString("inputFrequencyOffset: %1").arg(m_inputFrequencyOffset);
}
if (force || keys.contains("spreadFactor")) {
result << QString("spreadFactor: %1").arg(m_spreadFactor);
}
if (force || keys.contains("bandwidth")) {
result << QString("bandwidth: %1").arg(m_bandwidth);
}
if (force || keys.contains("effort")) {
result << QString("effort: %1").arg(m_effort);
}
if (force || keys.contains("autoEffort")) {
result << QString("autoEffort: %1").arg(m_autoEffort);
}
if (force || keys.contains("reportFailures")) {
result << QString("reportFailures: %1").arg(m_reportFailures);
}
if (force || keys.contains("maxBytes")) {
result << QString("maxBytes: %1").arg(m_maxBytes);
}
if (force || keys.contains("rgbColor")) {
result << QString("rgbColor: %1").arg(m_rgbColor);
}
if (force || keys.contains("title")) {
result << QString("title: %1").arg(m_title);
}
if (force || keys.contains("streamIndex")) {
result << QString("streamIndex: %1").arg(m_streamIndex);
}
if (force || keys.contains("useReverseAPI")) {
result << QString("useReverseAPI: %1").arg(m_useReverseAPI);
}
if (force || keys.contains("reverseAPIAddress")) {
result << QString("reverseAPIAddress: %1").arg(m_reverseAPIAddress);
}
if (force || keys.contains("reverseAPIPort")) {
result << QString("reverseAPIPort: %1").arg(m_reverseAPIPort);
}
if (force || keys.contains("reverseAPIDeviceIndex")) {
result << QString("reverseAPIDeviceIndex: %1").arg(m_reverseAPIDeviceIndex);
}
if (force || keys.contains("reverseAPIChannelIndex")) {
result << QString("reverseAPIChannelIndex: %1").arg(m_reverseAPIChannelIndex);
}
if (force || keys.contains("workspaceIndex")) {
result << QString("workspaceIndex: %1").arg(m_workspaceIndex);
}
if (force || keys.contains("hidden")) {
result << QString("hidden: %1").arg(m_hidden);
}
return result.join(" ");
}

77
plugins/channelrx/demodchirpmodem/chirpmodemdemodsettings.h

@ -0,0 +1,77 @@ @@ -0,0 +1,77 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Dan Chokola, KD2HSG //
// Based on the SELCAL demodulator plugin: //
// Copyright (C) 2021-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// //
// 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_CHIRPMODEMDEMODSETTINGS_H
#define INCLUDE_CHIRPMODEMDEMODSETTINGS_H
#include <QByteArray>
#include <QList>
#include <QStringList>
#include "dsp/dsptypes.h"
class Serializable;
struct ChirpModemDemodSettings {
// Columns of the frames table
static constexpr int m_columns = 12;
qint32 m_inputFrequencyOffset;
int m_spreadFactor; //!< 7..12
int m_bandwidth; //!< Chip rate = occupied bandwidth, Hz
int m_effort; //!< 0..2: retries per frame
bool m_autoEffort; //!< Lower effort while decoding lags real time
bool m_reportFailures; //!< Also report frames whose preamble was found but did not decode
int m_maxBytes; //!< Longest MAC frame to wait for
quint32 m_rgbColor;
QString m_title;
int m_streamIndex;
bool m_useReverseAPI;
QString m_reverseAPIAddress;
quint32 m_reverseAPIPort;
quint32 m_reverseAPIDeviceIndex;
quint32 m_reverseAPIChannelIndex;
int m_workspaceIndex;
QByteArray m_geometryBytes;
bool m_hidden;
Serializable *m_channelMarker = nullptr;
Serializable *m_rollupState = nullptr;
Serializable *m_spectrumGUI = nullptr;
QList<int> m_columnIndexes;
QList<int> m_columnSizes;
ChirpModemDemodSettings();
void resetToDefaults();
void normalize();
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
void applySettings(const QStringList& keys, const ChirpModemDemodSettings& settings);
QString getDebugString(const QStringList& keys, bool force = false) const;
//! Rate requested from the channelizer. The channelizer delivers at least this.
int requestedChannelSampleRate() const { return 2 * m_bandwidth; }
void setChannelMarker(Serializable *marker) { m_channelMarker = marker; }
void setRollupState(Serializable *state) { m_rollupState = state; }
void setSpectrumGUI(Serializable *spectrumGUI) { m_spectrumGUI = spectrumGUI; }
};
#endif

312
plugins/channelrx/demodchirpmodem/chirpmodemdemodsink.cpp

@ -0,0 +1,312 @@ @@ -0,0 +1,312 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Dan Chokola, KD2HSG //
// Based on the SELCAL demodulator plugin: //
// Copyright (C) 2021-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// //
// 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 <algorithm>
#include <cmath>
#include <cstring>
#include "dsp/spectrumvis.h"
#include "chirpmodemdemodsink.h"
#include "chirpmodemmessages.h"
// libchirpmodem needs a carrier frequency to tie the carrier offset to the
// sample clock. Used only until the device reports its centre frequency.
static constexpr double fallbackFrequency = 100e6;
ChirpModemDemodSink::ChirpModemDemodSink()
{
}
ChirpModemDemodSink::~ChirpModemDemodSink()
{
freeRx();
}
void ChirpModemDemodSink::freeRx()
{
if (m_rx)
{
chirpmodem_rx_free(m_rx);
m_rx = nullptr;
}
}
void ChirpModemDemodSink::applyChannelSettings(int channelSampleRate, int channelFrequencyOffset)
{
if ((channelSampleRate != m_channelSampleRate) || (channelFrequencyOffset != m_channelFrequencyOffset))
{
m_channelSampleRate = channelSampleRate;
m_channelFrequencyOffset = channelFrequencyOffset;
m_stale = true;
}
}
void ChirpModemDemodSink::setCenterFrequency(qint64 frequency)
{
if (frequency != m_centerFrequency)
{
m_centerFrequency = frequency;
m_stale = true;
}
}
void ChirpModemDemodSink::applySettings(const QStringList& keys, const ChirpModemDemodSettings& settings, bool force)
{
// Every receiver parameter is fixed when the handle is made
if (force ||
(keys.contains("inputFrequencyOffset") && (settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset)) ||
(keys.contains("spreadFactor") && (settings.m_spreadFactor != m_settings.m_spreadFactor)) ||
(keys.contains("bandwidth") && (settings.m_bandwidth != m_settings.m_bandwidth)) ||
(keys.contains("effort") && (settings.m_effort != m_settings.m_effort)) ||
(keys.contains("autoEffort") && (settings.m_autoEffort != m_settings.m_autoEffort)) ||
(keys.contains("reportFailures") && (settings.m_reportFailures != m_settings.m_reportFailures)) ||
(keys.contains("maxBytes") && (settings.m_maxBytes != m_settings.m_maxBytes)))
{
m_stale = true;
}
if (force) {
m_settings = settings;
} else {
m_settings.applySettings(keys, settings);
}
}
void ChirpModemDemodSink::reset()
{
m_stale = true;
commitConfig();
}
void ChirpModemDemodSink::commitConfig()
{
if (!m_stale) {
return;
}
m_stale = false;
freeRx();
m_samplesIn = 0;
m_nextStatus = 0;
if (m_channelSampleRate <= 0)
{
sendStatus(QStringLiteral("No channel sample rate yet"));
return;
}
qint64 frequency = m_centerFrequency + m_settings.m_inputFrequencyOffset;
chirpmodem_rx_config rc;
chirpmodem_rx_config_init(&rc);
rc.sf = m_settings.m_spreadFactor;
rc.bw = m_settings.m_bandwidth;
rc.fs = m_channelSampleRate;
rc.if_offset = m_channelFrequencyOffset;
rc.freq = frequency > 0 ? (double) frequency : fallbackFrequency;
rc.max_bytes = m_settings.m_maxBytes;
rc.effort = m_settings.m_effort;
rc.auto_effort = m_settings.m_autoEffort ? 1 : 0;
rc.report_failures = m_settings.m_reportFailures ? 1 : 0;
rc.on_frame = &ChirpModemDemodSink::onFrame;
rc.on_log = &ChirpModemDemodSink::onLog;
rc.user = this;
int err = CHIRPMODEM_OK;
m_rx = chirpmodem_rx_new(&rc, &err);
m_rxSampleRate = rc.fs;
m_rxFrequency = frequency;
if (!m_rx)
{
QString error = QString("chirpmodem_rx_new: %1 (SF %2, BW %3 Hz, fs %4 Hz, IF %5 Hz)")
.arg(chirpmodem_strerror(err))
.arg(rc.sf).arg(rc.bw).arg(rc.fs).arg(rc.if_offset);
qWarning() << "ChirpModemDemodSink::commitConfig:" << error;
sendStatus(error);
return;
}
qDebug() << "ChirpModemDemodSink::commitConfig: SF" << rc.sf << "BW" << rc.bw << "fs" << rc.fs
<< "IF" << rc.if_offset << "freq" << rc.freq << "effort" << rc.effort
<< "autoEffort" << rc.auto_effort << "reportFailures" << rc.report_failures;
sendStatus(frequency > 0 ? QString() : QStringLiteral("Centre frequency unknown: ppm is relative to 100 MHz"));
}
void ChirpModemDemodSink::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end)
{
if (m_stale) {
commitConfig();
}
const long n = end - begin;
if (n <= 0) {
return;
}
if (m_iq.size() < (size_t) (2 * n)) {
m_iq.resize(2 * n);
}
float *iq = m_iq.data();
double magSqSum = 0;
double magSqPeak = m_magSqPeak;
for (auto it = begin; it != end; ++it)
{
float re = it->real() / SDR_RX_SCALEF;
float im = it->imag() / SDR_RX_SCALEF;
*iq++ = re;
*iq++ = im;
double magSq = (double) re * re + (double) im * im;
magSqSum += magSq;
magSqPeak = std::max(magSqPeak, magSq);
}
m_magSqSum += magSqSum;
m_magSqPeak = magSqPeak;
m_magSqCount += n;
m_lastMagSq = magSqSum / n;
if (m_spectrumSink) {
m_spectrumSink->feed(begin, end, false);
}
if (!m_rx) {
return;
}
// Counted first, so that a frame reported during this push is timed
// against the end of the block
m_samplesIn += n;
int ret = chirpmodem_rx_push(m_rx, m_iq.data(), n, CHIRPMODEM_CF32);
if (ret < 0) {
qWarning() << "ChirpModemDemodSink::feed: chirpmodem_rx_push:" << chirpmodem_strerror(ret);
}
if (m_samplesIn >= m_nextStatus)
{
sendStatus();
m_nextStatus = m_samplesIn + (qint64) m_rxSampleRate;
}
}
void ChirpModemDemodSink::sendStatus(const QString& error)
{
if (!m_messageQueueToChannel) {
return;
}
ChirpModemMessages::Status status;
status.m_valid = m_rx != nullptr;
status.m_error = error;
status.m_channelSampleRate = m_channelSampleRate;
status.m_ifOffset = m_channelFrequencyOffset;
status.m_frequency = m_centerFrequency + m_settings.m_inputFrequencyOffset;
if (m_rx)
{
chirpmodem_rx_stats st;
chirpmodem_rx_get_stats(m_rx, &st);
status.m_framesOk = st.frames_ok;
status.m_framesFailed = st.frames_failed;
status.m_effort = st.effort;
status.m_load = st.load;
status.m_secondsIn = st.seconds_in;
}
m_messageQueueToChannel->push(ChirpModemMessages::MsgStatus::create(status));
}
void ChirpModemDemodSink::onFrame(void *user, const chirpmodem_frame *frame)
{
static_cast<ChirpModemDemodSink *>(user)->frameReceived(frame);
}
void ChirpModemDemodSink::onLog(void *user, const char *message)
{
(void) user;
qDebug() << "ChirpModemDemodSink: libchirpmodem:" << message;
}
// Runs inside chirpmodem_rx_push(), on the baseband thread. body and mac are
// only valid here, so everything is copied into the message.
void ChirpModemDemodSink::frameReceived(const chirpmodem_frame *frame)
{
if (!m_messageQueueToChannel) {
return;
}
ChirpModemMessages::Frame f;
double age = (m_rxSampleRate > 0 ? m_samplesIn / m_rxSampleRate : 0) - frame->t;
f.m_dateTime = QDateTime::currentDateTimeUtc().addMSecs(-std::llround(std::max(0.0, age) * 1000.0));
f.m_status = frame->status;
f.m_frequency = m_rxFrequency;
f.m_spreadFactor = m_settings.m_spreadFactor;
f.m_bandwidth = m_settings.m_bandwidth;
f.m_snr = frame->snr_db;
f.m_offsetHz = frame->offset_hz;
f.m_offsetPpm = frame->offset_ppm;
f.m_profile = frame->profile;
f.m_coherent = frame->coherent != 0;
f.m_encrypted = frame->encrypted != 0;
f.m_policyOk = frame->policy_ok != 0;
f.m_rampRetry = frame->ramp_retry != 0;
f.m_rampHzPerS = frame->ramp_hz_per_s;
f.m_driftRetry = frame->drift_retry != 0;
f.m_clockPpm = frame->clock_ppm;
f.m_ddPasses = frame->dd_passes;
f.m_src = QString::fromLatin1(frame->src, (int) strnlen(frame->src, sizeof(frame->src)));
f.m_dst = QString::fromLatin1(frame->dst, (int) strnlen(frame->dst, sizeof(frame->dst)));
if (frame->body && frame->body_len > 0) {
f.m_body = QByteArray(reinterpret_cast<const char *>(frame->body), frame->body_len);
}
if (frame->mac && frame->mac_len > 0) {
f.m_mac = QByteArray(reinterpret_cast<const char *>(frame->mac), frame->mac_len);
}
m_messageQueueToChannel->push(ChirpModemMessages::MsgFrame::create(f));
}
void ChirpModemDemodSink::getMagSqLevels(double& average, double& peak, int& count)
{
// As in other demodulators, read without waiting for the worker
if (m_magSqCount > 0)
{
average = m_magSqSum / m_magSqCount;
peak = m_magSqPeak;
count = m_magSqCount;
}
else
{
average = m_lastMagSq;
peak = m_lastMagSq;
count = 0;
}
m_magSqSum = 0;
m_magSqPeak = 0;
m_magSqCount = 0;
}

88
plugins/channelrx/demodchirpmodem/chirpmodemdemodsink.h

@ -0,0 +1,88 @@ @@ -0,0 +1,88 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Dan Chokola, KD2HSG //
// Based on the SELCAL demodulator plugin: //
// Copyright (C) 2021-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// //
// 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_CHIRPMODEMDEMODSINK_H
#define INCLUDE_CHIRPMODEMDEMODSINK_H
#include <vector>
#include <chirpmodem.h>
#include "dsp/channelsamplesink.h"
#include "util/messagequeue.h"
#include "chirpmodemdemodsettings.h"
class SpectrumVis;
// Feeds the channel's baseband to libchirpmodem.
//
// Threading: every method except getMagSqLevels() runs on the baseband thread
// with the baseband mutex held (or before that thread starts), so the
// chirpmodem_rx handle is only ever used from one thread at a time, as the
// library requires. Settings changes only mark the receiver stale; it is
// rebuilt once, by commitConfig(), after a whole message has been applied, and
// never while chirpmodem_rx_push() is running.
class ChirpModemDemodSink : public ChannelSampleSink {
public:
ChirpModemDemodSink();
~ChirpModemDemodSink();
void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end) override;
void applyChannelSettings(int channelSampleRate, int channelFrequencyOffset);
void applySettings(const QStringList& keys, const ChirpModemDemodSettings& settings, bool force = false);
void setCenterFrequency(qint64 frequency);
void commitConfig(); //!< Rebuild the receiver if a change made it stale
void reset(); //!< Drop any frame in progress
void setMessageQueueToChannel(MessageQueue *queue) { m_messageQueueToChannel = queue; }
void setSpectrumSink(SpectrumVis *spectrumSink) { m_spectrumSink = spectrumSink; }
void getMagSqLevels(double& average, double& peak, int& count);
double getMagSq() const { return m_lastMagSq; }
private:
ChirpModemDemodSettings m_settings;
MessageQueue *m_messageQueueToChannel = nullptr;
SpectrumVis *m_spectrumSink = nullptr;
qint64 m_centerFrequency = 0; //!< Device centre, Hz
int m_channelSampleRate = 0;
int m_channelFrequencyOffset = 0; //!< Signal centre within the channel, Hz
chirpmodem_rx *m_rx = nullptr;
bool m_stale = true;
double m_rxSampleRate = 0; //!< fs the handle was made with
qint64 m_rxFrequency = 0; //!< freq the handle was made with
qint64 m_samplesIn = 0; //!< Pushed to the handle, including the block being pushed
qint64 m_nextStatus = 0; //!< m_samplesIn at which to send the next status
std::vector<float> m_iq;
double m_magSqSum = 0;
double m_magSqPeak = 0;
int m_magSqCount = 0;
double m_lastMagSq = 1e-12;
void freeRx();
void sendStatus(const QString& error = QString());
void frameReceived(const chirpmodem_frame *frame);
static void onFrame(void *user, const chirpmodem_frame *frame);
static void onLog(void *user, const char *message);
};
#endif

49
plugins/channelrx/demodchirpmodem/chirpmodemdemodwebapiadapter.cpp

@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Dan Chokola, KD2HSG //
// Based on the SELCAL demodulator plugin: //
// Copyright (C) 2021-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// //
// 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 "chirpmodemdemod.h"
#include "chirpmodemdemodwebapiadapter.h"
ChirpModemDemodWebAPIAdapter::ChirpModemDemodWebAPIAdapter()
{
}
ChirpModemDemodWebAPIAdapter::~ChirpModemDemodWebAPIAdapter()
{
}
int ChirpModemDemodWebAPIAdapter::webapiSettingsGet(SWGSDRangel::SWGChannelSettings& response, QString& errorMessage)
{
(void) errorMessage;
response.setChirpModemDemodSettings(new SWGSDRangel::SWGChirpModemDemodSettings());
response.getChirpModemDemodSettings()->init();
ChirpModemDemod::webapiFormatChannelSettings(response, m_settings);
return 200;
}
int ChirpModemDemodWebAPIAdapter::webapiSettingsPutPatch(bool force, const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response, QString& errorMessage)
{
(void) force;
(void) errorMessage;
ChirpModemDemod::webapiUpdateChannelSettings(m_settings, channelSettingsKeys, response);
return 200;
}

43
plugins/channelrx/demodchirpmodem/chirpmodemdemodwebapiadapter.h

@ -0,0 +1,43 @@ @@ -0,0 +1,43 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Dan Chokola, KD2HSG //
// Based on the SELCAL demodulator plugin: //
// Copyright (C) 2021-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// //
// 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_CHIRPMODEMDEMOD_WEBAPIADAPTER_H
#define INCLUDE_CHIRPMODEMDEMOD_WEBAPIADAPTER_H
#include "channel/channelwebapiadapter.h"
#include "chirpmodemdemodsettings.h"
class ChirpModemDemodWebAPIAdapter : public ChannelWebAPIAdapter {
public:
ChirpModemDemodWebAPIAdapter();
virtual ~ChirpModemDemodWebAPIAdapter();
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:
ChirpModemDemodSettings m_settings;
};
#endif // INCLUDE_CHIRPMODEMDEMOD_WEBAPIADAPTER_H

48
plugins/channelrx/demodchirpmodem/chirpmodemmessages.cpp

@ -0,0 +1,48 @@ @@ -0,0 +1,48 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Dan Chokola, KD2HSG //
// Based on the SELCAL demodulator plugin: //
// Copyright (C) 2021-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// //
// 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 "chirpmodemmessages.h"
namespace ChirpModemMessages {
MESSAGE_CLASS_DEFINITION(MsgFrame, Message)
MESSAGE_CLASS_DEFINITION(MsgStatus, Message)
QString statusName(int status)
{
switch (status)
{
case StatusOK:
return QStringLiteral("OK");
case StatusHeaderFail:
return QStringLiteral("Header fail");
case StatusPayloadFail:
return QStringLiteral("Payload fail");
default:
return QStringLiteral("Unknown");
}
}
QString profileName(int profile)
{
return profile == 0 ? QStringLiteral("Licensed") : QStringLiteral("Unlicensed");
}
} // namespace ChirpModemMessages

105
plugins/channelrx/demodchirpmodem/chirpmodemmessages.h

@ -0,0 +1,105 @@ @@ -0,0 +1,105 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 Dan Chokola, KD2HSG //
// Based on the SELCAL demodulator plugin: //
// Copyright (C) 2021-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
// Copyright (C) 2026 Jon Beniston, M7RCE <jon@beniston.com> //
// //
// 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_CHIRPMODEMMESSAGES_H
#define INCLUDE_CHIRPMODEMMESSAGES_H
#include <QByteArray>
#include <QDateTime>
#include <QString>
#include "util/message.h"
namespace ChirpModemMessages {
// Frame status, as chirpmodem_frame.status
enum FrameStatus {
StatusOK = 0,
StatusHeaderFail = 1,
StatusPayloadFail = 2
};
QString statusName(int status);
QString profileName(int profile);
//! A copy of what libchirpmodem reports for a frame, made inside its callback
struct Frame {
QDateTime m_dateTime; //!< UTC, frame start
int m_status = StatusOK;
qint64 m_frequency = 0; //!< Channel centre, Hz
int m_spreadFactor = 0;
int m_bandwidth = 0;
double m_snr = 0; //!< dB, in the signal bandwidth
double m_offsetHz = 0; //!< Carrier offset, Hz
double m_offsetPpm = 0; //!< Carrier offset relative to m_frequency, ppm
int m_profile = 0; //!< 0 licensed, 1 unlicensed
bool m_coherent = false;
bool m_encrypted = false;
bool m_policyOk = true; //!< false: a licensed frame without source or with encryption
bool m_rampRetry = false;
double m_rampHzPerS = 0;
bool m_driftRetry = false;
double m_clockPpm = 0;
int m_ddPasses = 0;
QString m_src;
QString m_dst;
QByteArray m_body;
QByteArray m_mac; //!< The whole MAC frame
};
//! Receiver state, sent when it is (re)configured and about once a second
struct Status {
bool m_valid = false; //!< A receiver handle exists
QString m_error; //!< Why there is none
int m_channelSampleRate = 0; //!< Rate pushed to the library
int m_ifOffset = 0; //!< Signal centre within the channel, Hz
qint64 m_frequency = 0; //!< Signal centre, Hz
qint64 m_framesOk = 0;
qint64 m_framesFailed = 0;
int m_effort = 0; //!< Current effort
double m_load = 0; //!< Recent processing time / stream time
double m_secondsIn = 0;
};
class MsgFrame : public Message {
MESSAGE_CLASS_DECLARATION
public:
static MsgFrame *create(const Frame& frame) { return new MsgFrame(frame); }
const Frame& getFrame() const { return m_frame; }
private:
explicit MsgFrame(const Frame& frame) : m_frame(frame) {}
Frame m_frame;
};
class MsgStatus : public Message {
MESSAGE_CLASS_DECLARATION
public:
static MsgStatus *create(const Status& status) { return new MsgStatus(status); }
const Status& getStatus() const { return m_status; }
private:
explicit MsgStatus(const Status& status) : m_status(status) {}
Status m_status;
};
} // namespace ChirpModemMessages
#endif

88
plugins/channelrx/demodchirpmodem/readme.md

@ -0,0 +1,88 @@ @@ -0,0 +1,88 @@
<h1>ChirpModem demodulator plugin</h1>
<h2>Introduction</h2>
This plugin receives the chirpmodem chirp spread-spectrum format (version 1) with
[libchirpmodem](https://github.com/), the C library of the chirpmodem project. It
decodes frames, shows them in a table, and publishes them as packets, so that the
MCP server's `get_packets` and other packet consumers receive them.
It is a receiver only. SF and bandwidth are not signalled on air: set them to
those of the channel you are listening to.
The library is linked statically. Build it first and install it where CMake can
find it, for example `cmake --install build --prefix ~/.local`, or pass
`-DCHIRPMODEM_DIR=<prefix>` to the SDRangel build.
<h2>Interface</h2>
<h3>1: Frequency shift from centre frequency</h3>
Offset of the signal centre from the device centre frequency, in Hz.
<h3>2: Channel power</h3>
Average power in the channel, in dB, and the level meter.
<h3>3: SF</h3>
Spreading factor, 7 to 12.
<h3>4: BW</h3>
Chip rate, equal to the occupied bandwidth. 62.5 kHz and 125 kHz are in use.
The channel is decimated to at least twice this rate. The rate actually used and
the signal's offset within the decimated channel are shown in the status line (9).
<h3>5: Effort</h3>
Retries per frame, from 0 (none) to 2 (all: carrier ramp removal, sample clock
re-estimation and decision-directed passes).
<h3>6: Auto</h3>
Lower the effort while decoding lags real time.
<h3>7: Fail</h3>
Also list frames whose preamble was found but whose header or payload did not
decode. Failed frames are not published as packets.
<h3>8: Max</h3>
Longest MAC frame to wait for, in bytes (1 to 2047).
<h3>9: Status</h3>
Sample rate fed to the receiver, the signal's offset within it, the current
effort, and the processing load relative to real time. Errors in the receiver
configuration are shown here too.
<h3>10: Received frames</h3>
The last decoded frame is shown above the table: source > destination, SNR,
carrier offset and the start of the body. The table has, for each frame:
- UTC: start of the frame
- Status: OK, Header fail or Payload fail. "OK (policy)" on a red background marks
a frame with the licensed (amateur) profile that has no source callsign or is
encrypted, which the licensed profile forbids.
- Profile: Licensed or Unlicensed
- Src, Dst: callsigns
- SNR (dB): in the signal bandwidth
- Offset (Hz), ppm: carrier offset of the frame from the channel frequency
- Mode: coherent or non-coherent payload. The tooltip lists the retries used.
- Len, Text, Hex: the body
The bin button clears the table.
<h3>11: Channel spectrum</h3>
Spectrum of the channel as fed to the receiver.
<h2>Web API and MCP</h2>
Settings are under `ChirpModemDemodSettings` and the report under
`ChirpModemDemodReport` (see `ChirpModemDemod.yaml`). Decoded frames are published
on the channel's `packets` pipe as the whole MAC frame; the MCP server decodes the
source, destination and body from it.

71
plugins/feature/mcpserver/mcpdatafeed.cpp

@ -39,6 +39,7 @@ static const QStringList packetURIs = { @@ -39,6 +39,7 @@ static const QStringList packetURIs = {
QStringLiteral("sdrangel.channel.aisdemod"),
QStringLiteral("sdrangel.channel.packetdemod"),
QStringLiteral("sdrangel.channel.chirpchatdemod"),
QStringLiteral("sdrangel.channel.chirpmodemdemod"),
QStringLiteral("sdrangel.channel.m17demod"),
QStringLiteral("sdrangel.channel.meshtasticdemod"),
QStringLiteral("sdrangel.channel.meshcoredemod"),
@ -303,11 +304,79 @@ QString MCPDataFeed::stripHtml(const QString& html) @@ -303,11 +304,79 @@ QString MCPDataFeed::stripHtml(const QString& html)
return s.trimmed();
}
// chirpmodem MAC frame (FORMAT.md section 11): flags, then optional 6-byte
// base-40 source and destination callsigns, then the body.
static QString decodeChirpModemCallsign(const QByteArray& bytes, int start)
{
static const char alphabet[] = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-/.";
quint64 v = 0;
for (int i = 0; i < 6; i++) {
v = (v << 8) | (quint8) bytes[start + i];
}
QString callsign;
while (v > 0)
{
callsign.append(QChar(alphabet[v % 40]));
v /= 40;
}
return callsign.trimmed();
}
static QJsonObject decodeChirpModemMac(const QByteArray& bytes)
{
QJsonObject decoded;
if (bytes.isEmpty()) {
return decoded;
}
quint8 flags = (quint8) bytes[0];
bool hasSrc = (flags & 0x80) != 0;
bool hasDst = (flags & 0x40) != 0;
int bodyStart = 1 + (hasSrc ? 6 : 0) + (hasDst ? 6 : 0);
if (((flags & 0x3f) != 0) || (bytes.size() < bodyStart)) {
return decoded;
}
decoded["protocol"] = "chirpmodem";
int pos = 1;
if (hasSrc)
{
decoded["src"] = decodeChirpModemCallsign(bytes, pos);
pos += 6;
}
if (hasDst) {
decoded["dst"] = decodeChirpModemCallsign(bytes, pos);
}
QByteArray body = bytes.mid(bodyStart);
QString text;
for (char c : body) {
text.append(((c >= 0x20) && (c < 0x7f)) ? QChar(c) : QChar('.'));
}
decoded["bodyLength"] = body.size();
decoded["body"] = text;
return decoded;
}
QJsonObject MCPDataFeed::decodePacket(const QString& sourceType, const QByteArray& bytes)
{
QJsonObject decoded;
if (sourceType == "AISDemod")
if (sourceType == "ChirpModemDemod")
{
decoded = decodeChirpModemMac(bytes);
}
else if (sourceType == "AISDemod")
{
AISMessage *ais = AISMessage::decode(bytes);

1
sdrbase/resources/webapi.qrc

@ -50,6 +50,7 @@ @@ -50,6 +50,7 @@
<file>webapi/doc/swagger/include/DOA2.yaml</file>
<file>webapi/doc/swagger/include/DSCDemod.yaml</file>
<file>webapi/doc/swagger/include/SELCALDemod.yaml</file>
<file>webapi/doc/swagger/include/ChirpModemDemod.yaml</file>
<file>webapi/doc/swagger/include/DSDDemod.yaml</file>
<file>webapi/doc/swagger/include/DroneIDDemod.yaml</file>
<file>webapi/doc/swagger/include/EndOfTrainDemod.yaml</file>

2
sdrbase/resources/webapi/doc/swagger/include/ChannelReport.yaml

@ -209,3 +209,5 @@ ChannelReport: @@ -209,3 +209,5 @@ ChannelReport:
description: "Wfm mod report data for Channel."
SELCALDemodReport:
$ref: "/doc/swagger/include/SELCALDemod.yaml#/SELCALDemodReport"
ChirpModemDemodReport:
$ref: "/doc/swagger/include/ChirpModemDemod.yaml#/ChirpModemDemodReport"

2
sdrbase/resources/webapi/doc/swagger/include/ChannelSettings.yaml

@ -240,3 +240,5 @@ ChannelSettings: @@ -240,3 +240,5 @@ ChannelSettings:
description: "Wfm mod settings configuration for Channel."
SELCALDemodSettings:
$ref: "/doc/swagger/include/SELCALDemod.yaml#/SELCALDemodSettings"
ChirpModemDemodSettings:
$ref: "/doc/swagger/include/ChirpModemDemod.yaml#/ChirpModemDemodSettings"

162
sdrbase/resources/webapi/doc/swagger/include/ChirpModemDemod.yaml

@ -0,0 +1,162 @@ @@ -0,0 +1,162 @@
ChirpModemDemodSettings:
description: ChirpModem demodulator settings (libchirpmodem receiver, format v1)
type: object
properties:
inputFrequencyOffset:
type: integer
format: int64
spreadFactor:
type: integer
format: int32
description: Spreading factor
default: 9
minimum: 7
maximum: 12
bandwidth:
type: integer
format: int32
description: Chip rate, equal to the occupied bandwidth, in Hz. 62500 and 125000 are in use
default: 62500
minimum: 1000
maximum: 2000000
effort:
type: integer
format: int32
description: Retries per frame, 0 to 2 (2 = all)
default: 2
minimum: 0
maximum: 2
autoEffort:
type: integer
format: int32
description: Lower the effort while decoding lags real time
default: 1
enum: [0, 1]
reportFailures:
type: integer
format: int32
description: Also report frames whose preamble was found but whose header or payload did not decode
default: 0
enum: [0, 1]
maxBytes:
type: integer
format: int32
description: Longest MAC frame to wait for, in bytes
default: 255
minimum: 1
maximum: 2047
rgbColor:
type: integer
format: int32
title:
type: string
streamIndex:
type: integer
format: int32
description: MIMO channel. Not relevant when connected to SI (single Rx).
useReverseAPI:
type: integer
format: int32
description: Synchronize with reverse API (1 for yes, 0 for no)
reverseAPIAddress:
type: string
reverseAPIPort:
type: integer
format: int32
reverseAPIDeviceIndex:
type: integer
format: int32
reverseAPIChannelIndex:
type: integer
format: int32
channelMarker:
$ref: "/doc/swagger/include/ChannelMarker.yaml#/ChannelMarker"
rollupState:
$ref: "/doc/swagger/include/RollupState.yaml#/RollupState"
ChirpModemDemodReport:
description: ChirpModem demodulator report
type: object
properties:
channelPowerDb:
type: number
format: double
description: Channel power in dB
channelSampleRate:
type: integer
format: int32
description: Sample rate fed to the receiver, Hz
ifOffset:
type: integer
format: int32
description: Signal centre within the channel after decimation, Hz
frequency:
type: integer
format: int64
description: Signal centre frequency, Hz
receiverValid:
type: integer
format: int32
description: 1 if the receiver is configured and decoding
receiverError:
type: string
description: Why the receiver is not configured, or a warning
effort:
type: integer
format: int32
description: Current decoding effort, lowered by autoEffort when decoding lags
load:
type: number
format: float
description: Recent processing time relative to stream time
okCount:
type: integer
format: int64
description: Frames decoded since the channel started
failCount:
type: integer
format: int64
description: Frames reported as failed since the channel started (reportFailures)
policyFailCount:
type: integer
format: int64
description: Licensed frames without a source callsign or with encryption
lastTimestamp:
type: string
description: UTC start of the last frame
lastStatus:
type: string
description: OK, Header fail or Payload fail
lastProfile:
type: string
description: Licensed or Unlicensed
lastPolicyOk:
type: integer
format: int32
lastCoherent:
type: integer
format: int32
lastEncrypted:
type: integer
format: int32
lastSrc:
type: string
lastDst:
type: string
lastSnr:
type: number
format: float
description: dB, in the signal bandwidth
lastOffsetHz:
type: number
format: float
description: Carrier offset, Hz
lastOffsetPpm:
type: number
format: float
description: Carrier offset relative to the signal frequency, ppm
lastBodyText:
type: string
description: Body with non-printable bytes replaced by dots
lastBodyHex:
type: string

6
sdrbase/webapi/webapirequestmapper.cpp

@ -5002,6 +5002,12 @@ bool WebAPIRequestMapper::getChannelSettings( @@ -5002,6 +5002,12 @@ bool WebAPIRequestMapper::getChannelSettings(
channelSettings->getSelcalDemodSettings()->init();
channelSettings->getSelcalDemodSettings()->fromJsonObject(settingsJsonObject);
}
else if (channelSettingsKey == "ChirpModemDemodSettings")
{
channelSettings->setChirpModemDemodSettings(new SWGSDRangel::SWGChirpModemDemodSettings());
channelSettings->getChirpModemDemodSettings()->init();
channelSettings->getChirpModemDemodSettings()->fromJsonObject(settingsJsonObject);
}
else if (channelSettingsKey == "DSDDemodSettings")
{
channelSettings->setDsdDemodSettings(new SWGSDRangel::SWGDSDDemodSettings());

2
sdrbase/webapi/webapiutils.cpp

@ -51,6 +51,7 @@ const QMap<QString, QString> WebAPIUtils::m_channelURIToSettingsKey = { @@ -51,6 +51,7 @@ const QMap<QString, QString> WebAPIUtils::m_channelURIToSettingsKey = {
{"sdrangel.channel.doa2", "DOA2Settings"},
{"sdrangel.channel.dscdemod", "DSCDemodSettings"},
{"sdrangel.channel.selcaldemod", "SELCALDemodSettings"},
{"sdrangel.channel.chirpmodemdemod", "ChirpModemDemodSettings"},
{"sdrangel.channel.dsddemod", "DSDDemodSettings"},
{"sdrangel.channel.droneiddemod", "DroneIDDemodSettings"},
{"sdrangel.channel.endoftraindemod", "EndOfTrainDemodSettings"},
@ -191,6 +192,7 @@ const QMap<QString, QString> WebAPIUtils::m_channelTypeToSettingsKey = { @@ -191,6 +192,7 @@ const QMap<QString, QString> WebAPIUtils::m_channelTypeToSettingsKey = {
{"DOA2", "DOA2Settings"},
{"DSCDemod", "DSCDemodSettings"},
{"SELCALDemod", "SELCALDemodSettings"},
{"ChirpModemDemod", "ChirpModemDemodSettings"},
{"DSDDemod", "DSDDemodSettings"},
{"DroneIDDemod", "DroneIDDemodSettings"},
{"EndOfTrainDemod", "EndOfTrainDemodSettings"},

2
swagger/sdrangel/api/swagger/include/ChannelReport.yaml

@ -211,3 +211,5 @@ ChannelReport: @@ -211,3 +211,5 @@ ChannelReport:
description: "Wfm mod report data for Channel."
SELCALDemodReport:
$ref: "http://swgserver:8081/api/swagger/include/SELCALDemod.yaml#/SELCALDemodReport"
ChirpModemDemodReport:
$ref: "http://swgserver:8081/api/swagger/include/ChirpModemDemod.yaml#/ChirpModemDemodReport"

2
swagger/sdrangel/api/swagger/include/ChannelSettings.yaml

@ -242,3 +242,5 @@ ChannelSettings: @@ -242,3 +242,5 @@ ChannelSettings:
description: "Wfm mod settings configuration for Channel."
SELCALDemodSettings:
$ref: "http://swgserver:8081/api/swagger/include/SELCALDemod.yaml#/SELCALDemodSettings"
ChirpModemDemodSettings:
$ref: "http://swgserver:8081/api/swagger/include/ChirpModemDemod.yaml#/ChirpModemDemodSettings"

162
swagger/sdrangel/api/swagger/include/ChirpModemDemod.yaml

@ -0,0 +1,162 @@ @@ -0,0 +1,162 @@
ChirpModemDemodSettings:
description: ChirpModem demodulator settings (libchirpmodem receiver, format v1)
type: object
properties:
inputFrequencyOffset:
type: integer
format: int64
spreadFactor:
type: integer
format: int32
description: Spreading factor
default: 9
minimum: 7
maximum: 12
bandwidth:
type: integer
format: int32
description: Chip rate, equal to the occupied bandwidth, in Hz. 62500 and 125000 are in use
default: 62500
minimum: 1000
maximum: 2000000
effort:
type: integer
format: int32
description: Retries per frame, 0 to 2 (2 = all)
default: 2
minimum: 0
maximum: 2
autoEffort:
type: integer
format: int32
description: Lower the effort while decoding lags real time
default: 1
enum: [0, 1]
reportFailures:
type: integer
format: int32
description: Also report frames whose preamble was found but whose header or payload did not decode
default: 0
enum: [0, 1]
maxBytes:
type: integer
format: int32
description: Longest MAC frame to wait for, in bytes
default: 255
minimum: 1
maximum: 2047
rgbColor:
type: integer
format: int32
title:
type: string
streamIndex:
type: integer
format: int32
description: MIMO channel. Not relevant when connected to SI (single Rx).
useReverseAPI:
type: integer
format: int32
description: Synchronize with reverse API (1 for yes, 0 for no)
reverseAPIAddress:
type: string
reverseAPIPort:
type: integer
format: int32
reverseAPIDeviceIndex:
type: integer
format: int32
reverseAPIChannelIndex:
type: integer
format: int32
channelMarker:
$ref: "http://swgserver:8081/api/swagger/include/ChannelMarker.yaml#/ChannelMarker"
rollupState:
$ref: "http://swgserver:8081/api/swagger/include/RollupState.yaml#/RollupState"
ChirpModemDemodReport:
description: ChirpModem demodulator report
type: object
properties:
channelPowerDb:
type: number
format: double
description: Channel power in dB
channelSampleRate:
type: integer
format: int32
description: Sample rate fed to the receiver, Hz
ifOffset:
type: integer
format: int32
description: Signal centre within the channel after decimation, Hz
frequency:
type: integer
format: int64
description: Signal centre frequency, Hz
receiverValid:
type: integer
format: int32
description: 1 if the receiver is configured and decoding
receiverError:
type: string
description: Why the receiver is not configured, or a warning
effort:
type: integer
format: int32
description: Current decoding effort, lowered by autoEffort when decoding lags
load:
type: number
format: float
description: Recent processing time relative to stream time
okCount:
type: integer
format: int64
description: Frames decoded since the channel started
failCount:
type: integer
format: int64
description: Frames reported as failed since the channel started (reportFailures)
policyFailCount:
type: integer
format: int64
description: Licensed frames without a source callsign or with encryption
lastTimestamp:
type: string
description: UTC start of the last frame
lastStatus:
type: string
description: OK, Header fail or Payload fail
lastProfile:
type: string
description: Licensed or Unlicensed
lastPolicyOk:
type: integer
format: int32
lastCoherent:
type: integer
format: int32
lastEncrypted:
type: integer
format: int32
lastSrc:
type: string
lastDst:
type: string
lastSnr:
type: number
format: float
description: dB, in the signal bandwidth
lastOffsetHz:
type: number
format: float
description: Carrier offset, Hz
lastOffsetPpm:
type: number
format: float
description: Carrier offset relative to the signal frequency, ppm
lastBodyText:
type: string
description: Body with non-printable bytes replaced by dots
lastBodyHex:
type: string

26
swagger/sdrangel/code/qt5/client/SWGChannelReport.cpp

@ -74,8 +74,10 @@ SWGChannelReport::SWGChannelReport() { @@ -74,8 +74,10 @@ SWGChannelReport::SWGChannelReport() {
m_doa2_report_isSet = false;
dsc_demod_report = nullptr;
selcal_demod_report = nullptr;
chirpmodem_demod_report = nullptr;
m_dsc_demod_report_isSet = false;
m_selcal_demod_report_isSet = false;
m_chirpmodem_demod_report_isSet = false;
dsd_demod_report = nullptr;
m_dsd_demod_report_isSet = false;
drone_id_demod_report = nullptr;
@ -220,8 +222,10 @@ SWGChannelReport::init() { @@ -220,8 +222,10 @@ SWGChannelReport::init() {
m_doa2_report_isSet = false;
dsc_demod_report = new SWGDSCDemodReport();
selcal_demod_report = new SWGSELCALDemodReport();
chirpmodem_demod_report = new SWGChirpModemDemodReport();
m_dsc_demod_report_isSet = false;
m_selcal_demod_report_isSet = false;
m_chirpmodem_demod_report_isSet = false;
dsd_demod_report = new SWGDSDDemodReport();
m_dsd_demod_report_isSet = false;
drone_id_demod_report = new SWGDroneIDDemodReport();
@ -386,6 +390,9 @@ SWGChannelReport::cleanup() { @@ -386,6 +390,9 @@ SWGChannelReport::cleanup() {
if(selcal_demod_report != nullptr) {
delete selcal_demod_report;
}
if(chirpmodem_demod_report != nullptr) {
delete chirpmodem_demod_report;
}
if(dsd_demod_report != nullptr) {
delete dsd_demod_report;
}
@ -578,6 +585,7 @@ SWGChannelReport::fromJsonObject(QJsonObject &pJson) { @@ -578,6 +585,7 @@ SWGChannelReport::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&dsc_demod_report, pJson["DSCDemodReport"], "SWGDSCDemodReport", "SWGDSCDemodReport");
::SWGSDRangel::setValue(&selcal_demod_report, pJson["SELCALDemodReport"], "SWGSELCALDemodReport", "SWGSELCALDemodReport");
::SWGSDRangel::setValue(&chirpmodem_demod_report, pJson["ChirpModemDemodReport"], "SWGChirpModemDemodReport", "SWGChirpModemDemodReport");
::SWGSDRangel::setValue(&dsd_demod_report, pJson["DSDDemodReport"], "SWGDSDDemodReport", "SWGDSDDemodReport");
@ -756,6 +764,9 @@ SWGChannelReport::asJsonObject() { @@ -756,6 +764,9 @@ SWGChannelReport::asJsonObject() {
if((selcal_demod_report != nullptr) && (selcal_demod_report->isSet())){
toJsonValue(QString("SELCALDemodReport"), selcal_demod_report, obj, QString("SWGSELCALDemodReport"));
}
if((chirpmodem_demod_report != nullptr) && (chirpmodem_demod_report->isSet())){
toJsonValue(QString("ChirpModemDemodReport"), chirpmodem_demod_report, obj, QString("SWGChirpModemDemodReport"));
}
if((dsd_demod_report != nullptr) && (dsd_demod_report->isSet())){
toJsonValue(QString("DSDDemodReport"), dsd_demod_report, obj, QString("SWGDSDDemodReport"));
}
@ -1129,6 +1140,10 @@ SWGSELCALDemodReport* @@ -1129,6 +1140,10 @@ SWGSELCALDemodReport*
SWGChannelReport::getSelcalDemodReport() {
return selcal_demod_report;
}
SWGChirpModemDemodReport*
SWGChannelReport::getChirpModemDemodReport() {
return chirpmodem_demod_report;
}
void
SWGChannelReport::setSelcalDemodReport(SWGSELCALDemodReport* selcal_demod_report) {
if (this->selcal_demod_report != selcal_demod_report) {
@ -1137,6 +1152,14 @@ SWGChannelReport::setSelcalDemodReport(SWGSELCALDemodReport* selcal_demod_report @@ -1137,6 +1152,14 @@ SWGChannelReport::setSelcalDemodReport(SWGSELCALDemodReport* selcal_demod_report
this->selcal_demod_report = selcal_demod_report;
this->m_selcal_demod_report_isSet = true;
}
void
SWGChannelReport::setChirpModemDemodReport(SWGChirpModemDemodReport* chirpmodem_demod_report) {
if (this->chirpmodem_demod_report != chirpmodem_demod_report) {
delete this->chirpmodem_demod_report;
}
this->chirpmodem_demod_report = chirpmodem_demod_report;
this->m_chirpmodem_demod_report_isSet = true;
}
SWGDSDDemodReport*
SWGChannelReport::getDsdDemodReport() {
@ -1665,6 +1688,9 @@ SWGChannelReport::isSet(){ @@ -1665,6 +1688,9 @@ SWGChannelReport::isSet(){
if(selcal_demod_report && selcal_demod_report->isSet()){
isObjectUpdated = true; break;
}
if(chirpmodem_demod_report && chirpmodem_demod_report->isSet()){
isObjectUpdated = true; break;
}
if(dsd_demod_report && dsd_demod_report->isSet()){
isObjectUpdated = true; break;
}

5
swagger/sdrangel/code/qt5/client/SWGChannelReport.h

@ -44,6 +44,7 @@ @@ -44,6 +44,7 @@
#include "SWGDRMDemodReport.h"
#include "SWGDSCDemodReport.h"
#include "SWGSELCALDemodReport.h"
#include "SWGChirpModemDemodReport.h"
#include "SWGDSDDemodReport.h"
#include "SWGDroneIDDemodReport.h"
#include "SWGEndOfTrainDemodReport.h"
@ -177,8 +178,10 @@ public: @@ -177,8 +178,10 @@ public:
SWGDSCDemodReport* getDscDemodReport();
SWGSELCALDemodReport* getSelcalDemodReport();
SWGChirpModemDemodReport* getChirpModemDemodReport();
void setDscDemodReport(SWGDSCDemodReport* dsc_demod_report);
void setSelcalDemodReport(SWGSELCALDemodReport* selcal_demod_report);
void setChirpModemDemodReport(SWGChirpModemDemodReport* chirpmodem_demod_report);
SWGDSDDemodReport* getDsdDemodReport();
void setDsdDemodReport(SWGDSDDemodReport* dsd_demod_report);
@ -387,8 +390,10 @@ private: @@ -387,8 +390,10 @@ private:
SWGDSCDemodReport* dsc_demod_report;
SWGSELCALDemodReport* selcal_demod_report;
SWGChirpModemDemodReport* chirpmodem_demod_report;
bool m_dsc_demod_report_isSet;
bool m_selcal_demod_report_isSet;
bool m_chirpmodem_demod_report_isSet;
SWGDSDDemodReport* dsd_demod_report;
bool m_dsd_demod_report_isSet;

26
swagger/sdrangel/code/qt5/client/SWGChannelSettings.cpp

@ -84,8 +84,10 @@ SWGChannelSettings::SWGChannelSettings() { @@ -84,8 +84,10 @@ SWGChannelSettings::SWGChannelSettings() {
m_doa2_settings_isSet = false;
dsc_demod_settings = nullptr;
selcal_demod_settings = nullptr;
chirpmodem_demod_settings = nullptr;
m_dsc_demod_settings_isSet = false;
m_selcal_demod_settings_isSet = false;
m_chirpmodem_demod_settings_isSet = false;
dsd_demod_settings = nullptr;
m_dsd_demod_settings_isSet = false;
drone_id_demod_settings = nullptr;
@ -250,8 +252,10 @@ SWGChannelSettings::init() { @@ -250,8 +252,10 @@ SWGChannelSettings::init() {
m_doa2_settings_isSet = false;
dsc_demod_settings = new SWGDSCDemodSettings();
selcal_demod_settings = new SWGSELCALDemodSettings();
chirpmodem_demod_settings = new SWGChirpModemDemodSettings();
m_dsc_demod_settings_isSet = false;
m_selcal_demod_settings_isSet = false;
m_chirpmodem_demod_settings_isSet = false;
dsd_demod_settings = new SWGDSDDemodSettings();
m_dsd_demod_settings_isSet = false;
drone_id_demod_settings = new SWGDroneIDDemodSettings();
@ -437,6 +441,9 @@ SWGChannelSettings::cleanup() { @@ -437,6 +441,9 @@ SWGChannelSettings::cleanup() {
if(selcal_demod_settings != nullptr) {
delete selcal_demod_settings;
}
if(chirpmodem_demod_settings != nullptr) {
delete chirpmodem_demod_settings;
}
if(dsd_demod_settings != nullptr) {
delete dsd_demod_settings;
}
@ -654,6 +661,7 @@ SWGChannelSettings::fromJsonObject(QJsonObject &pJson) { @@ -654,6 +661,7 @@ SWGChannelSettings::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&dsc_demod_settings, pJson["DSCDemodSettings"], "SWGDSCDemodSettings", "SWGDSCDemodSettings");
::SWGSDRangel::setValue(&selcal_demod_settings, pJson["SELCALDemodSettings"], "SWGSELCALDemodSettings", "SWGSELCALDemodSettings");
::SWGSDRangel::setValue(&chirpmodem_demod_settings, pJson["ChirpModemDemodSettings"], "SWGChirpModemDemodSettings", "SWGChirpModemDemodSettings");
::SWGSDRangel::setValue(&dsd_demod_settings, pJson["DSDDemodSettings"], "SWGDSDDemodSettings", "SWGDSDDemodSettings");
@ -857,6 +865,9 @@ SWGChannelSettings::asJsonObject() { @@ -857,6 +865,9 @@ SWGChannelSettings::asJsonObject() {
if((selcal_demod_settings != nullptr) && (selcal_demod_settings->isSet())){
toJsonValue(QString("SELCALDemodSettings"), selcal_demod_settings, obj, QString("SWGSELCALDemodSettings"));
}
if((chirpmodem_demod_settings != nullptr) && (chirpmodem_demod_settings->isSet())){
toJsonValue(QString("ChirpModemDemodSettings"), chirpmodem_demod_settings, obj, QString("SWGChirpModemDemodSettings"));
}
if((dsd_demod_settings != nullptr) && (dsd_demod_settings->isSet())){
toJsonValue(QString("DSDDemodSettings"), dsd_demod_settings, obj, QString("SWGDSDDemodSettings"));
}
@ -1295,6 +1306,10 @@ SWGSELCALDemodSettings* @@ -1295,6 +1306,10 @@ SWGSELCALDemodSettings*
SWGChannelSettings::getSelcalDemodSettings() {
return selcal_demod_settings;
}
SWGChirpModemDemodSettings*
SWGChannelSettings::getChirpModemDemodSettings() {
return chirpmodem_demod_settings;
}
void
SWGChannelSettings::setSelcalDemodSettings(SWGSELCALDemodSettings* selcal_demod_settings) {
if (this->selcal_demod_settings != selcal_demod_settings) {
@ -1303,6 +1318,14 @@ SWGChannelSettings::setSelcalDemodSettings(SWGSELCALDemodSettings* selcal_demod_ @@ -1303,6 +1318,14 @@ SWGChannelSettings::setSelcalDemodSettings(SWGSELCALDemodSettings* selcal_demod_
this->selcal_demod_settings = selcal_demod_settings;
this->m_selcal_demod_settings_isSet = true;
}
void
SWGChannelSettings::setChirpModemDemodSettings(SWGChirpModemDemodSettings* chirpmodem_demod_settings) {
if (this->chirpmodem_demod_settings != chirpmodem_demod_settings) {
delete this->chirpmodem_demod_settings;
}
this->chirpmodem_demod_settings = chirpmodem_demod_settings;
this->m_chirpmodem_demod_settings_isSet = true;
}
SWGDSDDemodSettings*
SWGChannelSettings::getDsdDemodSettings() {
@ -1896,6 +1919,9 @@ SWGChannelSettings::isSet(){ @@ -1896,6 +1919,9 @@ SWGChannelSettings::isSet(){
if(selcal_demod_settings && selcal_demod_settings->isSet()){
isObjectUpdated = true; break;
}
if(chirpmodem_demod_settings && chirpmodem_demod_settings->isSet()){
isObjectUpdated = true; break;
}
if(dsd_demod_settings && dsd_demod_settings->isSet()){
isObjectUpdated = true; break;
}

5
swagger/sdrangel/code/qt5/client/SWGChannelSettings.h

@ -47,6 +47,7 @@ @@ -47,6 +47,7 @@
#include "SWGDRMDemodSettings.h"
#include "SWGDSCDemodSettings.h"
#include "SWGSELCALDemodSettings.h"
#include "SWGChirpModemDemodSettings.h"
#include "SWGDSDDemodSettings.h"
#include "SWGDroneIDDemodSettings.h"
#include "SWGEndOfTrainDemodSettings.h"
@ -200,8 +201,10 @@ public: @@ -200,8 +201,10 @@ public:
SWGDSCDemodSettings* getDscDemodSettings();
SWGSELCALDemodSettings* getSelcalDemodSettings();
SWGChirpModemDemodSettings* getChirpModemDemodSettings();
void setDscDemodSettings(SWGDSCDemodSettings* dsc_demod_settings);
void setSelcalDemodSettings(SWGSELCALDemodSettings* selcal_demod_settings);
void setChirpModemDemodSettings(SWGChirpModemDemodSettings* chirpmodem_demod_settings);
SWGDSDDemodSettings* getDsdDemodSettings();
void setDsdDemodSettings(SWGDSDDemodSettings* dsd_demod_settings);
@ -440,8 +443,10 @@ private: @@ -440,8 +443,10 @@ private:
SWGDSCDemodSettings* dsc_demod_settings;
SWGSELCALDemodSettings* selcal_demod_settings;
SWGChirpModemDemodSettings* chirpmodem_demod_settings;
bool m_dsc_demod_settings_isSet;
bool m_selcal_demod_settings_isSet;
bool m_chirpmodem_demod_settings_isSet;
SWGDSDDemodSettings* dsd_demod_settings;
bool m_dsd_demod_settings_isSet;

177
swagger/sdrangel/code/qt5/client/SWGChirpModemDemodReport.cpp

@ -0,0 +1,177 @@ @@ -0,0 +1,177 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Generated by gen_swg_models.py from ChirpModemDemod.yaml: edit the YAML, not this file.
#include "SWGChirpModemDemodReport.h"
#include "SWGHelpers.h"
#include <QJsonDocument>
namespace SWGSDRangel {
SWGChirpModemDemodReport::SWGChirpModemDemodReport() = default;
SWGChirpModemDemodReport::SWGChirpModemDemodReport(QString* json) { init(); if (json) { fromJson(*json); } }
SWGChirpModemDemodReport::~SWGChirpModemDemodReport() { cleanup(); }
void SWGChirpModemDemodReport::cleanup()
{
delete m_receiverError; m_receiverError = nullptr;
delete m_lastTimestamp; m_lastTimestamp = nullptr;
delete m_lastStatus; m_lastStatus = nullptr;
delete m_lastProfile; m_lastProfile = nullptr;
delete m_lastSrc; m_lastSrc = nullptr;
delete m_lastDst; m_lastDst = nullptr;
delete m_lastBodyText; m_lastBodyText = nullptr;
delete m_lastBodyHex; m_lastBodyHex = nullptr;
}
void SWGChirpModemDemodReport::init()
{
cleanup();
m_channelPowerDb = 0; m_channelPowerDbIsSet = false;
m_channelSampleRate = 0; m_channelSampleRateIsSet = false;
m_ifOffset = 0; m_ifOffsetIsSet = false;
m_frequency = 0; m_frequencyIsSet = false;
m_receiverValid = 0; m_receiverValidIsSet = false;
m_receiverError = new QString(); m_receiverErrorIsSet = false;
m_effort = 0; m_effortIsSet = false;
m_load = 0; m_loadIsSet = false;
m_okCount = 0; m_okCountIsSet = false;
m_failCount = 0; m_failCountIsSet = false;
m_policyFailCount = 0; m_policyFailCountIsSet = false;
m_lastTimestamp = new QString(); m_lastTimestampIsSet = false;
m_lastStatus = new QString(); m_lastStatusIsSet = false;
m_lastProfile = new QString(); m_lastProfileIsSet = false;
m_lastPolicyOk = 0; m_lastPolicyOkIsSet = false;
m_lastCoherent = 0; m_lastCoherentIsSet = false;
m_lastEncrypted = 0; m_lastEncryptedIsSet = false;
m_lastSrc = new QString(); m_lastSrcIsSet = false;
m_lastDst = new QString(); m_lastDstIsSet = false;
m_lastSnr = 0; m_lastSnrIsSet = false;
m_lastOffsetHz = 0; m_lastOffsetHzIsSet = false;
m_lastOffsetPpm = 0; m_lastOffsetPpmIsSet = false;
m_lastBodyText = new QString(); m_lastBodyTextIsSet = false;
m_lastBodyHex = new QString(); m_lastBodyHexIsSet = false;
}
SWGChirpModemDemodReport* SWGChirpModemDemodReport::fromJson(QString& json)
{
auto object = QJsonDocument::fromJson(json.toUtf8()).object(); fromJsonObject(object); return this;
}
void SWGChirpModemDemodReport::fromJsonObject(QJsonObject& json)
{
if (json.contains("channelPowerDb")) { ::SWGSDRangel::setValue(&m_channelPowerDb,json["channelPowerDb"],"double",""); m_channelPowerDbIsSet = true; }
if (json.contains("channelSampleRate")) { ::SWGSDRangel::setValue(&m_channelSampleRate,json["channelSampleRate"],"qint32",""); m_channelSampleRateIsSet = true; }
if (json.contains("ifOffset")) { ::SWGSDRangel::setValue(&m_ifOffset,json["ifOffset"],"qint32",""); m_ifOffsetIsSet = true; }
if (json.contains("frequency")) { ::SWGSDRangel::setValue(&m_frequency,json["frequency"],"qint64",""); m_frequencyIsSet = true; }
if (json.contains("receiverValid")) { ::SWGSDRangel::setValue(&m_receiverValid,json["receiverValid"],"qint32",""); m_receiverValidIsSet = true; }
if (json.contains("receiverError")) { ::SWGSDRangel::setValue(&m_receiverError,json["receiverError"],"QString","QString"); m_receiverErrorIsSet = true; }
if (json.contains("effort")) { ::SWGSDRangel::setValue(&m_effort,json["effort"],"qint32",""); m_effortIsSet = true; }
if (json.contains("load")) { ::SWGSDRangel::setValue(&m_load,json["load"],"float",""); m_loadIsSet = true; }
if (json.contains("okCount")) { ::SWGSDRangel::setValue(&m_okCount,json["okCount"],"qint64",""); m_okCountIsSet = true; }
if (json.contains("failCount")) { ::SWGSDRangel::setValue(&m_failCount,json["failCount"],"qint64",""); m_failCountIsSet = true; }
if (json.contains("policyFailCount")) { ::SWGSDRangel::setValue(&m_policyFailCount,json["policyFailCount"],"qint64",""); m_policyFailCountIsSet = true; }
if (json.contains("lastTimestamp")) { ::SWGSDRangel::setValue(&m_lastTimestamp,json["lastTimestamp"],"QString","QString"); m_lastTimestampIsSet = true; }
if (json.contains("lastStatus")) { ::SWGSDRangel::setValue(&m_lastStatus,json["lastStatus"],"QString","QString"); m_lastStatusIsSet = true; }
if (json.contains("lastProfile")) { ::SWGSDRangel::setValue(&m_lastProfile,json["lastProfile"],"QString","QString"); m_lastProfileIsSet = true; }
if (json.contains("lastPolicyOk")) { ::SWGSDRangel::setValue(&m_lastPolicyOk,json["lastPolicyOk"],"qint32",""); m_lastPolicyOkIsSet = true; }
if (json.contains("lastCoherent")) { ::SWGSDRangel::setValue(&m_lastCoherent,json["lastCoherent"],"qint32",""); m_lastCoherentIsSet = true; }
if (json.contains("lastEncrypted")) { ::SWGSDRangel::setValue(&m_lastEncrypted,json["lastEncrypted"],"qint32",""); m_lastEncryptedIsSet = true; }
if (json.contains("lastSrc")) { ::SWGSDRangel::setValue(&m_lastSrc,json["lastSrc"],"QString","QString"); m_lastSrcIsSet = true; }
if (json.contains("lastDst")) { ::SWGSDRangel::setValue(&m_lastDst,json["lastDst"],"QString","QString"); m_lastDstIsSet = true; }
if (json.contains("lastSnr")) { ::SWGSDRangel::setValue(&m_lastSnr,json["lastSnr"],"float",""); m_lastSnrIsSet = true; }
if (json.contains("lastOffsetHz")) { ::SWGSDRangel::setValue(&m_lastOffsetHz,json["lastOffsetHz"],"float",""); m_lastOffsetHzIsSet = true; }
if (json.contains("lastOffsetPpm")) { ::SWGSDRangel::setValue(&m_lastOffsetPpm,json["lastOffsetPpm"],"float",""); m_lastOffsetPpmIsSet = true; }
if (json.contains("lastBodyText")) { ::SWGSDRangel::setValue(&m_lastBodyText,json["lastBodyText"],"QString","QString"); m_lastBodyTextIsSet = true; }
if (json.contains("lastBodyHex")) { ::SWGSDRangel::setValue(&m_lastBodyHex,json["lastBodyHex"],"QString","QString"); m_lastBodyHexIsSet = true; }
}
QString SWGChirpModemDemodReport::asJson()
{
auto* object = asJsonObject(); QString result = QJsonDocument(*object).toJson(); delete object; return result;
}
QJsonObject* SWGChirpModemDemodReport::asJsonObject()
{
auto* object = new QJsonObject();
if (m_channelPowerDbIsSet) { object->insert("channelPowerDb",QJsonValue(m_channelPowerDb)); }
if (m_channelSampleRateIsSet) { object->insert("channelSampleRate",QJsonValue(m_channelSampleRate)); }
if (m_ifOffsetIsSet) { object->insert("ifOffset",QJsonValue(m_ifOffset)); }
if (m_frequencyIsSet) { object->insert("frequency",QJsonValue(m_frequency)); }
if (m_receiverValidIsSet) { object->insert("receiverValid",QJsonValue(m_receiverValid)); }
if (m_receiverError && (m_receiverErrorIsSet || !m_receiverError->isEmpty())) { toJsonValue(QString("receiverError"),m_receiverError,object,QString("QString")); }
if (m_effortIsSet) { object->insert("effort",QJsonValue(m_effort)); }
if (m_loadIsSet) { object->insert("load",QJsonValue(m_load)); }
if (m_okCountIsSet) { object->insert("okCount",QJsonValue(m_okCount)); }
if (m_failCountIsSet) { object->insert("failCount",QJsonValue(m_failCount)); }
if (m_policyFailCountIsSet) { object->insert("policyFailCount",QJsonValue(m_policyFailCount)); }
if (m_lastTimestamp && (m_lastTimestampIsSet || !m_lastTimestamp->isEmpty())) { toJsonValue(QString("lastTimestamp"),m_lastTimestamp,object,QString("QString")); }
if (m_lastStatus && (m_lastStatusIsSet || !m_lastStatus->isEmpty())) { toJsonValue(QString("lastStatus"),m_lastStatus,object,QString("QString")); }
if (m_lastProfile && (m_lastProfileIsSet || !m_lastProfile->isEmpty())) { toJsonValue(QString("lastProfile"),m_lastProfile,object,QString("QString")); }
if (m_lastPolicyOkIsSet) { object->insert("lastPolicyOk",QJsonValue(m_lastPolicyOk)); }
if (m_lastCoherentIsSet) { object->insert("lastCoherent",QJsonValue(m_lastCoherent)); }
if (m_lastEncryptedIsSet) { object->insert("lastEncrypted",QJsonValue(m_lastEncrypted)); }
if (m_lastSrc && (m_lastSrcIsSet || !m_lastSrc->isEmpty())) { toJsonValue(QString("lastSrc"),m_lastSrc,object,QString("QString")); }
if (m_lastDst && (m_lastDstIsSet || !m_lastDst->isEmpty())) { toJsonValue(QString("lastDst"),m_lastDst,object,QString("QString")); }
if (m_lastSnrIsSet) { object->insert("lastSnr",QJsonValue(m_lastSnr)); }
if (m_lastOffsetHzIsSet) { object->insert("lastOffsetHz",QJsonValue(m_lastOffsetHz)); }
if (m_lastOffsetPpmIsSet) { object->insert("lastOffsetPpm",QJsonValue(m_lastOffsetPpm)); }
if (m_lastBodyText && (m_lastBodyTextIsSet || !m_lastBodyText->isEmpty())) { toJsonValue(QString("lastBodyText"),m_lastBodyText,object,QString("QString")); }
if (m_lastBodyHex && (m_lastBodyHexIsSet || !m_lastBodyHex->isEmpty())) { toJsonValue(QString("lastBodyHex"),m_lastBodyHex,object,QString("QString")); }
return object;
}
bool SWGChirpModemDemodReport::isSet()
{
return m_channelPowerDbIsSet || m_channelSampleRateIsSet || m_ifOffsetIsSet || m_frequencyIsSet || m_receiverValidIsSet || m_receiverErrorIsSet || m_effortIsSet || m_loadIsSet || m_okCountIsSet || m_failCountIsSet || m_policyFailCountIsSet || m_lastTimestampIsSet || m_lastStatusIsSet || m_lastProfileIsSet || m_lastPolicyOkIsSet || m_lastCoherentIsSet || m_lastEncryptedIsSet || m_lastSrcIsSet || m_lastDstIsSet || m_lastSnrIsSet || m_lastOffsetHzIsSet || m_lastOffsetPpmIsSet || m_lastBodyTextIsSet || m_lastBodyHexIsSet;
}
double SWGChirpModemDemodReport::getChannelPowerDb() { return m_channelPowerDb; }
void SWGChirpModemDemodReport::setChannelPowerDb(double value) { m_channelPowerDb = value; m_channelPowerDbIsSet = true; }
qint32 SWGChirpModemDemodReport::getChannelSampleRate() { return m_channelSampleRate; }
void SWGChirpModemDemodReport::setChannelSampleRate(qint32 value) { m_channelSampleRate = value; m_channelSampleRateIsSet = true; }
qint32 SWGChirpModemDemodReport::getIfOffset() { return m_ifOffset; }
void SWGChirpModemDemodReport::setIfOffset(qint32 value) { m_ifOffset = value; m_ifOffsetIsSet = true; }
qint64 SWGChirpModemDemodReport::getFrequency() { return m_frequency; }
void SWGChirpModemDemodReport::setFrequency(qint64 value) { m_frequency = value; m_frequencyIsSet = true; }
qint32 SWGChirpModemDemodReport::getReceiverValid() { return m_receiverValid; }
void SWGChirpModemDemodReport::setReceiverValid(qint32 value) { m_receiverValid = value; m_receiverValidIsSet = true; }
QString* SWGChirpModemDemodReport::getReceiverError() { return m_receiverError; }
void SWGChirpModemDemodReport::setReceiverError(QString* value) { if (m_receiverError != value) { delete m_receiverError; m_receiverError = value; } m_receiverErrorIsSet = true; }
qint32 SWGChirpModemDemodReport::getEffort() { return m_effort; }
void SWGChirpModemDemodReport::setEffort(qint32 value) { m_effort = value; m_effortIsSet = true; }
float SWGChirpModemDemodReport::getLoad() { return m_load; }
void SWGChirpModemDemodReport::setLoad(float value) { m_load = value; m_loadIsSet = true; }
qint64 SWGChirpModemDemodReport::getOkCount() { return m_okCount; }
void SWGChirpModemDemodReport::setOkCount(qint64 value) { m_okCount = value; m_okCountIsSet = true; }
qint64 SWGChirpModemDemodReport::getFailCount() { return m_failCount; }
void SWGChirpModemDemodReport::setFailCount(qint64 value) { m_failCount = value; m_failCountIsSet = true; }
qint64 SWGChirpModemDemodReport::getPolicyFailCount() { return m_policyFailCount; }
void SWGChirpModemDemodReport::setPolicyFailCount(qint64 value) { m_policyFailCount = value; m_policyFailCountIsSet = true; }
QString* SWGChirpModemDemodReport::getLastTimestamp() { return m_lastTimestamp; }
void SWGChirpModemDemodReport::setLastTimestamp(QString* value) { if (m_lastTimestamp != value) { delete m_lastTimestamp; m_lastTimestamp = value; } m_lastTimestampIsSet = true; }
QString* SWGChirpModemDemodReport::getLastStatus() { return m_lastStatus; }
void SWGChirpModemDemodReport::setLastStatus(QString* value) { if (m_lastStatus != value) { delete m_lastStatus; m_lastStatus = value; } m_lastStatusIsSet = true; }
QString* SWGChirpModemDemodReport::getLastProfile() { return m_lastProfile; }
void SWGChirpModemDemodReport::setLastProfile(QString* value) { if (m_lastProfile != value) { delete m_lastProfile; m_lastProfile = value; } m_lastProfileIsSet = true; }
qint32 SWGChirpModemDemodReport::getLastPolicyOk() { return m_lastPolicyOk; }
void SWGChirpModemDemodReport::setLastPolicyOk(qint32 value) { m_lastPolicyOk = value; m_lastPolicyOkIsSet = true; }
qint32 SWGChirpModemDemodReport::getLastCoherent() { return m_lastCoherent; }
void SWGChirpModemDemodReport::setLastCoherent(qint32 value) { m_lastCoherent = value; m_lastCoherentIsSet = true; }
qint32 SWGChirpModemDemodReport::getLastEncrypted() { return m_lastEncrypted; }
void SWGChirpModemDemodReport::setLastEncrypted(qint32 value) { m_lastEncrypted = value; m_lastEncryptedIsSet = true; }
QString* SWGChirpModemDemodReport::getLastSrc() { return m_lastSrc; }
void SWGChirpModemDemodReport::setLastSrc(QString* value) { if (m_lastSrc != value) { delete m_lastSrc; m_lastSrc = value; } m_lastSrcIsSet = true; }
QString* SWGChirpModemDemodReport::getLastDst() { return m_lastDst; }
void SWGChirpModemDemodReport::setLastDst(QString* value) { if (m_lastDst != value) { delete m_lastDst; m_lastDst = value; } m_lastDstIsSet = true; }
float SWGChirpModemDemodReport::getLastSnr() { return m_lastSnr; }
void SWGChirpModemDemodReport::setLastSnr(float value) { m_lastSnr = value; m_lastSnrIsSet = true; }
float SWGChirpModemDemodReport::getLastOffsetHz() { return m_lastOffsetHz; }
void SWGChirpModemDemodReport::setLastOffsetHz(float value) { m_lastOffsetHz = value; m_lastOffsetHzIsSet = true; }
float SWGChirpModemDemodReport::getLastOffsetPpm() { return m_lastOffsetPpm; }
void SWGChirpModemDemodReport::setLastOffsetPpm(float value) { m_lastOffsetPpm = value; m_lastOffsetPpmIsSet = true; }
QString* SWGChirpModemDemodReport::getLastBodyText() { return m_lastBodyText; }
void SWGChirpModemDemodReport::setLastBodyText(QString* value) { if (m_lastBodyText != value) { delete m_lastBodyText; m_lastBodyText = value; } m_lastBodyTextIsSet = true; }
QString* SWGChirpModemDemodReport::getLastBodyHex() { return m_lastBodyHex; }
void SWGChirpModemDemodReport::setLastBodyHex(QString* value) { if (m_lastBodyHex != value) { delete m_lastBodyHex; m_lastBodyHex = value; } m_lastBodyHexIsSet = true; }
}

130
swagger/sdrangel/code/qt5/client/SWGChirpModemDemodReport.h

@ -0,0 +1,130 @@ @@ -0,0 +1,130 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Qt model for ChirpModemDemod.yaml, following the Swagger client model interface.
// Generated by gen_swg_models.py: edit the YAML, not this file.
#ifndef SWGChirpModemDemodReport_H_
#define SWGChirpModemDemodReport_H_
#include <QJsonObject>
#include <QString>
#include "SWGObject.h"
#include "export.h"
namespace SWGSDRangel {
class SWG_API SWGChirpModemDemodReport : public SWGObject {
public:
SWGChirpModemDemodReport();
explicit SWGChirpModemDemodReport(QString* json);
~SWGChirpModemDemodReport() override;
void init();
void cleanup();
QString asJson() override;
QJsonObject* asJsonObject() override;
void fromJsonObject(QJsonObject& json) override;
SWGChirpModemDemodReport* fromJson(QString& json) override;
bool isSet() override;
double getChannelPowerDb();
void setChannelPowerDb(double value);
qint32 getChannelSampleRate();
void setChannelSampleRate(qint32 value);
qint32 getIfOffset();
void setIfOffset(qint32 value);
qint64 getFrequency();
void setFrequency(qint64 value);
qint32 getReceiverValid();
void setReceiverValid(qint32 value);
QString* getReceiverError();
void setReceiverError(QString* value);
qint32 getEffort();
void setEffort(qint32 value);
float getLoad();
void setLoad(float value);
qint64 getOkCount();
void setOkCount(qint64 value);
qint64 getFailCount();
void setFailCount(qint64 value);
qint64 getPolicyFailCount();
void setPolicyFailCount(qint64 value);
QString* getLastTimestamp();
void setLastTimestamp(QString* value);
QString* getLastStatus();
void setLastStatus(QString* value);
QString* getLastProfile();
void setLastProfile(QString* value);
qint32 getLastPolicyOk();
void setLastPolicyOk(qint32 value);
qint32 getLastCoherent();
void setLastCoherent(qint32 value);
qint32 getLastEncrypted();
void setLastEncrypted(qint32 value);
QString* getLastSrc();
void setLastSrc(QString* value);
QString* getLastDst();
void setLastDst(QString* value);
float getLastSnr();
void setLastSnr(float value);
float getLastOffsetHz();
void setLastOffsetHz(float value);
float getLastOffsetPpm();
void setLastOffsetPpm(float value);
QString* getLastBodyText();
void setLastBodyText(QString* value);
QString* getLastBodyHex();
void setLastBodyHex(QString* value);
private:
double m_channelPowerDb = 0;
bool m_channelPowerDbIsSet = false;
qint32 m_channelSampleRate = 0;
bool m_channelSampleRateIsSet = false;
qint32 m_ifOffset = 0;
bool m_ifOffsetIsSet = false;
qint64 m_frequency = 0;
bool m_frequencyIsSet = false;
qint32 m_receiverValid = 0;
bool m_receiverValidIsSet = false;
QString* m_receiverError = nullptr;
bool m_receiverErrorIsSet = false;
qint32 m_effort = 0;
bool m_effortIsSet = false;
float m_load = 0;
bool m_loadIsSet = false;
qint64 m_okCount = 0;
bool m_okCountIsSet = false;
qint64 m_failCount = 0;
bool m_failCountIsSet = false;
qint64 m_policyFailCount = 0;
bool m_policyFailCountIsSet = false;
QString* m_lastTimestamp = nullptr;
bool m_lastTimestampIsSet = false;
QString* m_lastStatus = nullptr;
bool m_lastStatusIsSet = false;
QString* m_lastProfile = nullptr;
bool m_lastProfileIsSet = false;
qint32 m_lastPolicyOk = 0;
bool m_lastPolicyOkIsSet = false;
qint32 m_lastCoherent = 0;
bool m_lastCoherentIsSet = false;
qint32 m_lastEncrypted = 0;
bool m_lastEncryptedIsSet = false;
QString* m_lastSrc = nullptr;
bool m_lastSrcIsSet = false;
QString* m_lastDst = nullptr;
bool m_lastDstIsSet = false;
float m_lastSnr = 0;
bool m_lastSnrIsSet = false;
float m_lastOffsetHz = 0;
bool m_lastOffsetHzIsSet = false;
float m_lastOffsetPpm = 0;
bool m_lastOffsetPpmIsSet = false;
QString* m_lastBodyText = nullptr;
bool m_lastBodyTextIsSet = false;
QString* m_lastBodyHex = nullptr;
bool m_lastBodyHexIsSet = false;
};
}
#endif

138
swagger/sdrangel/code/qt5/client/SWGChirpModemDemodSettings.cpp

@ -0,0 +1,138 @@ @@ -0,0 +1,138 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Generated by gen_swg_models.py from ChirpModemDemod.yaml: edit the YAML, not this file.
#include "SWGChirpModemDemodSettings.h"
#include "SWGHelpers.h"
#include <QJsonDocument>
namespace SWGSDRangel {
SWGChirpModemDemodSettings::SWGChirpModemDemodSettings() = default;
SWGChirpModemDemodSettings::SWGChirpModemDemodSettings(QString* json) { init(); if (json) { fromJson(*json); } }
SWGChirpModemDemodSettings::~SWGChirpModemDemodSettings() { cleanup(); }
void SWGChirpModemDemodSettings::cleanup()
{
delete m_title; m_title = nullptr;
delete m_reverseAPIAddress; m_reverseAPIAddress = nullptr;
delete m_channelMarker; m_channelMarker = nullptr;
delete m_rollupState; m_rollupState = nullptr;
}
void SWGChirpModemDemodSettings::init()
{
cleanup();
m_inputFrequencyOffset = 0; m_inputFrequencyOffsetIsSet = false;
m_spreadFactor = 0; m_spreadFactorIsSet = false;
m_bandwidth = 0; m_bandwidthIsSet = false;
m_effort = 0; m_effortIsSet = false;
m_autoEffort = 0; m_autoEffortIsSet = false;
m_reportFailures = 0; m_reportFailuresIsSet = false;
m_maxBytes = 0; m_maxBytesIsSet = false;
m_rgbColor = 0; m_rgbColorIsSet = false;
m_title = new QString(); m_titleIsSet = false;
m_streamIndex = 0; m_streamIndexIsSet = false;
m_useReverseAPI = 0; m_useReverseAPIIsSet = false;
m_reverseAPIAddress = new QString(); m_reverseAPIAddressIsSet = false;
m_reverseAPIPort = 0; m_reverseAPIPortIsSet = false;
m_reverseAPIDeviceIndex = 0; m_reverseAPIDeviceIndexIsSet = false;
m_reverseAPIChannelIndex = 0; m_reverseAPIChannelIndexIsSet = false;
m_channelMarker = new SWGChannelMarker(); m_channelMarkerIsSet = false;
m_rollupState = new SWGRollupState(); m_rollupStateIsSet = false;
}
SWGChirpModemDemodSettings* SWGChirpModemDemodSettings::fromJson(QString& json)
{
auto object = QJsonDocument::fromJson(json.toUtf8()).object(); fromJsonObject(object); return this;
}
void SWGChirpModemDemodSettings::fromJsonObject(QJsonObject& json)
{
if (json.contains("inputFrequencyOffset")) { ::SWGSDRangel::setValue(&m_inputFrequencyOffset,json["inputFrequencyOffset"],"qint64",""); m_inputFrequencyOffsetIsSet = true; }
if (json.contains("spreadFactor")) { ::SWGSDRangel::setValue(&m_spreadFactor,json["spreadFactor"],"qint32",""); m_spreadFactorIsSet = true; }
if (json.contains("bandwidth")) { ::SWGSDRangel::setValue(&m_bandwidth,json["bandwidth"],"qint32",""); m_bandwidthIsSet = true; }
if (json.contains("effort")) { ::SWGSDRangel::setValue(&m_effort,json["effort"],"qint32",""); m_effortIsSet = true; }
if (json.contains("autoEffort")) { ::SWGSDRangel::setValue(&m_autoEffort,json["autoEffort"],"qint32",""); m_autoEffortIsSet = true; }
if (json.contains("reportFailures")) { ::SWGSDRangel::setValue(&m_reportFailures,json["reportFailures"],"qint32",""); m_reportFailuresIsSet = true; }
if (json.contains("maxBytes")) { ::SWGSDRangel::setValue(&m_maxBytes,json["maxBytes"],"qint32",""); m_maxBytesIsSet = true; }
if (json.contains("rgbColor")) { ::SWGSDRangel::setValue(&m_rgbColor,json["rgbColor"],"qint32",""); m_rgbColorIsSet = true; }
if (json.contains("title")) { ::SWGSDRangel::setValue(&m_title,json["title"],"QString","QString"); m_titleIsSet = true; }
if (json.contains("streamIndex")) { ::SWGSDRangel::setValue(&m_streamIndex,json["streamIndex"],"qint32",""); m_streamIndexIsSet = true; }
if (json.contains("useReverseAPI")) { ::SWGSDRangel::setValue(&m_useReverseAPI,json["useReverseAPI"],"qint32",""); m_useReverseAPIIsSet = true; }
if (json.contains("reverseAPIAddress")) { ::SWGSDRangel::setValue(&m_reverseAPIAddress,json["reverseAPIAddress"],"QString","QString"); m_reverseAPIAddressIsSet = true; }
if (json.contains("reverseAPIPort")) { ::SWGSDRangel::setValue(&m_reverseAPIPort,json["reverseAPIPort"],"qint32",""); m_reverseAPIPortIsSet = true; }
if (json.contains("reverseAPIDeviceIndex")) { ::SWGSDRangel::setValue(&m_reverseAPIDeviceIndex,json["reverseAPIDeviceIndex"],"qint32",""); m_reverseAPIDeviceIndexIsSet = true; }
if (json.contains("reverseAPIChannelIndex")) { ::SWGSDRangel::setValue(&m_reverseAPIChannelIndex,json["reverseAPIChannelIndex"],"qint32",""); m_reverseAPIChannelIndexIsSet = true; }
if (json.contains("channelMarker")) { ::SWGSDRangel::setValue(&m_channelMarker,json["channelMarker"],"SWGChannelMarker","SWGChannelMarker"); m_channelMarkerIsSet = true; }
if (json.contains("rollupState")) { ::SWGSDRangel::setValue(&m_rollupState,json["rollupState"],"SWGRollupState","SWGRollupState"); m_rollupStateIsSet = true; }
}
QString SWGChirpModemDemodSettings::asJson()
{
auto* object = asJsonObject(); QString result = QJsonDocument(*object).toJson(); delete object; return result;
}
QJsonObject* SWGChirpModemDemodSettings::asJsonObject()
{
auto* object = new QJsonObject();
if (m_inputFrequencyOffsetIsSet) { object->insert("inputFrequencyOffset",QJsonValue(m_inputFrequencyOffset)); }
if (m_spreadFactorIsSet) { object->insert("spreadFactor",QJsonValue(m_spreadFactor)); }
if (m_bandwidthIsSet) { object->insert("bandwidth",QJsonValue(m_bandwidth)); }
if (m_effortIsSet) { object->insert("effort",QJsonValue(m_effort)); }
if (m_autoEffortIsSet) { object->insert("autoEffort",QJsonValue(m_autoEffort)); }
if (m_reportFailuresIsSet) { object->insert("reportFailures",QJsonValue(m_reportFailures)); }
if (m_maxBytesIsSet) { object->insert("maxBytes",QJsonValue(m_maxBytes)); }
if (m_rgbColorIsSet) { object->insert("rgbColor",QJsonValue(m_rgbColor)); }
if (m_title && (m_titleIsSet || !m_title->isEmpty())) { toJsonValue(QString("title"),m_title,object,QString("QString")); }
if (m_streamIndexIsSet) { object->insert("streamIndex",QJsonValue(m_streamIndex)); }
if (m_useReverseAPIIsSet) { object->insert("useReverseAPI",QJsonValue(m_useReverseAPI)); }
if (m_reverseAPIAddress && (m_reverseAPIAddressIsSet || !m_reverseAPIAddress->isEmpty())) { toJsonValue(QString("reverseAPIAddress"),m_reverseAPIAddress,object,QString("QString")); }
if (m_reverseAPIPortIsSet) { object->insert("reverseAPIPort",QJsonValue(m_reverseAPIPort)); }
if (m_reverseAPIDeviceIndexIsSet) { object->insert("reverseAPIDeviceIndex",QJsonValue(m_reverseAPIDeviceIndex)); }
if (m_reverseAPIChannelIndexIsSet) { object->insert("reverseAPIChannelIndex",QJsonValue(m_reverseAPIChannelIndex)); }
if (m_channelMarker && (m_channelMarkerIsSet || m_channelMarker->isSet())) { toJsonValue(QString("channelMarker"),m_channelMarker,object,QString("SWGChannelMarker")); }
if (m_rollupState && (m_rollupStateIsSet || m_rollupState->isSet())) { toJsonValue(QString("rollupState"),m_rollupState,object,QString("SWGRollupState")); }
return object;
}
bool SWGChirpModemDemodSettings::isSet()
{
return m_inputFrequencyOffsetIsSet || m_spreadFactorIsSet || m_bandwidthIsSet || m_effortIsSet || m_autoEffortIsSet || m_reportFailuresIsSet || m_maxBytesIsSet || m_rgbColorIsSet || m_titleIsSet || m_streamIndexIsSet || m_useReverseAPIIsSet || m_reverseAPIAddressIsSet || m_reverseAPIPortIsSet || m_reverseAPIDeviceIndexIsSet || m_reverseAPIChannelIndexIsSet || m_channelMarkerIsSet || m_rollupStateIsSet;
}
qint64 SWGChirpModemDemodSettings::getInputFrequencyOffset() { return m_inputFrequencyOffset; }
void SWGChirpModemDemodSettings::setInputFrequencyOffset(qint64 value) { m_inputFrequencyOffset = value; m_inputFrequencyOffsetIsSet = true; }
qint32 SWGChirpModemDemodSettings::getSpreadFactor() { return m_spreadFactor; }
void SWGChirpModemDemodSettings::setSpreadFactor(qint32 value) { m_spreadFactor = value; m_spreadFactorIsSet = true; }
qint32 SWGChirpModemDemodSettings::getBandwidth() { return m_bandwidth; }
void SWGChirpModemDemodSettings::setBandwidth(qint32 value) { m_bandwidth = value; m_bandwidthIsSet = true; }
qint32 SWGChirpModemDemodSettings::getEffort() { return m_effort; }
void SWGChirpModemDemodSettings::setEffort(qint32 value) { m_effort = value; m_effortIsSet = true; }
qint32 SWGChirpModemDemodSettings::getAutoEffort() { return m_autoEffort; }
void SWGChirpModemDemodSettings::setAutoEffort(qint32 value) { m_autoEffort = value; m_autoEffortIsSet = true; }
qint32 SWGChirpModemDemodSettings::getReportFailures() { return m_reportFailures; }
void SWGChirpModemDemodSettings::setReportFailures(qint32 value) { m_reportFailures = value; m_reportFailuresIsSet = true; }
qint32 SWGChirpModemDemodSettings::getMaxBytes() { return m_maxBytes; }
void SWGChirpModemDemodSettings::setMaxBytes(qint32 value) { m_maxBytes = value; m_maxBytesIsSet = true; }
qint32 SWGChirpModemDemodSettings::getRgbColor() { return m_rgbColor; }
void SWGChirpModemDemodSettings::setRgbColor(qint32 value) { m_rgbColor = value; m_rgbColorIsSet = true; }
QString* SWGChirpModemDemodSettings::getTitle() { return m_title; }
void SWGChirpModemDemodSettings::setTitle(QString* value) { if (m_title != value) { delete m_title; m_title = value; } m_titleIsSet = true; }
qint32 SWGChirpModemDemodSettings::getStreamIndex() { return m_streamIndex; }
void SWGChirpModemDemodSettings::setStreamIndex(qint32 value) { m_streamIndex = value; m_streamIndexIsSet = true; }
qint32 SWGChirpModemDemodSettings::getUseReverseApi() { return m_useReverseAPI; }
void SWGChirpModemDemodSettings::setUseReverseApi(qint32 value) { m_useReverseAPI = value; m_useReverseAPIIsSet = true; }
QString* SWGChirpModemDemodSettings::getReverseApiAddress() { return m_reverseAPIAddress; }
void SWGChirpModemDemodSettings::setReverseApiAddress(QString* value) { if (m_reverseAPIAddress != value) { delete m_reverseAPIAddress; m_reverseAPIAddress = value; } m_reverseAPIAddressIsSet = true; }
qint32 SWGChirpModemDemodSettings::getReverseApiPort() { return m_reverseAPIPort; }
void SWGChirpModemDemodSettings::setReverseApiPort(qint32 value) { m_reverseAPIPort = value; m_reverseAPIPortIsSet = true; }
qint32 SWGChirpModemDemodSettings::getReverseApiDeviceIndex() { return m_reverseAPIDeviceIndex; }
void SWGChirpModemDemodSettings::setReverseApiDeviceIndex(qint32 value) { m_reverseAPIDeviceIndex = value; m_reverseAPIDeviceIndexIsSet = true; }
qint32 SWGChirpModemDemodSettings::getReverseApiChannelIndex() { return m_reverseAPIChannelIndex; }
void SWGChirpModemDemodSettings::setReverseApiChannelIndex(qint32 value) { m_reverseAPIChannelIndex = value; m_reverseAPIChannelIndexIsSet = true; }
SWGChannelMarker* SWGChirpModemDemodSettings::getChannelMarker() { return m_channelMarker; }
void SWGChirpModemDemodSettings::setChannelMarker(SWGChannelMarker* value) { if (m_channelMarker != value) { delete m_channelMarker; m_channelMarker = value; } m_channelMarkerIsSet = true; }
SWGRollupState* SWGChirpModemDemodSettings::getRollupState() { return m_rollupState; }
void SWGChirpModemDemodSettings::setRollupState(SWGRollupState* value) { if (m_rollupState != value) { delete m_rollupState; m_rollupState = value; } m_rollupStateIsSet = true; }
}

104
swagger/sdrangel/code/qt5/client/SWGChirpModemDemodSettings.h

@ -0,0 +1,104 @@ @@ -0,0 +1,104 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Qt model for ChirpModemDemod.yaml, following the Swagger client model interface.
// Generated by gen_swg_models.py: edit the YAML, not this file.
#ifndef SWGChirpModemDemodSettings_H_
#define SWGChirpModemDemodSettings_H_
#include <QJsonObject>
#include <QString>
#include "SWGObject.h"
#include "export.h"
#include "SWGChannelMarker.h"
#include "SWGRollupState.h"
namespace SWGSDRangel {
class SWG_API SWGChirpModemDemodSettings : public SWGObject {
public:
SWGChirpModemDemodSettings();
explicit SWGChirpModemDemodSettings(QString* json);
~SWGChirpModemDemodSettings() override;
void init();
void cleanup();
QString asJson() override;
QJsonObject* asJsonObject() override;
void fromJsonObject(QJsonObject& json) override;
SWGChirpModemDemodSettings* fromJson(QString& json) override;
bool isSet() override;
qint64 getInputFrequencyOffset();
void setInputFrequencyOffset(qint64 value);
qint32 getSpreadFactor();
void setSpreadFactor(qint32 value);
qint32 getBandwidth();
void setBandwidth(qint32 value);
qint32 getEffort();
void setEffort(qint32 value);
qint32 getAutoEffort();
void setAutoEffort(qint32 value);
qint32 getReportFailures();
void setReportFailures(qint32 value);
qint32 getMaxBytes();
void setMaxBytes(qint32 value);
qint32 getRgbColor();
void setRgbColor(qint32 value);
QString* getTitle();
void setTitle(QString* value);
qint32 getStreamIndex();
void setStreamIndex(qint32 value);
qint32 getUseReverseApi();
void setUseReverseApi(qint32 value);
QString* getReverseApiAddress();
void setReverseApiAddress(QString* value);
qint32 getReverseApiPort();
void setReverseApiPort(qint32 value);
qint32 getReverseApiDeviceIndex();
void setReverseApiDeviceIndex(qint32 value);
qint32 getReverseApiChannelIndex();
void setReverseApiChannelIndex(qint32 value);
SWGChannelMarker* getChannelMarker();
void setChannelMarker(SWGChannelMarker* value);
SWGRollupState* getRollupState();
void setRollupState(SWGRollupState* value);
private:
qint64 m_inputFrequencyOffset = 0;
bool m_inputFrequencyOffsetIsSet = false;
qint32 m_spreadFactor = 0;
bool m_spreadFactorIsSet = false;
qint32 m_bandwidth = 0;
bool m_bandwidthIsSet = false;
qint32 m_effort = 0;
bool m_effortIsSet = false;
qint32 m_autoEffort = 0;
bool m_autoEffortIsSet = false;
qint32 m_reportFailures = 0;
bool m_reportFailuresIsSet = false;
qint32 m_maxBytes = 0;
bool m_maxBytesIsSet = false;
qint32 m_rgbColor = 0;
bool m_rgbColorIsSet = false;
QString* m_title = nullptr;
bool m_titleIsSet = false;
qint32 m_streamIndex = 0;
bool m_streamIndexIsSet = false;
qint32 m_useReverseAPI = 0;
bool m_useReverseAPIIsSet = false;
QString* m_reverseAPIAddress = nullptr;
bool m_reverseAPIAddressIsSet = false;
qint32 m_reverseAPIPort = 0;
bool m_reverseAPIPortIsSet = false;
qint32 m_reverseAPIDeviceIndex = 0;
bool m_reverseAPIDeviceIndexIsSet = false;
qint32 m_reverseAPIChannelIndex = 0;
bool m_reverseAPIChannelIndexIsSet = false;
SWGChannelMarker* m_channelMarker = nullptr;
bool m_channelMarkerIsSet = false;
SWGRollupState* m_rollupState = nullptr;
bool m_rollupStateIsSet = false;
};
}
#endif

12
swagger/sdrangel/code/qt5/client/SWGModelFactory.h

@ -145,8 +145,10 @@ @@ -145,8 +145,10 @@
#include "SWGDRMService.h"
#include "SWGDSCDemodReport.h"
#include "SWGSELCALDemodReport.h"
#include "SWGChirpModemDemodReport.h"
#include "SWGDSCDemodSettings.h"
#include "SWGSELCALDemodSettings.h"
#include "SWGChirpModemDemodSettings.h"
#include "SWGDSDDemodReport.h"
#include "SWGDSDDemodSettings.h"
#include "SWGDroneIDDemodReport.h"
@ -1121,6 +1123,11 @@ namespace SWGSDRangel { @@ -1121,6 +1123,11 @@ namespace SWGSDRangel {
obj->init();
return obj;
}
if(QString("SWGChirpModemDemodReport").compare(type) == 0) {
SWGChirpModemDemodReport *obj = new SWGChirpModemDemodReport();
obj->init();
return obj;
}
if(QString("SWGDSCDemodSettings").compare(type) == 0) {
SWGDSCDemodSettings *obj = new SWGDSCDemodSettings();
obj->init();
@ -1131,6 +1138,11 @@ namespace SWGSDRangel { @@ -1131,6 +1138,11 @@ namespace SWGSDRangel {
obj->init();
return obj;
}
if(QString("SWGChirpModemDemodSettings").compare(type) == 0) {
SWGChirpModemDemodSettings *obj = new SWGChirpModemDemodSettings();
obj->init();
return obj;
}
if(QString("SWGDSDDemodReport").compare(type) == 0) {
SWGDSDDemodReport *obj = new SWGDSDDemodReport();
obj->init();

Loading…
Cancel
Save