2020-10-27 12:22:10 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2020 Jon Beniston, M7RCE //
|
|
|
|
// Copyright (C) 2020 Edouard Griffiths, F4EXB //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
|
|
// (at your option) any later version. //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <QDebug>
|
ADS-B Demodulator updates.
Add OpenSky Network aircraft database support, for information about
aircraft model, owner, registration.
Add airline logos and country & military flags for display in the table.
Add OurAirports airport database support, to allow airports and ATC
frequencies to be displayed on the map.
Allow ATC frequency to be tuned by clicking on the map.
Add support for displaying flight paths on the map.
Allow columns in table to be rearranged and hidden.
Allow rows in table to be sorted by clicking on header.
Allow switching units from ft, kn, ft/min to m, kph, m/s
Allow aircraft timeout to be set by the user.
Allow font used for the table to be set by the user.
Add optional display of demodulator statistics.
Support multithreading in demodulator to reduce FIFO overflows.
Add support for demodulating all Mode-S frames and feeding them.
Add support for feeding in Beast hex format.
Allow option of correlating against full preamble or partial preamble.
Supporting highlighting of an aircraft in the table by selecting it on
the map.
Use difference of zeros and ones correlation, rather than absolute
threshold, to better account for varying conditions and make the
threshold easier to set.
Enable anti-aliasing for text on the map.
Improve CRC performance by 5x-10x.
Add HttpDownloadManager class to support downloading of files from the
web to disk.
2020-11-06 07:18:55 -05:00
|
|
|
#include <QAbstractSocket>
|
2020-10-27 12:22:10 -04:00
|
|
|
#include <QTcpServer>
|
|
|
|
#include <QTcpSocket>
|
|
|
|
#include <QEventLoop>
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
#include "adsbdemodworker.h"
|
|
|
|
#include "adsbdemodreport.h"
|
|
|
|
|
|
|
|
MESSAGE_CLASS_DEFINITION(ADSBDemodWorker::MsgConfigureADSBDemodWorker, Message)
|
|
|
|
|
2022-02-09 11:36:09 -05:00
|
|
|
ADSBBeastServer::ADSBBeastServer()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void ADSBBeastServer::listen(quint16 port)
|
|
|
|
{
|
|
|
|
QTcpServer::listen(QHostAddress::Any, port);
|
|
|
|
qDebug() << "ADSBBeastServer listening on port " << serverPort();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ADSBBeastServer::incomingConnection(qintptr socket)
|
|
|
|
{
|
|
|
|
qDebug() << "ADSBBeastServer client connected";
|
|
|
|
QTcpSocket *s = new QTcpSocket(this);
|
|
|
|
connect(s, &QTcpSocket::readyRead, this, &ADSBBeastServer::readClient);
|
|
|
|
connect(s, SIGNAL(disconnected()), this, SLOT(discardClient()));
|
|
|
|
s->setSocketDescriptor(socket);
|
|
|
|
m_clients.append(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ADSBBeastServer::send(const char *data, int length)
|
|
|
|
{
|
|
|
|
// Send frame to all clients
|
|
|
|
for (auto client : m_clients) {
|
|
|
|
client->write(data, length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ADSBBeastServer::close()
|
|
|
|
{
|
|
|
|
for (auto client : m_clients) {
|
|
|
|
client->deleteLater();
|
|
|
|
}
|
|
|
|
m_clients.clear();
|
|
|
|
QTcpServer::close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ADSBBeastServer::readClient()
|
|
|
|
{
|
|
|
|
QTcpSocket *socket = (QTcpSocket *)sender();
|
|
|
|
socket->readAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ADSBBeastServer::discardClient()
|
|
|
|
{
|
|
|
|
qDebug() << "ADSBBeastServer client disconnected";
|
|
|
|
QTcpSocket *socket = (QTcpSocket*)sender();
|
|
|
|
socket->deleteLater();
|
|
|
|
m_clients.removeAll(socket);
|
|
|
|
}
|
|
|
|
|
2020-10-27 12:22:10 -04:00
|
|
|
ADSBDemodWorker::ADSBDemodWorker() :
|
|
|
|
m_running(false),
|
|
|
|
m_mutex(QMutex::Recursive)
|
|
|
|
{
|
|
|
|
connect(&m_heartbeatTimer, SIGNAL(timeout()), this, SLOT(heartbeat()));
|
|
|
|
connect(&m_socket, SIGNAL(readyRead()),this, SLOT(recv()));
|
ADS-B Demodulator updates.
Add OpenSky Network aircraft database support, for information about
aircraft model, owner, registration.
Add airline logos and country & military flags for display in the table.
Add OurAirports airport database support, to allow airports and ATC
frequencies to be displayed on the map.
Allow ATC frequency to be tuned by clicking on the map.
Add support for displaying flight paths on the map.
Allow columns in table to be rearranged and hidden.
Allow rows in table to be sorted by clicking on header.
Allow switching units from ft, kn, ft/min to m, kph, m/s
Allow aircraft timeout to be set by the user.
Allow font used for the table to be set by the user.
Add optional display of demodulator statistics.
Support multithreading in demodulator to reduce FIFO overflows.
Add support for demodulating all Mode-S frames and feeding them.
Add support for feeding in Beast hex format.
Allow option of correlating against full preamble or partial preamble.
Supporting highlighting of an aircraft in the table by selecting it on
the map.
Use difference of zeros and ones correlation, rather than absolute
threshold, to better account for varying conditions and make the
threshold easier to set.
Enable anti-aliasing for text on the map.
Improve CRC performance by 5x-10x.
Add HttpDownloadManager class to support downloading of files from the
web to disk.
2020-11-06 07:18:55 -05:00
|
|
|
connect(&m_socket, SIGNAL(connected()), this, SLOT(connected()));
|
|
|
|
connect(&m_socket, SIGNAL(disconnected()), this, SLOT(disconnected()));
|
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
|
|
|
connect(&m_socket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), this, &ADSBDemodWorker::errorOccurred);
|
|
|
|
#else
|
|
|
|
connect(&m_socket, &QAbstractSocket::errorOccurred, this, &ADSBDemodWorker::errorOccurred);
|
|
|
|
#endif
|
2022-02-09 11:36:09 -05:00
|
|
|
m_startTime = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
|
|
|
m_heartbeatTimer.start(60*1000);
|
2020-10-27 12:22:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ADSBDemodWorker::~ADSBDemodWorker()
|
|
|
|
{
|
|
|
|
m_inputMessageQueue.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ADSBDemodWorker::reset()
|
|
|
|
{
|
|
|
|
QMutexLocker mutexLocker(&m_mutex);
|
|
|
|
m_inputMessageQueue.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ADSBDemodWorker::startWork()
|
|
|
|
{
|
|
|
|
QMutexLocker mutexLocker(&m_mutex);
|
2021-06-05 13:46:39 -04:00
|
|
|
|
|
|
|
if (m_running) {
|
|
|
|
return m_running;
|
|
|
|
}
|
|
|
|
|
2020-10-27 12:22:10 -04:00
|
|
|
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
|
|
|
|
m_running = true;
|
|
|
|
return m_running;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ADSBDemodWorker::stopWork()
|
|
|
|
{
|
|
|
|
QMutexLocker mutexLocker(&m_mutex);
|
2021-06-05 13:46:39 -04:00
|
|
|
|
|
|
|
if (!m_running) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-27 12:22:10 -04:00
|
|
|
disconnect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
|
|
|
|
m_running = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ADSBDemodWorker::handleInputMessages()
|
|
|
|
{
|
|
|
|
Message* message;
|
|
|
|
|
|
|
|
while ((message = m_inputMessageQueue.pop()) != nullptr)
|
|
|
|
{
|
|
|
|
if (handleMessage(*message)) {
|
|
|
|
delete message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ADSBDemodWorker::handleMessage(const Message& message)
|
|
|
|
{
|
|
|
|
if (MsgConfigureADSBDemodWorker::match(message))
|
|
|
|
{
|
|
|
|
QMutexLocker mutexLocker(&m_mutex);
|
|
|
|
MsgConfigureADSBDemodWorker& cfg = (MsgConfigureADSBDemodWorker&) message;
|
|
|
|
|
|
|
|
applySettings(cfg.getSettings(), cfg.getForce());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (ADSBDemodReport::MsgReportADSB::match(message))
|
|
|
|
{
|
|
|
|
ADSBDemodReport::MsgReportADSB& report = (ADSBDemodReport::MsgReportADSB&) message;
|
ADS-B Demodulator updates.
Add OpenSky Network aircraft database support, for information about
aircraft model, owner, registration.
Add airline logos and country & military flags for display in the table.
Add OurAirports airport database support, to allow airports and ATC
frequencies to be displayed on the map.
Allow ATC frequency to be tuned by clicking on the map.
Add support for displaying flight paths on the map.
Allow columns in table to be rearranged and hidden.
Allow rows in table to be sorted by clicking on header.
Allow switching units from ft, kn, ft/min to m, kph, m/s
Allow aircraft timeout to be set by the user.
Allow font used for the table to be set by the user.
Add optional display of demodulator statistics.
Support multithreading in demodulator to reduce FIFO overflows.
Add support for demodulating all Mode-S frames and feeding them.
Add support for feeding in Beast hex format.
Allow option of correlating against full preamble or partial preamble.
Supporting highlighting of an aircraft in the table by selecting it on
the map.
Use difference of zeros and ones correlation, rather than absolute
threshold, to better account for varying conditions and make the
threshold easier to set.
Enable anti-aliasing for text on the map.
Improve CRC performance by 5x-10x.
Add HttpDownloadManager class to support downloading of files from the
web to disk.
2020-11-06 07:18:55 -05:00
|
|
|
handleADSB(report.getData(), report.getDateTime(), report.getPreambleCorrelation());
|
2020-10-27 12:22:10 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ADSBDemodWorker::applySettings(const ADSBDemodSettings& settings, bool force)
|
|
|
|
{
|
|
|
|
qDebug() << "ADSBDemodWorker::applySettings:"
|
ADS-B Demodulator updates.
Add OpenSky Network aircraft database support, for information about
aircraft model, owner, registration.
Add airline logos and country & military flags for display in the table.
Add OurAirports airport database support, to allow airports and ATC
frequencies to be displayed on the map.
Allow ATC frequency to be tuned by clicking on the map.
Add support for displaying flight paths on the map.
Allow columns in table to be rearranged and hidden.
Allow rows in table to be sorted by clicking on header.
Allow switching units from ft, kn, ft/min to m, kph, m/s
Allow aircraft timeout to be set by the user.
Allow font used for the table to be set by the user.
Add optional display of demodulator statistics.
Support multithreading in demodulator to reduce FIFO overflows.
Add support for demodulating all Mode-S frames and feeding them.
Add support for feeding in Beast hex format.
Allow option of correlating against full preamble or partial preamble.
Supporting highlighting of an aircraft in the table by selecting it on
the map.
Use difference of zeros and ones correlation, rather than absolute
threshold, to better account for varying conditions and make the
threshold easier to set.
Enable anti-aliasing for text on the map.
Improve CRC performance by 5x-10x.
Add HttpDownloadManager class to support downloading of files from the
web to disk.
2020-11-06 07:18:55 -05:00
|
|
|
<< " m_feedEnabled: " << settings.m_feedEnabled
|
2022-02-09 11:36:09 -05:00
|
|
|
<< " m_exportClientEnabled: " << settings.m_exportClientEnabled
|
|
|
|
<< " m_exportClientHost: " << settings.m_exportClientHost
|
|
|
|
<< " m_exportClientPort: " << settings.m_exportClientPort
|
|
|
|
<< " m_exportClientFormat: " << settings.m_exportClientFormat
|
|
|
|
<< " m_exportServerEnabled: " << settings.m_exportServerEnabled
|
|
|
|
<< " m_exportServerPort: " << settings.m_exportServerPort
|
2021-11-03 13:19:21 -04:00
|
|
|
<< " m_logEnabled: " << settings.m_logEnabled
|
|
|
|
<< " m_logFilename: " << settings.m_logFilename
|
2020-10-27 12:22:10 -04:00
|
|
|
<< " force: " << force;
|
|
|
|
|
ADS-B Demodulator updates.
Add OpenSky Network aircraft database support, for information about
aircraft model, owner, registration.
Add airline logos and country & military flags for display in the table.
Add OurAirports airport database support, to allow airports and ATC
frequencies to be displayed on the map.
Allow ATC frequency to be tuned by clicking on the map.
Add support for displaying flight paths on the map.
Allow columns in table to be rearranged and hidden.
Allow rows in table to be sorted by clicking on header.
Allow switching units from ft, kn, ft/min to m, kph, m/s
Allow aircraft timeout to be set by the user.
Allow font used for the table to be set by the user.
Add optional display of demodulator statistics.
Support multithreading in demodulator to reduce FIFO overflows.
Add support for demodulating all Mode-S frames and feeding them.
Add support for feeding in Beast hex format.
Allow option of correlating against full preamble or partial preamble.
Supporting highlighting of an aircraft in the table by selecting it on
the map.
Use difference of zeros and ones correlation, rather than absolute
threshold, to better account for varying conditions and make the
threshold easier to set.
Enable anti-aliasing for text on the map.
Improve CRC performance by 5x-10x.
Add HttpDownloadManager class to support downloading of files from the
web to disk.
2020-11-06 07:18:55 -05:00
|
|
|
if ((settings.m_feedEnabled != m_settings.m_feedEnabled)
|
2022-02-09 11:36:09 -05:00
|
|
|
|| (settings.m_exportClientEnabled != m_settings.m_exportClientEnabled)
|
|
|
|
|| (settings.m_exportClientHost != m_settings.m_exportClientHost)
|
|
|
|
|| (settings.m_exportClientPort != m_settings.m_exportClientPort)
|
|
|
|
|| force)
|
2020-10-27 12:22:10 -04:00
|
|
|
{
|
|
|
|
// Close any existing connection
|
2022-02-09 11:36:09 -05:00
|
|
|
if (m_socket.isOpen()) {
|
2020-10-27 12:22:10 -04:00
|
|
|
m_socket.close();
|
2022-02-09 11:36:09 -05:00
|
|
|
}
|
2020-10-27 12:22:10 -04:00
|
|
|
// Open connection
|
2022-02-09 11:36:09 -05:00
|
|
|
if (settings.m_feedEnabled && settings.m_exportClientEnabled) {
|
|
|
|
m_socket.connectToHost(settings.m_exportClientHost, settings.m_exportClientPort);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((settings.m_feedEnabled != m_settings.m_feedEnabled)
|
|
|
|
|| (settings.m_exportServerEnabled != m_settings.m_exportServerEnabled)
|
|
|
|
|| (settings.m_exportServerPort != m_settings.m_exportServerPort)
|
|
|
|
|| force)
|
|
|
|
{
|
|
|
|
if (m_beastServer.isListening()) {
|
|
|
|
m_beastServer.close();
|
|
|
|
}
|
|
|
|
if (settings.m_feedEnabled && settings.m_exportServerEnabled) {
|
|
|
|
m_beastServer.listen(settings.m_exportServerPort);
|
|
|
|
}
|
2020-10-27 12:22:10 -04:00
|
|
|
}
|
|
|
|
|
2021-11-03 13:19:21 -04:00
|
|
|
if ((settings.m_logEnabled != m_settings.m_logEnabled)
|
|
|
|
|| (settings.m_logFilename != m_settings.m_logFilename)
|
|
|
|
|| force)
|
|
|
|
{
|
|
|
|
if (m_logFile.isOpen())
|
|
|
|
{
|
|
|
|
m_logStream.flush();
|
|
|
|
m_logFile.close();
|
|
|
|
}
|
|
|
|
if (settings.m_logEnabled && !settings.m_logFilename.isEmpty())
|
|
|
|
{
|
|
|
|
m_logFile.setFileName(settings.m_logFilename);
|
|
|
|
if (m_logFile.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text))
|
|
|
|
{
|
|
|
|
qDebug() << "ADSBDemodWorker::applySettings - Logging to: " << settings.m_logFilename;
|
|
|
|
bool newFile = m_logFile.size() == 0;
|
|
|
|
m_logStream.setDevice(&m_logFile);
|
|
|
|
if (newFile)
|
|
|
|
{
|
|
|
|
// Write header
|
|
|
|
m_logStream << "Date,Time,Data,Correlation\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug() << "ADSBDemodWorker::applySettings - Unable to open log file: " << settings.m_logFilename;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-27 12:22:10 -04:00
|
|
|
m_settings = settings;
|
|
|
|
}
|
|
|
|
|
ADS-B Demodulator updates.
Add OpenSky Network aircraft database support, for information about
aircraft model, owner, registration.
Add airline logos and country & military flags for display in the table.
Add OurAirports airport database support, to allow airports and ATC
frequencies to be displayed on the map.
Allow ATC frequency to be tuned by clicking on the map.
Add support for displaying flight paths on the map.
Allow columns in table to be rearranged and hidden.
Allow rows in table to be sorted by clicking on header.
Allow switching units from ft, kn, ft/min to m, kph, m/s
Allow aircraft timeout to be set by the user.
Allow font used for the table to be set by the user.
Add optional display of demodulator statistics.
Support multithreading in demodulator to reduce FIFO overflows.
Add support for demodulating all Mode-S frames and feeding them.
Add support for feeding in Beast hex format.
Allow option of correlating against full preamble or partial preamble.
Supporting highlighting of an aircraft in the table by selecting it on
the map.
Use difference of zeros and ones correlation, rather than absolute
threshold, to better account for varying conditions and make the
threshold easier to set.
Enable anti-aliasing for text on the map.
Improve CRC performance by 5x-10x.
Add HttpDownloadManager class to support downloading of files from the
web to disk.
2020-11-06 07:18:55 -05:00
|
|
|
void ADSBDemodWorker::connected()
|
|
|
|
{
|
2022-02-09 11:36:09 -05:00
|
|
|
qDebug() << "ADSBDemodWorker::connected " << m_settings.m_exportClientHost;
|
ADS-B Demodulator updates.
Add OpenSky Network aircraft database support, for information about
aircraft model, owner, registration.
Add airline logos and country & military flags for display in the table.
Add OurAirports airport database support, to allow airports and ATC
frequencies to be displayed on the map.
Allow ATC frequency to be tuned by clicking on the map.
Add support for displaying flight paths on the map.
Allow columns in table to be rearranged and hidden.
Allow rows in table to be sorted by clicking on header.
Allow switching units from ft, kn, ft/min to m, kph, m/s
Allow aircraft timeout to be set by the user.
Allow font used for the table to be set by the user.
Add optional display of demodulator statistics.
Support multithreading in demodulator to reduce FIFO overflows.
Add support for demodulating all Mode-S frames and feeding them.
Add support for feeding in Beast hex format.
Allow option of correlating against full preamble or partial preamble.
Supporting highlighting of an aircraft in the table by selecting it on
the map.
Use difference of zeros and ones correlation, rather than absolute
threshold, to better account for varying conditions and make the
threshold easier to set.
Enable anti-aliasing for text on the map.
Improve CRC performance by 5x-10x.
Add HttpDownloadManager class to support downloading of files from the
web to disk.
2020-11-06 07:18:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void ADSBDemodWorker::disconnected()
|
|
|
|
{
|
|
|
|
qDebug() << "ADSBDemodWorker::disconnected";
|
|
|
|
}
|
|
|
|
|
|
|
|
void ADSBDemodWorker::errorOccurred(QAbstractSocket::SocketError socketError)
|
|
|
|
{
|
|
|
|
qDebug() << "ADSBDemodWorker::errorOccurred: " << socketError;
|
|
|
|
}
|
|
|
|
|
2020-10-27 12:22:10 -04:00
|
|
|
void ADSBDemodWorker::recv()
|
|
|
|
{
|
2021-01-19 06:36:56 -05:00
|
|
|
// Not expecting to receiving anything from server
|
2020-10-27 12:22:10 -04:00
|
|
|
qDebug() << "ADSBDemodWorker::recv";
|
|
|
|
qDebug() << m_socket.readAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ADSBDemodWorker::send(const char *data, int length)
|
|
|
|
{
|
2022-02-09 11:36:09 -05:00
|
|
|
if (m_settings.m_feedEnabled && m_settings.m_exportClientEnabled)
|
2020-10-27 12:22:10 -04:00
|
|
|
{
|
|
|
|
// Reopen connection if it was lost
|
2022-02-09 11:36:09 -05:00
|
|
|
if (!m_socket.isOpen()) {
|
|
|
|
m_socket.connectToHost(m_settings.m_exportClientHost, m_settings.m_exportClientPort);
|
|
|
|
}
|
2020-10-27 12:22:10 -04:00
|
|
|
// Send data
|
|
|
|
m_socket.write(data, length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define BEAST_ESC 0x1a
|
|
|
|
|
|
|
|
char *ADSBDemodWorker::escape(char *p, char c)
|
|
|
|
{
|
|
|
|
*p++ = c;
|
2022-02-09 11:36:09 -05:00
|
|
|
if (c == BEAST_ESC) {
|
2020-10-27 12:22:10 -04:00
|
|
|
*p++ = BEAST_ESC;
|
2022-02-09 11:36:09 -05:00
|
|
|
}
|
2020-10-27 12:22:10 -04:00
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Forward ADS-B data in Beast binary format to specified server
|
|
|
|
// See: https://wiki.jetvision.de/wiki/Mode-S_Beast:Data_Output_Formats
|
2021-11-03 13:19:21 -04:00
|
|
|
// Log to .csv file
|
2020-10-27 12:22:10 -04:00
|
|
|
void ADSBDemodWorker::handleADSB(QByteArray data, const QDateTime dateTime, float correlation)
|
|
|
|
{
|
2022-02-09 11:36:09 -05:00
|
|
|
if (m_logFile.isOpen()) {
|
2021-11-03 13:19:21 -04:00
|
|
|
m_logStream << dateTime.date().toString() << "," << dateTime.time().toString() << "," << data.toHex() << "," << correlation << "\n";
|
ADS-B Demodulator updates.
Add OpenSky Network aircraft database support, for information about
aircraft model, owner, registration.
Add airline logos and country & military flags for display in the table.
Add OurAirports airport database support, to allow airports and ATC
frequencies to be displayed on the map.
Allow ATC frequency to be tuned by clicking on the map.
Add support for displaying flight paths on the map.
Allow columns in table to be rearranged and hidden.
Allow rows in table to be sorted by clicking on header.
Allow switching units from ft, kn, ft/min to m, kph, m/s
Allow aircraft timeout to be set by the user.
Allow font used for the table to be set by the user.
Add optional display of demodulator statistics.
Support multithreading in demodulator to reduce FIFO overflows.
Add support for demodulating all Mode-S frames and feeding them.
Add support for feeding in Beast hex format.
Allow option of correlating against full preamble or partial preamble.
Supporting highlighting of an aircraft in the table by selecting it on
the map.
Use difference of zeros and ones correlation, rather than absolute
threshold, to better account for varying conditions and make the
threshold easier to set.
Enable anti-aliasing for text on the map.
Improve CRC performance by 5x-10x.
Add HttpDownloadManager class to support downloading of files from the
web to disk.
2020-11-06 07:18:55 -05:00
|
|
|
}
|
2022-02-09 11:36:09 -05:00
|
|
|
|
|
|
|
if (m_settings.m_feedEnabled && (m_settings.m_exportClientEnabled || m_settings.m_exportServerEnabled))
|
ADS-B Demodulator updates.
Add OpenSky Network aircraft database support, for information about
aircraft model, owner, registration.
Add airline logos and country & military flags for display in the table.
Add OurAirports airport database support, to allow airports and ATC
frequencies to be displayed on the map.
Allow ATC frequency to be tuned by clicking on the map.
Add support for displaying flight paths on the map.
Allow columns in table to be rearranged and hidden.
Allow rows in table to be sorted by clicking on header.
Allow switching units from ft, kn, ft/min to m, kph, m/s
Allow aircraft timeout to be set by the user.
Allow font used for the table to be set by the user.
Add optional display of demodulator statistics.
Support multithreading in demodulator to reduce FIFO overflows.
Add support for demodulating all Mode-S frames and feeding them.
Add support for feeding in Beast hex format.
Allow option of correlating against full preamble or partial preamble.
Supporting highlighting of an aircraft in the table by selecting it on
the map.
Use difference of zeros and ones correlation, rather than absolute
threshold, to better account for varying conditions and make the
threshold easier to set.
Enable anti-aliasing for text on the map.
Improve CRC performance by 5x-10x.
Add HttpDownloadManager class to support downloading of files from the
web to disk.
2020-11-06 07:18:55 -05:00
|
|
|
{
|
2022-02-09 11:36:09 -05:00
|
|
|
if ((m_settings.m_exportClientEnabled && (m_settings.m_exportClientFormat == ADSBDemodSettings::BeastBinary))
|
|
|
|
|| m_settings.m_exportServerEnabled)
|
2021-11-03 13:19:21 -04:00
|
|
|
{
|
|
|
|
char beastBinary[2+6*2+1*2+14*2];
|
|
|
|
int length;
|
|
|
|
char *p = beastBinary;
|
|
|
|
qint64 timestamp;
|
|
|
|
unsigned char signalStrength;
|
|
|
|
|
2022-02-09 11:36:09 -05:00
|
|
|
// Timestamp seems to be 12MHz ticks since device started
|
|
|
|
timestamp = (dateTime.toMSecsSinceEpoch() - m_startTime) * 12000;
|
2021-11-03 13:19:21 -04:00
|
|
|
|
2022-02-09 11:36:09 -05:00
|
|
|
if (correlation > 255) {
|
2021-11-03 13:19:21 -04:00
|
|
|
signalStrength = 255;
|
2022-02-09 11:36:09 -05:00
|
|
|
} else if (correlation < 1) {
|
2021-11-03 13:19:21 -04:00
|
|
|
signalStrength = 1;
|
2022-02-09 11:36:09 -05:00
|
|
|
} else {
|
2021-11-03 13:19:21 -04:00
|
|
|
signalStrength = (unsigned char)correlation;
|
2022-02-09 11:36:09 -05:00
|
|
|
}
|
2021-11-03 13:19:21 -04:00
|
|
|
|
|
|
|
*p++ = BEAST_ESC;
|
|
|
|
*p++ = '3'; // Mode-S long
|
|
|
|
|
2022-02-09 11:36:09 -05:00
|
|
|
p = escape(p, timestamp >> 48); // Big-endian timestamp
|
2021-11-03 13:19:21 -04:00
|
|
|
p = escape(p, timestamp >> 32);
|
|
|
|
p = escape(p, timestamp >> 24);
|
|
|
|
p = escape(p, timestamp >> 16);
|
|
|
|
p = escape(p, timestamp >> 8);
|
|
|
|
p = escape(p, timestamp);
|
|
|
|
|
|
|
|
p = escape(p, signalStrength); // Signal strength
|
|
|
|
|
2022-02-09 11:36:09 -05:00
|
|
|
for (int i = 0; i < data.length(); i++) { // ADS-B data
|
2021-11-03 13:19:21 -04:00
|
|
|
p = escape(p, data[i]);
|
2022-02-09 11:36:09 -05:00
|
|
|
}
|
2021-11-03 13:19:21 -04:00
|
|
|
|
|
|
|
length = p - beastBinary;
|
|
|
|
|
2022-02-09 11:36:09 -05:00
|
|
|
if ((m_settings.m_exportClientEnabled) && (m_settings.m_exportClientFormat == ADSBDemodSettings::BeastBinary)) {
|
|
|
|
send(beastBinary, length);
|
|
|
|
}
|
|
|
|
if (m_settings.m_exportServerEnabled) {
|
|
|
|
m_beastServer.send(beastBinary, length);
|
|
|
|
}
|
2021-11-03 13:19:21 -04:00
|
|
|
}
|
2022-02-09 11:36:09 -05:00
|
|
|
if (m_settings.m_exportClientEnabled && (m_settings.m_exportClientFormat == ADSBDemodSettings::BeastHex))
|
2021-11-03 13:19:21 -04:00
|
|
|
{
|
|
|
|
QString beastHex = "*" + data.toHex() + ";\n";
|
|
|
|
send(beastHex.toUtf8(), beastHex.size());
|
|
|
|
}
|
ADS-B Demodulator updates.
Add OpenSky Network aircraft database support, for information about
aircraft model, owner, registration.
Add airline logos and country & military flags for display in the table.
Add OurAirports airport database support, to allow airports and ATC
frequencies to be displayed on the map.
Allow ATC frequency to be tuned by clicking on the map.
Add support for displaying flight paths on the map.
Allow columns in table to be rearranged and hidden.
Allow rows in table to be sorted by clicking on header.
Allow switching units from ft, kn, ft/min to m, kph, m/s
Allow aircraft timeout to be set by the user.
Allow font used for the table to be set by the user.
Add optional display of demodulator statistics.
Support multithreading in demodulator to reduce FIFO overflows.
Add support for demodulating all Mode-S frames and feeding them.
Add support for feeding in Beast hex format.
Allow option of correlating against full preamble or partial preamble.
Supporting highlighting of an aircraft in the table by selecting it on
the map.
Use difference of zeros and ones correlation, rather than absolute
threshold, to better account for varying conditions and make the
threshold easier to set.
Enable anti-aliasing for text on the map.
Improve CRC performance by 5x-10x.
Add HttpDownloadManager class to support downloading of files from the
web to disk.
2020-11-06 07:18:55 -05:00
|
|
|
}
|
2020-10-27 12:22:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Periodically send heartbeat to keep connection alive
|
|
|
|
void ADSBDemodWorker::heartbeat()
|
|
|
|
{
|
2022-02-09 11:36:09 -05:00
|
|
|
if (m_running)
|
|
|
|
{
|
|
|
|
const char heartbeat[] = {BEAST_ESC, '1', 0, 0, 0, 0, 0, 0, 0, 0, 0}; // Mode AC packet
|
|
|
|
if (m_settings.m_exportClientEnabled) {
|
|
|
|
send(heartbeat, sizeof(heartbeat));
|
|
|
|
}
|
|
|
|
if (m_settings.m_exportServerEnabled) {
|
|
|
|
m_beastServer.send(heartbeat, sizeof(heartbeat));
|
|
|
|
}
|
|
|
|
}
|
2020-10-27 12:22:10 -04:00
|
|
|
}
|