diff --git a/CMakeLists.txt b/CMakeLists.txt index ea828e1e3..2bc16f30e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -968,6 +968,7 @@ add_subdirectory(swagger) add_subdirectory(devices) add_subdirectory(modemm17) +add_subdirectory(modemmeshtastic) if (FFTW3F_FOUND) add_subdirectory(ft8) diff --git a/exports/export.h b/exports/export.h index 697ab425f..2e585ba79 100644 --- a/exports/export.h +++ b/exports/export.h @@ -155,6 +155,18 @@ # define MODEMM17_API #endif +/* the 'MODEMMESHTASTIC_API' controls the import/export of 'modemmeshtastic' symbols + */ +#if !defined(sdrangel_STATIC) +# ifdef modemmeshtastic_EXPORTS +# define MODEMMESHTASTIC_API __SDR_EXPORT +# else +# define MODEMMESHTASTIC_API __SDR_IMPORT +# endif +#else +# define MODEMMESHTASTIC_API +#endif + /* the 'FT8_API' controls the import/export of 'ft8' symbols */ #if !defined(sdrangel_STATIC) diff --git a/modemmeshtastic/CMakeLists.txt b/modemmeshtastic/CMakeLists.txt new file mode 100644 index 000000000..59a3b4313 --- /dev/null +++ b/modemmeshtastic/CMakeLists.txt @@ -0,0 +1,23 @@ +project (modemmeshtatstic) + +set(modemmeshtastic_SOURCES + meshtasticpacket.cpp +) + +set(modemmeshtastic_HEADERS + meshtasticpacket.h +) + +include_directories( + ${CMAKE_SOURCE_DIR}/exports +) + +add_library(modemmeshtastic + ${modemmeshtastic_SOURCES} +) + +target_link_libraries(modemmeshtastic + Qt::Core +) + +install(TARGETS modemmeshtastic DESTINATION ${INSTALL_LIB_DIR}) diff --git a/plugins/meshtasticcommon/meshtasticpacket.cpp b/modemmeshtastic/meshtasticpacket.cpp similarity index 97% rename from plugins/meshtasticcommon/meshtasticpacket.cpp rename to modemmeshtastic/meshtasticpacket.cpp index b53ed26e3..fecb7ac08 100644 --- a/plugins/meshtasticcommon/meshtasticpacket.cpp +++ b/modemmeshtastic/meshtasticpacket.cpp @@ -1,6 +1,19 @@ /////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2026 // -// SPDX-License-Identifier: GPL-3.0-or-later // +// Copyright (C) 2026 Edouard Griffiths, F4EXB // +// Copyright (C) 2026 AI (unknown) // +// // +// 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 "meshtasticpacket.h" @@ -19,7 +32,7 @@ #include #include -namespace Meshtastic +namespace modemmeshtastic { namespace { diff --git a/plugins/meshtasticcommon/meshtasticpacket.h b/modemmeshtastic/meshtasticpacket.h similarity index 50% rename from plugins/meshtasticcommon/meshtasticpacket.h rename to modemmeshtastic/meshtasticpacket.h index 178725de3..1c194a543 100644 --- a/plugins/meshtasticcommon/meshtasticpacket.h +++ b/modemmeshtastic/meshtasticpacket.h @@ -1,10 +1,23 @@ /////////////////////////////////////////////////////////////////////////////////// -// Copyright (C) 2026 // -// SPDX-License-Identifier: GPL-3.0-or-later // +// Copyright (C) 2026 Edouard Griffiths, F4EXB // +// Copyright (C) 2026 AI (unknown) // +// // +// 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 PLUGINS_CHIRPCHATCOMMON_MESHTASTICPACKET_H_ -#define PLUGINS_CHIRPCHATCOMMON_MESHTASTICPACKET_H_ +#ifndef MODEMMESHTASTIC_MESHTASTICPACKET_H_ +#define MODEMMESHTASTIC_MESHTASTICPACKET_H_ #include #include @@ -13,10 +26,12 @@ #include -namespace Meshtastic +#include "export.h" + +namespace modemmeshtastic { -struct DecodeResult +struct MODEMMESHTASTIC_API DecodeResult { struct Field { @@ -32,7 +47,7 @@ struct DecodeResult QVector fields; }; -struct TxRadioSettings +struct MODEMMESHTASTIC_API TxRadioSettings { bool hasCommand = false; bool hasLoRaParams = false; @@ -49,7 +64,7 @@ struct TxRadioSettings QString summary; }; -class Packet +class MODEMMESHTASTIC_API Packet { public: static bool isCommand(const QString& text); @@ -85,6 +100,6 @@ public: ); }; -} // namespace Meshtastic +} // namespace modemmeshtastic -#endif // PLUGINS_CHIRPCHATCOMMON_MESHTASTICPACKET_H_ +#endif // MODEMMESHTASTIC_MESHTASTICPACKET_H_ diff --git a/plugins/channelrx/demodmeshtastic/CMakeLists.txt b/plugins/channelrx/demodmeshtastic/CMakeLists.txt index 27966dc4e..f7cb7d13e 100644 --- a/plugins/channelrx/demodmeshtastic/CMakeLists.txt +++ b/plugins/channelrx/demodmeshtastic/CMakeLists.txt @@ -17,7 +17,6 @@ set(meshtastic_SOURCES meshtasticdemoddecoderlora.cpp meshtasticdemoddecoderft.cpp meshtasticdemodmsg.cpp - ${CMAKE_SOURCE_DIR}/plugins/meshtasticcommon/meshtasticpacket.cpp ) set(meshtastic_HEADERS @@ -37,7 +36,7 @@ set(meshtastic_HEADERS include_directories( ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client ${meshtastic_FT8_INCLUDE} - ${CMAKE_SOURCE_DIR}/plugins/meshtasticcommon + ${CMAKE_SOURCE_DIR}/modemmeshtastic ) if(NOT SERVER_MODE) @@ -79,6 +78,7 @@ target_link_libraries(${TARGET_NAME} PRIVATE ${TARGET_LIB_GUI} swagger ${meshtastic_FT8_LIB} + modemmeshtastic ) install(TARGETS ${TARGET_NAME} DESTINATION ${INSTALL_FOLDER}) diff --git a/plugins/channelrx/demodmeshtastic/meshtasticdemod.cpp b/plugins/channelrx/demodmeshtastic/meshtasticdemod.cpp index 9ca1761aa..9da38bdc6 100644 --- a/plugins/channelrx/demodmeshtastic/meshtasticdemod.cpp +++ b/plugins/channelrx/demodmeshtastic/meshtasticdemod.cpp @@ -173,7 +173,7 @@ int MeshtasticDemod::findBandwidthIndexForHz(int bandwidthHz) const MeshtasticDemodSettings MeshtasticDemod::makePipelineSettingsFromMeshRadio( const MeshtasticDemodSettings& baseSettings, const QString& presetName, - const Meshtastic::TxRadioSettings& meshRadio, + const modemmeshtastic::TxRadioSettings& meshRadio, qint64 selectedPresetFrequencyHz, bool haveSelectedPresetFrequency ) const @@ -265,14 +265,14 @@ std::vector MeshtasticDemod::buildPipelineConfi qint64 selectedPresetFrequencyHz = 0; bool haveSelectedPresetFrequency = false; { - Meshtastic::TxRadioSettings selectedMeshRadio; + modemmeshtastic::TxRadioSettings selectedMeshRadio; QString error; const QString command = QString("MESH:preset=%1;region=%2;channel_num=%3") .arg(selectedPreset) .arg(region) .arg(channelNum); - if (Meshtastic::Packet::deriveTxRadioSettings(command, selectedMeshRadio, error) && selectedMeshRadio.hasCenterFrequency) + if (modemmeshtastic::Packet::deriveTxRadioSettings(command, selectedMeshRadio, error) && selectedMeshRadio.hasCenterFrequency) { selectedPresetFrequencyHz = selectedMeshRadio.centerFrequencyHz; haveSelectedPresetFrequency = true; @@ -283,14 +283,14 @@ std::vector MeshtasticDemod::buildPipelineConfi for (const QString& presetName : orderedPresets) { - Meshtastic::TxRadioSettings meshRadio; + modemmeshtastic::TxRadioSettings meshRadio; QString error; const QString command = QString("MESH:preset=%1;region=%2;channel_num=%3") .arg(presetName) .arg(region) .arg(channelNum); - if (!Meshtastic::Packet::deriveTxRadioSettings(command, meshRadio, error)) + if (!modemmeshtastic::Packet::deriveTxRadioSettings(command, meshRadio, error)) { qDebug() << "MeshtasticDemod::buildPipelineConfigs: skip preset" << presetName << ":" << error; continue; @@ -549,9 +549,9 @@ bool MeshtasticDemod::handleMessage(const Message& cmd) getMessageQueueToGUI()->push(new MeshtasticDemodMsg::MsgReportDecodeBytes(msg)); // make a copy } - Meshtastic::DecodeResult meshResult; + modemmeshtastic::DecodeResult meshResult; - if (Meshtastic::Packet::decodeFrame(m_lastMsgBytes, meshResult, m_settings.m_meshtasticKeySpecList)) + if (modemmeshtastic::Packet::decodeFrame(m_lastMsgBytes, meshResult, m_settings.m_meshtasticKeySpecList)) { qInfo() << "MeshtasticDemod::handleMessage:" << meshResult.summary; @@ -567,7 +567,7 @@ bool MeshtasticDemod::handleMessage(const Message& cmd) QVector> structuredFields; structuredFields.reserve(meshResult.fields.size()); - for (const Meshtastic::DecodeResult::Field& field : meshResult.fields) { + for (const modemmeshtastic::DecodeResult::Field& field : meshResult.fields) { structuredFields.append(qMakePair(field.path, field.value)); } diff --git a/plugins/channelrx/demodmeshtastic/meshtasticdemod.h b/plugins/channelrx/demodmeshtastic/meshtasticdemod.h index 33773ea18..875f88f27 100644 --- a/plugins/channelrx/demodmeshtastic/meshtasticdemod.h +++ b/plugins/channelrx/demodmeshtastic/meshtasticdemod.h @@ -42,7 +42,7 @@ class DeviceAPI; class QThread; class ObjectPipe; class MeshtasticDemodDecoder; -namespace Meshtastic { struct TxRadioSettings; } +namespace modemmeshtastic { struct TxRadioSettings; } class MeshtasticDemod : public BasebandSampleSink, public ChannelAPI { public: @@ -195,7 +195,7 @@ private: MeshtasticDemodSettings makePipelineSettingsFromMeshRadio( const MeshtasticDemodSettings& baseSettings, const QString& presetName, - const Meshtastic::TxRadioSettings& meshRadio, + const modemmeshtastic::TxRadioSettings& meshRadio, qint64 selectedPresetFrequencyHz, bool haveSelectedPresetFrequency ) const; diff --git a/plugins/channelrx/demodmeshtastic/meshtasticdemodgui.cpp b/plugins/channelrx/demodmeshtastic/meshtasticdemodgui.cpp index 57cdaab47..6dcf1ed34 100644 --- a/plugins/channelrx/demodmeshtastic/meshtasticdemodgui.cpp +++ b/plugins/channelrx/demodmeshtastic/meshtasticdemodgui.cpp @@ -1054,7 +1054,7 @@ void MeshtasticDemodGUI::editMeshtasticKeys() QString error; int keyCount = 0; - if (!Meshtastic::Packet::validateKeySpecList(keyText, error, &keyCount)) + if (!modemmeshtastic::Packet::validateKeySpecList(keyText, error, &keyCount)) { statusLabel->setStyleSheet("QLabel { color: #ff5555; }"); statusLabel->setText(QObject::tr("Invalid key list: %1").arg(error)); @@ -1340,10 +1340,10 @@ void MeshtasticDemodGUI::applyMeshtasticProfileFromSelection() } const QString command = QString("MESH:preset=%1;region=%2;channel_num=%3").arg(preset, region).arg(channelNum); - Meshtastic::TxRadioSettings meshRadio; + modemmeshtastic::TxRadioSettings meshRadio; QString error; - if (!Meshtastic::Packet::deriveTxRadioSettings(command, meshRadio, error)) + if (!modemmeshtastic::Packet::deriveTxRadioSettings(command, meshRadio, error)) { qWarning() << "MeshtasticDemodGUI::applyMeshtasticProfileFromSelection:" << error; return; @@ -1607,12 +1607,12 @@ void MeshtasticDemodGUI::rebuildMeshtasticChannelOptions() int added = 0; for (int meshChannel = 0; meshChannel <= 200; ++meshChannel) { - Meshtastic::TxRadioSettings meshRadio; + modemmeshtastic::TxRadioSettings meshRadio; QString error; const int channelNum = meshChannel + 1; // planner expects 1-based channel_num const QString command = QString("MESH:preset=%1;region=%2;channel_num=%3").arg(preset, region).arg(channelNum); - if (!Meshtastic::Packet::deriveTxRadioSettings(command, meshRadio, error)) + if (!modemmeshtastic::Packet::deriveTxRadioSettings(command, meshRadio, error)) { if (added > 0) { break; diff --git a/plugins/channeltx/modmeshtastic/CMakeLists.txt b/plugins/channeltx/modmeshtastic/CMakeLists.txt index 9d19b24a7..b9acad0a8 100644 --- a/plugins/channeltx/modmeshtastic/CMakeLists.txt +++ b/plugins/channeltx/modmeshtastic/CMakeLists.txt @@ -17,7 +17,6 @@ set(modmeshtastic_SOURCES meshtasticmodencoderlora.cpp meshtasticmodencoderft.cpp meshtasticmodwebapiadapter.cpp - ${CMAKE_SOURCE_DIR}/plugins/meshtasticcommon/meshtasticpacket.cpp ) set(modmeshtastic_HEADERS @@ -37,7 +36,7 @@ set(modmeshtastic_HEADERS include_directories( ${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client ${meshtasticmod_FT8_INCLUDE} - ${CMAKE_SOURCE_DIR}/plugins/meshtasticcommon + ${CMAKE_SOURCE_DIR}/modemmeshtastic ) if(NOT SERVER_MODE) @@ -79,6 +78,7 @@ target_link_libraries(${TARGET_NAME} PRIVATE ${TARGET_LIB_GUI} swagger ${meshtasticmod_FT8_LIB} + modemmeshtastic ) install(TARGETS ${TARGET_NAME} DESTINATION ${INSTALL_FOLDER}) diff --git a/plugins/channeltx/modmeshtastic/meshtasticmodencoder.cpp b/plugins/channeltx/modmeshtastic/meshtasticmodencoder.cpp index 8c7f0d58e..e1f75fdb9 100644 --- a/plugins/channeltx/modmeshtastic/meshtasticmodencoder.cpp +++ b/plugins/channeltx/modmeshtastic/meshtasticmodencoder.cpp @@ -110,9 +110,9 @@ void MeshtasticModEncoder::encodeString(const QString& str, std::vector