Browse Source

Meshtastic: moved meshtasticcommon to a modemmeshtastic module

chirpmodem-v8.0.0
f4exb 8 months ago
parent
commit
738bdfa744
  1. 1
      CMakeLists.txt
  2. 12
      exports/export.h
  3. 23
      modemmeshtastic/CMakeLists.txt
  4. 19
      modemmeshtastic/meshtasticpacket.cpp
  5. 35
      modemmeshtastic/meshtasticpacket.h
  6. 4
      plugins/channelrx/demodmeshtastic/CMakeLists.txt
  7. 16
      plugins/channelrx/demodmeshtastic/meshtasticdemod.cpp
  8. 4
      plugins/channelrx/demodmeshtastic/meshtasticdemod.h
  9. 10
      plugins/channelrx/demodmeshtastic/meshtasticdemodgui.cpp
  10. 4
      plugins/channeltx/modmeshtastic/CMakeLists.txt
  11. 8
      plugins/channeltx/modmeshtastic/meshtasticmodencoder.cpp
  12. 6
      plugins/channeltx/modmeshtastic/meshtasticmodgui.cpp

1
CMakeLists.txt

@ -968,6 +968,7 @@ add_subdirectory(swagger) @@ -968,6 +968,7 @@ add_subdirectory(swagger)
add_subdirectory(devices)
add_subdirectory(modemm17)
add_subdirectory(modemmeshtastic)
if (FFTW3F_FOUND)
add_subdirectory(ft8)

12
exports/export.h

@ -155,6 +155,18 @@ @@ -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)

23
modemmeshtastic/CMakeLists.txt

@ -0,0 +1,23 @@ @@ -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})

19
plugins/meshtasticcommon/meshtasticpacket.cpp → modemmeshtastic/meshtasticpacket.cpp

@ -1,6 +1,19 @@ @@ -1,6 +1,19 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 //
// SPDX-License-Identifier: GPL-3.0-or-later //
// Copyright (C) 2026 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
// 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 <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "meshtasticpacket.h"
@ -19,7 +32,7 @@ @@ -19,7 +32,7 @@
#include <set>
#include <vector>
namespace Meshtastic
namespace modemmeshtastic
{
namespace
{

35
plugins/meshtasticcommon/meshtasticpacket.h → modemmeshtastic/meshtasticpacket.h

@ -1,10 +1,23 @@ @@ -1,10 +1,23 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2026 //
// SPDX-License-Identifier: GPL-3.0-or-later //
// Copyright (C) 2026 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
// 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 <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef PLUGINS_CHIRPCHATCOMMON_MESHTASTICPACKET_H_
#define PLUGINS_CHIRPCHATCOMMON_MESHTASTICPACKET_H_
#ifndef MODEMMESHTASTIC_MESHTASTICPACKET_H_
#define MODEMMESHTASTIC_MESHTASTICPACKET_H_
#include <QByteArray>
#include <QString>
@ -13,10 +26,12 @@ @@ -13,10 +26,12 @@
#include <stdint.h>
namespace Meshtastic
#include "export.h"
namespace modemmeshtastic
{
struct DecodeResult
struct MODEMMESHTASTIC_API DecodeResult
{
struct Field
{
@ -32,7 +47,7 @@ struct DecodeResult @@ -32,7 +47,7 @@ struct DecodeResult
QVector<Field> fields;
};
struct TxRadioSettings
struct MODEMMESHTASTIC_API TxRadioSettings
{
bool hasCommand = false;
bool hasLoRaParams = false;
@ -49,7 +64,7 @@ struct TxRadioSettings @@ -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: @@ -85,6 +100,6 @@ public:
);
};
} // namespace Meshtastic
} // namespace modemmeshtastic
#endif // PLUGINS_CHIRPCHATCOMMON_MESHTASTICPACKET_H_
#endif // MODEMMESHTASTIC_MESHTASTICPACKET_H_

4
plugins/channelrx/demodmeshtastic/CMakeLists.txt

@ -17,7 +17,6 @@ set(meshtastic_SOURCES @@ -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 @@ -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 @@ -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})

16
plugins/channelrx/demodmeshtastic/meshtasticdemod.cpp

@ -173,7 +173,7 @@ int MeshtasticDemod::findBandwidthIndexForHz(int bandwidthHz) const @@ -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::PipelineConfig> MeshtasticDemod::buildPipelineConfi @@ -265,14 +265,14 @@ std::vector<MeshtasticDemod::PipelineConfig> 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::PipelineConfig> MeshtasticDemod::buildPipelineConfi @@ -283,14 +283,14 @@ std::vector<MeshtasticDemod::PipelineConfig> 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) @@ -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) @@ -567,7 +567,7 @@ bool MeshtasticDemod::handleMessage(const Message& cmd)
QVector<QPair<QString, QString>> 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));
}

4
plugins/channelrx/demodmeshtastic/meshtasticdemod.h

@ -42,7 +42,7 @@ class DeviceAPI; @@ -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: @@ -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;

10
plugins/channelrx/demodmeshtastic/meshtasticdemodgui.cpp

@ -1054,7 +1054,7 @@ void MeshtasticDemodGUI::editMeshtasticKeys() @@ -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() @@ -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() @@ -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;

4
plugins/channeltx/modmeshtastic/CMakeLists.txt

@ -17,7 +17,6 @@ set(modmeshtastic_SOURCES @@ -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 @@ -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 @@ -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})

8
plugins/channeltx/modmeshtastic/meshtasticmodencoder.cpp

@ -110,9 +110,9 @@ void MeshtasticModEncoder::encodeString(const QString& str, std::vector<unsigned @@ -110,9 +110,9 @@ void MeshtasticModEncoder::encodeString(const QString& str, std::vector<unsigned
QString summary;
QString error;
if (Meshtastic::Packet::isCommand(str))
if (modemmeshtastic::Packet::isCommand(str))
{
if (!Meshtastic::Packet::buildFrameFromCommand(str, bytes, summary, error))
if (!modemmeshtastic::Packet::buildFrameFromCommand(str, bytes, summary, error))
{
qWarning() << "MeshtasticModEncoder::encodeString: Meshtastic command error:" << error;
return;
@ -141,12 +141,12 @@ void MeshtasticModEncoder::encodeBytes(const QByteArray& bytes, std::vector<unsi @@ -141,12 +141,12 @@ void MeshtasticModEncoder::encodeBytes(const QByteArray& bytes, std::vector<unsi
{
QByteArray payload(bytes);
if (Meshtastic::Packet::isCommand(QString::fromUtf8(bytes)))
if (modemmeshtastic::Packet::isCommand(QString::fromUtf8(bytes)))
{
QString summary;
QString error;
if (!Meshtastic::Packet::buildFrameFromCommand(QString::fromUtf8(bytes), payload, summary, error))
if (!modemmeshtastic::Packet::buildFrameFromCommand(QString::fromUtf8(bytes), payload, summary, error))
{
qWarning() << "MeshtasticModEncoder::encodeBytes: Meshtastic command error:" << error;
return;

6
plugins/channeltx/modmeshtastic/meshtasticmodgui.cpp

@ -200,13 +200,13 @@ void MeshtasticModGUI::applyMeshtasticRadioSettingsIfPresent(const QString& payl @@ -200,13 +200,13 @@ void MeshtasticModGUI::applyMeshtasticRadioSettingsIfPresent(const QString& payl
return;
}
if (!Meshtastic::Packet::isCommand(payloadText)) {
if (!modemmeshtastic::Packet::isCommand(payloadText)) {
return;
}
Meshtastic::TxRadioSettings meshRadio;
modemmeshtastic::TxRadioSettings meshRadio;
QString error;
if (!Meshtastic::Packet::deriveTxRadioSettings(payloadText, meshRadio, error))
if (!modemmeshtastic::Packet::deriveTxRadioSettings(payloadText, meshRadio, error))
{
qWarning() << "MeshtasticModGUI::applyMeshtasticRadioSettingsIfPresent:" << error;
return;

Loading…
Cancel
Save