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 <QtQmlIntegration/QtQmlIntegration>
4
5#include <memory>
6
7#include "LinkConfiguration.h"
8
9class LinkManager;
11
14class LinkInterface : public QObject
15{
16 Q_OBJECT
17 QML_ELEMENT
18 QML_UNCREATABLE("")
19 friend class LinkManager;
20
21public:
22 virtual ~LinkInterface();
23
24 Q_INVOKABLE virtual void disconnect() = 0; // Implementations should guard against multiple calls
25
26 virtual bool isConnected() const = 0;
27 virtual bool isLogReplay() const { return false; }
28 virtual bool isSecureConnection() const { return false; }
29
32 uint8_t mavlinkChannel() const;
33 bool mavlinkChannelIsSet() const;
34 bool decodedFirstMavlinkPacket() const { return _decodedFirstMavlinkPacket; }
36 void writeBytesThreadSafe(const char *bytes, int length);
37 void addVehicleReference() { ++_vehicleReferenceCount; }
40
42 SigningController* signing() { return _signingController.get(); }
43 const SigningController* signing() const { return _signingController.get(); }
44
45signals:
46 void bytesReceived(LinkInterface *link, const QByteArray &data);
47 void bytesSent(LinkInterface *link, const QByteArray &data);
48 void connected();
50 void communicationError(const QString &title, const QString &error);
51
52protected:
54 explicit LinkInterface(SharedLinkConfigurationPtr &config, QObject *parent = nullptr);
55
58 virtual bool _allocateMavlinkChannel();
59
60 virtual void _freeMavlinkChannel();
61
62 void _connectionRemoved();
63
65
66private slots:
68 virtual void _writeBytes(const QByteArray &bytes) = 0;
69
70private:
72 virtual bool _connect() = 0;
73
74 uint8_t _mavlinkChannel = std::numeric_limits<uint8_t>::max();
75 bool _decodedFirstMavlinkPacket = false;
76 int _vehicleReferenceCount = 0;
77 bool _mavlinkV1TrafficReported = false;
80 std::unique_ptr<SigningController> _signingController;
81};
82
83typedef std::shared_ptr<LinkInterface> SharedLinkInterfacePtr;
84typedef std::weak_ptr<LinkInterface> WeakLinkInterfacePtr;
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)
uint8_t mavlinkChannel() const
void addVehicleReference()
virtual void _freeMavlinkChannel()
virtual bool isLogReplay() const
bool decodedFirstMavlinkPacket() const
virtual Q_INVOKABLE void disconnect()=0
void reportMavlinkV1Traffic()
const SharedLinkConfigurationPtr linkConfiguration() const
void _connectionRemoved()
bool mavlinkChannelIsSet() const
virtual bool isConnected() const =0
virtual bool _allocateMavlinkChannel()
SigningController * signing()
Per-link signing state and confirmation state machine. Non-null after channel allocation.
void removeVehicleReference()
virtual bool isSecureConnection() const
Returns true if the connection is secure (e.g. USB, wired ethernet)
void communicationError(const QString &title, const QString &error)
const SigningController * signing() const
void bytesSent(LinkInterface *link, const QByteArray &data)
void writeBytesThreadSafe(const char *bytes, int length)
void connected()
SharedLinkConfigurationPtr linkConfiguration()
SharedLinkConfigurationPtr _config
Manage communication links The Link Manager organizes the physical Links. It can manage arbitrary lin...
Definition LinkManager.h:32
Owns MAVLink signing state and the deferred-confirmation state machine for one LinkInterface.