M17 demod: view SMS messages in GUI

This commit is contained in:
f4exb 2022-06-19 06:39:05 +02:00
parent 9738e986c2
commit 5f2d2a0b2e
8 changed files with 920 additions and 748 deletions

View File

@ -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;

View File

@ -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; }

View File

@ -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;

View File

@ -19,6 +19,7 @@
#include <QDockWidget>
#include <QMainWindow>
#include <QDebug>
#include <QScrollBar>
#include <complex>
@ -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;

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>482</width>
<height>400</height>
<width>522</width>
<height>420</height>
</rect>
</property>
<property name="sizePolicy">
@ -18,14 +18,14 @@
</property>
<property name="minimumSize">
<size>
<width>482</width>
<height>400</height>
<width>522</width>
<height>420</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>560</width>
<height>400</height>
<height>420</height>
</size>
</property>
<property name="font">
@ -42,7 +42,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>480</width>
<width>520</width>
<height>136</height>
</rect>
</property>
@ -54,7 +54,7 @@
</property>
<property name="minimumSize">
<size>
<width>480</width>
<width>520</width>
<height>0</height>
</size>
</property>
@ -525,14 +525,14 @@
<rect>
<x>0</x>
<y>136</y>
<width>480</width>
<height>249</height>
<width>520</width>
<height>280</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>480</width>
<height>248</height>
<width>520</width>
<height>274</height>
</size>
</property>
<property name="windowTitle">
@ -637,7 +637,7 @@
<widget class="QLabel" name="typeText">
<property name="minimumSize">
<size>
<width>120</width>
<width>130</width>
<height>0</height>
</size>
</property>
@ -718,6 +718,45 @@
</layout>
</item>
<item>
<widget class="QTabWidget" name="digitalTabWidget">
<property name="minimumSize">
<size>
<width>0</width>
<height>210</height>
</size>
</property>
<property name="toolTip">
<string>Digital section</string>
</property>
<property name="tabPosition">
<enum>QTabWidget::East</enum>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="settingsTab">
<property name="toolTip">
<string>Dgital Settings</string>
</property>
<attribute name="icon">
<iconset resource="../../../sdrgui/resources/res.qrc">
<normaloff>:/gear.png</normaloff>:/gear.png</iconset>
</attribute>
<attribute name="title">
<string/>
</attribute>
<attribute name="toolTip">
<string>Settings</string>
</attribute>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>476</width>
<height>212</height>
</rect>
</property>
<layout class="QHBoxLayout" name="scopeLayout">
<item>
<widget class="TVScreen" name="screenTV" native="true">
@ -1454,6 +1493,64 @@
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QWidget" name="smsTab">
<property name="toolTip">
<string>SMS data</string>
</property>
<attribute name="icon">
<iconset resource="../../../sdrgui/resources/res.qrc">
<normaloff>:/sms.png</normaloff>:/sms.png</iconset>
</attribute>
<attribute name="title">
<string/>
</attribute>
<attribute name="toolTip">
<string>SMS</string>
</attribute>
<widget class="QPlainTextEdit" name="smsLog">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>471</width>
<height>210</height>
</rect>
</property>
<property name="font">
<font>
<family>Liberation Mono</family>
<pointsize>9</pointsize>
</font>
</property>
<property name="toolTip">
<string>SMS log</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</widget>
<widget class="QWidget" name="aprsTab">
<property name="toolTip">
<string>APRS data</string>
</property>
<attribute name="icon">
<iconset resource="../../../sdrgui/resources/res.qrc">
<normaloff>:/world.png</normaloff>:/world.png</iconset>
</attribute>
<attribute name="title">
<string/>
</attribute>
<attribute name="toolTip">
<string>APRS</string>
</attribute>
</widget>
</widget>
</item>
</layout>
</widget>

View File

@ -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;

View File

@ -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,

View File

@ -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