diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ec778585..c140a65fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -198,6 +198,7 @@ option(ENABLE_CHANNELTX_MODDATV "Enable channeltx moddatv plugin" ON) option(ENABLE_CHANNELTX_MODAM "Enable channeltx modam plugin" ON) option(ENABLE_CHANNELTX_MODFREEDV "Enable channeltx modfreedv plugin" ON) option(ENABLE_CHANNELTX_MODPACKET "Enable channeltx modpacket plugin" ON) +option(ENABLE_CHANNELTX_MODCHIRPMODEM "Enable channeltx modchirpmodem plugin (needs libchirpmodem)" ON) option(ENABLE_CHANNELTX_MODSSB "Enable channeltx modssb plugin" ON) option(ENABLE_CHANNELTX_UDPSOURCE "Enable channeltx udpsource plugin" ON) option(ENABLE_CHANNELTX_MODCHIRPCHAT "Enable channeltx modchirpchat plugin" ON) diff --git a/plugins/channeltx/CMakeLists.txt b/plugins/channeltx/CMakeLists.txt index d34e4d9e4..9c73bc511 100644 --- a/plugins/channeltx/CMakeLists.txt +++ b/plugins/channeltx/CMakeLists.txt @@ -48,6 +48,10 @@ if (ENABLE_CHANNELTX_MODPACKET) add_subdirectory(modpacket) endif() +if (ENABLE_CHANNELTX_MODCHIRPMODEM) + add_subdirectory(modchirpmodem) +endif() + if (ENABLE_CHANNELTX_MOD802.15.4) add_subdirectory(mod802.15.4) endif() diff --git a/plugins/channeltx/modchirpmodem/CMakeLists.txt b/plugins/channeltx/modchirpmodem/CMakeLists.txt new file mode 100644 index 000000000..a51ade606 --- /dev/null +++ b/plugins/channeltx/modchirpmodem/CMakeLists.txt @@ -0,0 +1,84 @@ +project(modchirpmodem) + +# 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(modchirpmodem_SOURCES + chirpmodemmod.cpp + chirpmodemmodsettings.cpp + chirpmodemmodbaseband.cpp + chirpmodemmodsource.cpp + chirpmodemmodmessages.cpp + chirpmodemmodplugin.cpp + chirpmodemmodwebapiadapter.cpp +) + +set(modchirpmodem_HEADERS + chirpmodemmod.h + chirpmodemmodsettings.h + chirpmodemmodbaseband.h + chirpmodemmodsource.h + chirpmodemmodmessages.h + chirpmodemmodplugin.h + chirpmodemmodwebapiadapter.h +) + +include_directories( + ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client +) + +if(NOT SERVER_MODE) + set(modchirpmodem_SOURCES + ${modchirpmodem_SOURCES} + chirpmodemmodgui.cpp + chirpmodemmodgui.ui + ) + set(modchirpmodem_HEADERS + ${modchirpmodem_HEADERS} + chirpmodemmodgui.h + ) + + set(TARGET_NAME ${PLUGINS_PREFIX}modchirpmodem) + set(TARGET_LIB "Qt::Widgets") + set(TARGET_LIB_GUI "sdrgui") + set(INSTALL_FOLDER ${INSTALL_PLUGINS_DIR}) +else() + set(TARGET_NAME ${PLUGINSSRV_PREFIX}modchirpmodemsrv) + set(TARGET_LIB "") + set(TARGET_LIB_GUI "") + set(INSTALL_FOLDER ${INSTALL_PLUGINSSRV_DIR}) +endif() + +if(NOT Qt6_FOUND) + add_library(${TARGET_NAME} ${modchirpmodem_SOURCES}) +else() + qt_add_plugin(${TARGET_NAME} CLASS_NAME ChirpModemModPlugin) + target_sources(${TARGET_NAME} PRIVATE ${modchirpmodem_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_NAME}stripped.pdb CONFIGURATIONS Release DESTINATION ${INSTALL_FOLDER} RENAME ${TARGET_NAME}.pdb ) + install(FILES $ CONFIGURATIONS Debug RelWithDebInfo DESTINATION ${INSTALL_FOLDER} ) +endif() diff --git a/plugins/channeltx/modchirpmodem/chirpmodemmod.cpp b/plugins/channeltx/modchirpmodem/chirpmodemmod.cpp new file mode 100644 index 000000000..78a379b08 --- /dev/null +++ b/plugins/channeltx/modchirpmodem/chirpmodemmod.cpp @@ -0,0 +1,625 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2026 Dan Chokola, KD2HSG // +// Based on the packet modulator plugin: // +// Copyright (C) 2020-2023 Jon Beniston, M7RCE // +// Copyright (C) 2020-2022 Edouard Griffiths, F4EXB // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include + +#include + +#include + +#include "SWGChannelSettings.h" +#include "SWGWorkspaceInfo.h" +#include "SWGChannelReport.h" +#include "SWGChannelActions.h" +#include "SWGChirpModemModSettings.h" +#include "SWGChirpModemModReport.h" +#include "SWGChirpModemModActions.h" + +#include "device/deviceapi.h" +#include "dsp/dspcommands.h" +#include "settings/serializable.h" +#include "util/db.h" +#include "maincore.h" + +#include "chirpmodemmodbaseband.h" +#include "chirpmodemmod.h" + +MESSAGE_CLASS_DEFINITION(ChirpModemMod::MsgConfigureChirpModemMod, Message) + +const char *const ChirpModemMod::m_channelIdURI = "sdrangel.channeltx.modchirpmodem"; +const char *const ChirpModemMod::m_channelId = "ChirpModemMod"; + +ChirpModemMod::ChirpModemMod(DeviceAPI *deviceAPI) : + ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSource), + m_deviceAPI(deviceAPI), + m_spectrumVis(SDR_TX_SCALEF) +{ + setObjectName(m_channelId); + + m_thread = new QThread(this); + m_thread->setObjectName("ChirpModemMod"); + m_basebandSource = new ChirpModemModBaseband(); + m_basebandSource->setSpectrumSampleSink(&m_spectrumVis); + m_basebandSource->setMessageQueueToChannel(getInputMessageQueue()); + m_basebandSource->moveToThread(m_thread); + + applySettings(QStringList(), m_settings, true); + + m_deviceAPI->addChannelSource(this); + m_deviceAPI->addChannelSourceAPI(this); + + m_networkManager = new QNetworkAccessManager(); + QObject::connect(m_networkManager, &QNetworkAccessManager::finished, this, &ChirpModemMod::networkManagerFinished); +} + +ChirpModemMod::~ChirpModemMod() +{ + QObject::disconnect(m_networkManager, &QNetworkAccessManager::finished, this, &ChirpModemMod::networkManagerFinished); + delete m_networkManager; + m_deviceAPI->removeChannelSourceAPI(this); + m_deviceAPI->removeChannelSource(this, true); + stop(); + delete m_basebandSource; + delete m_thread; +} + +void ChirpModemMod::setDeviceAPI(DeviceAPI *deviceAPI) +{ + if (deviceAPI != m_deviceAPI) + { + m_deviceAPI->removeChannelSourceAPI(this); + m_deviceAPI->removeChannelSource(this, false); + m_deviceAPI = deviceAPI; + m_deviceAPI->addChannelSource(this); + m_deviceAPI->addChannelSourceAPI(this); + } +} + +uint32_t ChirpModemMod::getNumberOfDeviceStreams() const +{ + return m_deviceAPI->getNbSinkStreams(); +} + +void ChirpModemMod::start() +{ + qDebug("ChirpModemMod::start"); + { + QMutexLocker lock(&m_reportMutex); + m_status = ChirpModemModMessages::Status(); + } + m_basebandSource->reset(); + m_thread->start(); +} + +void ChirpModemMod::stop() +{ + qDebug("ChirpModemMod::stop"); + m_thread->exit(); + m_thread->wait(); +} + +void ChirpModemMod::pull(SampleVector::iterator& begin, unsigned int nbSamples) +{ + m_basebandSource->pull(begin, nbSamples); +} + +void ChirpModemMod::transmit(const ChirpModemModMessages::TxRequest& request) +{ + m_basebandSource->getInputMessageQueue()->push(ChirpModemModMessages::MsgTx::create(request)); +} + +bool ChirpModemMod::handleMessage(const Message& cmd) +{ + if (MsgConfigureChirpModemMod::match(cmd)) + { + const auto& cfg = static_cast(cmd); + qDebug() << "ChirpModemMod::handleMessage: MsgConfigureChirpModemMod"; + applySettings(cfg.getSettingsKeys(), cfg.getSettings(), cfg.getForce()); + return true; + } + else if (ChirpModemModMessages::MsgTx::match(cmd)) + { + transmit(static_cast(cmd).getRequest()); + return true; + } + else if (ChirpModemModMessages::MsgStatus::match(cmd)) + { + const auto& status = static_cast(cmd).getStatus(); + { + QMutexLocker lock(&m_reportMutex); + m_status = status; + } + + if (getMessageQueueToGUI()) { + getMessageQueueToGUI()->push(ChirpModemModMessages::MsgStatus::create(status)); + } + + return true; + } + else if (DSPSignalNotification::match(cmd)) + { + const auto& notif = static_cast(cmd); + qDebug() << "ChirpModemMod::handleMessage: DSPSignalNotification"; + m_basebandSource->getInputMessageQueue()->push(new DSPSignalNotification(notif)); + + if (getMessageQueueToGUI()) { + getMessageQueueToGUI()->push(new DSPSignalNotification(notif)); + } + + return true; + } + else + { + return false; + } +} + +void ChirpModemMod::setCenterFrequency(qint64 frequency) +{ + ChirpModemModSettings settings = m_settings; + settings.m_inputFrequencyOffset = frequency; + applySettings(QStringList("inputFrequencyOffset"), settings, false); + + if (m_guiMessageQueue) { + m_guiMessageQueue->push(MsgConfigureChirpModemMod::create(QStringList("inputFrequencyOffset"), settings, false)); + } +} + +void ChirpModemMod::applySettings(const QStringList& settingsKeys, const ChirpModemModSettings& incomingSettings, bool force) +{ + ChirpModemModSettings settings = incomingSettings; + settings.normalize(); + qDebug() << "ChirpModemMod::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->removeChannelSourceAPI(this); + m_deviceAPI->removeChannelSource(this, false, m_settings.m_streamIndex); + m_deviceAPI->addChannelSource(this, settings.m_streamIndex); + m_deviceAPI->addChannelSourceAPI(this); + m_settings.m_streamIndex = settings.m_streamIndex; + emit streamIndexChanged(settings.m_streamIndex); + } + } + + m_basebandSource->getInputMessageQueue()->push( + ChirpModemModBaseband::MsgConfigureChirpModemModBaseband::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); + } +} + +ChirpModemMod::FrameInfo ChirpModemMod::frameInfo(const ChirpModemModSettings& settings) +{ + FrameInfo info; + QByteArray src = settings.m_source.toLatin1(); + QByteArray dst = settings.m_destination.toLatin1(); + info.m_bodyBytes = settings.m_message.toUtf8().size(); + info.m_maxBody = chirpmodem_max_body(src.isEmpty() ? nullptr : src.constData(), dst.isEmpty() ? nullptr : dst.constData()); + info.m_coherent = settings.m_mode == ChirpModemModSettings::ModeAuto + ? chirpmodem_default_coherent(settings.m_spreadFactor, settings.m_bandwidth) != 0 + : settings.m_mode == ChirpModemModSettings::ModeCoherent; + int macLen = 1 + (src.isEmpty() ? 0 : 6) + (dst.isEmpty() ? 0 : 6) + info.m_bodyBytes; + info.m_frameSeconds = chirpmodem_frame_seconds(settings.m_spreadFactor, settings.m_bandwidth, macLen, info.m_coherent ? 1 : 0); + + if (settings.cwIdWarning()) { + info.m_warning = QStringLiteral("CW ID is off: identify every 10 minutes and at the end of a communication some other way (47 CFR 97.119)"); + } else if (settings.m_cwId && settings.m_source.isEmpty()) { + info.m_warning = QStringLiteral("No CW ID: there is no source callsign"); + } + + return info; +} + +QByteArray ChirpModemMod::serialize() const +{ + return m_settings.serialize(); +} + +bool ChirpModemMod::deserialize(const QByteArray& data) +{ + bool valid = m_settings.deserialize(data); + + if (!valid) { + m_settings.resetToDefaults(); + } + + m_inputMessageQueue.push(MsgConfigureChirpModemMod::create(QStringList(), m_settings, true)); + return valid; +} + +int ChirpModemMod::getChannelSampleRate() const +{ + return m_basebandSource ? m_basebandSource->getChannelSampleRate() : 0; +} + +double ChirpModemMod::getMagSq() const +{ + return m_basebandSource->getMagSq(); +} + +void ChirpModemMod::setLevelMeter(QObject *levelMeter) +{ + connect(m_basebandSource, SIGNAL(levelChanged(qreal, qreal, int)), levelMeter, SLOT(levelChanged(qreal, qreal, int))); +} + +int ChirpModemMod::webapiSettingsGet(SWGSDRangel::SWGChannelSettings& response, QString& errorMessage) +{ + (void) errorMessage; + response.setChirpModemModSettings(new SWGSDRangel::SWGChirpModemModSettings()); + response.getChirpModemModSettings()->init(); + webapiFormatChannelSettings(response, m_settings); + return 200; +} + +int ChirpModemMod::webapiWorkspaceGet(SWGSDRangel::SWGWorkspaceInfo& response, QString& errorMessage) +{ + (void) errorMessage; + response.setIndex(m_settings.m_workspaceIndex); + return 200; +} + +int ChirpModemMod::webapiSettingsPutPatch(bool force, const QStringList& channelSettingsKeys, + SWGSDRangel::SWGChannelSettings& response, QString& errorMessage) +{ + (void) errorMessage; + ChirpModemModSettings settings = m_settings; + webapiUpdateChannelSettings(settings, channelSettingsKeys, response); + + m_inputMessageQueue.push(MsgConfigureChirpModemMod::create(channelSettingsKeys, settings, force)); + + if (m_guiMessageQueue) { + m_guiMessageQueue->push(MsgConfigureChirpModemMod::create(channelSettingsKeys, settings, force)); + } + + webapiFormatChannelSettings(response, settings); + return 200; +} + +int ChirpModemMod::webapiReportGet(SWGSDRangel::SWGChannelReport& response, QString& errorMessage) +{ + (void) errorMessage; + response.setChirpModemModReport(new SWGSDRangel::SWGChirpModemModReport()); + response.getChirpModemModReport()->init(); + webapiFormatChannelReport(response); + return 200; +} + +int ChirpModemMod::webapiActionsPost(const QStringList& channelActionsKeys, SWGSDRangel::SWGChannelActions& query, + QString& errorMessage) +{ + SWGSDRangel::SWGChirpModemModActions *actions = query.getChirpModemModActions(); + + if (!actions) + { + errorMessage = "Missing ChirpModemModActions in query"; + return 400; + } + + if (!channelActionsKeys.contains("tx") || (actions->getTx() == 0)) + { + errorMessage = "Give tx: 1 to transmit"; + return 400; + } + + // Values not given come from the settings. The checks, such as a source + // callsign in the licensed profile, are made when the frame is generated + // and reported in lastError. + ChirpModemModMessages::TxRequest request; + bool hasSrc = channelActionsKeys.contains("src") && actions->getSrc(); + bool hasDst = channelActionsKeys.contains("dst") && actions->getDst(); + bool hasMessage = channelActionsKeys.contains("message") && actions->getMessage(); + + if (hasSrc || hasDst || hasMessage) + { + request.m_override = true; + request.m_source = hasSrc ? *actions->getSrc() : m_settings.m_source; + request.m_destination = hasDst ? *actions->getDst() : m_settings.m_destination; + request.m_body = (hasMessage ? *actions->getMessage() : m_settings.m_message).toUtf8(); + } + + transmit(request); + return 202; +} + +void ChirpModemMod::webapiUpdateChannelSettings(ChirpModemModSettings& settings, const QStringList& channelSettingsKeys, + SWGSDRangel::SWGChannelSettings& response) +{ + auto *model = response.getChirpModemModSettings(); + + 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("mode")) { + settings.m_mode = model->getMode(); + } + if (channelSettingsKeys.contains("profile")) { + settings.m_profile = model->getProfile(); + } + if (channelSettingsKeys.contains("source") && model->getSource()) { + settings.m_source = *model->getSource(); + } + if (channelSettingsKeys.contains("destination") && model->getDestination()) { + settings.m_destination = *model->getDestination(); + } + if (channelSettingsKeys.contains("message") && model->getMessage()) { + settings.m_message = *model->getMessage(); + } + if (channelSettingsKeys.contains("repeat")) { + settings.m_repeat = model->getRepeat(); + } + if (channelSettingsKeys.contains("gap")) { + settings.m_gap = model->getGap(); + } + if (channelSettingsKeys.contains("amplitude")) { + settings.m_amplitude = model->getAmplitude(); + } + if (channelSettingsKeys.contains("cwId")) { + settings.m_cwId = model->getCwId() != 0; + } + if (channelSettingsKeys.contains("cwWpm")) { + settings.m_cwWpm = model->getCwWpm(); + } + 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 ChirpModemMod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const ChirpModemModSettings& settings) +{ + auto *model = response.getChirpModemModSettings(); + model->setInputFrequencyOffset(settings.m_inputFrequencyOffset); + model->setSpreadFactor(settings.m_spreadFactor); + model->setBandwidth(settings.m_bandwidth); + model->setMode(settings.m_mode); + model->setProfile(settings.m_profile); + model->setSource(new QString(settings.m_source)); + model->setDestination(new QString(settings.m_destination)); + model->setMessage(new QString(settings.m_message)); + model->setRepeat(settings.m_repeat); + model->setGap(settings.m_gap); + model->setAmplitude(settings.m_amplitude); + model->setCwId(settings.m_cwId ? 1 : 0); + model->setCwWpm(settings.m_cwWpm); + 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 ChirpModemMod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response) +{ + auto *model = response.getChirpModemModReport(); + FrameInfo info = frameInfo(m_settings); + model->setChannelPowerDb(CalcDb::dbPower(getMagSq())); + model->setFrameSeconds(info.m_frameSeconds); + model->setMaxBody(info.m_maxBody); + model->setWarning(new QString(info.m_warning)); + + // Read live, like other channels: the status only changes on events + model->setChannelSampleRate(getChannelSampleRate()); + model->setIfOffset(m_basebandSource->getChannelFrequencyOffset()); + + QMutexLocker lock(&m_reportMutex); + model->setTransmitting(m_status.m_transmitting ? 1 : 0); + model->setQueueLength(m_status.m_queueLength); + model->setFramesSent(m_status.m_framesSent); + model->setTransmissions(m_status.m_transmissions); + model->setAirtime(m_status.m_airtime); + model->setLastDuration(m_status.m_lastDuration); + model->setLastEvent(new QString(m_status.m_event)); + model->setLastError(new QString(m_status.m_error)); +} + +void ChirpModemMod::webapiReverseSendSettings(const QList& channelSettingsKeys, const ChirpModemModSettings& 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 ChirpModemMod::webapiFormatChannelSettings(const QList& channelSettingsKeys, + SWGSDRangel::SWGChannelSettings *swgChannelSettings, + const ChirpModemModSettings& settings, bool force) +{ + swgChannelSettings->setDirection(1); // single source (Tx) + swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet()); + swgChannelSettings->setOriginatorDeviceSetIndex(getDeviceSetIndex()); + swgChannelSettings->setChannelType(new QString(m_channelId)); + auto *model = new SWGSDRangel::SWGChirpModemModSettings(); + swgChannelSettings->setChirpModemModSettings(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("mode")) { + model->setMode(settings.m_mode); + } + if (force || channelSettingsKeys.contains("profile")) { + model->setProfile(settings.m_profile); + } + if (force || channelSettingsKeys.contains("source")) { + model->setSource(new QString(settings.m_source)); + } + if (force || channelSettingsKeys.contains("destination")) { + model->setDestination(new QString(settings.m_destination)); + } + if (force || channelSettingsKeys.contains("message")) { + model->setMessage(new QString(settings.m_message)); + } + if (force || channelSettingsKeys.contains("repeat")) { + model->setRepeat(settings.m_repeat); + } + if (force || channelSettingsKeys.contains("gap")) { + model->setGap(settings.m_gap); + } + if (force || channelSettingsKeys.contains("amplitude")) { + model->setAmplitude(settings.m_amplitude); + } + if (force || channelSettingsKeys.contains("cwId")) { + model->setCwId(settings.m_cwId ? 1 : 0); + } + if (force || channelSettingsKeys.contains("cwWpm")) { + model->setCwWpm(settings.m_cwWpm); + } + 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 ChirpModemMod::networkManagerFinished(QNetworkReply *reply) +{ + QNetworkReply::NetworkError replyError = reply->error(); + + if (replyError) + { + qWarning() << "ChirpModemMod::networkManagerFinished:" + << " error(" << (int) replyError << "): " << replyError << ": " << reply->errorString(); + } + else + { + QString answer = reply->readAll(); + answer.chop(1); // remove last \n + qDebug("ChirpModemMod::networkManagerFinished: reply:\n%s", answer.toStdString().c_str()); + } + + reply->deleteLater(); +} diff --git a/plugins/channeltx/modchirpmodem/chirpmodemmod.h b/plugins/channeltx/modchirpmodem/chirpmodemmod.h new file mode 100644 index 000000000..2d461022d --- /dev/null +++ b/plugins/channeltx/modchirpmodem/chirpmodemmod.h @@ -0,0 +1,156 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2026 Dan Chokola, KD2HSG // +// Based on the packet modulator plugin: // +// Copyright (C) 2020-2023 Jon Beniston, M7RCE // +// Copyright (C) 2020-2022 Edouard Griffiths, F4EXB // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef INCLUDE_CHIRPMODEMMOD_H +#define INCLUDE_CHIRPMODEMMOD_H + +#include +#include + +#include "dsp/basebandsamplesource.h" +#include "dsp/spectrumvis.h" +#include "channel/channelapi.h" +#include "util/message.h" + +#include "chirpmodemmodsettings.h" +#include "chirpmodemmodmessages.h" + +class QNetworkAccessManager; +class QNetworkReply; +class QThread; +class DeviceAPI; +class ChirpModemModBaseband; + +class ChirpModemMod : public BasebandSampleSource, public ChannelAPI { +public: + class MsgConfigureChirpModemMod : public Message { + MESSAGE_CLASS_DECLARATION + + public: + const ChirpModemModSettings& getSettings() const { return m_settings; } + const QStringList& getSettingsKeys() const { return m_settingsKeys; } + bool getForce() const { return m_force; } + + static MsgConfigureChirpModemMod *create(const QStringList& settingsKeys, const ChirpModemModSettings& settings, bool force) { + return new MsgConfigureChirpModemMod(settingsKeys, settings, force); + } + + private: + ChirpModemModSettings m_settings; + QStringList m_settingsKeys; + bool m_force; + + MsgConfigureChirpModemMod(const QStringList& settingsKeys, const ChirpModemModSettings& settings, bool force) : + Message(), + m_settings(settings), + m_settingsKeys(settingsKeys), + m_force(force) + { } + }; + + //! Airtime and capacity for the current settings, from libchirpmodem + struct FrameInfo { + double m_frameSeconds = 0; + int m_maxBody = 0; + int m_bodyBytes = 0; + bool m_coherent = false; //!< Payload mode the settings resolve to + QString m_warning; + }; + + ChirpModemMod(DeviceAPI *deviceAPI); + virtual ~ChirpModemMod(); + virtual void destroy() { delete this; } + virtual void setDeviceAPI(DeviceAPI *deviceAPI); + virtual DeviceAPI *getDeviceAPI() { return m_deviceAPI; } + + virtual void start(); + virtual void stop(); + virtual void pull(SampleVector::iterator& begin, unsigned int nbSamples); + virtual void pushMessage(Message *msg) { m_inputMessageQueue.push(msg); } + virtual QString getSourceName() { return objectName(); } + + virtual void getIdentifier(QString& id) { id = objectName(); } + virtual QString getIdentifier() const { return objectName(); } + 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 m_settings.m_inputFrequencyOffset; + } + + 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); + virtual int webapiActionsPost(const QStringList& channelActionsKeys, SWGSDRangel::SWGChannelActions& query, + QString& errorMessage); + + static void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const ChirpModemModSettings& settings); + static void webapiUpdateChannelSettings(ChirpModemModSettings& settings, const QStringList& channelSettingsKeys, + SWGSDRangel::SWGChannelSettings& response); + static FrameInfo frameInfo(const ChirpModemModSettings& settings); + + void transmit(const ChirpModemModMessages::TxRequest& request = ChirpModemModMessages::TxRequest()); + SpectrumVis *getSpectrumVis() { return &m_spectrumVis; } + double getMagSq() const; + void setLevelMeter(QObject *levelMeter); + uint32_t getNumberOfDeviceStreams() const; + + static const char *const m_channelIdURI; + static const char *const m_channelId; + +private: + DeviceAPI *m_deviceAPI; + QThread *m_thread; + ChirpModemModBaseband *m_basebandSource; + ChirpModemModSettings m_settings; + SpectrumVis m_spectrumVis; + + QMutex m_reportMutex; //!< Report state is read from web API threads + ChirpModemModMessages::Status m_status; + + QNetworkAccessManager *m_networkManager; + QNetworkRequest m_networkRequest; + + virtual bool handleMessage(const Message& cmd); + void applySettings(const QStringList& settingsKeys, const ChirpModemModSettings& settings, bool force = false); + void webapiReverseSendSettings(const QList& channelSettingsKeys, const ChirpModemModSettings& settings, bool force); + void webapiFormatChannelSettings(const QList& channelSettingsKeys, SWGSDRangel::SWGChannelSettings *swgChannelSettings, + const ChirpModemModSettings& settings, bool force); + void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response); + +private slots: + void networkManagerFinished(QNetworkReply *reply); +}; + +#endif // INCLUDE_CHIRPMODEMMOD_H diff --git a/plugins/channeltx/modchirpmodem/chirpmodemmodbaseband.cpp b/plugins/channeltx/modchirpmodem/chirpmodemmodbaseband.cpp new file mode 100644 index 000000000..b47b7ff17 --- /dev/null +++ b/plugins/channeltx/modchirpmodem/chirpmodemmodbaseband.cpp @@ -0,0 +1,220 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2026 Dan Chokola, KD2HSG // +// Based on the packet modulator plugin: // +// Copyright (C) 2020-2023 Jon Beniston, M7RCE // +// Copyright (C) 2020-2022 Edouard Griffiths, F4EXB // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#include + +#include "dsp/upchannelizer.h" +#include "dsp/dspcommands.h" + +#include "chirpmodemmodbaseband.h" + +MESSAGE_CLASS_DEFINITION(ChirpModemModBaseband::MsgConfigureChirpModemModBaseband, Message) + +ChirpModemModBaseband::ChirpModemModBaseband() +{ + m_sampleFifo.resize(SampleSourceFifo::getSizePolicy(48000)); + m_channelizer = new UpChannelizer(&m_source); + m_generator.setMaxThreadCount(1); + + qDebug("ChirpModemModBaseband::ChirpModemModBaseband"); + QObject::connect(&m_sampleFifo, &SampleSourceFifo::dataRead, this, &ChirpModemModBaseband::handleData, Qt::QueuedConnection); + QObject::connect(&m_inputMessageQueue, &MessageQueue::messageEnqueued, this, &ChirpModemModBaseband::handleInputMessages); +} + +ChirpModemModBaseband::~ChirpModemModBaseband() +{ + // A generation in progress posts to m_inputMessageQueue: let it finish first + m_generator.clear(); + m_generator.waitForDone(); + m_inputMessageQueue.clear(); + delete m_channelizer; +} + +void ChirpModemModBaseband::reset() +{ + QMutexLocker mutexLocker(&m_mutex); + m_generator.clear(); // not yet started; one running is dropped by its epoch + m_sampleFifo.reset(); + m_source.reset(); +} + +void ChirpModemModBaseband::pull(const SampleVector::iterator& begin, unsigned int nbSamples) +{ + unsigned int part1Begin, part1End, part2Begin, part2End; + m_sampleFifo.read(nbSamples, part1Begin, part1End, part2Begin, part2End); + SampleVector& data = m_sampleFifo.getData(); + + if (part1Begin != part1End) { + std::copy(data.begin() + part1Begin, data.begin() + part1End, begin); + } + + unsigned int shift = part1End - part1Begin; + + if (part2Begin != part2End) { + std::copy(data.begin() + part2Begin, data.begin() + part2End, begin + shift); + } +} + +void ChirpModemModBaseband::handleData() +{ + QMutexLocker mutexLocker(&m_mutex); + SampleVector& data = m_sampleFifo.getData(); + unsigned int ipart1begin, ipart1end, ipart2begin, ipart2end; + qreal rmsLevel, peakLevel; + int numSamples; + + unsigned int remainder = m_sampleFifo.remainder(); + + // Stops when a message is queued, so requests and settings take effect between blocks + while ((remainder > 0) && (m_inputMessageQueue.size() == 0)) + { + m_sampleFifo.write(remainder, ipart1begin, ipart1end, ipart2begin, ipart2end); + + if (ipart1begin != ipart1end) { + processFifo(data, ipart1begin, ipart1end); + } + + if (ipart2begin != ipart2end) { + processFifo(data, ipart2begin, ipart2end); + } + + remainder = m_sampleFifo.remainder(); + } + + m_source.getLevels(rmsLevel, peakLevel, numSamples); + emit levelChanged(rmsLevel, peakLevel, numSamples); +} + +void ChirpModemModBaseband::processFifo(SampleVector& data, unsigned int iBegin, unsigned int iEnd) +{ + m_channelizer->prefetch(iEnd - iBegin); + m_channelizer->pull(data.begin() + iBegin, iEnd - iBegin); +} + +void ChirpModemModBaseband::handleInputMessages() +{ + Message *message; + + while ((message = m_inputMessageQueue.pop())) + { + if (!handleMessage(*message)) { + qDebug("%s: unhandled message: %s", Q_FUNC_INFO, message->getIdentifier()); + } + delete message; + } +} + +bool ChirpModemModBaseband::handleMessage(const Message& cmd) +{ + if (MsgConfigureChirpModemModBaseband::match(cmd)) + { + QMutexLocker mutexLocker(&m_mutex); + const auto& cfg = static_cast(cmd); + qDebug() << "ChirpModemModBaseband::handleMessage: MsgConfigureChirpModemModBaseband"; + applySettings(cfg.getSettingsKeys(), cfg.getSettings(), cfg.getForce()); + return true; + } + else if (ChirpModemModMessages::MsgTx::match(cmd)) + { + QMutexLocker mutexLocker(&m_mutex); + generate(m_source.makeJob(static_cast(cmd).getRequest())); + return true; + } + else if (ChirpModemModGen::MsgGenerated::match(cmd)) + { + QMutexLocker mutexLocker(&m_mutex); + auto transmission = static_cast(cmd).getTransmission(); + + if (!m_source.addGenerated(transmission)) + { + // Made for a channel rate or offset that has since changed + ChirpModemModGen::Job job = transmission->m_job; + job.m_channelSampleRate = m_channelizer->getChannelSampleRate(); + job.m_channelFrequencyOffset = m_channelizer->getChannelFrequencyOffset(); + job.m_regenerated = true; + generate(job); + } + + return true; + } + else if (DSPSignalNotification::match(cmd)) + { + QMutexLocker mutexLocker(&m_mutex); + const auto& notif = static_cast(cmd); + qDebug() << "ChirpModemModBaseband::handleMessage: DSPSignalNotification: basebandSampleRate:" << notif.getSampleRate(); + m_sampleFifo.resize(SampleSourceFifo::getSizePolicy(notif.getSampleRate())); + m_channelizer->setBasebandSampleRate(notif.getSampleRate()); + + for (const auto& job : m_source.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset())) { + generate(job); + } + return true; + } + else + { + return false; + } +} + +void ChirpModemModBaseband::applySettings(const QStringList& settingsKeys, const ChirpModemModSettings& 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); + + for (const auto& job : m_source.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset())) { + generate(job); + } + } + + m_source.applySettings(settingsKeys, settings, force); + + if (force) { + m_settings = settings; + } else { + m_settings.applySettings(settingsKeys, settings); + } +} + +// On the generator thread. The result comes back to the DSP thread as a message. +void ChirpModemModBaseband::generate(const ChirpModemModGen::Job& job) +{ + m_source.generationStarted(); + MessageQueue *queue = &m_inputMessageQueue; + + m_generator.start([job, queue]() { + auto transmission = std::make_shared(); + transmission->m_job = job; + ChirpModemModGen::generate(*transmission); + queue->push(ChirpModemModGen::MsgGenerated::create(transmission)); + }); +} + +int ChirpModemModBaseband::getChannelSampleRate() const +{ + return m_channelizer->getChannelSampleRate(); +} + +int ChirpModemModBaseband::getChannelFrequencyOffset() const +{ + return m_channelizer->getChannelFrequencyOffset(); +} diff --git a/plugins/channeltx/modchirpmodem/chirpmodemmodbaseband.h b/plugins/channeltx/modchirpmodem/chirpmodemmodbaseband.h new file mode 100644 index 000000000..914497a76 --- /dev/null +++ b/plugins/channeltx/modchirpmodem/chirpmodemmodbaseband.h @@ -0,0 +1,98 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2026 Dan Chokola, KD2HSG // +// Based on the packet modulator plugin: // +// Copyright (C) 2020-2023 Jon Beniston, M7RCE // +// Copyright (C) 2020-2022 Edouard Griffiths, F4EXB // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef INCLUDE_CHIRPMODEMMODBASEBAND_H +#define INCLUDE_CHIRPMODEMMODBASEBAND_H + +#include +#include +#include + +#include "dsp/samplesourcefifo.h" +#include "util/message.h" +#include "util/messagequeue.h" + +#include "chirpmodemmodsource.h" + +class UpChannelizer; + +class ChirpModemModBaseband : public QObject +{ + Q_OBJECT +public: + class MsgConfigureChirpModemModBaseband : public Message { + MESSAGE_CLASS_DECLARATION + + public: + const ChirpModemModSettings& getSettings() const { return m_settings; } + const QStringList& getSettingsKeys() const { return m_settingsKeys; } + bool getForce() const { return m_force; } + + static MsgConfigureChirpModemModBaseband *create(const QStringList& settingsKeys, const ChirpModemModSettings& settings, bool force) { + return new MsgConfigureChirpModemModBaseband(settingsKeys, settings, force); + } + + private: + ChirpModemModSettings m_settings; + QStringList m_settingsKeys; + bool m_force; + + MsgConfigureChirpModemModBaseband(const QStringList& settingsKeys, const ChirpModemModSettings& settings, bool force) : + Message(), + m_settings(settings), + m_settingsKeys(settingsKeys), + m_force(force) + { } + }; + + ChirpModemModBaseband(); + ~ChirpModemModBaseband(); + void reset(); + void pull(const SampleVector::iterator& begin, unsigned int nbSamples); + MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } + double getMagSq() const { return m_source.getMagSq(); } + int getChannelSampleRate() const; + int getChannelFrequencyOffset() const; + void setSpectrumSampleSink(BasebandSampleSink *sampleSink) { m_source.setSpectrumSink(sampleSink); } + void setMessageQueueToChannel(MessageQueue *queue) { m_source.setMessageQueueToChannel(queue); } + +signals: + void levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples); + +private: + SampleSourceFifo m_sampleFifo; + UpChannelizer *m_channelizer; + ChirpModemModSource m_source; + MessageQueue m_inputMessageQueue; + ChirpModemModSettings m_settings; + QRecursiveMutex m_mutex; + QThreadPool m_generator; //!< One thread: generates transmissions in order, off the DSP thread + + void generate(const ChirpModemModGen::Job& job); + void processFifo(SampleVector& data, unsigned int iBegin, unsigned int iEnd); + bool handleMessage(const Message& cmd); + void applySettings(const QStringList& settingsKeys, const ChirpModemModSettings& settings, bool force = false); + +private slots: + void handleInputMessages(); + void handleData(); +}; + +#endif // INCLUDE_CHIRPMODEMMODBASEBAND_H diff --git a/plugins/channeltx/modchirpmodem/chirpmodemmodgui.cpp b/plugins/channeltx/modchirpmodem/chirpmodemmodgui.cpp new file mode 100644 index 000000000..4a40422e8 --- /dev/null +++ b/plugins/channeltx/modchirpmodem/chirpmodemmodgui.cpp @@ -0,0 +1,567 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2026 Dan Chokola, KD2HSG // +// Based on the packet modulator plugin: // +// Copyright (C) 2020-2023 Jon Beniston, M7RCE // +// Copyright (C) 2020-2022 Edouard Griffiths, F4EXB // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#include +#include + +#include + +#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 "chirpmodemmod.h" +#include "chirpmodemmodgui.h" +#include "ui_chirpmodemmodgui.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 bandwidthText(int bandwidth) +{ + return QString("%1 kHz").arg(bandwidth / 1000.0, 0, 'g', 6); +} + +ChirpModemModGUI *ChirpModemModGUI::create(PluginAPI *pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *txChannel) +{ + return new ChirpModemModGUI(pluginAPI, deviceUISet, txChannel); +} + +void ChirpModemModGUI::destroy() +{ + delete this; +} + +ChirpModemModGUI::ChirpModemModGUI(PluginAPI *, DeviceUISet *deviceUISet, BasebandSampleSource *txChannel, QWidget *parent) : + ChannelGUI(parent), + ui(new Ui::ChirpModemModGUI), + m_deviceUISet(deviceUISet), + m_channelMarker(this), + m_chirpModemMod(static_cast(txChannel)) +{ + setAttribute(Qt::WA_DeleteOnClose, true); + m_helpURL = "plugins/channeltx/modchirpmodem/readme.md"; + ui->setupUi(getRollupContents()); + setSizePolicy(getRollupContents()->sizePolicy()); + m_chirpModemMod->setMessageQueueToGUI(getInputMessageQueue()); + + // Spectrum of the channel being sent + m_spectrumVis = m_chirpModemMod->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_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); + + 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->cwWpm->setMaximum(ChirpModemModSettings::m_maxWpm); + m_chirpModemMod->setLevelMeter(ui->volumeMeter); + + m_settings.setChannelMarker(&m_channelMarker); + m_settings.setRollupState(&m_rollupState); + m_settings.setSpectrumGUI(ui->spectrumGUI); + m_channelMarker.setSourceOrSinkStream(false); + m_channelMarker.setVisible(true); + m_deviceUISet->addChannelMarker(&m_channelMarker); + connect(&m_channelMarker, &ChannelMarker::changedByCursor, this, &ChirpModemModGUI::channelMarkerChangedByCursor); + connect(&m_channelMarker, &ChannelMarker::highlightedByCursor, this, &ChirpModemModGUI::channelMarkerHighlightedByCursor); + connect(getInputMessageQueue(), &MessageQueue::messageEnqueued, this, &ChirpModemModGUI::handleInputMessages); + connect(&MainCore::instance()->getMasterTimer(), &QTimer::timeout, this, &ChirpModemModGUI::tick); + connect(this, &ChirpModemModGUI::customContextMenuRequested, this, &ChirpModemModGUI::onMenuDialogCalled); + connect(getRollupContents(), &RollupContents::widgetRolled, this, &ChirpModemModGUI::onWidgetRolled); + + displaySettings(); + makeUIConnections(); + applySettings({}, true); + getRollupContents()->arrangeRollups(); + m_resizer.enableChildMouseTracking(); +} + +ChirpModemModGUI::~ChirpModemModGUI() +{ + delete ui; +} + +void ChirpModemModGUI::resetToDefaults() +{ + m_settings.resetToDefaults(); + displaySettings(); + applySettings({}, true); +} + +QByteArray ChirpModemModGUI::serialize() const +{ + return m_settings.serialize(); +} + +bool ChirpModemModGUI::deserialize(const QByteArray& data) +{ + bool valid = m_settings.deserialize(data); + displaySettings(); + applySettings({}, true); + return valid; +} + +void ChirpModemModGUI::applySettings(const QStringList& keys, bool force) +{ + if (!m_doApplySettings) { + return; + } + + m_settings.normalize(); + updateChannelMarker(); + m_chirpModemMod->getInputMessageQueue()->push(ChirpModemMod::MsgConfigureChirpModemMod::create(keys, m_settings, force)); + updateAbsoluteCenterFrequency(); + displayFrameInfo(); +} + +void ChirpModemModGUI::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 ChirpModemModGUI::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); +} + +// Airtime, capacity and warnings for the settings as they stand, from libchirpmodem +void ChirpModemModGUI::displayFrameInfo() +{ + ChirpModemMod::FrameInfo info = ChirpModemMod::frameInfo(m_settings); + bool tooLong = info.m_bodyBytes > info.m_maxBody; + ui->frameInfo->setText(QString("%1 s/frame %2/%3 B %4") + .arg(info.m_frameSeconds, 0, 'f', 2) + .arg(info.m_bodyBytes) + .arg(info.m_maxBody) + .arg(info.m_coherent ? "coherent" : "non-coherent")); + ui->frameInfo->setStyleSheet(tooLong ? "QLabel { color: red; }" : ""); + ui->frameInfo->setToolTip(tooLong ? "The message does not fit one frame" : "Time on air of one frame, body bytes / most that fit, payload mode"); + + QStringList warnings; + + if (!info.m_warning.isEmpty()) { + warnings << info.m_warning; + } + if ((m_settings.m_profile == ChirpModemModSettings::ProfileLicensed) && m_settings.m_source.isEmpty()) { + warnings << "The licensed profile needs a source callsign"; + } + + ui->warning->setText(warnings.join("\n")); + ui->warning->setVisible(!warnings.isEmpty()); + + // The unlicensed profile is shown prominently, so it is never selected by accident + ui->profile->setStyleSheet(m_settings.m_profile == ChirpModemModSettings::ProfileUnlicensed + ? "QComboBox { background-color: rgb(160, 30, 30); }" : ""); +} + +void ChirpModemModGUI::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 b1(ui->deltaFrequency); + QSignalBlocker b2(ui->spreadFactor); + QSignalBlocker b3(ui->mode); + QSignalBlocker b4(ui->profile); + QSignalBlocker b5(ui->source); + QSignalBlocker b6(ui->destination); + QSignalBlocker b7(ui->message); + QSignalBlocker b8(ui->repeat); + QSignalBlocker b9(ui->gap); + QSignalBlocker b10(ui->amplitude); + QSignalBlocker b11(ui->cwId); + QSignalBlocker b12(ui->cwWpm); + + ui->deltaFrequency->setValue(m_settings.m_inputFrequencyOffset); + ui->spreadFactor->setCurrentIndex(ui->spreadFactor->findData(m_settings.m_spreadFactor)); + displayBandwidth(); + ui->mode->setCurrentIndex(m_settings.m_mode + 1); + ui->profile->setCurrentIndex(m_settings.m_profile); + ui->source->setText(m_settings.m_source); + ui->destination->setText(m_settings.m_destination); + ui->message->setText(m_settings.m_message); + ui->repeat->setValue(m_settings.m_repeat); + ui->gap->setValue(m_settings.m_gap); + ui->amplitude->setValue(m_settings.m_amplitude); + ui->cwId->setChecked(m_settings.m_cwId); + ui->cwWpm->setValue(m_settings.m_cwWpm); + + getRollupContents()->restoreState(m_rollupState); + updateIndexLabel(); + updateAbsoluteCenterFrequency(); + displayFrameInfo(); + m_doApplySettings = true; +} + +void ChirpModemModGUI::makeUIConnections() +{ + QObject::connect(ui->deltaFrequency, &ValueDialZ::changed, this, &ChirpModemModGUI::on_deltaFrequency_changed); + QObject::connect(ui->spreadFactor, QOverload::of(&QComboBox::currentIndexChanged), this, &ChirpModemModGUI::on_spreadFactor_currentIndexChanged); + QObject::connect(ui->bandwidth, QOverload::of(&QComboBox::currentIndexChanged), this, &ChirpModemModGUI::on_bandwidth_currentIndexChanged); + QObject::connect(ui->mode, QOverload::of(&QComboBox::currentIndexChanged), this, &ChirpModemModGUI::on_mode_currentIndexChanged); + QObject::connect(ui->profile, QOverload::of(&QComboBox::currentIndexChanged), this, &ChirpModemModGUI::on_profile_currentIndexChanged); + QObject::connect(ui->source, &QLineEdit::editingFinished, this, &ChirpModemModGUI::on_source_editingFinished); + QObject::connect(ui->destination, &QLineEdit::editingFinished, this, &ChirpModemModGUI::on_destination_editingFinished); + QObject::connect(ui->message, &QLineEdit::textEdited, this, &ChirpModemModGUI::on_message_textEdited); + QObject::connect(ui->message, &QLineEdit::editingFinished, this, &ChirpModemModGUI::on_message_editingFinished); + QObject::connect(ui->message, &QLineEdit::returnPressed, this, &ChirpModemModGUI::on_message_returnPressed); + QObject::connect(ui->repeat, QOverload::of(&QSpinBox::valueChanged), this, &ChirpModemModGUI::on_repeat_valueChanged); + QObject::connect(ui->gap, QOverload::of(&QDoubleSpinBox::valueChanged), this, &ChirpModemModGUI::on_gap_valueChanged); + QObject::connect(ui->amplitude, QOverload::of(&QDoubleSpinBox::valueChanged), this, &ChirpModemModGUI::on_amplitude_valueChanged); + QObject::connect(ui->cwId, &ButtonSwitch::toggled, this, &ChirpModemModGUI::on_cwId_toggled); + QObject::connect(ui->cwWpm, QOverload::of(&QSpinBox::valueChanged), this, &ChirpModemModGUI::on_cwWpm_valueChanged); + QObject::connect(ui->txButton, &QToolButton::clicked, this, &ChirpModemModGUI::on_txButton_clicked); + QObject::connect(ui->clearLog, &QPushButton::clicked, this, &ChirpModemModGUI::on_clearLog_clicked); +} + +void ChirpModemModGUI::on_deltaFrequency_changed(qint64 value) +{ + m_settings.m_inputFrequencyOffset = value; + applySettings({"inputFrequencyOffset"}); +} + +void ChirpModemModGUI::on_spreadFactor_currentIndexChanged(int index) +{ + m_settings.m_spreadFactor = ui->spreadFactor->itemData(index).toInt(); + applySettings({"spreadFactor"}); +} + +void ChirpModemModGUI::on_bandwidth_currentIndexChanged(int index) +{ + m_settings.m_bandwidth = ui->bandwidth->itemData(index).toInt(); + applySettings({"bandwidth"}); +} + +void ChirpModemModGUI::on_mode_currentIndexChanged(int index) +{ + m_settings.m_mode = index - 1; + applySettings({"mode"}); +} + +void ChirpModemModGUI::on_profile_currentIndexChanged(int index) +{ + m_settings.m_profile = index; + applySettings({"profile"}); +} + +void ChirpModemModGUI::on_source_editingFinished() +{ + if (ui->source->text() == m_settings.m_source) { + return; + } + + m_settings.m_source = ui->source->text(); + applySettings({"source"}); + ui->source->setText(m_settings.m_source); // normalized +} + +void ChirpModemModGUI::on_destination_editingFinished() +{ + if (ui->destination->text() == m_settings.m_destination) { + return; + } + + m_settings.m_destination = ui->destination->text(); + applySettings({"destination"}); + ui->destination->setText(m_settings.m_destination); +} + +void ChirpModemModGUI::on_message_textEdited(const QString& text) +{ + // Airtime and capacity follow the typing, settings are applied when done + ChirpModemModSettings settings = m_settings; + settings.m_message = text; + std::swap(settings, m_settings); + displayFrameInfo(); + std::swap(settings, m_settings); +} + +void ChirpModemModGUI::on_message_editingFinished() +{ + if (ui->message->text() != m_settings.m_message) + { + m_settings.m_message = ui->message->text(); + applySettings({"message"}); + } +} + +void ChirpModemModGUI::on_message_returnPressed() +{ + on_message_editingFinished(); + on_txButton_clicked(); +} + +void ChirpModemModGUI::on_repeat_valueChanged(int value) +{ + m_settings.m_repeat = value; + applySettings({"repeat"}); +} + +void ChirpModemModGUI::on_gap_valueChanged(double value) +{ + m_settings.m_gap = value; + applySettings({"gap"}); +} + +void ChirpModemModGUI::on_amplitude_valueChanged(double value) +{ + m_settings.m_amplitude = value; + applySettings({"amplitude"}); +} + +void ChirpModemModGUI::on_cwId_toggled(bool checked) +{ + m_settings.m_cwId = checked; + applySettings({"cwId"}); +} + +void ChirpModemModGUI::on_cwWpm_valueChanged(int value) +{ + m_settings.m_cwWpm = value; + applySettings({"cwWpm"}); +} + +void ChirpModemModGUI::on_txButton_clicked() +{ + // Make sure edits not yet applied go with this transmission + on_source_editingFinished(); + on_destination_editingFinished(); + on_message_editingFinished(); + // Through the channel's queue, behind the settings just applied, so they + // reach the DSP thread first + m_chirpModemMod->getInputMessageQueue()->push(ChirpModemModMessages::MsgTx::create()); + log(QString("TX %1>%2: %3 (x%4%5)") + .arg(m_settings.m_source.isEmpty() ? "?" : m_settings.m_source) + .arg(m_settings.m_destination.isEmpty() ? "*" : m_settings.m_destination) + .arg(m_settings.m_message) + .arg(m_settings.m_repeat) + .arg(m_settings.m_cwId && !m_settings.m_source.isEmpty() ? ", CW ID" : "")); +} + +void ChirpModemModGUI::on_clearLog_clicked() +{ + ui->log->clear(); +} + +void ChirpModemModGUI::log(const QString& text) +{ + ui->log->appendPlainText(QDateTime::currentDateTimeUtc().toString("HH:mm:ss ") + text); +} + +void ChirpModemModGUI::handleInputMessages() +{ + while (auto *message = m_inputMessageQueue.pop()) + { + if (ChirpModemMod::MsgConfigureChirpModemMod::match(*message)) + { + const auto& config = static_cast(*message); + + if (config.getForce()) + { + ChirpModemModSettings settings = config.getSettings(); + 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()); + } + + 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(*message); + m_deviceCenterFrequency = notification.getCenterFrequency(); + m_basebandSampleRate = notification.getSampleRate(); + { + // Changing the range clamps the dial: never send that back as a + // setting, and show the real offset again once the range allows it + QSignalBlocker blocker(ui->deltaFrequency); + ui->deltaFrequency->setValueRange(false, 8, -m_basebandSampleRate / 2, m_basebandSampleRate / 2); + ui->deltaFrequency->setValue(m_settings.m_inputFrequencyOffset); + } + updateAbsoluteCenterFrequency(); + } + else if (ChirpModemModMessages::MsgStatus::match(*message)) + { + statusReceived(static_cast(*message).getStatus()); + } + + delete message; + } +} + +void ChirpModemModGUI::statusReceived(const ChirpModemModMessages::Status& status) +{ + if (status.m_channelSampleRate > 0 && status.m_channelSampleRate != m_spectrumSampleRate) + { + m_spectrumSampleRate = status.m_channelSampleRate; + ui->glSpectrum->setSampleRate(m_spectrumSampleRate); + } + + ui->txButton->setStyleSheet(status.m_transmitting ? "QToolButton { background-color: rgb(160, 30, 30); }" : ""); + ui->status->setText(QString("%1 kS/s IF %2 Hz %3 queue %4 sent %5 frames, %6 s") + .arg(status.m_channelSampleRate / 1000.0, 0, 'f', 1) + .arg(status.m_ifOffset) + .arg(status.m_transmitting ? "ON AIR" : "idle") + .arg(status.m_queueLength) + .arg(status.m_framesSent) + .arg(status.m_airtime, 0, 'f', 1)); + + if (status.m_event == "error" || status.m_event == "aborted") { + log(status.m_event.toUpper() + ": " + status.m_error); + } else if (status.m_event == "queued") { + log(QString("queued, %1 s").arg(status.m_lastDuration, 0, 'f', 2)); + } else if (status.m_event == "sent") { + log("sent"); + } +} + +void ChirpModemModGUI::tick() +{ + double power = CalcDb::dbPower(m_chirpModemMod->getMagSq()); + ui->channelPower->setText(QString::number(power, 'f', 1) + " dB"); +} + +void ChirpModemModGUI::updateAbsoluteCenterFrequency() +{ + setStatusFrequency(m_deviceCenterFrequency + m_settings.m_inputFrequencyOffset); +} + +void ChirpModemModGUI::channelMarkerChangedByCursor() +{ + m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency(); + ui->deltaFrequency->setValue(m_settings.m_inputFrequencyOffset); + applySettings({"inputFrequencyOffset"}); +} + +void ChirpModemModGUI::channelMarkerHighlightedByCursor() +{ + setHighlighted(m_channelMarker.getHighlighted()); +} + +void ChirpModemModGUI::onWidgetRolled(QWidget *widget, bool rollDown) +{ + (void) widget; + (void) rollDown; + + if (!m_doApplySettings) { + return; + } + + getRollupContents()->saveState(m_rollupState); + applySettings({"rollupState"}); +} + +void ChirpModemModGUI::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_chirpModemMod->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(); +} diff --git a/plugins/channeltx/modchirpmodem/chirpmodemmodgui.h b/plugins/channeltx/modchirpmodem/chirpmodemmodgui.h new file mode 100644 index 000000000..3ab57877e --- /dev/null +++ b/plugins/channeltx/modchirpmodem/chirpmodemmodgui.h @@ -0,0 +1,119 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2026 Dan Chokola, KD2HSG // +// Based on the packet modulator plugin: // +// Copyright (C) 2020-2023 Jon Beniston, M7RCE // +// Copyright (C) 2020-2022 Edouard Griffiths, F4EXB // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef INCLUDE_CHIRPMODEMMODGUI_H +#define INCLUDE_CHIRPMODEMMODGUI_H + +#include "channel/channelgui.h" +#include "dsp/channelmarker.h" +#include "settings/rollupstate.h" +#include "util/messagequeue.h" + +#include "chirpmodemmodsettings.h" +#include "chirpmodemmodmessages.h" + +class PluginAPI; +class DeviceUISet; +class BasebandSampleSource; +class ChirpModemMod; +class SpectrumVis; + +namespace Ui { +class ChirpModemModGUI; +} + +class ChirpModemModGUI : public ChannelGUI { + Q_OBJECT + +public: + static ChirpModemModGUI *create(PluginAPI *pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *txChannel); + 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: + Ui::ChirpModemModGUI *ui; + DeviceUISet *m_deviceUISet; + ChannelMarker m_channelMarker; + RollupState m_rollupState; + ChirpModemModSettings m_settings; + ChirpModemMod *m_chirpModemMod; + SpectrumVis *m_spectrumVis; + MessageQueue m_inputMessageQueue; + qint64 m_deviceCenterFrequency = 0; + int m_basebandSampleRate = 48000; + int m_spectrumSampleRate = 0; + bool m_doApplySettings = true; + + explicit ChirpModemModGUI(PluginAPI *pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *txChannel, QWidget *parent = nullptr); + ~ChirpModemModGUI() override; + void applySettings(const QStringList& keys, bool force = false); + void displaySettings(); + void displayBandwidth(); + void displayFrameInfo(); + void makeUIConnections(); + void updateAbsoluteCenterFrequency(); + void updateChannelMarker(); + void statusReceived(const ChirpModemModMessages::Status& status); + void log(const QString& text); + +private slots: + void on_deltaFrequency_changed(qint64 value); + void on_spreadFactor_currentIndexChanged(int index); + void on_bandwidth_currentIndexChanged(int index); + void on_mode_currentIndexChanged(int index); + void on_profile_currentIndexChanged(int index); + void on_source_editingFinished(); + void on_destination_editingFinished(); + void on_message_textEdited(const QString& text); + void on_message_editingFinished(); + void on_message_returnPressed(); + void on_repeat_valueChanged(int value); + void on_gap_valueChanged(double value); + void on_amplitude_valueChanged(double value); + void on_cwId_toggled(bool checked); + void on_cwWpm_valueChanged(int value); + void on_txButton_clicked(); + void on_clearLog_clicked(); + void handleInputMessages(); + void tick(); + void onMenuDialogCalled(const QPoint& point); + void onWidgetRolled(QWidget *widget, bool rollDown); +}; + +#endif // INCLUDE_CHIRPMODEMMODGUI_H diff --git a/plugins/channeltx/modchirpmodem/chirpmodemmodgui.ui b/plugins/channeltx/modchirpmodem/chirpmodemmodgui.ui new file mode 100644 index 000000000..97aac6b5b --- /dev/null +++ b/plugins/channeltx/modchirpmodem/chirpmodemmodgui.ui @@ -0,0 +1,633 @@ + + + ChirpModemModGUI + + + + 0 + 0 + 560 + 710 + + + + + 480 + 300 + + + + ChirpModem Modulator + + + + + 0 + 0 + 560 + 240 + + + + + 480 + 240 + + + + Settings + + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + + + + + Δf + + + + + + + + 32 + 16 + + + + + Liberation Mono + 12 + + + + Channel offset from device centre frequency in Hz + + + + + + + Hz + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + Power of the samples being sent + + + -100.0 dB + + + + + + + + + + + Level + + + + + + + + 0 + 0 + + + + + 170 + 24 + + + + + 16777215 + 24 + + + + + Liberation Mono + 8 + + + + Level (% full scale) of the samples being sent. Top trace: average, bottom trace: instantaneous peak, tip: peak hold + + + + + + + + + + + SF + + + + + + + Spreading factor + + + + + + + BW + + + + + + + Chip rate, equal to the occupied bandwidth + + + + + + + Payload mode. Auto is non-coherent at SF 10 and above or BW 62.5 kHz and below + + + + Auto + + + + + Non-coherent + + + + + Coherent + + + + + + + + Licensed (amateur): source callsign required, no encryption. Unlicensed: ISM bands only + + + + Licensed + + + + + Unlicensed + + + + + + + + Qt::Orientation::Horizontal + + + + 10 + 20 + + + + + + + + + + + + Src + + + + + + + Source callsign (A-Z 0-9 - / ., at most 9 characters). Also sent as the CW ID + + + 9 + + + + + + + Dst + + + + + + + Destination callsign, empty for none + + + 9 + + + + + + + + + + + Msg + + + + + + + Body, sent as UTF-8. Enter transmits + + + + + + + + + + + x + + + + + + + Frames per transmission + + + 1 + + + 1000 + + + + + + + Gap + + + + + + + Silence between frames and before the CW ID, in seconds + + + 60.000000000000000 + + + 0.100000000000000 + + + + + + + Amp + + + + + + + Peak amplitude, 0 to 1 of full scale + + + 1.000000000000000 + + + 0.050000000000000 + + + + + + + CW ID "DE <source>" after each transmission (47 CFR 97.119) + + + CW ID + + + true + + + + + + + CW ID speed, words per minute (at most 20, 47 CFR 97.119(b)(1)) + + + wpm + + + 5 + + + 20 + + + + + + + Qt::Orientation::Horizontal + + + + 10 + 20 + + + + + + + + + + + + + 0 + 0 + + + + - + + + + + + + + 60 + 0 + + + + Transmit the message + + + TX + + + + + + + + + QLabel { color: rgb(255, 120, 0); } + + + true + + + + + + + + + + Rate the frames are generated at, residual offset, state, queue, frames and seconds sent + + + idle + + + + + + + Qt::Orientation::Vertical + + + + 20 + 0 + + + + + + + + + + 0 + 250 + 560 + 130 + + + + + 480 + 100 + + + + Transmissions + + + + 3 + + + 3 + + + 3 + + + 3 + + + 3 + + + + + true + + + + + + + + 24 + 24 + + + + Clear the log + + + + + + + :/bin.png:/bin.png + + + + + + + + + 0 + 390 + 560 + 310 + + + + + 480 + 250 + + + + Channel spectrum + + + + 2 + + + 3 + + + 3 + + + 3 + + + 3 + + + + + + 200 + 200 + + + + + Liberation Mono + 8 + + + + + + + + + + + + + RollupContents + QWidget +
gui/rollupcontents.h
+ 1 +
+ + LevelMeterVU + QWidget +
gui/levelmeter.h
+ 1 +
+ + ValueDialZ + QWidget +
gui/valuedialz.h
+ 1 +
+ + ButtonSwitch + QToolButton +
gui/buttonswitch.h
+
+ + GLSpectrum + QWidget +
gui/glspectrum.h
+ 1 +
+ + GLSpectrumGUI + QWidget +
gui/glspectrumgui.h
+ 1 +
+
+ + +
diff --git a/plugins/channeltx/modchirpmodem/chirpmodemmodmessages.cpp b/plugins/channeltx/modchirpmodem/chirpmodemmodmessages.cpp new file mode 100644 index 000000000..e6cd6dd59 --- /dev/null +++ b/plugins/channeltx/modchirpmodem/chirpmodemmodmessages.cpp @@ -0,0 +1,25 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2026 Dan Chokola, KD2HSG // +// // +// 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 . // +/////////////////////////////////////////////////////////////////////////////////// + +#include "chirpmodemmodmessages.h" + +namespace ChirpModemModMessages { + +MESSAGE_CLASS_DEFINITION(MsgTx, Message) +MESSAGE_CLASS_DEFINITION(MsgStatus, Message) + +} // namespace ChirpModemModMessages diff --git a/plugins/channeltx/modchirpmodem/chirpmodemmodmessages.h b/plugins/channeltx/modchirpmodem/chirpmodemmodmessages.h new file mode 100644 index 000000000..1899ee627 --- /dev/null +++ b/plugins/channeltx/modchirpmodem/chirpmodemmodmessages.h @@ -0,0 +1,75 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2026 Dan Chokola, KD2HSG // +// // +// 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 . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef INCLUDE_CHIRPMODEMMODMESSAGES_H +#define INCLUDE_CHIRPMODEMMODMESSAGES_H + +#include +#include +#include + +#include "util/message.h" + +namespace ChirpModemModMessages { + +//! What to send. Empty optional fields take their values from the settings. +struct TxRequest { + bool m_override = false; //!< Use m_source, m_destination and m_message below + QString m_source; + QString m_destination; + QByteArray m_body; +}; + +//! Transmitter state, sent by the DSP thread when it changes +struct Status { + QString m_event; //!< What happened: queued, started, sent, aborted, error + QString m_error; //!< Last error, empty if the last request was accepted + bool m_transmitting = false; + int m_queueLength = 0; //!< Transmissions waiting, not counting the one on air + qint64 m_framesSent = 0; //!< Since the channel started + qint64 m_transmissions = 0; //!< Requests completed, with their CW ID + double m_airtime = 0; //!< Seconds of samples sent with signal, since the channel started + double m_lastDuration = 0; //!< Seconds of the last transmission generated + int m_channelSampleRate = 0; + int m_ifOffset = 0; //!< Residual channel offset the frames are generated at +}; + +class MsgTx : public Message { + MESSAGE_CLASS_DECLARATION +public: + static MsgTx *create(const TxRequest& request = TxRequest()) { return new MsgTx(request); } + const TxRequest& getRequest() const { return m_request; } + +private: + explicit MsgTx(const TxRequest& request) : m_request(request) {} + TxRequest m_request; +}; + +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 ChirpModemModMessages + +#endif diff --git a/plugins/channeltx/modchirpmodem/chirpmodemmodplugin.cpp b/plugins/channeltx/modchirpmodem/chirpmodemmodplugin.cpp new file mode 100644 index 000000000..e75f32111 --- /dev/null +++ b/plugins/channeltx/modchirpmodem/chirpmodemmodplugin.cpp @@ -0,0 +1,91 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2026 Dan Chokola, KD2HSG // +// Based on the SELCAL demodulator plugin: // +// Copyright (C) 2021-2022 Edouard Griffiths, F4EXB // +// Copyright (C) 2026 Jon Beniston, M7RCE // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#include +#include "plugin/pluginapi.h" + +#ifndef SERVER_MODE +#include "chirpmodemmodgui.h" +#endif +#include "chirpmodemmod.h" +#include "chirpmodemmodwebapiadapter.h" +#include "chirpmodemmodplugin.h" + +const PluginDescriptor ChirpModemModPlugin::m_pluginDescriptor = { + ChirpModemMod::m_channelId, + QStringLiteral("ChirpModem Modulator"), + QStringLiteral("8.0.0"), + QStringLiteral("(c) Dan Chokola, KD2HSG"), + QStringLiteral("https://github.com/f4exb/sdrangel"), + true, + QStringLiteral("https://github.com/f4exb/sdrangel") +}; + +ChirpModemModPlugin::ChirpModemModPlugin(QObject *parent) : + QObject(parent), + m_pluginAPI(nullptr) +{ +} + +const PluginDescriptor& ChirpModemModPlugin::getPluginDescriptor() const +{ + return m_pluginDescriptor; +} + +void ChirpModemModPlugin::initPlugin(PluginAPI *pluginAPI) +{ + m_pluginAPI = pluginAPI; + m_pluginAPI->registerTxChannel(ChirpModemMod::m_channelIdURI, ChirpModemMod::m_channelId, this); +} + +void ChirpModemModPlugin::createTxChannel(DeviceAPI *deviceAPI, BasebandSampleSource **bs, ChannelAPI **cs) const +{ + if (bs || cs) + { + ChirpModemMod *instance = new ChirpModemMod(deviceAPI); + + if (bs) { + *bs = instance; + } + + if (cs) { + *cs = instance; + } + } +} + +#ifdef SERVER_MODE +ChannelGUI *ChirpModemModPlugin::createTxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSource *txChannel) const +{ + (void) deviceUISet; + (void) txChannel; + return nullptr; +} +#else +ChannelGUI *ChirpModemModPlugin::createTxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSource *txChannel) const +{ + return ChirpModemModGUI::create(m_pluginAPI, deviceUISet, txChannel); +} +#endif + +ChannelWebAPIAdapter *ChirpModemModPlugin::createChannelWebAPIAdapter() const +{ + return new ChirpModemModWebAPIAdapter(); +} diff --git a/plugins/channeltx/modchirpmodem/chirpmodemmodplugin.h b/plugins/channeltx/modchirpmodem/chirpmodemmodplugin.h new file mode 100644 index 000000000..75b97a828 --- /dev/null +++ b/plugins/channeltx/modchirpmodem/chirpmodemmodplugin.h @@ -0,0 +1,50 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2026 Dan Chokola, KD2HSG // +// Based on the SELCAL demodulator plugin: // +// Copyright (C) 2021-2022 Edouard Griffiths, F4EXB // +// Copyright (C) 2026 Jon Beniston, M7RCE // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef INCLUDE_CHIRPMODEMMODPLUGIN_H +#define INCLUDE_CHIRPMODEMMODPLUGIN_H + +#include +#include "plugin/plugininterface.h" + +class DeviceUISet; +class BasebandSampleSource; + +class ChirpModemModPlugin : public QObject, PluginInterface { + Q_OBJECT + Q_INTERFACES(PluginInterface) + Q_PLUGIN_METADATA(IID "sdrangel.channeltx.modchirpmodem") + +public: + explicit ChirpModemModPlugin(QObject *parent = nullptr); + + const PluginDescriptor& getPluginDescriptor() const; + void initPlugin(PluginAPI *pluginAPI); + + virtual void createTxChannel(DeviceAPI *deviceAPI, BasebandSampleSource **bs, ChannelAPI **cs) const; + virtual ChannelGUI *createTxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSource *txChannel) const; + virtual ChannelWebAPIAdapter *createChannelWebAPIAdapter() const; + +private: + static const PluginDescriptor m_pluginDescriptor; + PluginAPI *m_pluginAPI; +}; + +#endif // INCLUDE_CHIRPMODEMMODPLUGIN_H diff --git a/plugins/channeltx/modchirpmodem/chirpmodemmodsettings.cpp b/plugins/channeltx/modchirpmodem/chirpmodemmodsettings.cpp new file mode 100644 index 000000000..d593127c7 --- /dev/null +++ b/plugins/channeltx/modchirpmodem/chirpmodemmodsettings.cpp @@ -0,0 +1,313 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2026 Dan Chokola, KD2HSG // +// Based on the packet modulator plugin: // +// Copyright (C) 2020-2023 Jon Beniston, M7RCE // +// Copyright (C) 2020-2022 Edouard Griffiths, F4EXB // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#include + +#include +#include + +#include "settings/serializable.h" +#include "util/simpleserializer.h" + +#include "chirpmodemmodsettings.h" + +ChirpModemModSettings::ChirpModemModSettings() +{ + resetToDefaults(); +} + +void ChirpModemModSettings::resetToDefaults() +{ + m_inputFrequencyOffset = 0; + m_spreadFactor = 9; + m_bandwidth = 62500; + m_mode = ModeAuto; + m_profile = ProfileLicensed; + m_source = QString(); + m_destination = QString(); + m_message = QStringLiteral("test"); + m_repeat = 1; + m_gap = 0.5f; + m_amplitude = 0.7f; + m_cwId = true; + m_cwWpm = m_maxWpm; + m_rgbColor = QColor(255, 140, 0).rgb(); + m_title = QStringLiteral("ChirpModem Modulator"); + 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; +} + +void ChirpModemModSettings::normalize() +{ + m_spreadFactor = std::clamp(m_spreadFactor, 7, 12); + m_bandwidth = std::clamp(m_bandwidth, 1000, 2000000); + m_mode = std::clamp(m_mode, (int) ModeAuto, (int) ModeCoherent); + m_profile = m_profile == ProfileUnlicensed ? ProfileUnlicensed : ProfileLicensed; + m_source = m_source.trimmed().toUpper(); + m_destination = m_destination.trimmed().toUpper(); + m_repeat = std::clamp(m_repeat, 1, 1000); + m_gap = std::isfinite(m_gap) ? std::clamp(m_gap, 0.0f, 60.0f) : 0.5f; + m_amplitude = std::isfinite(m_amplitude) ? std::clamp(m_amplitude, 0.0f, 1.0f) : 0.7f; + m_cwWpm = std::clamp(m_cwWpm, 5, (int) m_maxWpm); + 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); +} + +QByteArray ChirpModemModSettings::serialize() const +{ + SimpleSerializer s(1); + + s.writeS64(1, m_inputFrequencyOffset); + s.writeS32(2, m_spreadFactor); + s.writeS32(3, m_bandwidth); + s.writeS32(4, m_mode); + s.writeS32(5, m_profile); + s.writeString(6, m_source); + s.writeString(7, m_destination); + s.writeString(8, m_message); + s.writeS32(9, m_repeat); + s.writeFloat(10, m_gap); + s.writeFloat(11, m_amplitude); + s.writeBool(12, m_cwId); + s.writeS32(13, m_cwWpm); + 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); + + 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 ChirpModemModSettings::deserialize(const QByteArray& data) +{ + SimpleDeserializer d(data); + + resetToDefaults(); + + if (!d.isValid() || d.getVersion() != 1) { + return false; + } + + d.readS64(1, &m_inputFrequencyOffset, 0); + d.readS32(2, &m_spreadFactor, 9); + d.readS32(3, &m_bandwidth, 62500); + d.readS32(4, &m_mode, ModeAuto); + d.readS32(5, &m_profile, ProfileLicensed); + d.readString(6, &m_source, QString()); + d.readString(7, &m_destination, QString()); + d.readString(8, &m_message, QStringLiteral("test")); + d.readS32(9, &m_repeat, 1); + d.readFloat(10, &m_gap, 0.5f); + d.readFloat(11, &m_amplitude, 0.7f); + d.readBool(12, &m_cwId, true); + d.readS32(13, &m_cwWpm, m_maxWpm); + d.readU32(15, &m_rgbColor, QColor(255, 140, 0).rgb()); + d.readString(16, &m_title, QStringLiteral("ChirpModem Modulator")); + 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); + + 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 ChirpModemModSettings::applySettings(const QStringList& keys, const ChirpModemModSettings& 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("mode")) { + m_mode = settings.m_mode; + } + if (keys.contains("profile")) { + m_profile = settings.m_profile; + } + if (keys.contains("source")) { + m_source = settings.m_source; + } + if (keys.contains("destination")) { + m_destination = settings.m_destination; + } + if (keys.contains("message")) { + m_message = settings.m_message; + } + if (keys.contains("repeat")) { + m_repeat = settings.m_repeat; + } + if (keys.contains("gap")) { + m_gap = settings.m_gap; + } + if (keys.contains("amplitude")) { + m_amplitude = settings.m_amplitude; + } + if (keys.contains("cwId")) { + m_cwId = settings.m_cwId; + } + if (keys.contains("cwWpm")) { + m_cwWpm = settings.m_cwWpm; + } + 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 ChirpModemModSettings::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("mode")) { + result << QString("mode: %1").arg(m_mode); + } + if (force || keys.contains("profile")) { + result << QString("profile: %1").arg(m_profile); + } + if (force || keys.contains("source")) { + result << QString("source: %1").arg(m_source); + } + if (force || keys.contains("destination")) { + result << QString("destination: %1").arg(m_destination); + } + if (force || keys.contains("message")) { + result << QString("message: %1").arg(m_message); + } + if (force || keys.contains("repeat")) { + result << QString("repeat: %1").arg(m_repeat); + } + if (force || keys.contains("gap")) { + result << QString("gap: %1").arg(m_gap); + } + if (force || keys.contains("amplitude")) { + result << QString("amplitude: %1").arg(m_amplitude); + } + if (force || keys.contains("cwId")) { + result << QString("cwId: %1").arg(m_cwId); + } + if (force || keys.contains("cwWpm")) { + result << QString("cwWpm: %1").arg(m_cwWpm); + } + 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); + } + + return result.join(" "); +} diff --git a/plugins/channeltx/modchirpmodem/chirpmodemmodsettings.h b/plugins/channeltx/modchirpmodem/chirpmodemmodsettings.h new file mode 100644 index 000000000..b7a1a7405 --- /dev/null +++ b/plugins/channeltx/modchirpmodem/chirpmodemmodsettings.h @@ -0,0 +1,94 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2026 Dan Chokola, KD2HSG // +// Based on the packet modulator plugin: // +// Copyright (C) 2020-2023 Jon Beniston, M7RCE // +// Copyright (C) 2020-2022 Edouard Griffiths, F4EXB // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef INCLUDE_CHIRPMODEMMODSETTINGS_H +#define INCLUDE_CHIRPMODEMMODSETTINGS_H + +#include +#include +#include + +#include "dsp/dsptypes.h" + +class Serializable; + +struct ChirpModemModSettings { + + enum Mode { // as CHIRPMODEM_MODE_* + ModeAuto = -1, + ModeNonCoherent = 0, + ModeCoherent = 1 + }; + + enum Profile { // as CHIRPMODEM_LICENSED / UNLICENSED + ProfileLicensed = 0, + ProfileUnlicensed = 1 + }; + + static constexpr int m_maxWpm = 20; //!< 47 CFR 97.119(b)(1); the library enforces it too + + qint64 m_inputFrequencyOffset; + int m_spreadFactor; //!< 7..12 + int m_bandwidth; //!< Chip rate = occupied bandwidth, Hz + int m_mode; //!< Payload mode, Mode + int m_profile; //!< Profile + QString m_source; //!< Source callsign: required by the licensed profile + QString m_destination; //!< Destination callsign, may be empty + QString m_message; //!< Body, UTF-8 + int m_repeat; //!< Frames per transmission + float m_gap; //!< Silence between frames and before the CW ID, s + float m_amplitude; //!< Peak amplitude, 0..1 of full scale + bool m_cwId; //!< CW ID with the source callsign after each transmission + int m_cwWpm; //!< CW ID speed, at most m_maxWpm + 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; + + ChirpModemModSettings(); + void resetToDefaults(); + void normalize(); + QByteArray serialize() const; + bool deserialize(const QByteArray& data); + void applySettings(const QStringList& keys, const ChirpModemModSettings& settings); + QString getDebugString(const QStringList& keys, bool force = false) const; + + //! Rate requested from the channelizer. Margin over 2 x BW, as chirpmodem_tx_new + //! needs fs >= 2.2 x (BW/2 + |IF|) and the channelizer leaves a residual IF. + int requestedChannelSampleRate() const { return 4 * m_bandwidth; } + //! The licensed profile without CW ID: allowed, but flagged + bool cwIdWarning() const { return (m_profile == ProfileLicensed) && !m_cwId; } + + void setChannelMarker(Serializable *marker) { m_channelMarker = marker; } + void setRollupState(Serializable *state) { m_rollupState = state; } + void setSpectrumGUI(Serializable *spectrumGUI) { m_spectrumGUI = spectrumGUI; } +}; + +#endif diff --git a/plugins/channeltx/modchirpmodem/chirpmodemmodsource.cpp b/plugins/channeltx/modchirpmodem/chirpmodemmodsource.cpp new file mode 100644 index 000000000..0d7cf8744 --- /dev/null +++ b/plugins/channeltx/modchirpmodem/chirpmodemmodsource.cpp @@ -0,0 +1,334 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2026 Dan Chokola, KD2HSG // +// Based on the packet modulator plugin: // +// Copyright (C) 2020-2023 Jon Beniston, M7RCE // +// Copyright (C) 2020-2022 Edouard Griffiths, F4EXB // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#include + +#include +#include + +#include + +#include "dsp/basebandsamplesink.h" + +#include "chirpmodemmodsource.h" + +namespace ChirpModemModGen { + +MESSAGE_CLASS_DEFINITION(MsgGenerated, Message) + +// All the policy checks are libchirpmodem's: a licensed frame without a source +// callsign is refused (EPOLICY), and so is a CW ID faster than 20 WPM. +void generate(Transmission& transmission) +{ + const Job& job = transmission.m_job; + const ChirpModemModSettings& s = job.m_settings; + transmission.m_iq.clear(); + transmission.m_position = 0; + transmission.m_frames = 0; + transmission.m_error.clear(); + + if (job.m_channelSampleRate <= 0) + { + transmission.m_error = QStringLiteral("No channel sample rate yet: start the device"); + return; + } + + chirpmodem_tx_config tc; + chirpmodem_tx_config_init(&tc); + tc.sf = s.m_spreadFactor; + tc.bw = s.m_bandwidth; + tc.fs = job.m_channelSampleRate; + tc.if_offset = job.m_channelFrequencyOffset; + tc.coherent = s.m_mode; + tc.profile = s.m_profile; + tc.amp = s.m_amplitude; + + int err = CHIRPMODEM_OK; + chirpmodem_tx *tx = chirpmodem_tx_new(&tc, &err); + + if (!tx) + { + transmission.m_error = QString("Transmitter: %1 (SF %2, BW %3 Hz, fs %4 Hz, IF %5 Hz)") + .arg(chirpmodem_strerror(err)).arg(tc.sf).arg(tc.bw).arg(tc.fs).arg(tc.if_offset); + return; + } + + QByteArray src = job.m_source.toLatin1(); + QByteArray dst = job.m_destination.toLatin1(); + const char *srcp = src.isEmpty() ? nullptr : src.constData(); + const char *dstp = dst.isEmpty() ? nullptr : dst.constData(); + const uint8_t *body = reinterpret_cast(job.m_body.constData()); + + long frameLen = chirpmodem_tx_frame(tx, srcp, dstp, body, job.m_body.size(), 0, nullptr, 0); + + if (frameLen < 0) + { + transmission.m_error = QString("Frame refused: %1").arg(chirpmodem_strerror((int) frameLen)); + chirpmodem_tx_free(tx); + return; + } + + std::vector frame(2 * frameLen); + chirpmodem_tx_frame(tx, srcp, dstp, body, job.m_body.size(), 0, frame.data(), frameLen); + std::vector cw; + + if (s.m_cwId && srcp) + { + long cwLen = chirpmodem_tx_cw_id(tx, srcp, s.m_cwWpm, nullptr, 0); + + if (cwLen < 0) + { + transmission.m_error = QString("CW ID refused: %1").arg(chirpmodem_strerror((int) cwLen)); + chirpmodem_tx_free(tx); + return; + } + + cw.resize(2 * cwLen); + chirpmodem_tx_cw_id(tx, srcp, s.m_cwWpm, cw.data(), cwLen); + } + + chirpmodem_tx_free(tx); + + const size_t gap = 2 * (size_t) std::lround(s.m_gap * job.m_channelSampleRate); + std::vector& iq = transmission.m_iq; + iq.reserve(s.m_repeat * (frame.size() + gap) + cw.size() + gap); + + for (int i = 0; i < s.m_repeat; i++) + { + if (i > 0) { + iq.insert(iq.end(), gap, 0.0f); + } + + iq.insert(iq.end(), frame.begin(), frame.end()); + } + + if (!cw.empty()) + { + iq.insert(iq.end(), gap, 0.0f); + iq.insert(iq.end(), cw.begin(), cw.end()); + } + + transmission.m_frames = s.m_repeat; +} + +} // namespace ChirpModemModGen + +using ChirpModemModGen::Job; +using ChirpModemModGen::Transmission; + +ChirpModemModSource::ChirpModemModSource() +{ +} + +ChirpModemModSource::~ChirpModemModSource() +{ +} + +void ChirpModemModSource::applySettings(const QStringList& settingsKeys, const ChirpModemModSettings& settings, bool force) +{ + // Settings apply to the next request. Queued transmissions keep theirs. + if (force) { + m_settings = settings; + } else { + m_settings.applySettings(settingsKeys, settings); + } +} + +std::vector ChirpModemModSource::applyChannelSettings(int channelSampleRate, int channelFrequencyOffset) +{ + std::vector again; + + if ((channelSampleRate == m_channelSampleRate) && (channelFrequencyOffset == m_channelFrequencyOffset)) { + return again; + } + + qDebug() << "ChirpModemModSource::applyChannelSettings: rate" << channelSampleRate << "offset" << channelFrequencyOffset; + m_channelSampleRate = channelSampleRate; + m_channelFrequencyOffset = channelFrequencyOffset; + m_levelNbSamples = std::max(100, channelSampleRate / 100); + + if (m_current) + { + m_current.reset(); + m_lastError = QStringLiteral("Transmission cut off: the channel rate or offset changed"); + sendStatus(QStringLiteral("aborted")); + } + + // Waiting transmissions were made for the old rate: generate them again + for (const auto& transmission : m_queue) + { + Job job = transmission->m_job; + job.m_channelSampleRate = m_channelSampleRate; + job.m_channelFrequencyOffset = m_channelFrequencyOffset; + job.m_regenerated = true; + again.push_back(job); + } + + m_queue.clear(); + return again; +} + +void ChirpModemModSource::reset() +{ + m_epoch++; + m_queue.clear(); + m_current.reset(); + m_pending = 0; + m_framesSent = 0; + m_transmissions = 0; + m_samplesOnAir = 0; + m_lastDuration = 0; + m_lastError.clear(); +} + +Job ChirpModemModSource::makeJob(const ChirpModemModMessages::TxRequest& request) +{ + Job job; + job.m_settings = m_settings; + job.m_channelSampleRate = m_channelSampleRate; + job.m_channelFrequencyOffset = m_channelFrequencyOffset; + job.m_epoch = m_epoch; + + if (request.m_override) + { + job.m_source = request.m_source.trimmed().toUpper(); + job.m_destination = request.m_destination.trimmed().toUpper(); + job.m_body = request.m_body; + } + else + { + job.m_source = m_settings.m_source; + job.m_destination = m_settings.m_destination; + job.m_body = m_settings.m_message.toUtf8(); + } + + return job; +} + +bool ChirpModemModSource::addGenerated(std::shared_ptr transmission) +{ + const Job& job = transmission->m_job; + + if (job.m_epoch != m_epoch) { + return true; // from before a reset: dropped + } + + m_pending = std::max(0, m_pending - 1); + + if ((job.m_channelSampleRate != m_channelSampleRate) || (job.m_channelFrequencyOffset != m_channelFrequencyOffset)) { + return false; // the rate changed while it was being made + } + + if (!transmission->m_error.isEmpty()) + { + m_lastError = transmission->m_error; + qWarning() << "ChirpModemModSource::addGenerated:" << m_lastError; + sendStatus(QStringLiteral("error")); + return true; + } + + if (!job.m_regenerated) { + m_lastError.clear(); // a new request succeeded + } + + m_lastDuration = transmission->m_iq.size() / 2.0 / job.m_channelSampleRate; + m_queue.push_back(transmission); + sendStatus(QStringLiteral("queued")); + return true; +} + +void ChirpModemModSource::pull(SampleVector::iterator begin, unsigned int nbSamples) +{ + std::for_each(begin, begin + nbSamples, [this](Sample& s) { pullOne(s); }); + + if (m_spectrumSink) { + m_spectrumSink->feed(begin, begin + nbSamples, false); + } +} + +void ChirpModemModSource::pullOne(Sample& sample) +{ + if (!m_current && !m_queue.empty()) + { + m_current = m_queue.front(); + m_queue.pop_front(); + sendStatus(QStringLiteral("started")); + } + + double magSq = 0; + + if (m_current) + { + const std::vector& iq = m_current->m_iq; + size_t i = 2 * m_current->m_position; + float re = iq[i]; + float im = iq[i + 1]; + sample.setReal((FixReal) std::lround(re * SDR_TX_SCALEF)); + sample.setImag((FixReal) std::lround(im * SDR_TX_SCALEF)); + magSq = (double) re * re + (double) im * im; + m_samplesOnAir++; + + if (++m_current->m_position >= iq.size() / 2) + { + m_framesSent += m_current->m_frames; + m_transmissions++; + m_current.reset(); // one free per transmission + + sendStatus(QStringLiteral("sent")); + } + } + else + { + sample.setReal(0); + sample.setImag(0); + } + + m_levelSum += magSq; + m_levelPeak = std::max(m_levelPeak, magSq); + + if (++m_levelCount >= m_levelNbSamples) + { + m_rmsLevel = std::sqrt(m_levelSum / m_levelCount); + m_peakLevel = std::sqrt(m_levelPeak); + m_levelSum = 0; + m_levelPeak = 0; + m_levelCount = 0; + } +} + +void ChirpModemModSource::sendStatus(const QString& event) +{ + if (!m_messageQueueToChannel) { + return; + } + + ChirpModemModMessages::Status status; + status.m_event = event; + status.m_error = m_lastError; + status.m_transmitting = m_current != nullptr; + status.m_queueLength = (int) m_queue.size() + m_pending; + status.m_framesSent = m_framesSent; + status.m_transmissions = m_transmissions; + status.m_airtime = m_channelSampleRate > 0 ? (double) m_samplesOnAir / m_channelSampleRate : 0; + status.m_lastDuration = m_lastDuration; + status.m_channelSampleRate = m_channelSampleRate; + status.m_ifOffset = m_channelFrequencyOffset; + m_messageQueueToChannel->push(ChirpModemModMessages::MsgStatus::create(status)); +} diff --git a/plugins/channeltx/modchirpmodem/chirpmodemmodsource.h b/plugins/channeltx/modchirpmodem/chirpmodemmodsource.h new file mode 100644 index 000000000..82e9c707d --- /dev/null +++ b/plugins/channeltx/modchirpmodem/chirpmodemmodsource.h @@ -0,0 +1,149 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2026 Dan Chokola, KD2HSG // +// Based on the packet modulator plugin: // +// Copyright (C) 2020-2023 Jon Beniston, M7RCE // +// Copyright (C) 2020-2022 Edouard Griffiths, F4EXB // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef INCLUDE_CHIRPMODEMMODSOURCE_H +#define INCLUDE_CHIRPMODEMMODSOURCE_H + +#include +#include +#include + +#include + +#include "dsp/channelsamplesource.h" +#include "util/message.h" +#include "util/messagequeue.h" + +#include "chirpmodemmodsettings.h" +#include "chirpmodemmodmessages.h" + +class BasebandSampleSink; + +namespace ChirpModemModGen { + +//! What to generate: a request resolved against the settings, for one channel rate and offset +struct Job { + QString m_source; + QString m_destination; + QByteArray m_body; + ChirpModemModSettings m_settings; //!< As when requested + int m_channelSampleRate = 0; + int m_channelFrequencyOffset = 0; + quint64 m_epoch = 0; //!< Results from before a reset are dropped + bool m_regenerated = false; //!< Made again after a rate change: keeps the last error +}; + +//! A generated transmission: the frames, separated by the gap, then the gap and the CW ID +struct Transmission { + Job m_job; + std::vector m_iq; //!< Interleaved I/Q, full scale 1.0 + size_t m_position = 0; //!< Next complex sample to play + int m_frames = 0; + QString m_error; //!< Not empty if generation failed +}; + +//! Thread safe: uses only its own libchirpmodem transmitter handle +void generate(Transmission& transmission); + +//! A finished generation, posted from the generator thread to the baseband +class MsgGenerated : public Message { + MESSAGE_CLASS_DECLARATION +public: + static MsgGenerated *create(std::shared_ptr transmission) { return new MsgGenerated(transmission); } + std::shared_ptr getTransmission() const { return m_transmission; } + +private: + explicit MsgGenerated(std::shared_ptr transmission) : m_transmission(transmission) {} + std::shared_ptr m_transmission; +}; + +} // namespace ChirpModemModGen + +// Plays chirpmodem transmissions at the channel sample rate. +// +// Threading: every method runs on the baseband thread with the baseband mutex +// held, except getLevels() and getMagSq(), which read single values without +// waiting, as in other modulators. Transmissions are generated on the +// baseband's generator thread (ChirpModemModGen::generate), never here, so the +// sample FIFO is always refilled in time. +// +// A transmission is played only at the channel rate and offset it was made +// for. If those change, the one on air is cut off and the waiting ones are +// handed back to be generated again. +class ChirpModemModSource : public ChannelSampleSource +{ +public: + ChirpModemModSource(); + virtual ~ChirpModemModSource(); + + virtual void pull(SampleVector::iterator begin, unsigned int nbSamples); + virtual void pullOne(Sample& sample); + virtual void prefetch(unsigned int nbSamples) { (void) nbSamples; } + + void applySettings(const QStringList& settingsKeys, const ChirpModemModSettings& settings, bool force = false); + //! Returns the jobs of waiting transmissions, which must be generated again + std::vector applyChannelSettings(int channelSampleRate, int channelFrequencyOffset); + //! A request resolved against the current settings, rate and offset, to be generated + ChirpModemModGen::Job makeJob(const ChirpModemModMessages::TxRequest& request); + //! A finished generation. Returns false if it is stale and must be generated again. + bool addGenerated(std::shared_ptr transmission); + void generationStarted() { m_pending++; sendStatus(QStringLiteral("generating")); } + void reset(); //!< Drop everything queued or on air, zero the counters + + void setSpectrumSink(BasebandSampleSink *sampleSink) { m_spectrumSink = sampleSink; } + void setMessageQueueToChannel(MessageQueue *queue) { m_messageQueueToChannel = queue; } + int getChannelSampleRate() const { return m_channelSampleRate; } + double getMagSq() const { return m_rmsLevel * m_rmsLevel; } //!< Mean over the last 10 ms + void getLevels(qreal& rmsLevel, qreal& peakLevel, int& numSamples) const + { + rmsLevel = m_rmsLevel; + peakLevel = m_peakLevel; + numSamples = m_levelNbSamples; + } + +private: + ChirpModemModSettings m_settings; + MessageQueue *m_messageQueueToChannel = nullptr; + BasebandSampleSink *m_spectrumSink = nullptr; + int m_channelSampleRate = 0; + int m_channelFrequencyOffset = 0; + quint64 m_epoch = 0; + + std::deque> m_queue; + std::shared_ptr m_current; //!< On air, or null + int m_pending = 0; //!< Being generated + + qint64 m_framesSent = 0; + qint64 m_transmissions = 0; + qint64 m_samplesOnAir = 0; + double m_lastDuration = 0; + QString m_lastError; + + double m_levelSum = 0; + double m_levelPeak = 0; + int m_levelCount = 0; + int m_levelNbSamples = 2500; //!< 10 ms at the channel rate + qreal m_rmsLevel = 0; + qreal m_peakLevel = 0; + + void sendStatus(const QString& event); +}; + +#endif // INCLUDE_CHIRPMODEMMODSOURCE_H diff --git a/plugins/channeltx/modchirpmodem/chirpmodemmodwebapiadapter.cpp b/plugins/channeltx/modchirpmodem/chirpmodemmodwebapiadapter.cpp new file mode 100644 index 000000000..671616a2a --- /dev/null +++ b/plugins/channeltx/modchirpmodem/chirpmodemmodwebapiadapter.cpp @@ -0,0 +1,49 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2026 Dan Chokola, KD2HSG // +// Based on the SELCAL demodulator plugin: // +// Copyright (C) 2021-2022 Edouard Griffiths, F4EXB // +// Copyright (C) 2026 Jon Beniston, M7RCE // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#include "SWGChannelSettings.h" +#include "chirpmodemmod.h" +#include "chirpmodemmodwebapiadapter.h" + +ChirpModemModWebAPIAdapter::ChirpModemModWebAPIAdapter() +{ +} + +ChirpModemModWebAPIAdapter::~ChirpModemModWebAPIAdapter() +{ +} + +int ChirpModemModWebAPIAdapter::webapiSettingsGet(SWGSDRangel::SWGChannelSettings& response, QString& errorMessage) +{ + (void) errorMessage; + response.setChirpModemModSettings(new SWGSDRangel::SWGChirpModemModSettings()); + response.getChirpModemModSettings()->init(); + ChirpModemMod::webapiFormatChannelSettings(response, m_settings); + return 200; +} + +int ChirpModemModWebAPIAdapter::webapiSettingsPutPatch(bool force, const QStringList& channelSettingsKeys, + SWGSDRangel::SWGChannelSettings& response, QString& errorMessage) +{ + (void) force; + (void) errorMessage; + ChirpModemMod::webapiUpdateChannelSettings(m_settings, channelSettingsKeys, response); + return 200; +} diff --git a/plugins/channeltx/modchirpmodem/chirpmodemmodwebapiadapter.h b/plugins/channeltx/modchirpmodem/chirpmodemmodwebapiadapter.h new file mode 100644 index 000000000..775294c8b --- /dev/null +++ b/plugins/channeltx/modchirpmodem/chirpmodemmodwebapiadapter.h @@ -0,0 +1,43 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2026 Dan Chokola, KD2HSG // +// Based on the SELCAL demodulator plugin: // +// Copyright (C) 2021-2022 Edouard Griffiths, F4EXB // +// Copyright (C) 2026 Jon Beniston, M7RCE // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef INCLUDE_CHIRPMODEMMOD_WEBAPIADAPTER_H +#define INCLUDE_CHIRPMODEMMOD_WEBAPIADAPTER_H + +#include "channel/channelwebapiadapter.h" +#include "chirpmodemmodsettings.h" + +class ChirpModemModWebAPIAdapter : public ChannelWebAPIAdapter { +public: + ChirpModemModWebAPIAdapter(); + virtual ~ChirpModemModWebAPIAdapter(); + + 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: + ChirpModemModSettings m_settings; +}; + +#endif // INCLUDE_CHIRPMODEMMOD_WEBAPIADAPTER_H diff --git a/plugins/channeltx/modchirpmodem/readme.md b/plugins/channeltx/modchirpmodem/readme.md new file mode 100644 index 000000000..af5d5dcd6 --- /dev/null +++ b/plugins/channeltx/modchirpmodem/readme.md @@ -0,0 +1,73 @@ +

ChirpModem modulator plugin

+ +

Introduction

+ +This plugin transmits the chirpmodem chirp spread-spectrum format (version 1) +with libchirpmodem, the C library of the chirpmodem project. The ChirpModem +demodulator plugin receives it. + +A transmission is one or more frames with the same message, separated by a gap, +followed by a CW ID. It is generated in full on a separate thread when requested, +then sent. Outside transmissions the plugin sends zeros. + +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=` to the SDRangel build. + +

Operating rules

+ +The rules are enforced by libchirpmodem, not by this plugin, so they cannot be +bypassed from the GUI or the web API: + +- The **licensed** (amateur) profile requires a source callsign. A frame without + one is refused and the reason is shown in the log and the report (`lastError`). +- Encryption is not offered: format v1 does not specify a cipher. +- The CW ID is at most 20 WPM (47 CFR 97.119(b)(1)). + +The callsign in the frame does not by itself identify the station in the US +(FORMAT.md section 12). The CW ID, sent after each transmission, does. It can be +turned off, for example when the station identifies some other way, but then a +warning is shown and reported (`warning`), because 97.119 still requires +identification every 10 minutes and at the end of a communication. + +The **unlicensed** profile is for ISM bands. Its selector turns red so it is not +chosen by accident. + +

Interface

+ +- **Δf**: offset of the signal centre from the device centre frequency, in Hz. +- **Power and meter**: level of the samples being sent. +- **SF, BW**: spreading factor (7 to 12) and chip rate, which is the occupied + bandwidth. The receiver must use the same values. +- **Mode**: payload mode. Auto is non-coherent at SF 10 and above or at 62.5 kHz + and below, coherent otherwise. +- **Profile**: licensed or unlicensed, see above. +- **Src, Dst**: callsigns (A-Z 0-9 - / ., at most 9 characters). The source is + also the CW ID. +- **Msg**: the body, sent as UTF-8. Enter transmits. +- **x, Gap, Amp**: frames per transmission, silence between frames (and before + the CW ID) in seconds, and peak amplitude as a fraction of full scale. +- **CW ID, wpm**: CW ID after each transmission, and its speed. +- **Info line**: time on air of one frame, body bytes and the most that fit one + frame, and the payload mode. It turns red when the message does not fit. +- **TX**: transmit. The button is red while a transmission is on air. +- **Status line**: the rate the frames are generated at and the residual offset + within it, the state, transmissions waiting, and frames and seconds sent. +- **Transmissions**: a log of requests, errors and transmissions sent. +- **Channel spectrum**: the samples being sent. + +

Web API and MCP

+ +Settings are under `ChirpModemModSettings`, the report under +`ChirpModemModReport`, and actions under `ChirpModemModActions` (see +`ChirpModemMod.yaml`). To transmit: + + {"tx": 1} the settings' message + {"tx": 1, "dst": "W1AW", "message": "hello"} this transmission only + +Values not given come from the settings. The request is accepted (202) and +queued; whether it was sent, refused or cut off is in the report +(`lastEvent`, `lastError`, `transmissions`, `framesSent`). + +If the channel rate or offset changes while a transmission is on air, it is cut +off. Transmissions waiting are generated again for the new rate and offset. diff --git a/sdrbase/resources/webapi.qrc b/sdrbase/resources/webapi.qrc index cf512a2ba..6d31bd1e9 100644 --- a/sdrbase/resources/webapi.qrc +++ b/sdrbase/resources/webapi.qrc @@ -97,6 +97,7 @@ webapi/doc/swagger/include/NoiseFigure.yaml webapi/doc/swagger/include/PacketDemod.yaml webapi/doc/swagger/include/PacketMod.yaml + webapi/doc/swagger/include/ChirpModemMod.yaml webapi/doc/swagger/include/PagerDemod.yaml webapi/doc/swagger/include/Perseus.yaml webapi/doc/swagger/include/PERTester.yaml diff --git a/sdrbase/resources/webapi/doc/swagger/include/ChannelActions.yaml b/sdrbase/resources/webapi/doc/swagger/include/ChannelActions.yaml index c72577ec7..8d2fd7358 100644 --- a/sdrbase/resources/webapi/doc/swagger/include/ChannelActions.yaml +++ b/sdrbase/resources/webapi/doc/swagger/include/ChannelActions.yaml @@ -51,6 +51,8 @@ ChannelActions: description: "Meshcore mod actions configuration for Channel." PacketModActions: $ref: "/doc/swagger/include/PacketMod.yaml#/PacketModActions" + ChirpModemModActions: + $ref: "/doc/swagger/include/ChirpModemMod.yaml#/ChirpModemModActions" description: "Packet mod actions configuration for Channel." PSK31ModActions: $ref: "/doc/swagger/include/PSK31Mod.yaml#/PSK31ModActions" diff --git a/sdrbase/resources/webapi/doc/swagger/include/ChannelReport.yaml b/sdrbase/resources/webapi/doc/swagger/include/ChannelReport.yaml index 8029d9448..54d210491 100644 --- a/sdrbase/resources/webapi/doc/swagger/include/ChannelReport.yaml +++ b/sdrbase/resources/webapi/doc/swagger/include/ChannelReport.yaml @@ -171,6 +171,8 @@ ChannelReport: description: "Packet demod report data for Channel." PacketModReport: $ref: "/doc/swagger/include/PacketMod.yaml#/PacketModReport" + ChirpModemModReport: + $ref: "/doc/swagger/include/ChirpModemMod.yaml#/ChirpModemModReport" description: "Packet mod report data for Channel." PagerDemodReport: $ref: "/doc/swagger/include/PagerDemod.yaml#/PagerDemodReport" diff --git a/sdrbase/resources/webapi/doc/swagger/include/ChannelSettings.yaml b/sdrbase/resources/webapi/doc/swagger/include/ChannelSettings.yaml index c2eb784a8..2d4a2f08d 100644 --- a/sdrbase/resources/webapi/doc/swagger/include/ChannelSettings.yaml +++ b/sdrbase/resources/webapi/doc/swagger/include/ChannelSettings.yaml @@ -175,6 +175,8 @@ ChannelSettings: description: "Packet demod settings configuration for Channel." PacketModSettings: $ref: "/doc/swagger/include/PacketMod.yaml#/PacketModSettings" + ChirpModemModSettings: + $ref: "/doc/swagger/include/ChirpModemMod.yaml#/ChirpModemModSettings" description: "Packet mod settings configuration for Channel." PagerDemodSettings: $ref: "/doc/swagger/include/PagerDemod.yaml#/PagerDemodSettings" diff --git a/sdrbase/resources/webapi/doc/swagger/include/ChirpModemMod.yaml b/sdrbase/resources/webapi/doc/swagger/include/ChirpModemMod.yaml new file mode 100644 index 000000000..c48aca16e --- /dev/null +++ b/sdrbase/resources/webapi/doc/swagger/include/ChirpModemMod.yaml @@ -0,0 +1,181 @@ +ChirpModemModSettings: + description: ChirpModem modulator settings (libchirpmodem transmitter, 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 + mode: + type: integer + format: int32 + description: "Payload mode: -1 auto (non-coherent at SF >= 10 or BW <= 62.5 kHz), 0 non-coherent, 1 coherent" + default: -1 + enum: [-1, 0, 1] + profile: + type: integer + format: int32 + description: "0 licensed (amateur: source callsign required, no encryption), 1 unlicensed (ISM)" + default: 0 + enum: [0, 1] + source: + type: string + description: Source callsign (A-Z 0-9 - / ., at most 9 characters). Required by the licensed profile + destination: + type: string + description: Destination callsign, empty for none + message: + type: string + description: Body, sent as UTF-8 + repeat: + type: integer + format: int32 + description: Frames per transmission + default: 1 + minimum: 1 + maximum: 1000 + gap: + type: number + format: float + description: Silence between frames and before the CW ID, in seconds + default: 0.5 + minimum: 0 + maximum: 60 + amplitude: + type: number + format: float + description: Peak amplitude, 0 to 1 of full scale + default: 0.7 + minimum: 0 + maximum: 1 + cwId: + type: integer + format: int32 + description: Send "DE " in Morse after each transmission (47 CFR 97.119). Turning it off in the licensed profile is reported as a warning + default: 1 + enum: [0, 1] + cwWpm: + type: integer + format: int32 + description: CW ID speed in words per minute, at most 20 (47 CFR 97.119(b)(1)) + default: 20 + minimum: 5 + maximum: 20 + rgbColor: + type: integer + format: int32 + title: + type: string + streamIndex: + type: integer + format: int32 + description: MIMO channel. Not relevant when connected to SO (single Tx). + 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" + +ChirpModemModReport: + description: ChirpModem modulator report + type: object + properties: + channelPowerDb: + type: number + format: double + description: Power of the samples being sent, in dB + channelSampleRate: + type: integer + format: int32 + description: Rate the frames are generated at, Hz + ifOffset: + type: integer + format: int32 + description: Signal centre within the channel before interpolation, Hz + transmitting: + type: integer + format: int32 + description: 1 while a transmission is being sent + queueLength: + type: integer + format: int32 + description: Transmissions waiting + framesSent: + type: integer + format: int64 + description: Frames sent since the channel started + transmissions: + type: integer + format: int64 + description: Transmissions completed since the channel started, each with its CW ID + airtime: + type: number + format: float + description: Seconds of transmissions sent since the channel started + lastDuration: + type: number + format: float + description: Length of the last transmission queued, in seconds + frameSeconds: + type: number + format: float + description: Time on air of one frame with the current settings and message, in seconds + maxBody: + type: integer + format: int32 + description: Longest body that fits one frame with the current callsigns, in bytes + lastEvent: + type: string + description: queued, started, sent, aborted or error + lastError: + type: string + description: Why the last request was refused or cut off, empty otherwise + warning: + type: string + description: A configuration that is allowed but needs attention, such as no CW ID in the licensed profile + +ChirpModemModActions: + description: ChirpModem modulator actions + type: object + properties: + tx: + type: integer + format: int32 + description: "1: transmit. Without src, dst or message, the settings' values are used" + enum: [0, 1] + src: + type: string + description: Source callsign for this transmission only + dst: + type: string + description: Destination callsign for this transmission only + message: + type: string + description: Body for this transmission only, sent as UTF-8 diff --git a/sdrbase/webapi/webapirequestmapper.cpp b/sdrbase/webapi/webapirequestmapper.cpp index 7f365e8b1..aed9421cf 100644 --- a/sdrbase/webapi/webapirequestmapper.cpp +++ b/sdrbase/webapi/webapirequestmapper.cpp @@ -5176,6 +5176,12 @@ bool WebAPIRequestMapper::getChannelSettings( channelSettings->getPacketModSettings()->init(); channelSettings->getPacketModSettings()->fromJsonObject(settingsJsonObject); } + else if (channelSettingsKey == "ChirpModemModSettings") + { + channelSettings->setChirpModemModSettings(new SWGSDRangel::SWGChirpModemModSettings()); + channelSettings->getChirpModemModSettings()->init(); + channelSettings->getChirpModemModSettings()->fromJsonObject(settingsJsonObject); + } else if (channelSettingsKey == "PagerDemodSettings") { channelSettings->setPagerDemodSettings(new SWGSDRangel::SWGPagerDemodSettings()); @@ -5388,6 +5394,11 @@ bool WebAPIRequestMapper::getChannelActions( channelActions->setPacketModActions(new SWGSDRangel::SWGPacketModActions()); channelActions->getPacketModActions()->fromJsonObject(actionsJsonObject); } + else if (channelActionsKey == "ChirpModemModActions") + { + channelActions->setChirpModemModActions(new SWGSDRangel::SWGChirpModemModActions()); + channelActions->getChirpModemModActions()->fromJsonObject(actionsJsonObject); + } else if (channelActionsKey == "PSK31ModActions") { channelActions->setPsk31ModActions(new SWGSDRangel::SWGPSK31ModActions()); @@ -6158,6 +6169,7 @@ void WebAPIRequestMapper::resetChannelSettings(SWGSDRangel::SWGChannelSettings& channelSettings.setNoiseFigureSettings(nullptr); channelSettings.setPacketDemodSettings(nullptr); channelSettings.setPacketModSettings(nullptr); + channelSettings.setChirpModemModSettings(nullptr); channelSettings.setPagerDemodSettings(nullptr); channelSettings.setPsk31ModSettings(nullptr); channelSettings.setRadioAstronomySettings(nullptr); @@ -6211,6 +6223,7 @@ void WebAPIRequestMapper::resetChannelReport(SWGSDRangel::SWGChannelReport& chan channelReport.setNoiseFigureReport(nullptr); channelReport.setIeee802154ModReport(nullptr); channelReport.setPacketModReport(nullptr); + channelReport.setChirpModemModReport(nullptr); channelReport.setPsk31ModReport(nullptr); channelReport.setRadioAstronomyReport(nullptr); channelReport.setRadioClockReport(nullptr); @@ -6240,6 +6253,7 @@ void WebAPIRequestMapper::resetChannelActions(SWGSDRangel::SWGChannelActions& ch channelActions.setFreqScannerActions(nullptr); channelActions.setIeee802154ModActions(nullptr); channelActions.setPacketModActions(nullptr); + channelActions.setChirpModemModActions(nullptr); channelActions.setPsk31ModActions(nullptr); channelActions.setRadioAstronomyActions(nullptr); channelActions.setRttyModActions(nullptr); diff --git a/sdrbase/webapi/webapiutils.cpp b/sdrbase/webapi/webapiutils.cpp index 978dc1b63..73d8aad10 100644 --- a/sdrbase/webapi/webapiutils.cpp +++ b/sdrbase/webapi/webapiutils.cpp @@ -78,6 +78,7 @@ const QMap WebAPIUtils::m_channelURIToSettingsKey = { {"sdrangel.channel.packetdemod", "PacketDemodSettings"}, {"sdrangel.channel.pagerdemod", "PagerDemodSettings"}, {"sdrangel.channeltx.modpacket", "PacketModSettings"}, + {"sdrangel.channeltx.modchirpmodem", "ChirpModemModSettings"}, {"sdrangel.channel.psk31mod", "PSK31ModSettings"}, {"sdrangel.channel.psk31demod", "PSK31DemodSettings"}, {"sdrangel.channelrx.demod802.15.4", "IEEE_802_15_4_DemodSettings"}, @@ -213,6 +214,7 @@ const QMap WebAPIUtils::m_channelTypeToSettingsKey = { {"NoiseFigure", "NoiseFigureSettings"}, {"PacketDemod", "PacketDemodSettings"}, {"PacketMod", "PacketModSettings"}, + {"ChirpModemMod", "ChirpModemModSettings"}, {"PagerDemod", "PagerDemodSettings"}, {"PSK31Mod", "PSK31ModSettings"}, {"PSK31Demod", "PSK31DemodSettings"}, @@ -255,6 +257,7 @@ const QMap WebAPIUtils::m_channelTypeToActionsKey = { {"IEEE_802_15_4_Mod", "IEEE_802_15_4_ModActions"}, {"RadioAstronomy", "RadioAstronomyActions"}, {"PacketMod", "PacketModActions"}, + {"ChirpModemMod", "ChirpModemModActions"}, {"PSK31Mod", "PSK31ModActions"}, {"RTTYMod", "RTTYModActions"} }; diff --git a/swagger/sdrangel/api/swagger/include/ChannelActions.yaml b/swagger/sdrangel/api/swagger/include/ChannelActions.yaml index a04fd1cce..438da7dd9 100644 --- a/swagger/sdrangel/api/swagger/include/ChannelActions.yaml +++ b/swagger/sdrangel/api/swagger/include/ChannelActions.yaml @@ -51,6 +51,8 @@ ChannelActions: description: "Meshcore mod actions configuration for Channel." PacketModActions: $ref: "http://swgserver:8081/api/swagger/include/PacketMod.yaml#/PacketModActions" + ChirpModemModActions: + $ref: "http://swgserver:8081/api/swagger/include/ChirpModemMod.yaml#/ChirpModemModActions" description: "Packet mod actions configuration for Channel." PSK31ModActions: $ref: "http://swgserver:8081/api/swagger/include/PSK31Mod.yaml#/PSK31ModActions" diff --git a/swagger/sdrangel/api/swagger/include/ChannelReport.yaml b/swagger/sdrangel/api/swagger/include/ChannelReport.yaml index f1b0d0918..c159b476d 100644 --- a/swagger/sdrangel/api/swagger/include/ChannelReport.yaml +++ b/swagger/sdrangel/api/swagger/include/ChannelReport.yaml @@ -173,6 +173,8 @@ ChannelReport: description: "Packet demod report data for Channel." PacketModReport: $ref: "http://swgserver:8081/api/swagger/include/PacketMod.yaml#/PacketModReport" + ChirpModemModReport: + $ref: "http://swgserver:8081/api/swagger/include/ChirpModemMod.yaml#/ChirpModemModReport" description: "Packet mod report data for Channel." PagerDemodReport: $ref: "http://swgserver:8081/api/swagger/include/PagerDemod.yaml#/PagerDemodReport" diff --git a/swagger/sdrangel/api/swagger/include/ChannelSettings.yaml b/swagger/sdrangel/api/swagger/include/ChannelSettings.yaml index aed593ea4..9569a83e8 100644 --- a/swagger/sdrangel/api/swagger/include/ChannelSettings.yaml +++ b/swagger/sdrangel/api/swagger/include/ChannelSettings.yaml @@ -177,6 +177,8 @@ ChannelSettings: description: "Packet demod settings configuration for Channel." PacketModSettings: $ref: "http://swgserver:8081/api/swagger/include/PacketMod.yaml#/PacketModSettings" + ChirpModemModSettings: + $ref: "http://swgserver:8081/api/swagger/include/ChirpModemMod.yaml#/ChirpModemModSettings" description: "Packet mod settings configuration for Channel." PagerDemodSettings: $ref: "http://swgserver:8081/api/swagger/include/PagerDemod.yaml#/PagerDemodSettings" diff --git a/swagger/sdrangel/api/swagger/include/ChirpModemMod.yaml b/swagger/sdrangel/api/swagger/include/ChirpModemMod.yaml new file mode 100644 index 000000000..f2a85b328 --- /dev/null +++ b/swagger/sdrangel/api/swagger/include/ChirpModemMod.yaml @@ -0,0 +1,181 @@ +ChirpModemModSettings: + description: ChirpModem modulator settings (libchirpmodem transmitter, 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 + mode: + type: integer + format: int32 + description: "Payload mode: -1 auto (non-coherent at SF >= 10 or BW <= 62.5 kHz), 0 non-coherent, 1 coherent" + default: -1 + enum: [-1, 0, 1] + profile: + type: integer + format: int32 + description: "0 licensed (amateur: source callsign required, no encryption), 1 unlicensed (ISM)" + default: 0 + enum: [0, 1] + source: + type: string + description: Source callsign (A-Z 0-9 - / ., at most 9 characters). Required by the licensed profile + destination: + type: string + description: Destination callsign, empty for none + message: + type: string + description: Body, sent as UTF-8 + repeat: + type: integer + format: int32 + description: Frames per transmission + default: 1 + minimum: 1 + maximum: 1000 + gap: + type: number + format: float + description: Silence between frames and before the CW ID, in seconds + default: 0.5 + minimum: 0 + maximum: 60 + amplitude: + type: number + format: float + description: Peak amplitude, 0 to 1 of full scale + default: 0.7 + minimum: 0 + maximum: 1 + cwId: + type: integer + format: int32 + description: Send "DE " in Morse after each transmission (47 CFR 97.119). Turning it off in the licensed profile is reported as a warning + default: 1 + enum: [0, 1] + cwWpm: + type: integer + format: int32 + description: CW ID speed in words per minute, at most 20 (47 CFR 97.119(b)(1)) + default: 20 + minimum: 5 + maximum: 20 + rgbColor: + type: integer + format: int32 + title: + type: string + streamIndex: + type: integer + format: int32 + description: MIMO channel. Not relevant when connected to SO (single Tx). + 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" + +ChirpModemModReport: + description: ChirpModem modulator report + type: object + properties: + channelPowerDb: + type: number + format: double + description: Power of the samples being sent, in dB + channelSampleRate: + type: integer + format: int32 + description: Rate the frames are generated at, Hz + ifOffset: + type: integer + format: int32 + description: Signal centre within the channel before interpolation, Hz + transmitting: + type: integer + format: int32 + description: 1 while a transmission is being sent + queueLength: + type: integer + format: int32 + description: Transmissions waiting + framesSent: + type: integer + format: int64 + description: Frames sent since the channel started + transmissions: + type: integer + format: int64 + description: Transmissions completed since the channel started, each with its CW ID + airtime: + type: number + format: float + description: Seconds of transmissions sent since the channel started + lastDuration: + type: number + format: float + description: Length of the last transmission queued, in seconds + frameSeconds: + type: number + format: float + description: Time on air of one frame with the current settings and message, in seconds + maxBody: + type: integer + format: int32 + description: Longest body that fits one frame with the current callsigns, in bytes + lastEvent: + type: string + description: queued, started, sent, aborted or error + lastError: + type: string + description: Why the last request was refused or cut off, empty otherwise + warning: + type: string + description: A configuration that is allowed but needs attention, such as no CW ID in the licensed profile + +ChirpModemModActions: + description: ChirpModem modulator actions + type: object + properties: + tx: + type: integer + format: int32 + description: "1: transmit. Without src, dst or message, the settings' values are used" + enum: [0, 1] + src: + type: string + description: Source callsign for this transmission only + dst: + type: string + description: Destination callsign for this transmission only + message: + type: string + description: Body for this transmission only, sent as UTF-8 diff --git a/swagger/sdrangel/code/qt5/client/SWGChannelActions.cpp b/swagger/sdrangel/code/qt5/client/SWGChannelActions.cpp index a83ff108b..c1425e604 100644 --- a/swagger/sdrangel/code/qt5/client/SWGChannelActions.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGChannelActions.cpp @@ -57,7 +57,9 @@ SWGChannelActions::SWGChannelActions() { meshcore_mod_actions = nullptr; m_meshcore_mod_actions_isSet = false; packet_mod_actions = nullptr; + chirpmodem_mod_actions = nullptr; m_packet_mod_actions_isSet = false; + m_chirpmodem_mod_actions_isSet = false; psk31_mod_actions = nullptr; m_psk31_mod_actions_isSet = false; radio_astronomy_actions = nullptr; @@ -103,7 +105,9 @@ SWGChannelActions::init() { meshcore_mod_actions = new SWGMeshcoreModActions(); m_meshcore_mod_actions_isSet = false; packet_mod_actions = new SWGPacketModActions(); + chirpmodem_mod_actions = new SWGChirpModemModActions(); m_packet_mod_actions_isSet = false; + m_chirpmodem_mod_actions_isSet = false; psk31_mod_actions = new SWGPSK31ModActions(); m_psk31_mod_actions_isSet = false; radio_astronomy_actions = new SWGRadioAstronomyActions(); @@ -155,6 +159,9 @@ SWGChannelActions::cleanup() { if(packet_mod_actions != nullptr) { delete packet_mod_actions; } + if(chirpmodem_mod_actions != nullptr) { + delete chirpmodem_mod_actions; + } if(psk31_mod_actions != nullptr) { delete psk31_mod_actions; } @@ -209,6 +216,7 @@ SWGChannelActions::fromJsonObject(QJsonObject &pJson) { ::SWGSDRangel::setValue(&meshcore_mod_actions, pJson["MeshcoreModActions"], "SWGMeshcoreModActions", "SWGMeshcoreModActions"); ::SWGSDRangel::setValue(&packet_mod_actions, pJson["PacketModActions"], "SWGPacketModActions", "SWGPacketModActions"); + ::SWGSDRangel::setValue(&chirpmodem_mod_actions, pJson["ChirpModemModActions"], "SWGChirpModemModActions", "SWGChirpModemModActions"); ::SWGSDRangel::setValue(&psk31_mod_actions, pJson["PSK31ModActions"], "SWGPSK31ModActions", "SWGPSK31ModActions"); @@ -279,6 +287,9 @@ SWGChannelActions::asJsonObject() { if((packet_mod_actions != nullptr) && (packet_mod_actions->isSet())){ toJsonValue(QString("PacketModActions"), packet_mod_actions, obj, QString("SWGPacketModActions")); } + if((chirpmodem_mod_actions != nullptr) && (chirpmodem_mod_actions->isSet())){ + toJsonValue(QString("ChirpModemModActions"), chirpmodem_mod_actions, obj, QString("SWGChirpModemModActions")); + } if((psk31_mod_actions != nullptr) && (psk31_mod_actions->isSet())){ toJsonValue(QString("PSK31ModActions"), psk31_mod_actions, obj, QString("SWGPSK31ModActions")); } @@ -439,11 +450,20 @@ SWGPacketModActions* SWGChannelActions::getPacketModActions() { return packet_mod_actions; } +SWGChirpModemModActions* +SWGChannelActions::getChirpModemModActions() { + return chirpmodem_mod_actions; +} void SWGChannelActions::setPacketModActions(SWGPacketModActions* packet_mod_actions) { this->packet_mod_actions = packet_mod_actions; this->m_packet_mod_actions_isSet = true; } +void +SWGChannelActions::setChirpModemModActions(SWGChirpModemModActions* chirpmodem_mod_actions) { + this->chirpmodem_mod_actions = chirpmodem_mod_actions; + this->m_chirpmodem_mod_actions_isSet = true; +} SWGPSK31ModActions* SWGChannelActions::getPsk31ModActions() { @@ -535,6 +555,9 @@ SWGChannelActions::isSet(){ if(packet_mod_actions && packet_mod_actions->isSet()){ isObjectUpdated = true; break; } + if(chirpmodem_mod_actions && chirpmodem_mod_actions->isSet()){ + isObjectUpdated = true; break; + } if(psk31_mod_actions && psk31_mod_actions->isSet()){ isObjectUpdated = true; break; } diff --git a/swagger/sdrangel/code/qt5/client/SWGChannelActions.h b/swagger/sdrangel/code/qt5/client/SWGChannelActions.h index c936c3832..85e962b7b 100644 --- a/swagger/sdrangel/code/qt5/client/SWGChannelActions.h +++ b/swagger/sdrangel/code/qt5/client/SWGChannelActions.h @@ -34,6 +34,7 @@ #include "SWGMeshcoreModActions.h" #include "SWGPSK31ModActions.h" #include "SWGPacketModActions.h" +#include "SWGChirpModemModActions.h" #include "SWGRTTYModActions.h" #include "SWGRadioAstronomyActions.h" #include "SWGSigMFFileSinkActions.h" @@ -100,7 +101,9 @@ public: void setMeshcoreModActions(SWGMeshcoreModActions* meshcore_mod_actions); SWGPacketModActions* getPacketModActions(); + SWGChirpModemModActions* getChirpModemModActions(); void setPacketModActions(SWGPacketModActions* packet_mod_actions); + void setChirpModemModActions(SWGChirpModemModActions* chirpmodem_mod_actions); SWGPSK31ModActions* getPsk31ModActions(); void setPsk31ModActions(SWGPSK31ModActions* psk31_mod_actions); @@ -161,7 +164,9 @@ private: bool m_meshcore_mod_actions_isSet; SWGPacketModActions* packet_mod_actions; + SWGChirpModemModActions* chirpmodem_mod_actions; bool m_packet_mod_actions_isSet; + bool m_chirpmodem_mod_actions_isSet; SWGPSK31ModActions* psk31_mod_actions; bool m_psk31_mod_actions_isSet; diff --git a/swagger/sdrangel/code/qt5/client/SWGChannelReport.cpp b/swagger/sdrangel/code/qt5/client/SWGChannelReport.cpp index e5737d86b..a8f210363 100644 --- a/swagger/sdrangel/code/qt5/client/SWGChannelReport.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGChannelReport.cpp @@ -145,7 +145,9 @@ SWGChannelReport::SWGChannelReport() { packet_demod_report = nullptr; m_packet_demod_report_isSet = false; packet_mod_report = nullptr; + chirpmodem_mod_report = nullptr; m_packet_mod_report_isSet = false; + m_chirpmodem_mod_report_isSet = false; pager_demod_report = nullptr; m_pager_demod_report_isSet = false; psk31_mod_report = nullptr; @@ -295,7 +297,9 @@ SWGChannelReport::init() { packet_demod_report = new SWGPacketDemodReport(); m_packet_demod_report_isSet = false; packet_mod_report = new SWGPacketModReport(); + chirpmodem_mod_report = new SWGChirpModemModReport(); m_packet_mod_report_isSet = false; + m_chirpmodem_mod_report_isSet = false; pager_demod_report = new SWGPagerDemodReport(); m_pager_demod_report_isSet = false; psk31_mod_report = new SWGPSK31ModReport(); @@ -498,6 +502,9 @@ SWGChannelReport::cleanup() { if(packet_mod_report != nullptr) { delete packet_mod_report; } + if(chirpmodem_mod_report != nullptr) { + delete chirpmodem_mod_report; + } if(pager_demod_report != nullptr) { delete pager_demod_report; } @@ -655,6 +662,7 @@ SWGChannelReport::fromJsonObject(QJsonObject &pJson) { ::SWGSDRangel::setValue(&packet_demod_report, pJson["PacketDemodReport"], "SWGPacketDemodReport", "SWGPacketDemodReport"); ::SWGSDRangel::setValue(&packet_mod_report, pJson["PacketModReport"], "SWGPacketModReport", "SWGPacketModReport"); + ::SWGSDRangel::setValue(&chirpmodem_mod_report, pJson["ChirpModemModReport"], "SWGChirpModemModReport", "SWGChirpModemModReport"); ::SWGSDRangel::setValue(&pager_demod_report, pJson["PagerDemodReport"], "SWGPagerDemodReport", "SWGPagerDemodReport"); @@ -872,6 +880,9 @@ SWGChannelReport::asJsonObject() { if((packet_mod_report != nullptr) && (packet_mod_report->isSet())){ toJsonValue(QString("PacketModReport"), packet_mod_report, obj, QString("SWGPacketModReport")); } + if((chirpmodem_mod_report != nullptr) && (chirpmodem_mod_report->isSet())){ + toJsonValue(QString("ChirpModemModReport"), chirpmodem_mod_report, obj, QString("SWGChirpModemModReport")); + } if((pager_demod_report != nullptr) && (pager_demod_report->isSet())){ toJsonValue(QString("PagerDemodReport"), pager_demod_report, obj, QString("SWGPagerDemodReport")); } @@ -1505,11 +1516,20 @@ SWGPacketModReport* SWGChannelReport::getPacketModReport() { return packet_mod_report; } +SWGChirpModemModReport* +SWGChannelReport::getChirpModemModReport() { + return chirpmodem_mod_report; +} void SWGChannelReport::setPacketModReport(SWGPacketModReport* packet_mod_report) { this->packet_mod_report = packet_mod_report; this->m_packet_mod_report_isSet = true; } +void +SWGChannelReport::setChirpModemModReport(SWGChirpModemModReport* chirpmodem_mod_report) { + this->chirpmodem_mod_report = chirpmodem_mod_report; + this->m_chirpmodem_mod_report_isSet = true; +} SWGPagerDemodReport* SWGChannelReport::getPagerDemodReport() { @@ -1793,6 +1813,9 @@ SWGChannelReport::isSet(){ if(packet_mod_report && packet_mod_report->isSet()){ isObjectUpdated = true; break; } + if(chirpmodem_mod_report && chirpmodem_mod_report->isSet()){ + isObjectUpdated = true; break; + } if(pager_demod_report && pager_demod_report->isSet()){ isObjectUpdated = true; break; } diff --git a/swagger/sdrangel/code/qt5/client/SWGChannelReport.h b/swagger/sdrangel/code/qt5/client/SWGChannelReport.h index a93d21db0..d603801d4 100644 --- a/swagger/sdrangel/code/qt5/client/SWGChannelReport.h +++ b/swagger/sdrangel/code/qt5/client/SWGChannelReport.h @@ -73,6 +73,7 @@ #include "SWGPSK31ModReport.h" #include "SWGPacketDemodReport.h" #include "SWGPacketModReport.h" +#include "SWGChirpModemModReport.h" #include "SWGPagerDemodReport.h" #include "SWGRTTYDemodReport.h" #include "SWGPSK31DemodReport.h" @@ -286,7 +287,9 @@ public: void setPacketDemodReport(SWGPacketDemodReport* packet_demod_report); SWGPacketModReport* getPacketModReport(); + SWGChirpModemModReport* getChirpModemModReport(); void setPacketModReport(SWGPacketModReport* packet_mod_report); + void setChirpModemModReport(SWGChirpModemModReport* chirpmodem_mod_report); SWGPagerDemodReport* getPagerDemodReport(); void setPagerDemodReport(SWGPagerDemodReport* pager_demod_report); @@ -498,7 +501,9 @@ private: bool m_packet_demod_report_isSet; SWGPacketModReport* packet_mod_report; + SWGChirpModemModReport* chirpmodem_mod_report; bool m_packet_mod_report_isSet; + bool m_chirpmodem_mod_report_isSet; SWGPagerDemodReport* pager_demod_report; bool m_pager_demod_report_isSet; diff --git a/swagger/sdrangel/code/qt5/client/SWGChannelSettings.cpp b/swagger/sdrangel/code/qt5/client/SWGChannelSettings.cpp index f33ae3457..eb7694106 100644 --- a/swagger/sdrangel/code/qt5/client/SWGChannelSettings.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGChannelSettings.cpp @@ -147,7 +147,9 @@ SWGChannelSettings::SWGChannelSettings() { packet_demod_settings = nullptr; m_packet_demod_settings_isSet = false; packet_mod_settings = nullptr; + chirpmodem_mod_settings = nullptr; m_packet_mod_settings_isSet = false; + m_chirpmodem_mod_settings_isSet = false; pager_demod_settings = nullptr; m_pager_demod_settings_isSet = false; psk31_mod_settings = nullptr; @@ -315,7 +317,9 @@ SWGChannelSettings::init() { packet_demod_settings = new SWGPacketDemodSettings(); m_packet_demod_settings_isSet = false; packet_mod_settings = new SWGPacketModSettings(); + chirpmodem_mod_settings = new SWGChirpModemModSettings(); m_packet_mod_settings_isSet = false; + m_chirpmodem_mod_settings_isSet = false; pager_demod_settings = new SWGPagerDemodSettings(); m_pager_demod_settings_isSet = false; psk31_mod_settings = new SWGPSK31ModSettings(); @@ -534,6 +538,9 @@ SWGChannelSettings::cleanup() { if(packet_mod_settings != nullptr) { delete packet_mod_settings; } + if(chirpmodem_mod_settings != nullptr) { + delete chirpmodem_mod_settings; + } if(pager_demod_settings != nullptr) { delete pager_demod_settings; } @@ -722,6 +729,7 @@ SWGChannelSettings::fromJsonObject(QJsonObject &pJson) { ::SWGSDRangel::setValue(&packet_demod_settings, pJson["PacketDemodSettings"], "SWGPacketDemodSettings", "SWGPacketDemodSettings"); ::SWGSDRangel::setValue(&packet_mod_settings, pJson["PacketModSettings"], "SWGPacketModSettings", "SWGPacketModSettings"); + ::SWGSDRangel::setValue(&chirpmodem_mod_settings, pJson["ChirpModemModSettings"], "SWGChirpModemModSettings", "SWGChirpModemModSettings"); ::SWGSDRangel::setValue(&pager_demod_settings, pJson["PagerDemodSettings"], "SWGPagerDemodSettings", "SWGPagerDemodSettings"); @@ -958,6 +966,9 @@ SWGChannelSettings::asJsonObject() { if((packet_mod_settings != nullptr) && (packet_mod_settings->isSet())){ toJsonValue(QString("PacketModSettings"), packet_mod_settings, obj, QString("SWGPacketModSettings")); } + if((chirpmodem_mod_settings != nullptr) && (chirpmodem_mod_settings->isSet())){ + toJsonValue(QString("ChirpModemModSettings"), chirpmodem_mod_settings, obj, QString("SWGChirpModemModSettings")); + } if((pager_demod_settings != nullptr) && (pager_demod_settings->isSet())){ toJsonValue(QString("PagerDemodSettings"), pager_demod_settings, obj, QString("SWGPagerDemodSettings")); } @@ -1621,11 +1632,20 @@ SWGPacketModSettings* SWGChannelSettings::getPacketModSettings() { return packet_mod_settings; } +SWGChirpModemModSettings* +SWGChannelSettings::getChirpModemModSettings() { + return chirpmodem_mod_settings; +} void SWGChannelSettings::setPacketModSettings(SWGPacketModSettings* packet_mod_settings) { this->packet_mod_settings = packet_mod_settings; this->m_packet_mod_settings_isSet = true; } +void +SWGChannelSettings::setChirpModemModSettings(SWGChirpModemModSettings* chirpmodem_mod_settings) { + this->chirpmodem_mod_settings = chirpmodem_mod_settings; + this->m_chirpmodem_mod_settings_isSet = true; +} SWGPagerDemodSettings* SWGChannelSettings::getPagerDemodSettings() { @@ -2012,6 +2032,9 @@ SWGChannelSettings::isSet(){ if(packet_mod_settings && packet_mod_settings->isSet()){ isObjectUpdated = true; break; } + if(chirpmodem_mod_settings && chirpmodem_mod_settings->isSet()){ + isObjectUpdated = true; break; + } if(pager_demod_settings && pager_demod_settings->isSet()){ isObjectUpdated = true; break; } diff --git a/swagger/sdrangel/code/qt5/client/SWGChannelSettings.h b/swagger/sdrangel/code/qt5/client/SWGChannelSettings.h index 0a567981e..782a737de 100644 --- a/swagger/sdrangel/code/qt5/client/SWGChannelSettings.h +++ b/swagger/sdrangel/code/qt5/client/SWGChannelSettings.h @@ -79,6 +79,7 @@ #include "SWGPSK31ModSettings.h" #include "SWGPacketDemodSettings.h" #include "SWGPacketModSettings.h" +#include "SWGChirpModemModSettings.h" #include "SWGPagerDemodSettings.h" #include "SWGRTTYDemodSettings.h" #include "SWGPSK31DemodSettings.h" @@ -294,7 +295,9 @@ public: void setPacketDemodSettings(SWGPacketDemodSettings* packet_demod_settings); SWGPacketModSettings* getPacketModSettings(); + SWGChirpModemModSettings* getChirpModemModSettings(); void setPacketModSettings(SWGPacketModSettings* packet_mod_settings); + void setChirpModemModSettings(SWGChirpModemModSettings* chirpmodem_mod_settings); SWGPagerDemodSettings* getPagerDemodSettings(); void setPagerDemodSettings(SWGPagerDemodSettings* pager_demod_settings); @@ -536,7 +539,9 @@ private: bool m_packet_demod_settings_isSet; SWGPacketModSettings* packet_mod_settings; + SWGChirpModemModSettings* chirpmodem_mod_settings; bool m_packet_mod_settings_isSet; + bool m_chirpmodem_mod_settings_isSet; SWGPagerDemodSettings* pager_demod_settings; bool m_pager_demod_settings_isSet; diff --git a/swagger/sdrangel/code/qt5/client/SWGChirpModemModActions.cpp b/swagger/sdrangel/code/qt5/client/SWGChirpModemModActions.cpp new file mode 100644 index 000000000..7287141ea --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGChirpModemModActions.cpp @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Generated by gen_swg_models.py from ChirpModemMod.yaml: edit the YAML, not this file. +#include "SWGChirpModemModActions.h" +#include "SWGHelpers.h" + +#include + +namespace SWGSDRangel { + +SWGChirpModemModActions::SWGChirpModemModActions() = default; +SWGChirpModemModActions::SWGChirpModemModActions(QString* json) { init(); if (json) { fromJson(*json); } } +SWGChirpModemModActions::~SWGChirpModemModActions() { cleanup(); } + +void SWGChirpModemModActions::cleanup() +{ + delete m_src; m_src = nullptr; + delete m_dst; m_dst = nullptr; + delete m_message; m_message = nullptr; +} + +void SWGChirpModemModActions::init() +{ + cleanup(); + m_tx = 0; m_txIsSet = false; + m_src = new QString(); m_srcIsSet = false; + m_dst = new QString(); m_dstIsSet = false; + m_message = new QString(); m_messageIsSet = false; +} + +SWGChirpModemModActions* SWGChirpModemModActions::fromJson(QString& json) +{ + auto object = QJsonDocument::fromJson(json.toUtf8()).object(); fromJsonObject(object); return this; +} + +void SWGChirpModemModActions::fromJsonObject(QJsonObject& json) +{ + if (json.contains("tx")) { ::SWGSDRangel::setValue(&m_tx,json["tx"],"qint32",""); m_txIsSet = true; } + if (json.contains("src")) { ::SWGSDRangel::setValue(&m_src,json["src"],"QString","QString"); m_srcIsSet = true; } + if (json.contains("dst")) { ::SWGSDRangel::setValue(&m_dst,json["dst"],"QString","QString"); m_dstIsSet = true; } + if (json.contains("message")) { ::SWGSDRangel::setValue(&m_message,json["message"],"QString","QString"); m_messageIsSet = true; } +} + +QString SWGChirpModemModActions::asJson() +{ + auto* object = asJsonObject(); QString result = QJsonDocument(*object).toJson(); delete object; return result; +} + +QJsonObject* SWGChirpModemModActions::asJsonObject() +{ + auto* object = new QJsonObject(); + if (m_txIsSet) { object->insert("tx",QJsonValue(m_tx)); } + if (m_src && (m_srcIsSet || !m_src->isEmpty())) { toJsonValue(QString("src"),m_src,object,QString("QString")); } + if (m_dst && (m_dstIsSet || !m_dst->isEmpty())) { toJsonValue(QString("dst"),m_dst,object,QString("QString")); } + if (m_message && (m_messageIsSet || !m_message->isEmpty())) { toJsonValue(QString("message"),m_message,object,QString("QString")); } + return object; +} + +bool SWGChirpModemModActions::isSet() +{ + return m_txIsSet || m_srcIsSet || m_dstIsSet || m_messageIsSet; +} + +qint32 SWGChirpModemModActions::getTx() { return m_tx; } +void SWGChirpModemModActions::setTx(qint32 value) { m_tx = value; m_txIsSet = true; } +QString* SWGChirpModemModActions::getSrc() { return m_src; } +void SWGChirpModemModActions::setSrc(QString* value) { if (m_src != value) { delete m_src; m_src = value; } m_srcIsSet = true; } +QString* SWGChirpModemModActions::getDst() { return m_dst; } +void SWGChirpModemModActions::setDst(QString* value) { if (m_dst != value) { delete m_dst; m_dst = value; } m_dstIsSet = true; } +QString* SWGChirpModemModActions::getMessage() { return m_message; } +void SWGChirpModemModActions::setMessage(QString* value) { if (m_message != value) { delete m_message; m_message = value; } m_messageIsSet = true; } + +} diff --git a/swagger/sdrangel/code/qt5/client/SWGChirpModemModActions.h b/swagger/sdrangel/code/qt5/client/SWGChirpModemModActions.h new file mode 100644 index 000000000..4775bba59 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGChirpModemModActions.h @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Qt model for ChirpModemMod.yaml, following the Swagger client model interface. +// Generated by gen_swg_models.py: edit the YAML, not this file. +#ifndef SWGChirpModemModActions_H_ +#define SWGChirpModemModActions_H_ + +#include +#include + +#include "SWGObject.h" +#include "export.h" + +namespace SWGSDRangel { + +class SWG_API SWGChirpModemModActions : public SWGObject { +public: + SWGChirpModemModActions(); + explicit SWGChirpModemModActions(QString* json); + ~SWGChirpModemModActions() override; + void init(); + void cleanup(); + QString asJson() override; + QJsonObject* asJsonObject() override; + void fromJsonObject(QJsonObject& json) override; + SWGChirpModemModActions* fromJson(QString& json) override; + bool isSet() override; + + qint32 getTx(); + void setTx(qint32 value); + QString* getSrc(); + void setSrc(QString* value); + QString* getDst(); + void setDst(QString* value); + QString* getMessage(); + void setMessage(QString* value); + +private: + qint32 m_tx = 0; + bool m_txIsSet = false; + QString* m_src = nullptr; + bool m_srcIsSet = false; + QString* m_dst = nullptr; + bool m_dstIsSet = false; + QString* m_message = nullptr; + bool m_messageIsSet = false; +}; + +} + +#endif diff --git a/swagger/sdrangel/code/qt5/client/SWGChirpModemModReport.cpp b/swagger/sdrangel/code/qt5/client/SWGChirpModemModReport.cpp new file mode 100644 index 000000000..db699b575 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGChirpModemModReport.cpp @@ -0,0 +1,122 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Generated by gen_swg_models.py from ChirpModemMod.yaml: edit the YAML, not this file. +#include "SWGChirpModemModReport.h" +#include "SWGHelpers.h" + +#include + +namespace SWGSDRangel { + +SWGChirpModemModReport::SWGChirpModemModReport() = default; +SWGChirpModemModReport::SWGChirpModemModReport(QString* json) { init(); if (json) { fromJson(*json); } } +SWGChirpModemModReport::~SWGChirpModemModReport() { cleanup(); } + +void SWGChirpModemModReport::cleanup() +{ + delete m_lastEvent; m_lastEvent = nullptr; + delete m_lastError; m_lastError = nullptr; + delete m_warning; m_warning = nullptr; +} + +void SWGChirpModemModReport::init() +{ + cleanup(); + m_channelPowerDb = 0; m_channelPowerDbIsSet = false; + m_channelSampleRate = 0; m_channelSampleRateIsSet = false; + m_ifOffset = 0; m_ifOffsetIsSet = false; + m_transmitting = 0; m_transmittingIsSet = false; + m_queueLength = 0; m_queueLengthIsSet = false; + m_framesSent = 0; m_framesSentIsSet = false; + m_transmissions = 0; m_transmissionsIsSet = false; + m_airtime = 0; m_airtimeIsSet = false; + m_lastDuration = 0; m_lastDurationIsSet = false; + m_frameSeconds = 0; m_frameSecondsIsSet = false; + m_maxBody = 0; m_maxBodyIsSet = false; + m_lastEvent = new QString(); m_lastEventIsSet = false; + m_lastError = new QString(); m_lastErrorIsSet = false; + m_warning = new QString(); m_warningIsSet = false; +} + +SWGChirpModemModReport* SWGChirpModemModReport::fromJson(QString& json) +{ + auto object = QJsonDocument::fromJson(json.toUtf8()).object(); fromJsonObject(object); return this; +} + +void SWGChirpModemModReport::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("transmitting")) { ::SWGSDRangel::setValue(&m_transmitting,json["transmitting"],"qint32",""); m_transmittingIsSet = true; } + if (json.contains("queueLength")) { ::SWGSDRangel::setValue(&m_queueLength,json["queueLength"],"qint32",""); m_queueLengthIsSet = true; } + if (json.contains("framesSent")) { ::SWGSDRangel::setValue(&m_framesSent,json["framesSent"],"qint64",""); m_framesSentIsSet = true; } + if (json.contains("transmissions")) { ::SWGSDRangel::setValue(&m_transmissions,json["transmissions"],"qint64",""); m_transmissionsIsSet = true; } + if (json.contains("airtime")) { ::SWGSDRangel::setValue(&m_airtime,json["airtime"],"float",""); m_airtimeIsSet = true; } + if (json.contains("lastDuration")) { ::SWGSDRangel::setValue(&m_lastDuration,json["lastDuration"],"float",""); m_lastDurationIsSet = true; } + if (json.contains("frameSeconds")) { ::SWGSDRangel::setValue(&m_frameSeconds,json["frameSeconds"],"float",""); m_frameSecondsIsSet = true; } + if (json.contains("maxBody")) { ::SWGSDRangel::setValue(&m_maxBody,json["maxBody"],"qint32",""); m_maxBodyIsSet = true; } + if (json.contains("lastEvent")) { ::SWGSDRangel::setValue(&m_lastEvent,json["lastEvent"],"QString","QString"); m_lastEventIsSet = true; } + if (json.contains("lastError")) { ::SWGSDRangel::setValue(&m_lastError,json["lastError"],"QString","QString"); m_lastErrorIsSet = true; } + if (json.contains("warning")) { ::SWGSDRangel::setValue(&m_warning,json["warning"],"QString","QString"); m_warningIsSet = true; } +} + +QString SWGChirpModemModReport::asJson() +{ + auto* object = asJsonObject(); QString result = QJsonDocument(*object).toJson(); delete object; return result; +} + +QJsonObject* SWGChirpModemModReport::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_transmittingIsSet) { object->insert("transmitting",QJsonValue(m_transmitting)); } + if (m_queueLengthIsSet) { object->insert("queueLength",QJsonValue(m_queueLength)); } + if (m_framesSentIsSet) { object->insert("framesSent",QJsonValue(m_framesSent)); } + if (m_transmissionsIsSet) { object->insert("transmissions",QJsonValue(m_transmissions)); } + if (m_airtimeIsSet) { object->insert("airtime",QJsonValue(m_airtime)); } + if (m_lastDurationIsSet) { object->insert("lastDuration",QJsonValue(m_lastDuration)); } + if (m_frameSecondsIsSet) { object->insert("frameSeconds",QJsonValue(m_frameSeconds)); } + if (m_maxBodyIsSet) { object->insert("maxBody",QJsonValue(m_maxBody)); } + if (m_lastEvent && (m_lastEventIsSet || !m_lastEvent->isEmpty())) { toJsonValue(QString("lastEvent"),m_lastEvent,object,QString("QString")); } + if (m_lastError && (m_lastErrorIsSet || !m_lastError->isEmpty())) { toJsonValue(QString("lastError"),m_lastError,object,QString("QString")); } + if (m_warning && (m_warningIsSet || !m_warning->isEmpty())) { toJsonValue(QString("warning"),m_warning,object,QString("QString")); } + return object; +} + +bool SWGChirpModemModReport::isSet() +{ + return m_channelPowerDbIsSet || m_channelSampleRateIsSet || m_ifOffsetIsSet || m_transmittingIsSet || m_queueLengthIsSet || m_framesSentIsSet || m_transmissionsIsSet || m_airtimeIsSet || m_lastDurationIsSet || m_frameSecondsIsSet || m_maxBodyIsSet || m_lastEventIsSet || m_lastErrorIsSet || m_warningIsSet; +} + +double SWGChirpModemModReport::getChannelPowerDb() { return m_channelPowerDb; } +void SWGChirpModemModReport::setChannelPowerDb(double value) { m_channelPowerDb = value; m_channelPowerDbIsSet = true; } +qint32 SWGChirpModemModReport::getChannelSampleRate() { return m_channelSampleRate; } +void SWGChirpModemModReport::setChannelSampleRate(qint32 value) { m_channelSampleRate = value; m_channelSampleRateIsSet = true; } +qint32 SWGChirpModemModReport::getIfOffset() { return m_ifOffset; } +void SWGChirpModemModReport::setIfOffset(qint32 value) { m_ifOffset = value; m_ifOffsetIsSet = true; } +qint32 SWGChirpModemModReport::getTransmitting() { return m_transmitting; } +void SWGChirpModemModReport::setTransmitting(qint32 value) { m_transmitting = value; m_transmittingIsSet = true; } +qint32 SWGChirpModemModReport::getQueueLength() { return m_queueLength; } +void SWGChirpModemModReport::setQueueLength(qint32 value) { m_queueLength = value; m_queueLengthIsSet = true; } +qint64 SWGChirpModemModReport::getFramesSent() { return m_framesSent; } +void SWGChirpModemModReport::setFramesSent(qint64 value) { m_framesSent = value; m_framesSentIsSet = true; } +qint64 SWGChirpModemModReport::getTransmissions() { return m_transmissions; } +void SWGChirpModemModReport::setTransmissions(qint64 value) { m_transmissions = value; m_transmissionsIsSet = true; } +float SWGChirpModemModReport::getAirtime() { return m_airtime; } +void SWGChirpModemModReport::setAirtime(float value) { m_airtime = value; m_airtimeIsSet = true; } +float SWGChirpModemModReport::getLastDuration() { return m_lastDuration; } +void SWGChirpModemModReport::setLastDuration(float value) { m_lastDuration = value; m_lastDurationIsSet = true; } +float SWGChirpModemModReport::getFrameSeconds() { return m_frameSeconds; } +void SWGChirpModemModReport::setFrameSeconds(float value) { m_frameSeconds = value; m_frameSecondsIsSet = true; } +qint32 SWGChirpModemModReport::getMaxBody() { return m_maxBody; } +void SWGChirpModemModReport::setMaxBody(qint32 value) { m_maxBody = value; m_maxBodyIsSet = true; } +QString* SWGChirpModemModReport::getLastEvent() { return m_lastEvent; } +void SWGChirpModemModReport::setLastEvent(QString* value) { if (m_lastEvent != value) { delete m_lastEvent; m_lastEvent = value; } m_lastEventIsSet = true; } +QString* SWGChirpModemModReport::getLastError() { return m_lastError; } +void SWGChirpModemModReport::setLastError(QString* value) { if (m_lastError != value) { delete m_lastError; m_lastError = value; } m_lastErrorIsSet = true; } +QString* SWGChirpModemModReport::getWarning() { return m_warning; } +void SWGChirpModemModReport::setWarning(QString* value) { if (m_warning != value) { delete m_warning; m_warning = value; } m_warningIsSet = true; } + +} diff --git a/swagger/sdrangel/code/qt5/client/SWGChirpModemModReport.h b/swagger/sdrangel/code/qt5/client/SWGChirpModemModReport.h new file mode 100644 index 000000000..0075a903b --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGChirpModemModReport.h @@ -0,0 +1,90 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Qt model for ChirpModemMod.yaml, following the Swagger client model interface. +// Generated by gen_swg_models.py: edit the YAML, not this file. +#ifndef SWGChirpModemModReport_H_ +#define SWGChirpModemModReport_H_ + +#include +#include + +#include "SWGObject.h" +#include "export.h" + +namespace SWGSDRangel { + +class SWG_API SWGChirpModemModReport : public SWGObject { +public: + SWGChirpModemModReport(); + explicit SWGChirpModemModReport(QString* json); + ~SWGChirpModemModReport() override; + void init(); + void cleanup(); + QString asJson() override; + QJsonObject* asJsonObject() override; + void fromJsonObject(QJsonObject& json) override; + SWGChirpModemModReport* 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); + qint32 getTransmitting(); + void setTransmitting(qint32 value); + qint32 getQueueLength(); + void setQueueLength(qint32 value); + qint64 getFramesSent(); + void setFramesSent(qint64 value); + qint64 getTransmissions(); + void setTransmissions(qint64 value); + float getAirtime(); + void setAirtime(float value); + float getLastDuration(); + void setLastDuration(float value); + float getFrameSeconds(); + void setFrameSeconds(float value); + qint32 getMaxBody(); + void setMaxBody(qint32 value); + QString* getLastEvent(); + void setLastEvent(QString* value); + QString* getLastError(); + void setLastError(QString* value); + QString* getWarning(); + void setWarning(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; + qint32 m_transmitting = 0; + bool m_transmittingIsSet = false; + qint32 m_queueLength = 0; + bool m_queueLengthIsSet = false; + qint64 m_framesSent = 0; + bool m_framesSentIsSet = false; + qint64 m_transmissions = 0; + bool m_transmissionsIsSet = false; + float m_airtime = 0; + bool m_airtimeIsSet = false; + float m_lastDuration = 0; + bool m_lastDurationIsSet = false; + float m_frameSeconds = 0; + bool m_frameSecondsIsSet = false; + qint32 m_maxBody = 0; + bool m_maxBodyIsSet = false; + QString* m_lastEvent = nullptr; + bool m_lastEventIsSet = false; + QString* m_lastError = nullptr; + bool m_lastErrorIsSet = false; + QString* m_warning = nullptr; + bool m_warningIsSet = false; +}; + +} + +#endif diff --git a/swagger/sdrangel/code/qt5/client/SWGChirpModemModSettings.cpp b/swagger/sdrangel/code/qt5/client/SWGChirpModemModSettings.cpp new file mode 100644 index 000000000..892c786a0 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGChirpModemModSettings.cpp @@ -0,0 +1,171 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Generated by gen_swg_models.py from ChirpModemMod.yaml: edit the YAML, not this file. +#include "SWGChirpModemModSettings.h" +#include "SWGHelpers.h" + +#include + +namespace SWGSDRangel { + +SWGChirpModemModSettings::SWGChirpModemModSettings() = default; +SWGChirpModemModSettings::SWGChirpModemModSettings(QString* json) { init(); if (json) { fromJson(*json); } } +SWGChirpModemModSettings::~SWGChirpModemModSettings() { cleanup(); } + +void SWGChirpModemModSettings::cleanup() +{ + delete m_source; m_source = nullptr; + delete m_destination; m_destination = nullptr; + delete m_message; m_message = nullptr; + 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 SWGChirpModemModSettings::init() +{ + cleanup(); + m_inputFrequencyOffset = 0; m_inputFrequencyOffsetIsSet = false; + m_spreadFactor = 0; m_spreadFactorIsSet = false; + m_bandwidth = 0; m_bandwidthIsSet = false; + m_mode = 0; m_modeIsSet = false; + m_profile = 0; m_profileIsSet = false; + m_source = new QString(); m_sourceIsSet = false; + m_destination = new QString(); m_destinationIsSet = false; + m_message = new QString(); m_messageIsSet = false; + m_repeat = 0; m_repeatIsSet = false; + m_gap = 0; m_gapIsSet = false; + m_amplitude = 0; m_amplitudeIsSet = false; + m_cwId = 0; m_cwIdIsSet = false; + m_cwWpm = 0; m_cwWpmIsSet = 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; +} + +SWGChirpModemModSettings* SWGChirpModemModSettings::fromJson(QString& json) +{ + auto object = QJsonDocument::fromJson(json.toUtf8()).object(); fromJsonObject(object); return this; +} + +void SWGChirpModemModSettings::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("mode")) { ::SWGSDRangel::setValue(&m_mode,json["mode"],"qint32",""); m_modeIsSet = true; } + if (json.contains("profile")) { ::SWGSDRangel::setValue(&m_profile,json["profile"],"qint32",""); m_profileIsSet = true; } + if (json.contains("source")) { ::SWGSDRangel::setValue(&m_source,json["source"],"QString","QString"); m_sourceIsSet = true; } + if (json.contains("destination")) { ::SWGSDRangel::setValue(&m_destination,json["destination"],"QString","QString"); m_destinationIsSet = true; } + if (json.contains("message")) { ::SWGSDRangel::setValue(&m_message,json["message"],"QString","QString"); m_messageIsSet = true; } + if (json.contains("repeat")) { ::SWGSDRangel::setValue(&m_repeat,json["repeat"],"qint32",""); m_repeatIsSet = true; } + if (json.contains("gap")) { ::SWGSDRangel::setValue(&m_gap,json["gap"],"float",""); m_gapIsSet = true; } + if (json.contains("amplitude")) { ::SWGSDRangel::setValue(&m_amplitude,json["amplitude"],"float",""); m_amplitudeIsSet = true; } + if (json.contains("cwId")) { ::SWGSDRangel::setValue(&m_cwId,json["cwId"],"qint32",""); m_cwIdIsSet = true; } + if (json.contains("cwWpm")) { ::SWGSDRangel::setValue(&m_cwWpm,json["cwWpm"],"qint32",""); m_cwWpmIsSet = 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 SWGChirpModemModSettings::asJson() +{ + auto* object = asJsonObject(); QString result = QJsonDocument(*object).toJson(); delete object; return result; +} + +QJsonObject* SWGChirpModemModSettings::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_modeIsSet) { object->insert("mode",QJsonValue(m_mode)); } + if (m_profileIsSet) { object->insert("profile",QJsonValue(m_profile)); } + if (m_source && (m_sourceIsSet || !m_source->isEmpty())) { toJsonValue(QString("source"),m_source,object,QString("QString")); } + if (m_destination && (m_destinationIsSet || !m_destination->isEmpty())) { toJsonValue(QString("destination"),m_destination,object,QString("QString")); } + if (m_message && (m_messageIsSet || !m_message->isEmpty())) { toJsonValue(QString("message"),m_message,object,QString("QString")); } + if (m_repeatIsSet) { object->insert("repeat",QJsonValue(m_repeat)); } + if (m_gapIsSet) { object->insert("gap",QJsonValue(m_gap)); } + if (m_amplitudeIsSet) { object->insert("amplitude",QJsonValue(m_amplitude)); } + if (m_cwIdIsSet) { object->insert("cwId",QJsonValue(m_cwId)); } + if (m_cwWpmIsSet) { object->insert("cwWpm",QJsonValue(m_cwWpm)); } + 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 SWGChirpModemModSettings::isSet() +{ + return m_inputFrequencyOffsetIsSet || m_spreadFactorIsSet || m_bandwidthIsSet || m_modeIsSet || m_profileIsSet || m_sourceIsSet || m_destinationIsSet || m_messageIsSet || m_repeatIsSet || m_gapIsSet || m_amplitudeIsSet || m_cwIdIsSet || m_cwWpmIsSet || m_rgbColorIsSet || m_titleIsSet || m_streamIndexIsSet || m_useReverseAPIIsSet || m_reverseAPIAddressIsSet || m_reverseAPIPortIsSet || m_reverseAPIDeviceIndexIsSet || m_reverseAPIChannelIndexIsSet || m_channelMarkerIsSet || m_rollupStateIsSet; +} + +qint64 SWGChirpModemModSettings::getInputFrequencyOffset() { return m_inputFrequencyOffset; } +void SWGChirpModemModSettings::setInputFrequencyOffset(qint64 value) { m_inputFrequencyOffset = value; m_inputFrequencyOffsetIsSet = true; } +qint32 SWGChirpModemModSettings::getSpreadFactor() { return m_spreadFactor; } +void SWGChirpModemModSettings::setSpreadFactor(qint32 value) { m_spreadFactor = value; m_spreadFactorIsSet = true; } +qint32 SWGChirpModemModSettings::getBandwidth() { return m_bandwidth; } +void SWGChirpModemModSettings::setBandwidth(qint32 value) { m_bandwidth = value; m_bandwidthIsSet = true; } +qint32 SWGChirpModemModSettings::getMode() { return m_mode; } +void SWGChirpModemModSettings::setMode(qint32 value) { m_mode = value; m_modeIsSet = true; } +qint32 SWGChirpModemModSettings::getProfile() { return m_profile; } +void SWGChirpModemModSettings::setProfile(qint32 value) { m_profile = value; m_profileIsSet = true; } +QString* SWGChirpModemModSettings::getSource() { return m_source; } +void SWGChirpModemModSettings::setSource(QString* value) { if (m_source != value) { delete m_source; m_source = value; } m_sourceIsSet = true; } +QString* SWGChirpModemModSettings::getDestination() { return m_destination; } +void SWGChirpModemModSettings::setDestination(QString* value) { if (m_destination != value) { delete m_destination; m_destination = value; } m_destinationIsSet = true; } +QString* SWGChirpModemModSettings::getMessage() { return m_message; } +void SWGChirpModemModSettings::setMessage(QString* value) { if (m_message != value) { delete m_message; m_message = value; } m_messageIsSet = true; } +qint32 SWGChirpModemModSettings::getRepeat() { return m_repeat; } +void SWGChirpModemModSettings::setRepeat(qint32 value) { m_repeat = value; m_repeatIsSet = true; } +float SWGChirpModemModSettings::getGap() { return m_gap; } +void SWGChirpModemModSettings::setGap(float value) { m_gap = value; m_gapIsSet = true; } +float SWGChirpModemModSettings::getAmplitude() { return m_amplitude; } +void SWGChirpModemModSettings::setAmplitude(float value) { m_amplitude = value; m_amplitudeIsSet = true; } +qint32 SWGChirpModemModSettings::getCwId() { return m_cwId; } +void SWGChirpModemModSettings::setCwId(qint32 value) { m_cwId = value; m_cwIdIsSet = true; } +qint32 SWGChirpModemModSettings::getCwWpm() { return m_cwWpm; } +void SWGChirpModemModSettings::setCwWpm(qint32 value) { m_cwWpm = value; m_cwWpmIsSet = true; } +qint32 SWGChirpModemModSettings::getRgbColor() { return m_rgbColor; } +void SWGChirpModemModSettings::setRgbColor(qint32 value) { m_rgbColor = value; m_rgbColorIsSet = true; } +QString* SWGChirpModemModSettings::getTitle() { return m_title; } +void SWGChirpModemModSettings::setTitle(QString* value) { if (m_title != value) { delete m_title; m_title = value; } m_titleIsSet = true; } +qint32 SWGChirpModemModSettings::getStreamIndex() { return m_streamIndex; } +void SWGChirpModemModSettings::setStreamIndex(qint32 value) { m_streamIndex = value; m_streamIndexIsSet = true; } +qint32 SWGChirpModemModSettings::getUseReverseApi() { return m_useReverseAPI; } +void SWGChirpModemModSettings::setUseReverseApi(qint32 value) { m_useReverseAPI = value; m_useReverseAPIIsSet = true; } +QString* SWGChirpModemModSettings::getReverseApiAddress() { return m_reverseAPIAddress; } +void SWGChirpModemModSettings::setReverseApiAddress(QString* value) { if (m_reverseAPIAddress != value) { delete m_reverseAPIAddress; m_reverseAPIAddress = value; } m_reverseAPIAddressIsSet = true; } +qint32 SWGChirpModemModSettings::getReverseApiPort() { return m_reverseAPIPort; } +void SWGChirpModemModSettings::setReverseApiPort(qint32 value) { m_reverseAPIPort = value; m_reverseAPIPortIsSet = true; } +qint32 SWGChirpModemModSettings::getReverseApiDeviceIndex() { return m_reverseAPIDeviceIndex; } +void SWGChirpModemModSettings::setReverseApiDeviceIndex(qint32 value) { m_reverseAPIDeviceIndex = value; m_reverseAPIDeviceIndexIsSet = true; } +qint32 SWGChirpModemModSettings::getReverseApiChannelIndex() { return m_reverseAPIChannelIndex; } +void SWGChirpModemModSettings::setReverseApiChannelIndex(qint32 value) { m_reverseAPIChannelIndex = value; m_reverseAPIChannelIndexIsSet = true; } +SWGChannelMarker* SWGChirpModemModSettings::getChannelMarker() { return m_channelMarker; } +void SWGChirpModemModSettings::setChannelMarker(SWGChannelMarker* value) { if (m_channelMarker != value) { delete m_channelMarker; m_channelMarker = value; } m_channelMarkerIsSet = true; } +SWGRollupState* SWGChirpModemModSettings::getRollupState() { return m_rollupState; } +void SWGChirpModemModSettings::setRollupState(SWGRollupState* value) { if (m_rollupState != value) { delete m_rollupState; m_rollupState = value; } m_rollupStateIsSet = true; } + +} diff --git a/swagger/sdrangel/code/qt5/client/SWGChirpModemModSettings.h b/swagger/sdrangel/code/qt5/client/SWGChirpModemModSettings.h new file mode 100644 index 000000000..5ccba6f39 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGChirpModemModSettings.h @@ -0,0 +1,128 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +// Qt model for ChirpModemMod.yaml, following the Swagger client model interface. +// Generated by gen_swg_models.py: edit the YAML, not this file. +#ifndef SWGChirpModemModSettings_H_ +#define SWGChirpModemModSettings_H_ + +#include +#include + +#include "SWGObject.h" +#include "export.h" +#include "SWGChannelMarker.h" +#include "SWGRollupState.h" + +namespace SWGSDRangel { + +class SWG_API SWGChirpModemModSettings : public SWGObject { +public: + SWGChirpModemModSettings(); + explicit SWGChirpModemModSettings(QString* json); + ~SWGChirpModemModSettings() override; + void init(); + void cleanup(); + QString asJson() override; + QJsonObject* asJsonObject() override; + void fromJsonObject(QJsonObject& json) override; + SWGChirpModemModSettings* 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 getMode(); + void setMode(qint32 value); + qint32 getProfile(); + void setProfile(qint32 value); + QString* getSource(); + void setSource(QString* value); + QString* getDestination(); + void setDestination(QString* value); + QString* getMessage(); + void setMessage(QString* value); + qint32 getRepeat(); + void setRepeat(qint32 value); + float getGap(); + void setGap(float value); + float getAmplitude(); + void setAmplitude(float value); + qint32 getCwId(); + void setCwId(qint32 value); + qint32 getCwWpm(); + void setCwWpm(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_mode = 0; + bool m_modeIsSet = false; + qint32 m_profile = 0; + bool m_profileIsSet = false; + QString* m_source = nullptr; + bool m_sourceIsSet = false; + QString* m_destination = nullptr; + bool m_destinationIsSet = false; + QString* m_message = nullptr; + bool m_messageIsSet = false; + qint32 m_repeat = 0; + bool m_repeatIsSet = false; + float m_gap = 0; + bool m_gapIsSet = false; + float m_amplitude = 0; + bool m_amplitudeIsSet = false; + qint32 m_cwId = 0; + bool m_cwIdIsSet = false; + qint32 m_cwWpm = 0; + bool m_cwWpmIsSet = 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 diff --git a/swagger/sdrangel/code/qt5/client/SWGModelFactory.h b/swagger/sdrangel/code/qt5/client/SWGModelFactory.h index b3c8ac176..dfd3cc79a 100644 --- a/swagger/sdrangel/code/qt5/client/SWGModelFactory.h +++ b/swagger/sdrangel/code/qt5/client/SWGModelFactory.h @@ -313,9 +313,12 @@ #include "SWGPacketDemodReport.h" #include "SWGPacketDemodSettings.h" #include "SWGPacketModActions.h" +#include "SWGChirpModemModActions.h" #include "SWGPacketModActions_payload.h" #include "SWGPacketModReport.h" +#include "SWGChirpModemModReport.h" #include "SWGPacketModSettings.h" +#include "SWGChirpModemModSettings.h" #include "SWGPagerDemodReport.h" #include "SWGPagerDemodSettings.h" #include "SWGPerseusReport.h" @@ -1963,6 +1966,11 @@ namespace SWGSDRangel { obj->init(); return obj; } + if(QString("SWGChirpModemModActions").compare(type) == 0) { + SWGChirpModemModActions *obj = new SWGChirpModemModActions(); + obj->init(); + return obj; + } if(QString("SWGPacketModActions_payload").compare(type) == 0) { SWGPacketModActions_payload *obj = new SWGPacketModActions_payload(); obj->init(); @@ -1973,11 +1981,21 @@ namespace SWGSDRangel { obj->init(); return obj; } + if(QString("SWGChirpModemModReport").compare(type) == 0) { + SWGChirpModemModReport *obj = new SWGChirpModemModReport(); + obj->init(); + return obj; + } if(QString("SWGPacketModSettings").compare(type) == 0) { SWGPacketModSettings *obj = new SWGPacketModSettings(); obj->init(); return obj; } + if(QString("SWGChirpModemModSettings").compare(type) == 0) { + SWGChirpModemModSettings *obj = new SWGChirpModemModSettings(); + obj->init(); + return obj; + } if(QString("SWGPagerDemodReport").compare(type) == 0) { SWGPagerDemodReport *obj = new SWGPagerDemodReport(); obj->init();