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"
9
10class LinkManager;
12
15class LinkInterface : public QObject
16{
17 Q_OBJECT
18 QML_ELEMENT
19 QML_UNCREATABLE("")
20 friend class LinkManager;
21
22public:
23 virtual ~LinkInterface();
24
25 Q_INVOKABLE virtual void disconnect() = 0; // Implementations should guard against multiple calls
26
27 virtual bool isConnected() const = 0;
28 virtual bool isLogReplay() const { return false; }
29 virtual bool isSecureConnection() const { return false; }
30
33 uint8_t mavlinkChannel() const;
34 bool mavlinkChannelIsSet() const;
35 bool decodedFirstMavlinkPacket() const { return _decodedFirstMavlinkPacket; }
37 void writeBytesThreadSafe(const char *bytes, int length);
41 void addVehicleReference() { ++_vehicleReferenceCount; }
44
46 SigningController* signing() { return _signingController.get(); }
47 const SigningController* signing() const { return _signingController.get(); }
48
49signals:
50 void bytesReceived(LinkInterface *link, const QByteArray &data);
51 void bytesSent(LinkInterface *link, const QByteArray &data);
52 void connected();
54 void communicationError(const QString &title, const QString &error);
55
56protected:
58 explicit LinkInterface(SharedLinkConfigurationPtr &config, QObject *parent = nullptr);
59
62 virtual bool _allocateMavlinkChannel();
63
64 virtual void _freeMavlinkChannel();
65
66 void _connectionRemoved();
67
69
70private slots:
72 virtual void _writeBytes(const QByteArray &bytes) = 0;
73
74private:
76 virtual bool _connect() = 0;
77
78 uint8_t _mavlinkChannel = std::numeric_limits<uint8_t>::max();
79 bool _decodedFirstMavlinkPacket = false;
80 int _vehicleReferenceCount = 0;
81 bool _mavlinkV1TrafficReported = false;
84 std::unique_ptr<SigningController> _signingController;
85};
86
87typedef std::shared_ptr<LinkInterface> SharedLinkInterfacePtr;
88typedef std::weak_ptr<LinkInterface> WeakLinkInterfacePtr;
Config config
std::shared_ptr< LinkConfiguration > SharedLinkConfigurationPtr
std::shared_ptr< LinkInterface > SharedLinkInterfacePtr
std::weak_ptr< LinkInterface > WeakLinkInterfacePtr
Error error
struct __mavlink_message mavlink_message_t
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 sendMessageThreadSafe(mavlink_message_t &message)
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.