Extended charset via escapes. DE added to retransmits

This commit is contained in:
Jordan Sherer 2018-07-26 14:31:28 -04:00
parent de66664635
commit 4290dd6e2f
3 changed files with 22 additions and 18 deletions

View File

@ -163,8 +163,7 @@ QVector<QColor> g_ColorTbl;
namespace namespace
{ {
Radio::Frequency constexpr default_frequency {14074000}; Radio::Frequency constexpr default_frequency {14074000};
QRegExp message_alphabet {"[- A-Za-z0-9+./?:!^]*"}; QRegExp message_alphabet {"[- A-Za-z0-9+./?:!]*"}; // base alphabet supported by FT8
QRegExp message_input_alphabet {"[- A-Za-z0-9+./?\\n:!^,&@#$%*()<>'\"|=]*"};
// grid exact match excluding RR73 // grid exact match excluding RR73
QRegularExpression grid_regexp {"\\A(?![Rr]{2}73)[A-Ra-r]{2}[0-9]{2}([A-Xa-x]{2}){0,1}\\z"}; QRegularExpression grid_regexp {"\\A(?![Rr]{2}73)[A-Ra-r]{2}[0-9]{2}([A-Xa-x]{2}){0,1}\\z"};
@ -5442,17 +5441,15 @@ int MainWindow::logRxTxMessageText(QDateTime date, QString text, int freq, bool
c.insertBlock(); c.insertBlock();
} }
if(tx){ if(found && !tx){
text = "<strong>" + text + "</strong>";
// TODO: jsherer - move this out of this function
m_rxFrameBlockNumbers.clear();
}
if(found){
c.clearSelection(); c.clearSelection();
c.insertText(text); c.insertText(text);
} else { } else {
text = text.toHtmlEscaped();
if(tx){
text = QString("<strong>%1</strong>").arg(text);
m_rxFrameBlockNumbers.clear();
}
c.insertHtml(QString("<strong>%1 - (%2)</strong> - %3").arg(date.time().toString()).arg(freq).arg(text)); c.insertHtml(QString("<strong>%1 - (%2)</strong> - %3").arg(date.time().toString()).arg(freq).arg(text));
} }
@ -5573,9 +5570,11 @@ void MainWindow::on_extFreeTextMsgEdit_currentTextChanged (QString const& text)
{ {
QString x; QString x;
QString::const_iterator i; QString::const_iterator i;
auto validChars = Varicode::huffValidChars();
for(i = text.constBegin(); i != text.constEnd(); i++){ for(i = text.constBegin(); i != text.constEnd(); i++){
if(message_input_alphabet.exactMatch(QString(*i))){ auto ch = (*i).toUpper();
x += (*i).toUpper(); if(validChars.contains(ch) || ch == '\n'){
x += ch;
} }
} }
if(x != text){ if(x != text){
@ -8733,8 +8732,8 @@ void MainWindow::displayActivity(bool force){
} }
// PROCESS RETRANSMIT // PROCESS RETRANSMIT
else if(d.cmd == "|" && !isAllCall){ else if(d.cmd == "|" && !isAllCall){
// TODO: jsherer - perhaps parse d.text and ensure it is a valid message? // TODO: jsherer - perhaps parse d.text and ensure it is a valid message as well as prefix it with our call...
reply = QString("%1 ACK\n%2").arg(d.from).arg(d.text); reply = QString("%1 ACK\n%2 DE %1").arg(d.from).arg(d.text);
} }
if(reply.isEmpty()){ if(reply.isEmpty()){

View File

@ -124,14 +124,14 @@ QMap<QChar, QString> hufftable = {
{ '\x04' , "110101100010" }, // 1 <- eot { '\x04' , "110101100010" }, // 1 <- eot
/* /*
A-Z 0-9 Space . ! ? : + - / \\ A-Z 0-9 Space \\ ? / : - + !
special chars that are escaped will be added here too... special chars that are escaped will be added here too...
*/ */
}; };
/* /*
original: space + - / ? . ! : \\ original: Space \\ ? / : - + !
needed: ^,&@#$%*()<>'"|={}[];_~` needed: ^,&@#$%'"()<>|*[]{}=;_~`
*/ */
QMap<QString, QChar> huffescapes = { QMap<QString, QChar> huffescapes = {
{ "\\ ", '^' }, { "\\ ", '^' },
@ -161,7 +161,7 @@ QMap<QString, QChar> huffescapes = {
#if 0 #if 0
// reserved <= 14 bits // reserved <= 14 bits
{ "\\1", '' }, { "\\1", '' },
{ "\\2", '' }, { "\\2", '' },
{ "\\3", '' }, { "\\3", '' },
{ "\\4", '' }, { "\\4", '' },
@ -415,6 +415,10 @@ QString Varicode::huffEscape(QString const &input){
return text; return text;
} }
QSet<QChar> Varicode::huffValidChars(){
return QSet<QChar>::fromList(hufftableescaped.keys());
}
bool Varicode::huffShouldEscape(QString const &input){ bool Varicode::huffShouldEscape(QString const &input){
foreach(auto ch, huffescapes.values()){ foreach(auto ch, huffescapes.values()){
if(input.contains(ch)){ if(input.contains(ch)){

View File

@ -44,6 +44,7 @@ public:
static QString huffUnescape(QString const &input); static QString huffUnescape(QString const &input);
static QString huffEscape(QString const &input); static QString huffEscape(QString const &input);
static QSet<QChar> huffValidChars();
static bool huffShouldEscape(QString const &input); static bool huffShouldEscape(QString const &input);
static QVector<bool> bytesToBits(char * bitvec, int n); static QVector<bool> bytesToBits(char * bitvec, int n);