From 039c4d032e6bb3f3571cb85b262e4fb504ffcc91 Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Thu, 25 Mar 2021 22:15:41 +0000 Subject: [PATCH] Add basic APRS support to ChirpChatDemod --- .../demodchirpchat/chirpchatdemod.cpp | 39 +++++++++++++++++++ plugins/feature/aprs/aprssettings.cpp | 4 +- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/plugins/channelrx/demodchirpchat/chirpchatdemod.cpp b/plugins/channelrx/demodchirpchat/chirpchatdemod.cpp index 51765c4e6..9c3f0c117 100644 --- a/plugins/channelrx/demodchirpchat/chirpchatdemod.cpp +++ b/plugins/channelrx/demodchirpchat/chirpchatdemod.cpp @@ -34,6 +34,7 @@ #include "dsp/dspcommands.h" #include "device/deviceapi.h" #include "feature/feature.h" +#include "util/ax25.h" #include "util/db.h" #include "maincore.h" @@ -188,6 +189,44 @@ bool ChirpChatDemod::handleMessage(const Message& cmd) getMessageQueueToGUI()->push(msgToGUI); } + // Is this an APRS packet? + // As per: https://github.com/oe3cjb/TTGO-T-Beam-LoRa-APRS/blob/master/lib/BG_RF95/BG_RF95.cpp + // There is a 3 byte header for LoRa APRS packets. Addressing follows in ASCII: srccall>dst: + // TODO: Should we check for valid CRC? + int colonIdx = m_lastMsgBytes.indexOf(':'); + int greaterThanIdx = m_lastMsgBytes.indexOf('>'); + if ((m_lastMsgBytes[0] == '<') && (greaterThanIdx != -1) && (colonIdx != -1)) + { + QByteArray packet; + + // Extract addresses + const char *d = m_lastMsgBytes.data(); + QString srcString = QString::fromLatin1(d + 3, greaterThanIdx - 3); + QString dstString = QString::fromLatin1(d + greaterThanIdx + 1, colonIdx - greaterThanIdx - 1); + + // Convert to AX.25 format + packet.append(AX25Packet::encodeAddress(dstString)); + packet.append(AX25Packet::encodeAddress(srcString, 1)); + packet.append(3); + packet.append(-16); // 0xf0 + packet.append(m_lastMsgBytes.mid(colonIdx+1)); + packet.append((char)0); // dummy crc + packet.append((char)0); + + // Forward to APRS and other packet features + MessagePipes& messagePipes = MainCore::instance()->getMessagePipes(); + QList *packetMessageQueues = messagePipes.getMessageQueues(this, "packets"); + if (packetMessageQueues) + { + QList::iterator it = packetMessageQueues->begin(); + for (; it != packetMessageQueues->end(); ++it) + { + MainCore::MsgPacket *msg = MainCore::MsgPacket::create(this, packet, QDateTime::currentDateTime()); + (*it)->push(msg); + } + } + } + if (m_settings.m_autoNbSymbolsMax) { ChirpChatDemodSettings settings = m_settings; diff --git a/plugins/feature/aprs/aprssettings.cpp b/plugins/feature/aprs/aprssettings.cpp index 368beca30..aa4d42654 100644 --- a/plugins/feature/aprs/aprssettings.cpp +++ b/plugins/feature/aprs/aprssettings.cpp @@ -24,11 +24,13 @@ #include "aprssettings.h" const QStringList APRSSettings::m_pipeTypes = { - QStringLiteral("PacketDemod") + QStringLiteral("PacketDemod"), + QStringLiteral("ChirpChatDemod") }; const QStringList APRSSettings::m_pipeURIs = { QStringLiteral("sdrangel.channel.packetdemod"), + QStringLiteral("sdrangel.channel.chirpchatdemod") }; APRSSettings::APRSSettings()