1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-07 08:24:43 -04:00

Meshtastic: implement API properly

This commit is contained in:
f4exb
2026-03-22 21:36:41 +01:00
parent 239ebc38f9
commit 3530dd33ed
30 changed files with 4488 additions and 278 deletions
@@ -39,7 +39,7 @@
#include "SWGChannelSettings.h"
#include "SWGWorkspaceInfo.h"
#include "SWGChannelReport.h"
#include "SWGChirpChatDemodReport.h"
#include "SWGMeshtasticDemodReport.h"
#include "dsp/dspcommands.h"
#include "device/deviceapi.h"
@@ -530,6 +530,8 @@ bool MeshtasticDemod::handleMessage(const Message& cmd)
m_lastMsgHeaderParityStatus = msg.getHeaderParityStatus();
m_lastMsgPayloadCRC = msg.getPayloadCRCStatus();
m_lastMsgPayloadParityStatus = msg.getPayloadParityStatus();
m_lastMsgPipelineName = msg.getPipelineName();
m_lastFrameType = QStringLiteral("LORA_FRAME");
QByteArray bytesCopy(m_lastMsgBytes);
bytesCopy.truncate(m_lastMsgPacketLength);
@@ -550,6 +552,17 @@ bool MeshtasticDemod::handleMessage(const Message& cmd)
if (modemmeshtastic::Packet::decodeFrame(m_lastMsgBytes, meshResult, m_settings.m_meshtasticKeySpecList))
{
m_lastMsgString = meshResult.summary;
for (const modemmeshtastic::DecodeResult::Field& field : meshResult.fields)
{
if (field.path == QStringLiteral("data.port_name"))
{
m_lastFrameType = field.value;
break;
}
}
qInfo() << "MeshtasticDemod::handleMessage:" << meshResult.summary;
if (meshResult.dataDecoded && getMessageQueueToGUI())
@@ -658,44 +671,6 @@ bool MeshtasticDemod::handleMessage(const Message& cmd)
return true;
}
else if (MeshtasticDemodMsg::MsgReportDecodeFT::match(cmd))
{
qDebug() << "MeshtasticDemod::handleMessage: MsgReportDecodeFT";
MeshtasticDemodMsg::MsgReportDecodeFT& msg = (MeshtasticDemodMsg::MsgReportDecodeFT&) cmd;
m_lastMsgSignalDb = msg.getSingalDb();
m_lastMsgNoiseDb = msg.getNoiseDb();
m_lastMsgSyncWord = msg.getSyncWord();
m_lastMsgTimestamp = msg.getMsgTimestamp();
m_lastMsgString = msg.getMessage(); // for now we do not handle message components (call1, ...)
int nbSymbolBits = m_settings.m_spreadFactor - m_settings.m_deBits;
m_lastMsgNbSymbols = (174 / nbSymbolBits) + ((174 % nbSymbolBits) == 0 ? 0 : 1);
if (m_settings.m_autoNbSymbolsMax)
{
MeshtasticDemodSettings settings = m_settings;
settings.m_nbSymbolsMax = m_lastMsgNbSymbols;
applySettings(settings);
if (getMessageQueueToGUI()) // forward to GUI if any
{
MsgConfigureMeshtasticDemod *msgToGUI = MsgConfigureMeshtasticDemod::create(settings, false);
getMessageQueueToGUI()->push(msgToGUI);
}
}
if (m_settings.m_sendViaUDP)
{
const QByteArray& byteArray = m_lastMsgString.toUtf8();
const uint8_t *bytes = reinterpret_cast<const uint8_t*>(byteArray.data());
m_udpSink.writeUnbuffered(bytes, byteArray.size());
}
if (getMessageQueueToGUI()) {
getMessageQueueToGUI()->push(new MeshtasticDemodMsg::MsgReportDecodeFT(msg)); // make a copy
}
return true;
}
else if (DSPSignalNotification::match(cmd))
{
DSPSignalNotification& notif = (DSPSignalNotification&) cmd;
@@ -912,8 +887,8 @@ int MeshtasticDemod::webapiSettingsGet(
QString& errorMessage)
{
(void) errorMessage;
response.setChirpChatDemodSettings(new SWGSDRangel::SWGChirpChatDemodSettings());
response.getChirpChatDemodSettings()->init();
response.setMeshtasticDemodSettings(new SWGSDRangel::SWGMeshtasticDemodSettings());
response.getMeshtasticDemodSettings()->init();
webapiFormatChannelSettings(response, m_settings);
return 200;
@@ -958,81 +933,81 @@ void MeshtasticDemod::webapiUpdateChannelSettings(
SWGSDRangel::SWGChannelSettings& response)
{
if (channelSettingsKeys.contains("inputFrequencyOffset")) {
settings.m_inputFrequencyOffset = response.getChirpChatDemodSettings()->getInputFrequencyOffset();
settings.m_inputFrequencyOffset = response.getMeshtasticDemodSettings()->getInputFrequencyOffset();
}
if (channelSettingsKeys.contains("bandwidthIndex")) {
settings.m_bandwidthIndex = response.getChirpChatDemodSettings()->getBandwidthIndex();
settings.m_bandwidthIndex = response.getMeshtasticDemodSettings()->getBandwidthIndex();
}
if (channelSettingsKeys.contains("spreadFactor")) {
settings.m_spreadFactor = response.getChirpChatDemodSettings()->getSpreadFactor();
settings.m_spreadFactor = response.getMeshtasticDemodSettings()->getSpreadFactor();
}
if (channelSettingsKeys.contains("deBits")) {
settings.m_deBits = response.getChirpChatDemodSettings()->getDeBits();
settings.m_deBits = response.getMeshtasticDemodSettings()->getDeBits();
}
if (channelSettingsKeys.contains("decodeActive")) {
settings.m_decodeActive = response.getChirpChatDemodSettings()->getDecodeActive() != 0;
settings.m_decodeActive = response.getMeshtasticDemodSettings()->getDecodeActive() != 0;
}
if (channelSettingsKeys.contains("eomSquelchTenths")) {
settings.m_eomSquelchTenths = response.getChirpChatDemodSettings()->getEomSquelchTenths();
settings.m_eomSquelchTenths = response.getMeshtasticDemodSettings()->getEomSquelchTenths();
}
if (channelSettingsKeys.contains("nbSymbolsMax")) {
settings.m_nbSymbolsMax = response.getChirpChatDemodSettings()->getNbSymbolsMax();
settings.m_nbSymbolsMax = response.getMeshtasticDemodSettings()->getNbSymbolsMax();
}
if (channelSettingsKeys.contains("preambleChirps")) {
settings.m_preambleChirps = response.getChirpChatDemodSettings()->getPreambleChirps();
settings.m_preambleChirps = response.getMeshtasticDemodSettings()->getPreambleChirps();
}
if (channelSettingsKeys.contains("nbParityBits")) {
settings.m_nbParityBits = response.getChirpChatDemodSettings()->getNbParityBits();
settings.m_nbParityBits = response.getMeshtasticDemodSettings()->getNbParityBits();
}
if (channelSettingsKeys.contains("packetLength")) {
settings.m_packetLength = response.getChirpChatDemodSettings()->getPacketLength();
settings.m_packetLength = response.getMeshtasticDemodSettings()->getPacketLength();
}
if (channelSettingsKeys.contains("sendViaUDP")) {
settings.m_sendViaUDP = response.getChirpChatDemodSettings()->getSendViaUdp() != 0;
settings.m_sendViaUDP = response.getMeshtasticDemodSettings()->getSendViaUdp() != 0;
}
if (channelSettingsKeys.contains("udpAddress")) {
settings.m_udpAddress = *response.getChirpChatDemodSettings()->getUdpAddress();
settings.m_udpAddress = *response.getMeshtasticDemodSettings()->getUdpAddress();
}
if (channelSettingsKeys.contains("udpPort"))
{
uint16_t port = response.getChirpChatDemodSettings()->getUdpPort();
uint16_t port = response.getMeshtasticDemodSettings()->getUdpPort();
settings.m_udpPort = port < 1024 ? 1024 : port;
}
if (channelSettingsKeys.contains("invertRamps")) {
settings.m_invertRamps = response.getChirpChatDemodSettings()->getInvertRamps() != 0;
settings.m_invertRamps = response.getMeshtasticDemodSettings()->getInvertRamps() != 0;
}
if (channelSettingsKeys.contains("rgbColor")) {
settings.m_rgbColor = response.getChirpChatDemodSettings()->getRgbColor();
settings.m_rgbColor = response.getMeshtasticDemodSettings()->getRgbColor();
}
if (channelSettingsKeys.contains("title")) {
settings.m_title = *response.getChirpChatDemodSettings()->getTitle();
settings.m_title = *response.getMeshtasticDemodSettings()->getTitle();
}
if (channelSettingsKeys.contains("streamIndex")) {
settings.m_streamIndex = response.getChirpChatDemodSettings()->getStreamIndex();
settings.m_streamIndex = response.getMeshtasticDemodSettings()->getStreamIndex();
}
if (channelSettingsKeys.contains("useReverseAPI")) {
settings.m_useReverseAPI = response.getChirpChatDemodSettings()->getUseReverseApi() != 0;
settings.m_useReverseAPI = response.getMeshtasticDemodSettings()->getUseReverseApi() != 0;
}
if (channelSettingsKeys.contains("reverseAPIAddress")) {
settings.m_reverseAPIAddress = *response.getChirpChatDemodSettings()->getReverseApiAddress();
settings.m_reverseAPIAddress = *response.getMeshtasticDemodSettings()->getReverseApiAddress();
}
if (channelSettingsKeys.contains("reverseAPIPort")) {
settings.m_reverseAPIPort = response.getChirpChatDemodSettings()->getReverseApiPort();
settings.m_reverseAPIPort = response.getMeshtasticDemodSettings()->getReverseApiPort();
}
if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
settings.m_reverseAPIDeviceIndex = response.getChirpChatDemodSettings()->getReverseApiDeviceIndex();
settings.m_reverseAPIDeviceIndex = response.getMeshtasticDemodSettings()->getReverseApiDeviceIndex();
}
if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
settings.m_reverseAPIChannelIndex = response.getChirpChatDemodSettings()->getReverseApiChannelIndex();
settings.m_reverseAPIChannelIndex = response.getMeshtasticDemodSettings()->getReverseApiChannelIndex();
}
if (settings.m_spectrumGUI && channelSettingsKeys.contains("spectrumConfig")) {
settings.m_spectrumGUI->updateFrom(channelSettingsKeys, response.getChirpChatDemodSettings()->getSpectrumConfig());
settings.m_spectrumGUI->updateFrom(channelSettingsKeys, response.getMeshtasticDemodSettings()->getSpectrumConfig());
}
if (settings.m_channelMarker && channelSettingsKeys.contains("channelMarker")) {
settings.m_channelMarker->updateFrom(channelSettingsKeys, response.getChirpChatDemodSettings()->getChannelMarker());
settings.m_channelMarker->updateFrom(channelSettingsKeys, response.getMeshtasticDemodSettings()->getChannelMarker());
}
if (settings.m_rollupState && channelSettingsKeys.contains("rollupState")) {
settings.m_rollupState->updateFrom(channelSettingsKeys, response.getChirpChatDemodSettings()->getRollupState());
settings.m_rollupState->updateFrom(channelSettingsKeys, response.getMeshtasticDemodSettings()->getRollupState());
}
}
@@ -1041,97 +1016,93 @@ int MeshtasticDemod::webapiReportGet(
QString& errorMessage)
{
(void) errorMessage;
response.setChirpChatDemodReport(new SWGSDRangel::SWGChirpChatDemodReport());
response.getChirpChatDemodReport()->init();
response.setMeshtasticDemodReport(new SWGSDRangel::SWGMeshtasticDemodReport());
response.getMeshtasticDemodReport()->init();
webapiFormatChannelReport(response);
return 200;
}
void MeshtasticDemod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const MeshtasticDemodSettings& settings)
{
response.getChirpChatDemodSettings()->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
response.getChirpChatDemodSettings()->setBandwidthIndex(settings.m_bandwidthIndex);
response.getChirpChatDemodSettings()->setSpreadFactor(settings.m_spreadFactor);
response.getChirpChatDemodSettings()->setDeBits(settings.m_deBits);
response.getChirpChatDemodSettings()->setCodingScheme((int) settings.m_codingScheme);
response.getChirpChatDemodSettings()->setDecodeActive(settings.m_decodeActive ? 1 : 0);
response.getChirpChatDemodSettings()->setEomSquelchTenths(settings.m_eomSquelchTenths);
response.getChirpChatDemodSettings()->setNbSymbolsMax(settings.m_nbSymbolsMax);
response.getChirpChatDemodSettings()->setAutoNbSymbolsMax(settings.m_autoNbSymbolsMax ? 1 : 0);
response.getChirpChatDemodSettings()->setPreambleChirps(settings.m_preambleChirps);
response.getChirpChatDemodSettings()->setNbParityBits(settings.m_nbParityBits);
response.getChirpChatDemodSettings()->setPacketLength(settings.m_packetLength);
response.getChirpChatDemodSettings()->setHasCrc(settings.m_hasCRC ? 1 : 0);
response.getChirpChatDemodSettings()->setHasHeader(settings.m_hasHeader ? 1 : 0);
response.getChirpChatDemodSettings()->setSendViaUdp(settings.m_sendViaUDP ? 1 : 0);
response.getChirpChatDemodSettings()->setInvertRamps(settings.m_invertRamps ? 1 : 0);
response.getMeshtasticDemodSettings()->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
response.getMeshtasticDemodSettings()->setBandwidthIndex(settings.m_bandwidthIndex);
response.getMeshtasticDemodSettings()->setSpreadFactor(settings.m_spreadFactor);
response.getMeshtasticDemodSettings()->setDeBits(settings.m_deBits);
response.getMeshtasticDemodSettings()->setDecodeActive(settings.m_decodeActive ? 1 : 0);
response.getMeshtasticDemodSettings()->setEomSquelchTenths(settings.m_eomSquelchTenths);
response.getMeshtasticDemodSettings()->setNbSymbolsMax(settings.m_nbSymbolsMax);
response.getMeshtasticDemodSettings()->setPreambleChirps(settings.m_preambleChirps);
response.getMeshtasticDemodSettings()->setNbParityBits(settings.m_nbParityBits);
response.getMeshtasticDemodSettings()->setPacketLength(settings.m_packetLength);
response.getMeshtasticDemodSettings()->setSendViaUdp(settings.m_sendViaUDP ? 1 : 0);
response.getMeshtasticDemodSettings()->setInvertRamps(settings.m_invertRamps ? 1 : 0);
if (response.getChirpChatDemodSettings()->getUdpAddress()) {
*response.getChirpChatDemodSettings()->getUdpAddress() = settings.m_udpAddress;
if (response.getMeshtasticDemodSettings()->getUdpAddress()) {
*response.getMeshtasticDemodSettings()->getUdpAddress() = settings.m_udpAddress;
} else {
response.getChirpChatDemodSettings()->setUdpAddress(new QString(settings.m_udpAddress));
response.getMeshtasticDemodSettings()->setUdpAddress(new QString(settings.m_udpAddress));
}
response.getChirpChatDemodSettings()->setUdpPort(settings.m_udpPort);
response.getChirpChatDemodSettings()->setRgbColor(settings.m_rgbColor);
response.getMeshtasticDemodSettings()->setUdpPort(settings.m_udpPort);
response.getMeshtasticDemodSettings()->setRgbColor(settings.m_rgbColor);
if (response.getChirpChatDemodSettings()->getTitle()) {
*response.getChirpChatDemodSettings()->getTitle() = settings.m_title;
if (response.getMeshtasticDemodSettings()->getTitle()) {
*response.getMeshtasticDemodSettings()->getTitle() = settings.m_title;
} else {
response.getChirpChatDemodSettings()->setTitle(new QString(settings.m_title));
response.getMeshtasticDemodSettings()->setTitle(new QString(settings.m_title));
}
response.getChirpChatDemodSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
response.getMeshtasticDemodSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
if (response.getChirpChatDemodSettings()->getReverseApiAddress()) {
*response.getChirpChatDemodSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress;
if (response.getMeshtasticDemodSettings()->getReverseApiAddress()) {
*response.getMeshtasticDemodSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress;
} else {
response.getChirpChatDemodSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
response.getMeshtasticDemodSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
}
response.getChirpChatDemodSettings()->setReverseApiPort(settings.m_reverseAPIPort);
response.getChirpChatDemodSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
response.getChirpChatDemodSettings()->setReverseApiChannelIndex(settings.m_reverseAPIChannelIndex);
response.getMeshtasticDemodSettings()->setReverseApiPort(settings.m_reverseAPIPort);
response.getMeshtasticDemodSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
response.getMeshtasticDemodSettings()->setReverseApiChannelIndex(settings.m_reverseAPIChannelIndex);
if (settings.m_spectrumGUI)
{
if (response.getChirpChatDemodSettings()->getSpectrumConfig())
if (response.getMeshtasticDemodSettings()->getSpectrumConfig())
{
settings.m_spectrumGUI->formatTo(response.getChirpChatDemodSettings()->getSpectrumConfig());
settings.m_spectrumGUI->formatTo(response.getMeshtasticDemodSettings()->getSpectrumConfig());
}
else
{
SWGSDRangel::SWGGLSpectrum *swgGLSpectrum = new SWGSDRangel::SWGGLSpectrum();
settings.m_spectrumGUI->formatTo(swgGLSpectrum);
response.getChirpChatDemodSettings()->setSpectrumConfig(swgGLSpectrum);
response.getMeshtasticDemodSettings()->setSpectrumConfig(swgGLSpectrum);
}
}
if (settings.m_channelMarker)
{
if (response.getChirpChatDemodSettings()->getChannelMarker())
if (response.getMeshtasticDemodSettings()->getChannelMarker())
{
settings.m_channelMarker->formatTo(response.getChirpChatDemodSettings()->getChannelMarker());
settings.m_channelMarker->formatTo(response.getMeshtasticDemodSettings()->getChannelMarker());
}
else
{
SWGSDRangel::SWGChannelMarker *swgChannelMarker = new SWGSDRangel::SWGChannelMarker();
settings.m_channelMarker->formatTo(swgChannelMarker);
response.getChirpChatDemodSettings()->setChannelMarker(swgChannelMarker);
response.getMeshtasticDemodSettings()->setChannelMarker(swgChannelMarker);
}
}
if (settings.m_rollupState)
{
if (response.getChirpChatDemodSettings()->getRollupState())
if (response.getMeshtasticDemodSettings()->getRollupState())
{
settings.m_rollupState->formatTo(response.getChirpChatDemodSettings()->getRollupState());
settings.m_rollupState->formatTo(response.getMeshtasticDemodSettings()->getRollupState());
}
else
{
SWGSDRangel::SWGRollupState *swgRollupState = new SWGSDRangel::SWGRollupState();
settings.m_rollupState->formatTo(swgRollupState);
response.getChirpChatDemodSettings()->setRollupState(swgRollupState);
response.getMeshtasticDemodSettings()->setRollupState(swgRollupState);
}
}
}
@@ -1139,28 +1110,29 @@ void MeshtasticDemod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSetting
void MeshtasticDemod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response)
{
if (m_running && !m_pipelines.empty() && m_pipelines[0].basebandSink) {
response.getChirpChatDemodReport()->setChannelSampleRate(m_pipelines[0].basebandSink->getChannelSampleRate());
response.getMeshtasticDemodReport()->setChannelSampleRate(m_pipelines[0].basebandSink->getChannelSampleRate());
}
response.getChirpChatDemodReport()->setChannelPowerDb(CalcDb::dbPower(getTotalPower()));
response.getChirpChatDemodReport()->setSignalPowerDb(m_lastMsgSignalDb);
response.getChirpChatDemodReport()->setNoisePowerDb(CalcDb::dbPower(getCurrentNoiseLevel()));
response.getChirpChatDemodReport()->setSnrPowerDb(m_lastMsgSignalDb - m_lastMsgNoiseDb);
response.getChirpChatDemodReport()->setHasCrc(m_lastMsgHasCRC);
response.getChirpChatDemodReport()->setNbParityBits(m_lastMsgNbParityBits);
response.getChirpChatDemodReport()->setPacketLength(m_lastMsgPacketLength);
response.getChirpChatDemodReport()->setNbSymbols(m_lastMsgNbSymbols);
response.getChirpChatDemodReport()->setNbCodewords(m_lastMsgNbCodewords);
response.getChirpChatDemodReport()->setHeaderParityStatus(m_lastMsgHeaderParityStatus);
response.getChirpChatDemodReport()->setHeaderCrcStatus(m_lastMsgHeaderCRC);
response.getChirpChatDemodReport()->setPayloadParityStatus(m_lastMsgPayloadParityStatus);
response.getChirpChatDemodReport()->setPayloadCrcStatus(m_lastMsgPayloadCRC);
response.getChirpChatDemodReport()->setMessageTimestamp(new QString(m_lastMsgTimestamp));
response.getChirpChatDemodReport()->setMessageString(new QString(m_lastMsgString));
response.getChirpChatDemodReport()->setDecoding(getDemodActive() ? 1 : 0);
response.getMeshtasticDemodReport()->setChannelPowerDb(CalcDb::dbPower(getTotalPower()));
response.getMeshtasticDemodReport()->setSignalPowerDb(m_lastMsgSignalDb);
response.getMeshtasticDemodReport()->setNoisePowerDb(CalcDb::dbPower(getCurrentNoiseLevel()));
response.getMeshtasticDemodReport()->setSnrPowerDb(m_lastMsgSignalDb - m_lastMsgNoiseDb);
response.getMeshtasticDemodReport()->setNbParityBits(m_lastMsgNbParityBits);
response.getMeshtasticDemodReport()->setPacketLength(m_lastMsgPacketLength);
response.getMeshtasticDemodReport()->setNbSymbols(m_lastMsgNbSymbols);
response.getMeshtasticDemodReport()->setNbCodewords(m_lastMsgNbCodewords);
response.getMeshtasticDemodReport()->setHeaderParityStatus(m_lastMsgHeaderParityStatus);
response.getMeshtasticDemodReport()->setHeaderCrcStatus(m_lastMsgHeaderCRC);
response.getMeshtasticDemodReport()->setPayloadParityStatus(m_lastMsgPayloadParityStatus);
response.getMeshtasticDemodReport()->setPayloadCrcStatus(m_lastMsgPayloadCRC);
response.getMeshtasticDemodReport()->setMessageTimestamp(new QString(m_lastMsgTimestamp));
response.getMeshtasticDemodReport()->setMessageString(new QString(m_lastMsgString));
response.getMeshtasticDemodReport()->setFrameType(new QString(m_lastFrameType));
response.getMeshtasticDemodReport()->setChannelType(new QString(m_lastMsgPipelineName));
response.getMeshtasticDemodReport()->setDecoding(getDemodActive() ? 1 : 0);
response.getChirpChatDemodReport()->setMessageBytes(new QList<QString *>);
QList<QString *> *bytesStr = response.getChirpChatDemodReport()->getMessageBytes();
response.getMeshtasticDemodReport()->setMessageBytes(new QList<QString *>);
QList<QString *> *bytesStr = response.getMeshtasticDemodReport()->getMessageBytes();
for (QByteArray::const_iterator it = m_lastMsgBytes.begin(); it != m_lastMsgBytes.end(); ++it)
{
@@ -1230,8 +1202,8 @@ void MeshtasticDemod::webapiFormatChannelSettings(
swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet());
swgChannelSettings->setOriginatorDeviceSetIndex(getDeviceSetIndex());
swgChannelSettings->setChannelType(new QString(m_channelId));
swgChannelSettings->setChirpChatDemodSettings(new SWGSDRangel::SWGChirpChatDemodSettings());
SWGSDRangel::SWGChirpChatDemodSettings *swgMeshtasticDemodSettings = swgChannelSettings->getChirpChatDemodSettings();
swgChannelSettings->setMeshtasticDemodSettings(new SWGSDRangel::SWGMeshtasticDemodSettings());
SWGSDRangel::SWGMeshtasticDemodSettings *swgMeshtasticDemodSettings = swgChannelSettings->getMeshtasticDemodSettings();
// transfer data that has been modified. When force is on transfer all data except reverse API data
@@ -1247,9 +1219,6 @@ void MeshtasticDemod::webapiFormatChannelSettings(
if (channelSettingsKeys.contains("deBits") || force) {
swgMeshtasticDemodSettings->setDeBits(settings.m_deBits);
}
if (channelSettingsKeys.contains("codingScheme") || force) {
swgMeshtasticDemodSettings->setCodingScheme((int) settings.m_codingScheme);
}
if (channelSettingsKeys.contains("decodeActive") || force) {
swgMeshtasticDemodSettings->setDecodeActive(settings.m_decodeActive ? 1 : 0);
}
@@ -1259,9 +1228,6 @@ void MeshtasticDemod::webapiFormatChannelSettings(
if (channelSettingsKeys.contains("nbSymbolsMax") || force) {
swgMeshtasticDemodSettings->setNbSymbolsMax(settings.m_nbSymbolsMax);
}
if (channelSettingsKeys.contains("autoNbSymbolsMax") || force) {
swgMeshtasticDemodSettings->setAutoNbSymbolsMax(settings.m_autoNbSymbolsMax ? 1 : 0);
}
if (channelSettingsKeys.contains("preambleChirps") || force) {
swgMeshtasticDemodSettings->setPreambleChirps(settings.m_preambleChirps);
}
@@ -1271,12 +1237,6 @@ void MeshtasticDemod::webapiFormatChannelSettings(
if (channelSettingsKeys.contains("packetLength") || force) {
swgMeshtasticDemodSettings->setPacketLength(settings.m_packetLength);
}
if (channelSettingsKeys.contains("hasCRC") || force) {
swgMeshtasticDemodSettings->setHasCrc(settings.m_hasCRC ? 1 : 0);
}
if (channelSettingsKeys.contains("hasHeader") || force) {
swgMeshtasticDemodSettings->setHasHeader(settings.m_hasHeader ? 1 : 0);
}
if (channelSettingsKeys.contains("sendViaUDP") || force) {
swgMeshtasticDemodSettings->setSendViaUdp(settings.m_sendViaUDP ? 1 : 0);
}
@@ -181,8 +181,10 @@ private:
int m_lastMsgHeaderParityStatus;
bool m_lastMsgPayloadCRC;
int m_lastMsgPayloadParityStatus;
QString m_lastMsgPipelineName;
QString m_lastMsgTimestamp;
QString m_lastMsgString;
QString m_lastFrameType;
QByteArray m_lastMsgBytes;
UDPSinkUtil<uint8_t> m_udpSink;
@@ -351,7 +351,8 @@ bool MeshtasticDemodDecoder::handleMessage(const Message& cmd)
if (m_outputMessageQueue)
{
qDebug(
"MeshtasticDemodDecoder::handleMessage: push report ts=%s bytes=%lld pCRC=%d",
"MeshtasticDemodDecoder::handleMessage: push report name=%s ts=%s bytes=%lld pCRC=%d",
qPrintable(m_pipelineName),
qPrintable(msgTimestamp),
static_cast<long long>(msgBytes.size()),
m_payloadCRCStatus ? 1 : 0
@@ -196,6 +196,7 @@ bool MeshtasticDemodGUI::handleMessage(const Message& message)
}
else if (MeshtasticDemodMsg::MsgReportDecodeBytes::match(message))
{
// Populates the upper unstructured view including raw bytes in hex
const MeshtasticDemodMsg::MsgReportDecodeBytes& msg = (MeshtasticDemodMsg::MsgReportDecodeBytes&) message;
handleMeshAutoLockObservation(msg);
@@ -207,6 +208,7 @@ bool MeshtasticDemodGUI::handleMessage(const Message& message)
}
else if (MeshtasticDemodMsg::MsgReportDecodeString::match(message))
{
// Populates the lower structured tree view with decoded fields
if ((m_settings.m_codingScheme == MeshtasticDemodSettings::CodingLoRa)) {
showTextMessage(message);
}
+9 -9
View File
@@ -2,7 +2,7 @@
<h2>Introduction</h2>
This plugin can be used to demodulate and decode transmissions based on Chirp Spread Spectrum (CSS). The basic idea is to transform each symbol of a MFSK modulation to an ascending frequency ramp shifted in time. It could equally be a descending ramp but this one is reserved to detect a break in the preamble sequence (synchronization). This plugin has been designed to work in conjunction with the ChirpChat modulator plugin that should be used ideally on the transmission side.
This plugin can be used to demodulate and decode transmissions based on Chirp Spread Spectrum (CSS). The basic idea is to transform each symbol of a MFSK modulation to an ascending frequency ramp shifted in time. It could equally be a descending ramp but this one is reserved to detect a break in the preamble sequence (synchronization). This plugin may be used in conjunction with the Meshtastic modulator plugin on the transmission side.
It has clearly been inspired by the LoRa technique but is designed for experimentation and extension to other protocols mostly inspired by amateur radio techniques using chirp modulation to transmit symbols. Thanks to the MFSK to chirp translation it is possible to adapt any MFSK based mode.
@@ -83,11 +83,11 @@ Use the wheels to adjust the frequency shift in Hz from the center frequency of
<h3>2: De-chirped channel power</h3>
This is the total power in the FFT of the de-chirped signal in dB. When no ChirpChat signal is detected this corresponds to the power received in the bandwidth (3). It will show a significant increase in presence of a ChirpChat signal that can be detected.
This is the total power in the FFT of the de-chirped signal in dB. When no Meshtastic signal is detected this corresponds to the power received in the bandwidth (3). It will show a significant increase in presence of a Meshtastic signal that can be detected.
<h3>3: Bandwidth</h3>
This is the bandwidth of the ChirpChat signal. Similarly to LoRa the signal sweeps between the lower and the upper frequency of this bandwidth. The sample rate of the ChirpChat signal in seconds is exactly one over this bandwidth in Hertz.
This is the bandwidth of the Meshtastic signal. Similarly to LoRa the signal sweeps between the lower and the upper frequency of this bandwidth. The sample rate of the Meshtastic signal in seconds is exactly one over this bandwidth in Hertz.
In the LoRa standard there are 2 base bandwidths: 500 and 333.333 kHz. A 400 kHz base has been added. Possible bandwidths are obtained by a division of these base bandwidths by a power of two from 1 to 64. Extra divisor of 128 is provided to achieve smaller bandwidths that can fit in a SSB channel. Finally special divisors from a 384 kHz base are provided to allow even more narrow bandwidths.
@@ -122,7 +122,7 @@ Thus available bandwidths are:
- **488** (500000 / 1024) Hz not in LoRa standard
- **375** (384000 / 1024) Hz not in LoRa standard
The ChirpChat signal is oversampled by two therefore it needs a baseband of at least twice the bandwidth. This drives the maximum value on the slider automatically.
The Meshtastic signal is oversampled by two therefore it needs a baseband of at least twice the bandwidth. This drives the maximum value on the slider automatically.
<h3>4: De-chirped noise maximum power</h3>
@@ -154,11 +154,11 @@ A choice of FFT Windows to apply to the FFT performed on the de-chirped signal i
<h3>8: Spread Factor</h3>
This is the Spread Factor parameter of the ChirpChat signal. This is the log2 of the FFT size used over the bandwidth (3). The number of symbols is 2<sup>SF-DE</sup> where SF is the spread factor and DE the Distance Enhancement factor (8)
This is the Spread Factor parameter of the Meshtastic signal. This is the log2 of the FFT size used over the bandwidth (3). The number of symbols is 2<sup>SF-DE</sup> where SF is the spread factor and DE the Distance Enhancement factor (8)
<h3>9: Distance Enhancement factor</h3>
The LoRa standard specifies 0 (no DE) or 2 (DE active). The ChirpChat DE range is extended to all values between 0 and 4 bits.
The LoRa standard specifies 0 (no DE) or 2 (DE active). The Meshtastic DE range is extended to all values between 0 and 4 bits.
The LoRa standard also specifies that the LowDataRateOptimizatio flag (thus DE=2 vs DE=0 here) should be set when the symbol time defined as BW / 2^SF exceeds 16 ms (See section 4.1.1.6 of the SX127x datasheet). In practice this happens for SF=11 and SF=12 and large enough bandwidths (you can do the maths).
@@ -305,11 +305,11 @@ This is the UDP address and port to where the decoded message is sent when (12)
<h3>B: De-chirped spectrum</h3>
This is the spectrum of the de-chirped signal when a ChirpChat signal can be decoded. Details on the spectrum view and controls can be found [here](../../../sdrgui/gui/spectrum.md)
This is the spectrum of the de-chirped signal when a Meshtastic signal can be decoded. Details on the spectrum view and controls can be found [here](../../../sdrgui/gui/spectrum.md)
The frequency span corresponds to the bandwidth of the ChirpChat signal (3). Default FFT size is 2<sup>SF</sup> where SF is the spread factor (7).
The frequency span corresponds to the bandwidth of the Meshtastic signal (3). Default FFT size is 2<sup>SF</sup> where SF is the spread factor (7).
Sequences of successful ChirpChat signal demodulation are separated by blank lines (generated with a string of high value bins).
Sequences of successful Meshtastic signal demodulation are separated by blank lines (generated with a string of high value bins).
Controls are the usual controls of spectrum displays with the following restrictions:
+72 -124
View File
@@ -499,8 +499,8 @@ int MeshtasticMod::webapiSettingsGet(
QString& errorMessage)
{
(void) errorMessage;
response.setChirpChatModSettings(new SWGSDRangel::SWGChirpChatModSettings());
response.getChirpChatModSettings()->init();
response.setMeshtasticModSettings(new SWGSDRangel::SWGMeshtasticModSettings());
response.getMeshtasticModSettings()->init();
webapiFormatChannelSettings(response, m_settings);
return 200;
@@ -545,97 +545,82 @@ void MeshtasticMod::webapiUpdateChannelSettings(
SWGSDRangel::SWGChannelSettings& response)
{
if (channelSettingsKeys.contains("inputFrequencyOffset")) {
settings.m_inputFrequencyOffset = response.getChirpChatModSettings()->getInputFrequencyOffset();
settings.m_inputFrequencyOffset = response.getMeshtasticModSettings()->getInputFrequencyOffset();
}
if (channelSettingsKeys.contains("bandwidthIndex")) {
settings.m_bandwidthIndex = response.getChirpChatModSettings()->getBandwidthIndex();
settings.m_bandwidthIndex = response.getMeshtasticModSettings()->getBandwidthIndex();
}
if (channelSettingsKeys.contains("spreadFactor")) {
settings.m_spreadFactor = response.getChirpChatModSettings()->getSpreadFactor();
settings.m_spreadFactor = response.getMeshtasticModSettings()->getSpreadFactor();
}
if (channelSettingsKeys.contains("deBits")) {
settings.m_deBits = response.getChirpChatModSettings()->getDeBits();
settings.m_deBits = response.getMeshtasticModSettings()->getDeBits();
}
if (channelSettingsKeys.contains("preambleChirps")) {
settings.m_preambleChirps = response.getChirpChatModSettings()->getPreambleChirps();
settings.m_preambleChirps = response.getMeshtasticModSettings()->getPreambleChirps();
}
if (channelSettingsKeys.contains("quietMillis")) {
settings.m_quietMillis = response.getChirpChatModSettings()->getQuietMillis();
settings.m_quietMillis = response.getMeshtasticModSettings()->getQuietMillis();
}
if (channelSettingsKeys.contains("syncWord")) {
settings.m_syncWord = response.getChirpChatModSettings()->getSyncWord();
settings.m_syncWord = response.getMeshtasticModSettings()->getSyncWord();
}
if (channelSettingsKeys.contains("syncWord")) {
settings.m_syncWord = response.getChirpChatModSettings()->getSyncWord();
settings.m_syncWord = response.getMeshtasticModSettings()->getSyncWord();
}
if (channelSettingsKeys.contains("channelMute")) {
settings.m_channelMute = response.getChirpChatModSettings()->getChannelMute() != 0;
settings.m_channelMute = response.getMeshtasticModSettings()->getChannelMute() != 0;
}
if (channelSettingsKeys.contains("nbParityBits")) {
settings.m_nbParityBits = response.getChirpChatModSettings()->getNbParityBits();
settings.m_nbParityBits = response.getMeshtasticModSettings()->getNbParityBits();
}
if (channelSettingsKeys.contains("textMessage")) {
settings.m_textMessage = *response.getChirpChatModSettings()->getTextMessage();
}
if (channelSettingsKeys.contains("bytesMessage"))
{
const QList<QString *> *bytesStr = response.getChirpChatModSettings()->getBytesMessage();
settings.m_bytesMessage.clear();
for (QList<QString *>::const_iterator it = bytesStr->begin(); it != bytesStr->end(); ++it)
{
bool bStatus = false;
unsigned int byteInt = (**it).toUInt(&bStatus, 16);
if (bStatus) {
settings.m_bytesMessage.append((char) (byteInt % 256));
}
}
settings.m_textMessage = *response.getMeshtasticModSettings()->getTextMessage();
}
if (channelSettingsKeys.contains("messageRepeat")) {
settings.m_messageRepeat = response.getChirpChatModSettings()->getMessageRepeat();
settings.m_messageRepeat = response.getMeshtasticModSettings()->getMessageRepeat();
}
if (channelSettingsKeys.contains("udpEnabled")) {
settings.m_udpEnabled = response.getChirpChatModSettings()->getUdpEnabled();
settings.m_udpEnabled = response.getMeshtasticModSettings()->getUdpEnabled();
}
if (channelSettingsKeys.contains("udpAddress")) {
settings.m_udpAddress = *response.getChirpChatModSettings()->getUdpAddress();
settings.m_udpAddress = *response.getMeshtasticModSettings()->getUdpAddress();
}
if (channelSettingsKeys.contains("udpPort")) {
settings.m_udpPort = response.getChirpChatModSettings()->getUdpPort();
settings.m_udpPort = response.getMeshtasticModSettings()->getUdpPort();
}
if (channelSettingsKeys.contains("invertRamps")) {
settings.m_invertRamps = response.getChirpChatModSettings()->getInvertRamps();
settings.m_invertRamps = response.getMeshtasticModSettings()->getInvertRamps();
}
if (channelSettingsKeys.contains("rgbColor")) {
settings.m_rgbColor = response.getChirpChatModSettings()->getRgbColor();
settings.m_rgbColor = response.getMeshtasticModSettings()->getRgbColor();
}
if (channelSettingsKeys.contains("title")) {
settings.m_title = *response.getChirpChatModSettings()->getTitle();
settings.m_title = *response.getMeshtasticModSettings()->getTitle();
}
if (channelSettingsKeys.contains("streamIndex")) {
settings.m_streamIndex = response.getChirpChatModSettings()->getStreamIndex();
settings.m_streamIndex = response.getMeshtasticModSettings()->getStreamIndex();
}
if (channelSettingsKeys.contains("useReverseAPI")) {
settings.m_useReverseAPI = response.getChirpChatModSettings()->getUseReverseApi() != 0;
settings.m_useReverseAPI = response.getMeshtasticModSettings()->getUseReverseApi() != 0;
}
if (channelSettingsKeys.contains("reverseAPIAddress")) {
settings.m_reverseAPIAddress = *response.getChirpChatModSettings()->getReverseApiAddress();
settings.m_reverseAPIAddress = *response.getMeshtasticModSettings()->getReverseApiAddress();
}
if (channelSettingsKeys.contains("reverseAPIPort")) {
settings.m_reverseAPIPort = response.getChirpChatModSettings()->getReverseApiPort();
settings.m_reverseAPIPort = response.getMeshtasticModSettings()->getReverseApiPort();
}
if (channelSettingsKeys.contains("reverseAPIDeviceIndex")) {
settings.m_reverseAPIDeviceIndex = response.getChirpChatModSettings()->getReverseApiDeviceIndex();
settings.m_reverseAPIDeviceIndex = response.getMeshtasticModSettings()->getReverseApiDeviceIndex();
}
if (channelSettingsKeys.contains("reverseAPIChannelIndex")) {
settings.m_reverseAPIChannelIndex = response.getChirpChatModSettings()->getReverseApiChannelIndex();
settings.m_reverseAPIChannelIndex = response.getMeshtasticModSettings()->getReverseApiChannelIndex();
}
if (settings.m_channelMarker && channelSettingsKeys.contains("channelMarker")) {
settings.m_channelMarker->updateFrom(channelSettingsKeys, response.getChirpChatModSettings()->getChannelMarker());
settings.m_channelMarker->updateFrom(channelSettingsKeys, response.getMeshtasticModSettings()->getChannelMarker());
}
if (settings.m_rollupState && channelSettingsKeys.contains("rollupState")) {
settings.m_rollupState->updateFrom(channelSettingsKeys, response.getChirpChatModSettings()->getChannelMarker());
settings.m_rollupState->updateFrom(channelSettingsKeys, response.getMeshtasticModSettings()->getRollupState());
}
}
@@ -644,108 +629,95 @@ int MeshtasticMod::webapiReportGet(
QString& errorMessage)
{
(void) errorMessage;
response.setChirpChatModReport(new SWGSDRangel::SWGChirpChatModReport());
response.getChirpChatModReport()->init();
response.setMeshtasticModReport(new SWGSDRangel::SWGMeshtasticModReport());
response.getMeshtasticModReport()->init();
webapiFormatChannelReport(response);
return 200;
}
void MeshtasticMod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const MeshtasticModSettings& settings)
{
response.getChirpChatModSettings()->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
response.getChirpChatModSettings()->setBandwidthIndex(settings.m_bandwidthIndex);
response.getChirpChatModSettings()->setSpreadFactor(settings.m_spreadFactor);
response.getChirpChatModSettings()->setDeBits(settings.m_deBits);
response.getChirpChatModSettings()->setPreambleChirps(settings.m_preambleChirps);
response.getChirpChatModSettings()->setQuietMillis(settings.m_quietMillis);
response.getChirpChatModSettings()->setSyncWord(settings.m_syncWord);
response.getChirpChatModSettings()->setChannelMute(settings.m_channelMute ? 1 : 0);
response.getChirpChatModSettings()->setCodingScheme((int) settings.m_codingScheme);
response.getChirpChatModSettings()->setNbParityBits(settings.m_nbParityBits);
response.getChirpChatModSettings()->setHasCrc(settings.m_hasCRC ? 1 : 0);
response.getChirpChatModSettings()->setHasHeader(settings.m_hasHeader ? 1 : 0);
response.getChirpChatModSettings()->setMessageType((int) settings.m_messageType);
response.getMeshtasticModSettings()->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
response.getMeshtasticModSettings()->setBandwidthIndex(settings.m_bandwidthIndex);
response.getMeshtasticModSettings()->setSpreadFactor(settings.m_spreadFactor);
response.getMeshtasticModSettings()->setDeBits(settings.m_deBits);
response.getMeshtasticModSettings()->setPreambleChirps(settings.m_preambleChirps);
response.getMeshtasticModSettings()->setQuietMillis(settings.m_quietMillis);
response.getMeshtasticModSettings()->setSyncWord(settings.m_syncWord);
response.getMeshtasticModSettings()->setChannelMute(settings.m_channelMute ? 1 : 0);
response.getMeshtasticModSettings()->setNbParityBits(settings.m_nbParityBits);
if (response.getChirpChatModSettings()->getTextMessage()) {
*response.getChirpChatModSettings()->getTextMessage() = settings.m_textMessage;
if (response.getMeshtasticModSettings()->getTextMessage()) {
*response.getMeshtasticModSettings()->getTextMessage() = settings.m_textMessage;
} else {
response.getChirpChatModSettings()->setTextMessage(new QString(settings.m_textMessage));
response.getMeshtasticModSettings()->setTextMessage(new QString(settings.m_textMessage));
}
response.getChirpChatModSettings()->setBytesMessage(new QList<QString *>);
QList<QString *> *bytesStr = response.getChirpChatModSettings()->getBytesMessage();
response.getMeshtasticModSettings()->setMessageRepeat(settings.m_messageRepeat);
response.getMeshtasticModSettings()->setUdpEnabled(settings.m_udpEnabled);
response.getMeshtasticModSettings()->setUdpAddress(new QString(settings.m_udpAddress));
response.getMeshtasticModSettings()->setUdpPort(settings.m_udpPort);
response.getMeshtasticModSettings()->setInvertRamps(settings.m_invertRamps ? 1 : 0);
for (QByteArray::const_iterator it = settings.m_bytesMessage.begin(); it != settings.m_bytesMessage.end(); ++it)
{
unsigned char b = *it;
bytesStr->push_back(new QString(tr("%1").arg(b, 2, 16, QChar('0'))));
}
response.getMeshtasticModSettings()->setRgbColor(settings.m_rgbColor);
response.getChirpChatModSettings()->setMessageRepeat(settings.m_messageRepeat);
response.getChirpChatModSettings()->setUdpEnabled(settings.m_udpEnabled);
response.getChirpChatModSettings()->setUdpAddress(new QString(settings.m_udpAddress));
response.getChirpChatModSettings()->setUdpPort(settings.m_udpPort);
response.getChirpChatModSettings()->setInvertRamps(settings.m_invertRamps ? 1 : 0);
response.getChirpChatModSettings()->setRgbColor(settings.m_rgbColor);
if (response.getChirpChatModSettings()->getTitle()) {
*response.getChirpChatModSettings()->getTitle() = settings.m_title;
if (response.getMeshtasticModSettings()->getTitle()) {
*response.getMeshtasticModSettings()->getTitle() = settings.m_title;
} else {
response.getChirpChatModSettings()->setTitle(new QString(settings.m_title));
response.getMeshtasticModSettings()->setTitle(new QString(settings.m_title));
}
response.getChirpChatModSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
response.getMeshtasticModSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
if (response.getChirpChatModSettings()->getReverseApiAddress()) {
*response.getChirpChatModSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress;
if (response.getMeshtasticModSettings()->getReverseApiAddress()) {
*response.getMeshtasticModSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress;
} else {
response.getChirpChatModSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
response.getMeshtasticModSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
}
response.getChirpChatModSettings()->setReverseApiPort(settings.m_reverseAPIPort);
response.getChirpChatModSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
response.getChirpChatModSettings()->setReverseApiChannelIndex(settings.m_reverseAPIChannelIndex);
response.getMeshtasticModSettings()->setReverseApiPort(settings.m_reverseAPIPort);
response.getMeshtasticModSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
response.getMeshtasticModSettings()->setReverseApiChannelIndex(settings.m_reverseAPIChannelIndex);
if (settings.m_channelMarker)
{
if (response.getChirpChatModSettings()->getChannelMarker())
if (response.getMeshtasticModSettings()->getChannelMarker())
{
settings.m_channelMarker->formatTo(response.getChirpChatModSettings()->getChannelMarker());
settings.m_channelMarker->formatTo(response.getMeshtasticModSettings()->getChannelMarker());
}
else
{
SWGSDRangel::SWGChannelMarker *swgChannelMarker = new SWGSDRangel::SWGChannelMarker();
settings.m_channelMarker->formatTo(swgChannelMarker);
response.getChirpChatModSettings()->setChannelMarker(swgChannelMarker);
response.getMeshtasticModSettings()->setChannelMarker(swgChannelMarker);
}
}
if (settings.m_rollupState)
{
if (response.getChirpChatModSettings()->getRollupState())
if (response.getMeshtasticModSettings()->getRollupState())
{
settings.m_rollupState->formatTo(response.getChirpChatModSettings()->getRollupState());
settings.m_rollupState->formatTo(response.getMeshtasticModSettings()->getRollupState());
}
else
{
SWGSDRangel::SWGRollupState *swgRollupState = new SWGSDRangel::SWGRollupState();
settings.m_rollupState->formatTo(swgRollupState);
response.getChirpChatModSettings()->setRollupState(swgRollupState);
response.getMeshtasticModSettings()->setRollupState(swgRollupState);
}
}
}
void MeshtasticMod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response)
{
response.getChirpChatModReport()->setChannelPowerDb(CalcDb::dbPower(getMagSq()));
response.getChirpChatModReport()->setChannelSampleRate(m_basebandSource->getChannelSampleRate());
response.getMeshtasticModReport()->setChannelPowerDb(CalcDb::dbPower(getMagSq()));
response.getMeshtasticModReport()->setChannelSampleRate(m_basebandSource->getChannelSampleRate());
float fourthsMs = ((1<<m_settings.m_spreadFactor) * 250.0) / MeshtasticModSettings::bandwidths[m_settings.m_bandwidthIndex];
float controlMs = (4*m_settings.m_preambleChirps + 8 + 9) * fourthsMs; // preamble + sync word + SFD
response.getChirpChatModReport()->setPayloadTimeMs(m_currentPayloadTime);
response.getChirpChatModReport()->setTotalTimeMs(m_currentPayloadTime + controlMs);
response.getChirpChatModReport()->setSymbolTimeMs(4.0 * fourthsMs);
response.getChirpChatModReport()->setPlaying(getModulatorActive() ? 1 : 0);
response.getMeshtasticModReport()->setPayloadTimeMs(m_currentPayloadTime);
response.getMeshtasticModReport()->setTotalTimeMs(m_currentPayloadTime + controlMs);
response.getMeshtasticModReport()->setSymbolTimeMs(4.0 * fourthsMs);
response.getMeshtasticModReport()->setPlaying(getModulatorActive() ? 1 : 0);
}
void MeshtasticMod::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const MeshtasticModSettings& settings, bool force)
@@ -809,8 +781,8 @@ void MeshtasticMod::webapiFormatChannelSettings(
swgChannelSettings->setOriginatorChannelIndex(getIndexInDeviceSet());
swgChannelSettings->setOriginatorDeviceSetIndex(getDeviceSetIndex());
swgChannelSettings->setChannelType(new QString(m_channelId));
swgChannelSettings->setChirpChatModSettings(new SWGSDRangel::SWGChirpChatModSettings());
SWGSDRangel::SWGChirpChatModSettings *swgMeshtasticModSettings = swgChannelSettings->getChirpChatModSettings();
swgChannelSettings->setMeshtasticModSettings(new SWGSDRangel::SWGMeshtasticModSettings());
SWGSDRangel::SWGMeshtasticModSettings *swgMeshtasticModSettings = swgChannelSettings->getMeshtasticModSettings();
// transfer data that has been modified. When force is on transfer all data except reverse API data
@@ -838,37 +810,13 @@ void MeshtasticMod::webapiFormatChannelSettings(
if (channelSettingsKeys.contains("channelMute") || force) {
swgMeshtasticModSettings->setChannelMute(settings.m_channelMute ? 1 : 0);
}
if (channelSettingsKeys.contains("codingScheme") || force) {
swgMeshtasticModSettings->setCodingScheme((int) settings.m_codingScheme);
}
if (channelSettingsKeys.contains("nbParityBits") || force) {
swgMeshtasticModSettings->setNbParityBits(settings.m_nbParityBits);
}
if (channelSettingsKeys.contains("hasCRC") || force) {
swgMeshtasticModSettings->setHasCrc(settings.m_hasCRC ? 1 : 0);
}
if (channelSettingsKeys.contains("hasHeader") || force) {
swgMeshtasticModSettings->setHasHeader(settings.m_hasHeader ? 1 : 0);
}
if (channelSettingsKeys.contains("messageType") || force) {
swgMeshtasticModSettings->setMessageType((int) settings.m_messageType);
}
if (channelSettingsKeys.contains("textMessage") || force) {
swgMeshtasticModSettings->setTextMessage(new QString(settings.m_textMessage));
}
if (channelSettingsKeys.contains("bytesMessage") || force)
{
swgMeshtasticModSettings->setBytesMessage(new QList<QString *>);
QList<QString *> *bytesStr = swgMeshtasticModSettings-> getBytesMessage();
for (QByteArray::const_iterator it = settings.m_bytesMessage.begin(); it != settings.m_bytesMessage.end(); ++it)
{
unsigned char b = *it;
bytesStr->push_back(new QString(tr("%1").arg(b, 2, 16, QChar('0'))));
}
}
if (channelSettingsKeys.contains("messageRepeat") || force) {
swgMeshtasticModSettings->setMessageRepeat(settings.m_messageRepeat);
}