From 5f2d2a0b2ead9f51459ea5638d38b5b764cbe513 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 19 Jun 2022 06:39:05 +0200 Subject: [PATCH] M17 demod: view SMS messages in GUI --- plugins/channelrx/demodm17/m17demod.cpp | 12 + plugins/channelrx/demodm17/m17demod.h | 28 +- plugins/channelrx/demodm17/m17demodbaseband.h | 1 + plugins/channelrx/demodm17/m17demodgui.cpp | 18 + plugins/channelrx/demodm17/m17demodgui.ui | 1585 +++++++++-------- .../channelrx/demodm17/m17demodprocessor.cpp | 19 +- .../channelrx/demodm17/m17demodprocessor.h | 4 + plugins/channelrx/demodm17/m17demodsink.h | 1 + 8 files changed, 920 insertions(+), 748 deletions(-) diff --git a/plugins/channelrx/demodm17/m17demod.cpp b/plugins/channelrx/demodm17/m17demod.cpp index 0eb93f814..2972127e6 100644 --- a/plugins/channelrx/demodm17/m17demod.cpp +++ b/plugins/channelrx/demodm17/m17demod.cpp @@ -44,6 +44,7 @@ #include "m17demod.h" MESSAGE_CLASS_DEFINITION(M17Demod::MsgConfigureM17Demod, Message) +MESSAGE_CLASS_DEFINITION(M17Demod::MsgReportSMS, Message) const char* const M17Demod::m_channelIdURI = "sdrangel.channel.m17demod"; const char* const M17Demod::m_channelId = "M17Demod"; @@ -60,6 +61,7 @@ M17Demod::M17Demod(DeviceAPI *deviceAPI) : m_thread = new QThread(this); m_basebandSink = new M17DemodBaseband(); m_basebandSink->setChannel(this); + m_basebandSink->setDemodInputMessageQueue(&m_inputMessageQueue); m_basebandSink->moveToThread(m_thread); applySettings(m_settings, true); @@ -173,6 +175,16 @@ bool M17Demod::handleMessage(const Message& cmd) return true; } + else if (MsgReportSMS::match(cmd)) + { + MsgReportSMS& report = (MsgReportSMS&) cmd; + // Forward to GUI if any + if (getMessageQueueToGUI()) { + getMessageQueueToGUI()->push(new MsgReportSMS(report)); + } + + return true; + } else { return false; diff --git a/plugins/channelrx/demodm17/m17demod.h b/plugins/channelrx/demodm17/m17demod.h index 8ab883909..9ccec1e09 100644 --- a/plugins/channelrx/demodm17/m17demod.h +++ b/plugins/channelrx/demodm17/m17demod.h @@ -45,8 +45,7 @@ public: const M17DemodSettings& getSettings() const { return m_settings; } bool getForce() const { return m_force; } - static MsgConfigureM17Demod* create(const M17DemodSettings& settings, bool force) - { + static MsgConfigureM17Demod* create(const M17DemodSettings& settings, bool force) { return new MsgConfigureM17Demod(settings, force); } @@ -61,6 +60,31 @@ public: { } }; + class MsgReportSMS : public Message { + MESSAGE_CLASS_DECLARATION + + public: + const QString& getSource() const { return m_source; } + const QString& getDest() const { return m_dest; } + const QString& getSMS() const { return m_sms; } + + static MsgReportSMS* create(const QString& source, const QString& dest, const QString& sms) { + return new MsgReportSMS(source, dest, sms); + } + + private: + QString m_source; + QString m_dest; + QString m_sms; + + MsgReportSMS(const QString& source, const QString& dest, const QString& sms) : + Message(), + m_source(source), + m_dest(dest), + m_sms(sms) + { } + }; + M17Demod(DeviceAPI *deviceAPI); virtual ~M17Demod(); virtual void destroy() { delete this; } diff --git a/plugins/channelrx/demodm17/m17demodbaseband.h b/plugins/channelrx/demodm17/m17demodbaseband.h index 37a9061b2..bac5205a3 100644 --- a/plugins/channelrx/demodm17/m17demodbaseband.h +++ b/plugins/channelrx/demodm17/m17demodbaseband.h @@ -97,6 +97,7 @@ public: bool getStreamElsePacket() const { return m_sink.getStreamElsePacket(); } uint16_t getCRC() const { return m_sink.getCRC(); } int getStdPacketProtocol() const { return m_sink.getStdPacketProtocol(); } + void setDemodInputMessageQueue(MessageQueue *messageQueue) { m_sink.setDemodInputMessageQueue(messageQueue); } private: SampleSinkFifo m_sampleFifo; diff --git a/plugins/channelrx/demodm17/m17demodgui.cpp b/plugins/channelrx/demodm17/m17demodgui.cpp index a6d9cf467..3e2efbb27 100644 --- a/plugins/channelrx/demodm17/m17demodgui.cpp +++ b/plugins/channelrx/demodm17/m17demodgui.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -113,6 +114,23 @@ bool M17DemodGUI::handleMessage(const Message& message) updateAbsoluteCenterFrequency(); return true; } + else if (M17Demod::MsgReportSMS::match(message)) + { + const M17Demod::MsgReportSMS& report = (M17Demod::MsgReportSMS&) message; + QDateTime dt = QDateTime::currentDateTime(); + QString dateStr = dt.toString("HH:mm:ss"); + QTextCursor cursor = ui->smsLog->textCursor(); + cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor); + cursor.insertText(tr("=== %1 %2 to %3 ===\n%4\n") + .arg(dateStr) + .arg(report.getSource()) + .arg(report.getDest()) + .arg(report.getSMS()) + ); + ui->smsLog->verticalScrollBar()->setValue(ui->smsLog->verticalScrollBar()->maximum()); + + return true; + } else { return false; diff --git a/plugins/channelrx/demodm17/m17demodgui.ui b/plugins/channelrx/demodm17/m17demodgui.ui index 4da0798ab..b04054974 100644 --- a/plugins/channelrx/demodm17/m17demodgui.ui +++ b/plugins/channelrx/demodm17/m17demodgui.ui @@ -6,8 +6,8 @@ 0 0 - 482 - 400 + 522 + 420 @@ -18,14 +18,14 @@ - 482 - 400 + 522 + 420 560 - 400 + 420 @@ -42,7 +42,7 @@ 0 0 - 480 + 520 136 @@ -54,7 +54,7 @@ - 480 + 520 0 @@ -525,14 +525,14 @@ 0 136 - 480 - 249 + 520 + 280 - 480 - 248 + 520 + 274 @@ -637,7 +637,7 @@ - 120 + 130 0 @@ -718,742 +718,839 @@ - - - - - - 0 - 0 - + + + + 0 + 210 + + + + Digital section + + + QTabWidget::East + + + 0 + + + + Dgital Settings + + + + :/gear.png:/gear.png + + + + + + Settings + + + + + 0 + 0 + 476 + 212 + - - - 200 - 200 - - - - - - - - - 0 - 210 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - 10 - 10 - 60 - 24 - - - - - 0 - 0 - - - - - 35 - 0 - - - - - 16777215 - 16777215 - - - - Baud rate: 2.4k: NXDN48, dPMR 4.8k: DMR, D-Star, YSF, NXDN96 - + - - 4.8k - + + + + 0 + 0 + + + + + 200 + 200 + + + - - - - - 80 - 10 - 110 - 24 - - - - - 110 - 0 - - - - - 16777215 - 24 - - - - - Liberation Mono - 9 - - - - Synchronization status - - - QFrame::Box - - - QFrame::Sunken - - - 1 - - - No Sync______ - - - - - - 194 - 10 - 24 - 24 - - - - - 0 - 0 - - - - - 24 - 24 - - - - - 24 - 24 - - - - Data Carrier Detect (DCD) - - - QFrame::Box - - - QFrame::Sunken - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 84 - 40 - 25 - 28 - - - - - 25 - 0 - - - - Carrier relative position (%) when synchronized - - - Dev - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 110 - 40 - 31 - 28 - - - - - 25 - 0 - - - - Detected FM deviation relative to nominal deviation - - - 0.00 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 10 - 100 - 23 - 22 - - - - Toggle between transition constellation and symbol synchronization displays - - - - - - - :/constellation.png - :/slopep_icon.png:/constellation.png - - - true - - - - - - 50 - 135 - 154 - 22 - - - - Maximum frequency deviation (kHz) - - - 100 - - - 1 - - - 35 - - - 35 - - - Qt::Horizontal - - - - - - 10 - 130 - 25 - 29 - - - - FMd - - - - - - 205 - 130 - 50 - 29 - - - - - 50 - 0 - - - - +00.0k - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 40 - 100 - 24 - 24 - - - - - 24 - 24 - - - - Display trace length (ms) - - - 6 - - - 30 - - - 1 - - - 6 - - - - - - 68 - 100 - 31 - 22 - - - - Display trace length (ms) - - - 0000 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 108 - 100 - 24 - 24 - - - - - 24 - 24 - - - - Trace stroke [0..255] - - - 0 - - - 255 - - - 1 - - - 100 - - - - - - 128 - 100 - 31 - 22 - - - - Trace stroke value - - - 000 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 168 - 100 - 24 - 24 - - - - - 24 - 24 - - - - Trace decay [0..255] - - - 0 - - - 255 - - - 1 - - - 200 - - - - - - 188 - 100 - 31 - 22 - - - - Trace decay value - - - 000 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 222 - 10 - 24 - 24 - - - - - 0 - 0 - - - - - 24 - 24 - - - - - 24 - 24 - - - - Locked state - - - QFrame::Box - - - QFrame::Sunken - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 10 - 40 - 27 - 28 - - - - - 27 - 0 - - - - Carrier relative position (%) when synchronized - - - EVM - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 40 - 40 - 38 - 28 - - - - - 30 - 0 - - - - Error Vector Magnitude (%) when synchronized - - - 00.0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 148 - 40 - 25 - 28 - - - - - 25 - 0 - - - - Carrier relative position (%) when synchronized - - - Ofs - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 172 - 40 - 31 - 28 - - - - - 25 - 0 - - - - Detected carrier deviation relative to nominal deviation - - - 0.00 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 178 - 65 - 25 - 28 - - - - - 25 - 0 - - - - Carrier relative position (%) when synchronized - - - Vit - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 203 - 65 - 25 - 28 - - - - - 25 - 0 - - - - Viterbi cost. -1 if not available. - - - 128 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 10 - 65 - 25 - 28 - - - - - 25 - 0 - - - - Carrier relative position (%) when synchronized - - - Clk - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 40 - 65 - 25 - 28 - - - - - 25 - 0 - - - - Difference between Tx and Rx clock normalized - - - 0.0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - 80 - 65 - 35 - 28 - - - - - 25 - 0 - - - - Carrier relative position (%) when synchronized - - - Samp - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 120 - 65 - 46 - 28 - - - - - 25 - 0 - - - - Estimated sample point: sample, sync, clock. Clock wins - - - 0, 0, 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + + + + 0 + 210 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 10 + 10 + 60 + 24 + + + + + 0 + 0 + + + + + 35 + 0 + + + + + 16777215 + 16777215 + + + + Baud rate: 2.4k: NXDN48, dPMR 4.8k: DMR, D-Star, YSF, NXDN96 + + + + 4.8k + + + + + + + 80 + 10 + 110 + 24 + + + + + 110 + 0 + + + + + 16777215 + 24 + + + + + Liberation Mono + 9 + + + + Synchronization status + + + QFrame::Box + + + QFrame::Sunken + + + 1 + + + No Sync______ + + + + + + 194 + 10 + 24 + 24 + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + Data Carrier Detect (DCD) + + + QFrame::Box + + + QFrame::Sunken + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 84 + 40 + 25 + 28 + + + + + 25 + 0 + + + + Carrier relative position (%) when synchronized + + + Dev + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 110 + 40 + 31 + 28 + + + + + 25 + 0 + + + + Detected FM deviation relative to nominal deviation + + + 0.00 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 100 + 23 + 22 + + + + Toggle between transition constellation and symbol synchronization displays + + + + + + + :/constellation.png + :/slopep_icon.png:/constellation.png + + + true + + + + + + 50 + 135 + 154 + 22 + + + + Maximum frequency deviation (kHz) + + + 100 + + + 1 + + + 35 + + + 35 + + + Qt::Horizontal + + + + + + 10 + 130 + 25 + 29 + + + + FMd + + + + + + 205 + 130 + 50 + 29 + + + + + 50 + 0 + + + + +00.0k + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 40 + 100 + 24 + 24 + + + + + 24 + 24 + + + + Display trace length (ms) + + + 6 + + + 30 + + + 1 + + + 6 + + + + + + 68 + 100 + 31 + 22 + + + + Display trace length (ms) + + + 0000 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 108 + 100 + 24 + 24 + + + + + 24 + 24 + + + + Trace stroke [0..255] + + + 0 + + + 255 + + + 1 + + + 100 + + + + + + 128 + 100 + 31 + 22 + + + + Trace stroke value + + + 000 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 168 + 100 + 24 + 24 + + + + + 24 + 24 + + + + Trace decay [0..255] + + + 0 + + + 255 + + + 1 + + + 200 + + + + + + 188 + 100 + 31 + 22 + + + + Trace decay value + + + 000 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 222 + 10 + 24 + 24 + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + Locked state + + + QFrame::Box + + + QFrame::Sunken + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 40 + 27 + 28 + + + + + 27 + 0 + + + + Carrier relative position (%) when synchronized + + + EVM + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 40 + 40 + 38 + 28 + + + + + 30 + 0 + + + + Error Vector Magnitude (%) when synchronized + + + 00.0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 148 + 40 + 25 + 28 + + + + + 25 + 0 + + + + Carrier relative position (%) when synchronized + + + Ofs + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 172 + 40 + 31 + 28 + + + + + 25 + 0 + + + + Detected carrier deviation relative to nominal deviation + + + 0.00 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 178 + 65 + 25 + 28 + + + + + 25 + 0 + + + + Carrier relative position (%) when synchronized + + + Vit + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 203 + 65 + 25 + 28 + + + + + 25 + 0 + + + + Viterbi cost. -1 if not available. + + + 128 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 65 + 25 + 28 + + + + + 25 + 0 + + + + Carrier relative position (%) when synchronized + + + Clk + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 40 + 65 + 25 + 28 + + + + + 25 + 0 + + + + Difference between Tx and Rx clock normalized + + + 0.0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 80 + 65 + 35 + 28 + + + + + 25 + 0 + + + + Carrier relative position (%) when synchronized + + + Samp + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 120 + 65 + 46 + 28 + + + + + 25 + 0 + + + + Estimated sample point: sample, sync, clock. Clock wins + + + 0, 0, 0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + - - + + + + SMS data + + + + :/sms.png:/sms.png + + + + + + SMS + + + + true + + + + 0 + 0 + 471 + 210 + + + + + Liberation Mono + 9 + + + + SMS log + + + true + + + + + + APRS data + + + + :/world.png:/world.png + + + + + + APRS + + + diff --git a/plugins/channelrx/demodm17/m17demodprocessor.cpp b/plugins/channelrx/demodm17/m17demodprocessor.cpp index 0067c89a2..8e9ca506a 100644 --- a/plugins/channelrx/demodm17/m17demodprocessor.cpp +++ b/plugins/channelrx/demodm17/m17demodprocessor.cpp @@ -25,6 +25,7 @@ #include "audio/audiofifo.h" #include "m17/ax25_frame.h" +#include "m17demod.h" #include "m17demodprocessor.h" M17DemodProcessor* M17DemodProcessor::m_this = nullptr; @@ -36,7 +37,8 @@ M17DemodProcessor::M17DemodProcessor() : m_demod(handle_frame), m_audioFifo(nullptr), m_audioMute(false), - m_volume(1.0f) + m_volume(1.0f), + m_demodInputMessageQueue(nullptr) { m_this = this; m_codec2 = ::codec2_create(CODEC2_MODE_3200); @@ -359,7 +361,20 @@ bool M17DemodProcessor::decode_packet(mobilinkd::M17FrameDecoder::packet_buffer_ oss << *it; } - qDebug() << "M17DemodProcessor::decode_packet: SMS:" << oss.str().c_str(); + qDebug() << "M17DemodProcessor::decode_packet: " + << " From:" << getSrcCall() + << " To:" << getDestcCall() + << " SMS:" << oss.str().c_str(); + + if (m_demodInputMessageQueue) + { + M17Demod::MsgReportSMS *msg = M17Demod::MsgReportSMS::create( + getSrcCall(), + getDestcCall(), + QString(oss.str().c_str()) + ); + m_demodInputMessageQueue->push(msg); + } } return true; diff --git a/plugins/channelrx/demodm17/m17demodprocessor.h b/plugins/channelrx/demodm17/m17demodprocessor.h index 90a4e7f1d..de0051e18 100644 --- a/plugins/channelrx/demodm17/m17demodprocessor.h +++ b/plugins/channelrx/demodm17/m17demodprocessor.h @@ -25,6 +25,7 @@ #include "m17demodfilters.h" class AudioFifo; +class MessageQueue; class M17DemodProcessor : public QObject { @@ -45,6 +46,7 @@ public: M17DemodProcessor(); ~M17DemodProcessor(); + void setDemodInputMessageQueue(MessageQueue *messageQueue) { m_demodInputMessageQueue = messageQueue; } void pushSample(qint16 sample); void setDisplayLSF(bool displayLSF) { m_displayLSF = displayLSF; } void setNoiseBlanker(bool noiseBlanker) { m_noiseBlanker = noiseBlanker; } @@ -130,6 +132,8 @@ private: uint32_t m_lsfCount; // Incremented each time a new LSF is decoded. Reset when lock is lost. StdPacketProtocol m_stdPacketProtocol; + MessageQueue *m_demodInputMessageQueue; + static bool handle_frame(mobilinkd::M17FrameDecoder::output_buffer_t const& frame, int viterbi_cost); static void diagnostic_callback( bool dcd, diff --git a/plugins/channelrx/demodm17/m17demodsink.h b/plugins/channelrx/demodm17/m17demodsink.h index 503c9cd2e..97f163887 100644 --- a/plugins/channelrx/demodm17/m17demodsink.h +++ b/plugins/channelrx/demodm17/m17demodsink.h @@ -99,6 +99,7 @@ public: bool getStreamElsePacket() const { return m_m17DemodProcessor.getStreamElsePacket(); } uint16_t getCRC() const { return m_m17DemodProcessor.getCRC(); } int getStdPacketProtocol() const { return (int) m_m17DemodProcessor.getStdPacketProtocol(); } + void setDemodInputMessageQueue(MessageQueue *messageQueue) { m_m17DemodProcessor.setDemodInputMessageQueue(messageQueue); } private: struct MagSqLevelsStore