Process directed free text messages. Bump beacon on transmit.
This commit is contained in:
parent
28df33b218
commit
2832572741
@ -61,6 +61,8 @@ DecodedText::DecodedText (QString const& the_string, bool contest_mode, QString
|
|||||||
|
|
||||||
void DecodedText::tryUnpackDirected(){
|
void DecodedText::tryUnpackDirected(){
|
||||||
QString m = message().trimmed();
|
QString m = message().trimmed();
|
||||||
|
|
||||||
|
// directed calls will always be 12+ chars and contain no spaces.
|
||||||
if(m.length() < 12 || m.contains(' ')){
|
if(m.length() < 12 || m.contains(' ')){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -71,8 +73,13 @@ void DecodedText::tryUnpackDirected(){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// replace it with the correct unpacked
|
if(parts.length() == 3){
|
||||||
|
// replace it with the correct unpacked (query)
|
||||||
message_ = QString("%1: %2%3").arg(parts.at(0), parts.at(1), parts.at(2));
|
message_ = QString("%1: %2%3").arg(parts.at(0), parts.at(1), parts.at(2));
|
||||||
|
} else {
|
||||||
|
// replace it with the correct unpacked (freetext)
|
||||||
|
message_ = QString(parts.join(QChar()));
|
||||||
|
}
|
||||||
|
|
||||||
directed_ = parts;
|
directed_ = parts;
|
||||||
}
|
}
|
||||||
|
@ -3305,7 +3305,7 @@ void MainWindow::readFromStdout() //readFromStdout
|
|||||||
bDisplayRight=true;
|
bDisplayRight=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isRecentOffset(audioFreq)){
|
if(isRecentOffset(audioFreq) || isAllCallIncluded(decodedtext.message())){
|
||||||
m_rxRecentCache.insert(audioFreq/10*10, new QDateTime(QDateTime::currentDateTimeUtc()), 25);
|
m_rxRecentCache.insert(audioFreq/10*10, new QDateTime(QDateTime::currentDateTimeUtc()), 25);
|
||||||
bDisplayRight = true;
|
bDisplayRight = true;
|
||||||
}
|
}
|
||||||
@ -5431,10 +5431,11 @@ void MainWindow::on_extFreeTextMsgEdit_currentTextChanged (QString const& text)
|
|||||||
QStringList MainWindow::buildFT8MessageFrames(QString const& text){
|
QStringList MainWindow::buildFT8MessageFrames(QString const& text){
|
||||||
QStringList frames;
|
QStringList frames;
|
||||||
|
|
||||||
|
QString mycall = m_config.my_callsign();
|
||||||
foreach(QString line, text.split(QRegExp("[\\r\\n]"), QString::SkipEmptyParts)){
|
foreach(QString line, text.split(QRegExp("[\\r\\n]"), QString::SkipEmptyParts)){
|
||||||
while(line.size() > 0){
|
while(line.size() > 0){
|
||||||
int n = 0;
|
int n = 0;
|
||||||
QString frame = Varicode::packDirectedMessage(line, &n);
|
QString frame = Varicode::packDirectedMessage(line, mycall, &n);
|
||||||
if(n > 0){
|
if(n > 0){
|
||||||
frames.append(frame);
|
frames.append(frame);
|
||||||
line = line.mid(n).trimmed();
|
line = line.mid(n).trimmed();
|
||||||
@ -5493,6 +5494,10 @@ bool MainWindow::prepareNextMessageFrame()
|
|||||||
int count = m_txFrameCount;
|
int count = m_txFrameCount;
|
||||||
int sent = count - m_txFrameQueue.count();
|
int sent = count - m_txFrameQueue.count();
|
||||||
ui->startTxButton->setText(QString("Sending (%1/%2)").arg(sent).arg(count));
|
ui->startTxButton->setText(QString("Sending (%1/%2)").arg(sent).arg(count));
|
||||||
|
|
||||||
|
// bump beacon
|
||||||
|
m_nextBeacon = m_nextBeacon.addSecs(15);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7850,6 +7855,11 @@ bool MainWindow::isMyCallIncluded(const QString &text){
|
|||||||
return text.contains(myCall);
|
return text.contains(myCall);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool MainWindow::isAllCallIncluded(const QString &text){
|
||||||
|
return text.contains("ALLCALL");
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::displayActivity(bool force){
|
void MainWindow::displayActivity(bool force){
|
||||||
if(!m_rxDirty && !force){
|
if(!m_rxDirty && !force){
|
||||||
return;
|
return;
|
||||||
|
@ -757,6 +757,7 @@ private:
|
|||||||
void displayTransmit();
|
void displayTransmit();
|
||||||
void updateButtonDisplay();
|
void updateButtonDisplay();
|
||||||
bool isMyCallIncluded(QString const &text);
|
bool isMyCallIncluded(QString const &text);
|
||||||
|
bool isAllCallIncluded(QString const &text);
|
||||||
QString callsignSelected();
|
QString callsignSelected();
|
||||||
bool isRecentOffset(int offset);
|
bool isRecentOffset(int offset);
|
||||||
bool isDirectedOffset(int offset);
|
bool isDirectedOffset(int offset);
|
||||||
|
44
varicode.cpp
44
varicode.cpp
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
#include <QSet>
|
||||||
|
|
||||||
#define CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
|
#define CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS
|
||||||
#include "crc.h"
|
#include "crc.h"
|
||||||
@ -33,8 +34,25 @@ QString callsign_pattern1 = {R"((?<callsign>[A-Z0-9/]{2,}))"};
|
|||||||
QString callsign_pattern2 = {R"((?<callsign>(\d|[A-Z])+\/?((\d|[A-Z]){3,})(\/(\d|[A-Z])+)?(\/(\d|[A-Z])+)?))"};
|
QString callsign_pattern2 = {R"((?<callsign>(\d|[A-Z])+\/?((\d|[A-Z]){3,})(\/(\d|[A-Z])+)?(\/(\d|[A-Z])+)?))"};
|
||||||
QString callsign_pattern3 = {R"(([0-9A-Z ])([0-9A-Z])([0-9])([A-Z ])([A-Z ])([A-Z ]))"};
|
QString callsign_pattern3 = {R"(([0-9A-Z ])([0-9A-Z])([0-9])([A-Z ])([A-Z ])([A-Z ]))"};
|
||||||
QString callsign_alphabet = {"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ "};
|
QString callsign_alphabet = {"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ "};
|
||||||
QString directed_cmds("?$@&| ");
|
|
||||||
QRegularExpression directed_re(R"((?<from>[A-Z0-9/]+):(?<to>[A-Z0-9/]+)(?<cmd>[?$@&| ]))");
|
QMap<QString, int> directed_cmds = {
|
||||||
|
// any changes here need to be made also in the directed regular xpression for parsing
|
||||||
|
{"?", 0 }, // query snr
|
||||||
|
{"$", 1 }, // query stations heard
|
||||||
|
{"@", 2 }, // query qth
|
||||||
|
{"&", 3 }, // query station message
|
||||||
|
{"|", 4 }, // relay message
|
||||||
|
{":+", 5 }, // report +snr
|
||||||
|
{":-", 6 }, // report -snr
|
||||||
|
{":ACK", 7 }, // ack message
|
||||||
|
{":NACK", 8 }, // nack message
|
||||||
|
// ...
|
||||||
|
{" ", 31 }, // send freetext
|
||||||
|
};
|
||||||
|
|
||||||
|
QSet<int> allowed_cmds = {0, 2, 31};
|
||||||
|
|
||||||
|
QRegularExpression directed_re(R"(^(?:(?<from>[A-Z0-9/]+):\s?)?(?<to>[A-Z0-9/]+)(?<cmd>([?$@&| ]|:N?ACK|:[-+])))");
|
||||||
|
|
||||||
QMap<QChar, QString> huff = {
|
QMap<QChar, QString> huff = {
|
||||||
// char code weight
|
// char code weight
|
||||||
@ -466,16 +484,20 @@ QString Varicode::unpackGrid(quint16 value){
|
|||||||
return deg2grid(dlong, dlat).left(4);
|
return deg2grid(dlong, dlat).left(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Varicode::packDirectedMessage(const QString &text, int *n){
|
QString Varicode::packDirectedMessage(const QString &text, const QString &callsign, int *n){
|
||||||
QString frame;
|
QString frame;
|
||||||
|
|
||||||
auto match = directed_re.match(text);
|
auto match = directed_re.match(text);
|
||||||
if(match.hasMatch()){
|
if(match.hasMatch()){
|
||||||
QString from = match.captured("from");
|
QString from = match.captured("from");
|
||||||
|
if(from.isEmpty()){
|
||||||
|
from = callsign;
|
||||||
|
}
|
||||||
QString to = match.captured("to");
|
QString to = match.captured("to");
|
||||||
QString cmd = match.captured("cmd");
|
QString cmd = match.captured("cmd");
|
||||||
if(cmd.at(0) != '?'){
|
|
||||||
// this is the only allowed one at this point...
|
bool validToCallsign = basecalls.contains(to) || QRegularExpression(callsign_pattern2).match(to).hasMatch();
|
||||||
|
if(!validToCallsign || !directed_cmds.contains(cmd) || !allowed_cmds.contains(directed_cmds[cmd])){
|
||||||
*n = 0;
|
*n = 0;
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
@ -486,7 +508,13 @@ QString Varicode::packDirectedMessage(const QString &text, int *n){
|
|||||||
quint8 packed_flag = 0;
|
quint8 packed_flag = 0;
|
||||||
quint32 packed_from = Varicode::packCallsign(from);
|
quint32 packed_from = Varicode::packCallsign(from);
|
||||||
quint32 packed_to = Varicode::packCallsign(to);
|
quint32 packed_to = Varicode::packCallsign(to);
|
||||||
quint8 packed_cmd = directed_cmds.indexOf(cmd.at(0));
|
|
||||||
|
if(packed_from == 0 || packed_to == 0){
|
||||||
|
*n = 0;
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
|
||||||
|
quint8 packed_cmd = directed_cmds[cmd];
|
||||||
quint8 packed_extra = fromCRC;
|
quint8 packed_extra = fromCRC;
|
||||||
|
|
||||||
// [3][28][28][5],[5] = 69
|
// [3][28][28][5],[5] = 69
|
||||||
@ -494,7 +522,7 @@ QString Varicode::packDirectedMessage(const QString &text, int *n){
|
|||||||
Varicode::intToBits(packed_flag, 3) +
|
Varicode::intToBits(packed_flag, 3) +
|
||||||
Varicode::intToBits(packed_from, 28) +
|
Varicode::intToBits(packed_from, 28) +
|
||||||
Varicode::intToBits(packed_to, 28) +
|
Varicode::intToBits(packed_to, 28) +
|
||||||
Varicode::intToBits(packed_cmd & 5, 5)
|
Varicode::intToBits(packed_cmd & 31, 5)
|
||||||
);
|
);
|
||||||
frame = Varicode::pack64bits(Varicode::bitsToInt(bits)) + Varicode::pack5bits(packed_extra & 31);
|
frame = Varicode::pack64bits(Varicode::bitsToInt(bits)) + Varicode::pack5bits(packed_extra & 31);
|
||||||
*n = match.captured(0).length();
|
*n = match.captured(0).length();
|
||||||
@ -528,7 +556,7 @@ QStringList Varicode::unpackDirectedMessage(const QString &text){
|
|||||||
|
|
||||||
unpacked.append(from);
|
unpacked.append(from);
|
||||||
unpacked.append(Varicode::unpackCallsign(packed_to).trimmed());
|
unpacked.append(Varicode::unpackCallsign(packed_to).trimmed());
|
||||||
unpacked.append(QString(directed_cmds.at(packed_cmd & 5)));
|
unpacked.append(directed_cmds.key(packed_cmd & 31));
|
||||||
|
|
||||||
return unpacked;
|
return unpacked;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ public:
|
|||||||
static quint16 packGrid(QString const& value);
|
static quint16 packGrid(QString const& value);
|
||||||
static QString unpackGrid(quint16 value);
|
static QString unpackGrid(quint16 value);
|
||||||
|
|
||||||
static QString packDirectedMessage(QString const& text, int *n);
|
static QString packDirectedMessage(QString const& text, QString const& callsign, int *n);
|
||||||
static QStringList unpackDirectedMessage(QString const& text);
|
static QStringList unpackDirectedMessage(QString const& text);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user