QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
LinkInterface Class Referenceabstract

The link interface defines the interface for all links used to communicate with the ground station application. More...

#include <LinkInterface.h>

Inheritance diagram for LinkInterface:
Collaboration diagram for LinkInterface:

Signals

void bytesReceived (LinkInterface *link, const QByteArray &data)
void bytesSent (LinkInterface *link, const QByteArray &data)
void connected ()
void disconnected ()
void communicationError (const QString &title, const QString &error)

Public Member Functions

virtual ~LinkInterface ()
virtual Q_INVOKABLE void disconnect ()=0
virtual bool isConnected () const =0
virtual bool isLogReplay () const
virtual bool isSecureConnection () const
virtual bool isRadioLink () const
void reportRadioStatusReceived ()
SharedLinkConfigurationPtr linkConfiguration ()
const SharedLinkConfigurationPtr linkConfiguration () const
uint8_t mavlinkChannel () const
bool mavlinkChannelIsSet () const
bool decodedFirstMavlinkPacket () const
void setDecodedFirstMavlinkPacket (bool decodedFirstMavlinkPacket)
void writeBytesThreadSafe (const char *bytes, int length)
void sendMessageThreadSafe (mavlink_message_t &message)
void addVehicleReference ()
void removeVehicleReference ()
void reportMavlinkV1Traffic ()
void reportMavlinkV2Traffic ()
 Called when a v2 message is received: permanently suppresses the v1-only warning for this link.
bool mavlinkV1TrafficReported () const
SigningController * signing ()
 Per-link signing state and confirmation state machine. Non-null after channel allocation.
const SigningController * signing () const

Static Public Member Functions

static void setMavlinkV1TrafficGraceMsecs (int msecs)

Static Public Attributes

static constexpr int kMavlinkV1TrafficGraceMsecsDefault = 10000

Protected Member Functions

 LinkInterface (SharedLinkConfigurationPtr &config, QObject *parent=nullptr)
 Links are only created by LinkManager so constructor is not public.
virtual bool _allocateMavlinkChannel ()
virtual void _freeMavlinkChannel ()
void _connectionRemoved ()
void _shutdownWorkerThread (QThread *thread, const QLoggingCategory &category, bool allowTerminate=true)

Protected Attributes

SharedLinkConfigurationPtr _config

Friends

class LinkManager

Detailed Description

The link interface defines the interface for all links used to communicate with the ground station application.

Definition at line 18 of file LinkInterface.h.

Constructor & Destructor Documentation

◆ ~LinkInterface()

LinkInterface::~LinkInterface ( )
virtual

Definition at line 25 of file LinkInterface.cc.

References _config.

◆ LinkInterface()

LinkInterface::LinkInterface ( SharedLinkConfigurationPtr & config,
QObject * parent = nullptr )
explicitprotected

Member Function Documentation

◆ _allocateMavlinkChannel()

bool LinkInterface::_allocateMavlinkChannel ( )
protectedvirtual

Called by the LinkManager during LinkInterface construction instructing the link to setup channels. Default implementation allocates a single channel. But some link types (such as MockLink) need more than one.

Definition at line 94 of file LinkInterface.cc.

References LinkManager::allocateMavlinkChannel(), LinkManager::instance(), isSecureConnection(), and mavlinkChannelIsSet().

◆ _connectionRemoved()

void LinkInterface::_connectionRemoved ( )
protected

Definition at line 172 of file LinkInterface.cc.

References disconnect().

Referenced by removeVehicleReference(), and MockLink::simulateConnectionRemoved().

◆ _freeMavlinkChannel()

void LinkInterface::_freeMavlinkChannel ( )
protectedvirtual

◆ _shutdownWorkerThread()

void LinkInterface::_shutdownWorkerThread ( QThread * thread,
const QLoggingCategory & category,
bool allowTerminate = true )
protected

Stops a link's worker thread, bounding the wait so destruction can always proceed. Guarantees the thread is never left as a QObject child while running (which would abort in ~QThread when child cleanup deletes it) — NOT that execution has stopped on return: on quit timeout the thread is terminated, and as a last resort it is orphaned and leaked, still running, with the link configuration kept alive so a resumed worker can't dereference a destroyed config. Pass allowTerminate = false when the worker holds locks that termination could leave locked.

Definition at line 34 of file LinkInterface.cc.

Referenced by BluetoothLink::~BluetoothLink(), LogReplayLink::~LogReplayLink(), SerialLink::~SerialLink(), TCPLink::~TCPLink(), and UDPLink::~UDPLink().

◆ addVehicleReference()

void LinkInterface::addVehicleReference ( )
inline

Definition at line 48 of file LinkInterface.h.

◆ bytesReceived

void LinkInterface::bytesReceived ( LinkInterface * link,
const QByteArray & data )
signal

◆ bytesSent

void LinkInterface::bytesSent ( LinkInterface * link,
const QByteArray & data )
signal

◆ communicationError

void LinkInterface::communicationError ( const QString & title,
const QString & error )
signal

◆ connected

void LinkInterface::connected ( )
signal

◆ decodedFirstMavlinkPacket()

bool LinkInterface::decodedFirstMavlinkPacket ( ) const
inline

Definition at line 42 of file LinkInterface.h.

Referenced by setDecodedFirstMavlinkPacket().

◆ disconnect()

virtual Q_INVOKABLE void LinkInterface::disconnect ( )
pure virtual

◆ disconnected

◆ isConnected()

virtual bool LinkInterface::isConnected ( ) const
pure virtual

◆ isLogReplay()

virtual bool LinkInterface::isLogReplay ( ) const
inlinevirtual

Reimplemented in LogReplayLink.

Definition at line 31 of file LinkInterface.h.

References isLogReplay().

Referenced by isLogReplay().

◆ isRadioLink()

virtual bool LinkInterface::isRadioLink ( ) const
inlinevirtual

True for SiK/RFD telemetry radio links (~252 byte air frame). Detected from RADIO_STATUS traffic, which only the radios inject, so it also works through UDP/TCP bridges. Subclasses may add transport-specific knowledge.

Reimplemented in SerialLink.

Definition at line 35 of file LinkInterface.h.

Referenced by SerialLink::isRadioLink().

◆ isSecureConnection()

virtual bool LinkInterface::isSecureConnection ( ) const
inlinevirtual

Returns true if the connection is secure (e.g. USB, wired ethernet)

Reimplemented in SerialLink, TCPLink, and UDPLink.

Definition at line 32 of file LinkInterface.h.

Referenced by _allocateMavlinkChannel().

◆ linkConfiguration() [1/2]

◆ linkConfiguration() [2/2]

const SharedLinkConfigurationPtr LinkInterface::linkConfiguration ( ) const
inline

Definition at line 39 of file LinkInterface.h.

References _config.

◆ mavlinkChannel()

uint8_t LinkInterface::mavlinkChannel ( ) const

◆ mavlinkChannelIsSet()

◆ mavlinkV1TrafficReported()

bool LinkInterface::mavlinkV1TrafficReported ( ) const
inline

Definition at line 55 of file LinkInterface.h.

◆ removeVehicleReference()

void LinkInterface::removeVehicleReference ( )

Definition at line 162 of file LinkInterface.cc.

References _connectionRemoved().

◆ reportMavlinkV1Traffic()

void LinkInterface::reportMavlinkV1Traffic ( )

Called for each received v1 message which QGC drops. The warning is deferred by a grace period since ArduPilot starts links in v1 and upgrades to v2 on first v2 message from QGC.

Definition at line 190 of file LinkInterface.cc.

References linkConfiguration(), qgcApp, and QGC::showAppMessage().

Referenced by MAVLinkProtocol::receiveBytes().

◆ reportMavlinkV2Traffic()

void LinkInterface::reportMavlinkV2Traffic ( )
inline

Called when a v2 message is received: permanently suppresses the v1-only warning for this link.

Definition at line 54 of file LinkInterface.h.

Referenced by MAVLinkProtocol::receiveBytes().

◆ reportRadioStatusReceived()

void LinkInterface::reportRadioStatusReceived ( )

Definition at line 182 of file LinkInterface.cc.

References _config.

Referenced by MAVLinkProtocol::receiveBytes().

◆ sendMessageThreadSafe()

void LinkInterface::sendMessageThreadSafe ( mavlink_message_t & message)

Single message-level send chokepoint: re-signs (if signing is active), serializes, then writes. All outbound mavlink_message_t sends must route through here so signing can't be bypassed.

Definition at line 148 of file LinkInterface.cc.

References writeBytesThreadSafe().

Referenced by Vehicle::sendMessageOnLinkThreadSafe().

◆ setDecodedFirstMavlinkPacket()

void LinkInterface::setDecodedFirstMavlinkPacket ( bool decodedFirstMavlinkPacket)
inline

Definition at line 43 of file LinkInterface.h.

References decodedFirstMavlinkPacket().

Referenced by MAVLinkProtocol::resetMetadataForLink().

◆ setMavlinkV1TrafficGraceMsecs()

void LinkInterface::setMavlinkV1TrafficGraceMsecs ( int msecs)
inlinestatic

Definition at line 60 of file LinkInterface.h.

◆ signing() [1/2]

SigningController * LinkInterface::signing ( )
inline

Per-link signing state and confirmation state machine. Non-null after channel allocation.

Definition at line 63 of file LinkInterface.h.

Referenced by MAVLinkProtocol::receiveBytes().

◆ signing() [2/2]

const SigningController * LinkInterface::signing ( ) const
inline

Definition at line 64 of file LinkInterface.h.

◆ writeBytesThreadSafe()

void LinkInterface::writeBytesThreadSafe ( const char * bytes,
int length )

Definition at line 142 of file LinkInterface.cc.

Referenced by sendMessageThreadSafe().

◆ LinkManager

friend class LinkManager
friend

Definition at line 23 of file LinkInterface.h.

References LinkInterface(), and LinkManager.

Referenced by LinkManager.

Member Data Documentation

◆ _config

◆ kMavlinkV1TrafficGraceMsecsDefault

int LinkInterface::kMavlinkV1TrafficGraceMsecsDefault = 10000
staticconstexpr

Grace period a link is given to upgrade from MAVLink v1 to v2 (ArduPilot starts out in v1) before the v1-only warning is reported. Settable for tests.

Definition at line 59 of file LinkInterface.h.


The documentation for this class was generated from the following files: