diff --git a/mainwindow.cpp b/mainwindow.cpp index 8869cbe..1fb4740 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1034,6 +1034,9 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, auto enterFilter = new EnterKeyPressEater(); connect(enterFilter, &EnterKeyPressEater::enterKeyPressed, this, [this](QKeyEvent *, QObject *){ + if(ui->extFreeTextMsgEdit->isReadOnly()){ + return; + } toggleTx(true); }); ui->extFreeTextMsgEdit->installEventFilter(enterFilter); @@ -5628,6 +5631,9 @@ QPair MainWindow::buildFT8MessageFrames(QString const& } #endif + // once we find a directed call, data encode the rest of the line. + bool hasDirected = false; + while(line.size() > 0){ QString frame; @@ -5646,10 +5652,11 @@ QPair MainWindow::buildFT8MessageFrames(QString const& // if this parses to a standard FT8 free text message // but it can be parsed as a directed message, then we // should send the directed version - if(isFree && n > 0){ + if(isFree && !hasDirected && n > 0){ useDir = true; + hasDirected = true; frame = dirFrame; - } else if (isFree && m > 0) { + } else if ((isFree || hasDirected) && m > 0) { useDat = true; frame = datFrame; } else { @@ -5693,6 +5700,13 @@ QPair MainWindow::buildFT8MessageFrames(QString const& lines.append(line.left(n) + " "); line = line.mid(n); + +#if 0 + // TODO: jsherer - this is how we'll prepend a 16-bit checksum to the message, just encode it in the data... + if(!line.isEmpty()){ + line = Varicode::checksum16(line) + line; + } +#endif } if(useDat){ @@ -5985,16 +5999,7 @@ QString MainWindow::calculateDistance(QString const& grid) // this function is called by auto_tx_mode, which is called by autoButton.clicked void MainWindow::on_startTxButton_toggled(bool checked) { - toggleTx(checked); -} - -void MainWindow::toggleTx(bool start){ - if(start){ - // ensure the start button is checked - if(!ui->startTxButton->isChecked()){ - ui->startTxButton->setChecked(true); - } - + if(checked){ createMessage(ui->extFreeTextMsgEdit->toPlainText()); startTx(); } else { @@ -6003,6 +6008,12 @@ void MainWindow::toggleTx(bool start){ } } +void MainWindow::toggleTx(bool start){ + if(start && ui->startTxButton->isChecked()) { return; } + if(!start && !ui->startTxButton->isChecked()) { return; } + ui->startTxButton->setChecked(start); +} + void MainWindow::splitAndSendNextMessage() { } diff --git a/varicode.cpp b/varicode.cpp index c8c55c6..68110bd 100644 --- a/varicode.cpp +++ b/varicode.cpp @@ -61,7 +61,7 @@ QMap directed_cmds = { {" ", 31 }, // send freetext }; -QSet allowed_cmds = {0, 1, 2, 3, 4, /*5,*/ 10, 23, 24, 25, 26, 27, 28, 29, 30, 31}; +QSet allowed_cmds = {0, 1, 2, 3, 4, 5, /*6,*/ 10, 23, 24, 25, 26, 27, 28, 29, 30, 31}; QRegularExpression directed_re("^" "(?[A-Z0-9/]+)" @@ -199,7 +199,7 @@ QString Varicode::formatPWR(int dbm){ return QString("%1W").arg(mwatts/1000); } -QString Varicode::checksum(QString const &input){ +QString Varicode::checksum16(QString const &input){ auto fromBytes = input.toLocal8Bit(); auto crc = CRC::Calculate(fromBytes.data(), fromBytes.length(), CRC::CRC_16_KERMIT()); auto checksum = Varicode::pack16bits(crc); @@ -209,12 +209,28 @@ QString Varicode::checksum(QString const &input){ return checksum; } -bool Varicode::checksumValid(QString const &checksum, QString const &input){ +bool Varicode::checksum16Valid(QString const &checksum, QString const &input){ auto fromBytes = input.toLocal8Bit(); auto crc = CRC::Calculate(fromBytes.data(), fromBytes.length(), CRC::CRC_16_KERMIT()); return Varicode::pack16bits(crc) == checksum; } +QString Varicode::checksum32(QString const &input){ + auto fromBytes = input.toLocal8Bit(); + auto crc = CRC::Calculate(fromBytes.data(), fromBytes.length(), CRC::CRC_32_BZIP2()); + auto checksum = Varicode::pack32bits(crc); + if(checksum.length() < 6){ + checksum += QString(" ").repeated(6-checksum.length()); + } + return checksum; +} + +bool Varicode::checksum32Valid(QString const &checksum, QString const &input){ + auto fromBytes = input.toLocal8Bit(); + auto crc = CRC::Calculate(fromBytes.data(), fromBytes.length(), CRC::CRC_32_BZIP2()); + return Varicode::pack32bits(crc) == checksum; +} + QStringList Varicode::parseCallsigns(QString const &input){ QStringList callsigns; QRegularExpression re(compound_callsign_pattern); diff --git a/varicode.h b/varicode.h index a37d381..7bc7e91 100644 --- a/varicode.h +++ b/varicode.h @@ -30,8 +30,11 @@ public: static QString formatSNR(int snr); static QString formatPWR(int dbm); - static QString checksum(QString const &input); - static bool checksumValid(QString const &checksum, QString const &input); + static QString checksum16(QString const &input); + static bool checksum16Valid(QString const &checksum, QString const &input); + + static QString checksum32(QString const &input); + static bool checksum32Valid(QString const &checksum, QString const &input); static QStringList parseCallsigns(QString const &input); static QStringList parseGrids(QString const &input);