Skip to content

Commit

Permalink
Fix output bug with nonacars content
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy committed Jan 17, 2025
1 parent a041536 commit e267ad1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 16 deletions.
20 changes: 20 additions & 0 deletions decode/decode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@ OutputFormat parseOutputFormat(const QString &raw) {
return OutputFormat::None;
}

ForwardTarget::ForwardTarget(const QUrl &url, OutputFormat fmt) : target(url), format(fmt) {
// TODO: implement me!
conn = nullptr;
}

ForwardTarget::~ForwardTarget() {
if (conn != nullptr) {
conn->disconnectFromHost();
delete conn;
}
}

void ForwardTarget::reconnect() {
// TODO: implement me
}

ForwardTarget *ForwardTarget::fromRaw(const QString &raw) {
if (raw.isEmpty()) {
return nullptr;
Expand Down Expand Up @@ -215,6 +231,10 @@ void Decoder::parseForwarder(const QString &raw) {
}
}

void Decoder::reconnectForwarder() {
// TODO: implement me
}

void Decoder::publisherConsumer() {
int bufSize = 192000;
int recvSize = 0;
Expand Down
10 changes: 8 additions & 2 deletions decode/decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "hunter.h"
#include "mskdemodulator.h"
#include "oqpskdemodulator.h"
#include <QAbstractSocket>
#include <QList>
#include <QObject>
#include <QUrl>
Expand All @@ -14,10 +15,14 @@ enum OutputFormat { None, Text, Jaero, JsonDump };

struct ForwardTarget {
QUrl target;
QAbstractSocket *conn;
OutputFormat format;

ForwardTarget(const QUrl &url, OutputFormat fmt);
~ForwardTarget();

ForwardTarget(const QUrl &url, OutputFormat fmt) : target(url), format(fmt) {}

void reconnect();
static ForwardTarget *fromRaw(const QString &raw);
};

Expand All @@ -36,6 +41,7 @@ class Decoder : public QObject {

private:
void parseForwarder(const QString &raw);
void reconnectForwarder();
void publisherConsumer();

const QList<int> validBitRates = {600, 1200, 10500};
Expand Down
33 changes: 19 additions & 14 deletions decode/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ QString *toOutputFormat(OutputFormat fmt, const QString &station_id,
label1 = 'd';
}

QDateTime time = QDateTime::currentDateTimeUtc();

if (fmt == OutputFormat::JsonDump || fmt == OutputFormat::Jaero) {
QJsonObject root;
QString message = item.message;
Expand All @@ -44,8 +46,6 @@ QString *toOutputFormat(OutputFormat fmt, const QString &station_id,
message.remove(0, 1);
message.replace("\n", "\n\t");

QDateTime time = QDateTime::currentDateTimeUtc();

if (fmt == OutputFormat::JsonDump) {
QJsonObject app;
app["name"] = QCoreApplication::applicationName();
Expand Down Expand Up @@ -129,21 +129,26 @@ QString *toOutputFormat(OutputFormat fmt, const QString &station_id,
.replace("\t", "\\t")
.replace("\a", "\\a");

*out += QString("AES:%1 GES:%2 [%3] ACK=%4 BLK=%5 ")
*out += QString("%1 AES:%2 GES:%3")
.arg(time.toUTC().toString("yyyy-MM-ddThh:mm:ssZ"))
.arg(upperHex(item.isuitem.AESID, 6, 16, QChar('0')))
.arg(upperHex(item.isuitem.GESID, 6, 16, QChar('0')))
.arg(item.PLANEREG, 7)
.arg(QString(TAKstr), 1)
.arg(QString((QChar)item.BI));
.arg(upperHex(item.isuitem.GESID, 6, 16, QChar('0')));

if (disableReassembly) {
*out += QString("M=%1 ").arg(item.moretocome ? "1" : "0");
}
if (!item.nonacars) {
*out += QString(" [%1] ACK=%2 BLK=%3 ")
.arg(item.PLANEREG, 7)
.arg(QString(TAKstr), 1)
.arg(QString((QChar)item.BI));

*out += QString("LBL=%1%2 %3")
.arg(QChar(item.LABEL[0]))
.arg(QChar(label1))
.arg(message);
if (disableReassembly) {
*out += QString("M=%1 ").arg(item.moretocome ? "1" : "0");
}

*out += QString("LBL=%1%2 %3")
.arg(QChar(item.LABEL[0]))
.arg(QChar(label1))
.arg(message);
}
return out;
} else {
// NOTE: unreachable
Expand Down

0 comments on commit e267ad1

Please sign in to comment.