QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
RTCMUdpInput.h
Go to the documentation of this file.
1#pragma once
2
3#include <chrono>
4#include <memory>
5
6#include <QtCore/QHash>
7#include <QtCore/QObject>
8#include <QtNetwork/QHostAddress>
9
10#include "RTCMFramer.h"
11
12class QUdpSocket;
14
18class RTCMUdpInput : public QObject
19{
20 Q_OBJECT
21
22public:
23 explicit RTCMUdpInput(QObject* parent = nullptr, RuntimeScheduler* scheduler = nullptr);
24 ~RTCMUdpInput() override;
25
28 bool start(quint16 port, QString* errorString = nullptr);
29
30 void stop();
31
32signals:
34 void frameReceived(const QString& sender, const QByteArray& data, qint64 receivedAtMs);
35
36private slots:
37 void _readDatagrams();
38
39private:
40 void _scheduleRead();
41
42 RuntimeScheduler* const _scheduler;
43 QUdpSocket* _socket = nullptr;
44
45 struct PeerParser
46 {
47 RTCMFrameDecoder decoder;
48 qint64 lastReceivedMs = 0;
49 };
50
51 std::shared_ptr<PeerParser> _parserForPeer(const QHostAddress& address, quint16 port);
52 QHash<QString, std::shared_ptr<PeerParser>> _peerParsers;
53 static constexpr qsizetype MAX_PEERS = 32;
54 static constexpr std::chrono::milliseconds PEER_IDLE_TIMEOUT{30000};
55 bool _drainScheduled = false;
56};
QString errorString
Frames RTCM bytes while retaining the first fragment's monotonic receipt time.
Definition RTCMFramer.h:102
void frameReceived(const QString &sender, const QByteArray &data, qint64 receivedAtMs)
A valid frame from sender, the sender's address, stamped receivedAtMs with the scheduler's time.
~RTCMUdpInput() override
bool start(quint16 port, QString *errorString=nullptr)