QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
LinkInterface.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QLoggingCategory>
4#include <QtQmlIntegration/QtQmlIntegration>
5
6#include "LinkConfiguration.h"
7
8class LinkManager;
9
10Q_DECLARE_LOGGING_CATEGORY(LinkInterfaceLog)
11
12
13class LinkInterface : public QObject
14{
15 Q_OBJECT
16 QML_ELEMENT
17 QML_UNCREATABLE("")
18 friend class LinkManager;
19
20public:
21 virtual ~LinkInterface();
22
23 Q_INVOKABLE virtual void disconnect() = 0; // Implementations should guard against multiple calls
24
25 virtual bool isConnected() const = 0;
26 virtual bool isLogReplay() const { return false; }
27 virtual bool isSecureConnection() const { return false; }
28
30 const SharedLinkConfigurationPtr linkConfiguration() const { return _config; }
31 uint8_t mavlinkChannel() const;
32 bool mavlinkChannelIsSet() const;
33 bool decodedFirstMavlinkPacket() const { return _decodedFirstMavlinkPacket; }
34 void setDecodedFirstMavlinkPacket(bool decodedFirstMavlinkPacket) { _decodedFirstMavlinkPacket = decodedFirstMavlinkPacket; }
35 void writeBytesThreadSafe(const char *bytes, int length);
36 void addVehicleReference() { ++_vehicleReferenceCount; }
37 void removeVehicleReference();
38 bool initMavlinkSigning();
39 void setSigningSignatureFailure(bool failure);
40 void reportMavlinkV1Traffic();
41
42signals:
43 void bytesReceived(LinkInterface *link, const QByteArray &data);
44 void bytesSent(LinkInterface *link, const QByteArray &data);
45 void connected();
47 void communicationError(const QString &title, const QString &error);
48
49protected:
51 explicit LinkInterface(SharedLinkConfigurationPtr &config, QObject *parent = nullptr);
52
55 virtual bool _allocateMavlinkChannel();
56
57 virtual void _freeMavlinkChannel();
58
59 void _connectionRemoved();
60
62
63private slots:
65 virtual void _writeBytes(const QByteArray &bytes) = 0;
66
67private:
69 virtual bool _connect() = 0;
70
71 uint8_t _mavlinkChannel = std::numeric_limits<uint8_t>::max();
72 bool _decodedFirstMavlinkPacket = false;
73 int _vehicleReferenceCount = 0;
74 bool _signingSignatureFailure = false;
75 bool _mavlinkV1TrafficReported = false;
76};
77
78typedef std::shared_ptr<LinkInterface> SharedLinkInterfacePtr;
79typedef std::weak_ptr<LinkInterface> WeakLinkInterfacePtr;
Q_DECLARE_LOGGING_CATEGORY(AndroidSerialLog)
std::shared_ptr< LinkConfiguration > SharedLinkConfigurationPtr
std::shared_ptr< LinkInterface > SharedLinkInterfacePtr
std::weak_ptr< LinkInterface > WeakLinkInterfacePtr
Error error
The link interface defines the interface for all links used to communicate with the ground station ap...
void bytesReceived(LinkInterface *link, const QByteArray &data)
void disconnected()
void setDecodedFirstMavlinkPacket(bool decodedFirstMavlinkPacket)
void addVehicleReference()
bool decodedFirstMavlinkPacket() const
const SharedLinkConfigurationPtr linkConfiguration() const
virtual bool isSecureConnection() const
Returns true if the connection is secure (e.g. USB, wired ethernet)
void communicationError(const QString &title, const QString &error)
void bytesSent(LinkInterface *link, const QByteArray &data)
void connected()
SharedLinkConfigurationPtr linkConfiguration()
SharedLinkConfigurationPtr _config
Manage communication links The Link Manager organizes the physical Links. It can manage arbitrary lin...
Definition LinkManager.h:35