QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
TransportStrategy Class Reference

#include <TransportStrategy.h>

+ Inheritance diagram for TransportStrategy:
+ Collaboration diagram for TransportStrategy:

Public Types

enum class  Protocol { UDP , TCP , AutoFallback }
 

Signals

void connected ()
 
void disconnected ()
 
void errorOccurred (const QString &message)
 

Public Member Functions

 TransportStrategy (QObject *parent=nullptr)
 
 ~TransportStrategy () override
 
Protocol protocol () const
 
QString host () const
 
quint16 port () const
 
bool tlsEnabled () const
 
bool tlsVerifyPeer () const
 
void setProtocol (Protocol protocol)
 
void setTarget (const QString &host, quint16 port)
 
void setTlsEnabled (bool enabled)
 
void setTlsVerifyPeer (bool verify)
 
void setTlsCaCertificates (const QList< QSslCertificate > &certs)
 
void setTlsClientCertificate (const QSslCertificate &cert, const QSslKey &key)
 
quint64 send (const QByteArray &data)
 Send pre-formatted payload. Returns bytes sent (0 on failure/pending).
 
bool isConnected () const
 Whether the active transport is connected and ready.
 
bool tcpConnected () const
 
void reset ()
 Reset transports (e.g. after host/port change).
 

Detailed Description

Encapsulates UDP/TCP/AutoFallback protocol selection, lazy transport creation, TLS configuration, and TCP reconnection with exponential backoff.

Definition at line 13 of file TransportStrategy.h.

Member Enumeration Documentation

◆ Protocol

enum class TransportStrategy::Protocol
strong
Enumerator
UDP 
TCP 
AutoFallback 

Definition at line 18 of file TransportStrategy.h.

Constructor & Destructor Documentation

◆ TransportStrategy()

TransportStrategy::TransportStrategy ( QObject *  parent = nullptr)
explicit

Definition at line 8 of file TransportStrategy.cc.

◆ ~TransportStrategy()

TransportStrategy::~TransportStrategy ( )
override

Definition at line 12 of file TransportStrategy.cc.

References UdpTransport::close(), and TcpTransport::close().

Member Function Documentation

◆ connected

void TransportStrategy::connected ( )
signal

Referenced by Q_LOGGING_CATEGORY().

◆ disconnected

void TransportStrategy::disconnected ( )
signal

Referenced by Q_LOGGING_CATEGORY().

◆ errorOccurred

void TransportStrategy::errorOccurred ( const QString &  message)
signal

Referenced by Q_LOGGING_CATEGORY().

◆ host()

QString TransportStrategy::host ( ) const
inline

Definition at line 30 of file TransportStrategy.h.

Referenced by setTarget().

◆ isConnected()

bool TransportStrategy::isConnected ( ) const

Whether the active transport is connected and ready.

Definition at line 184 of file TransportStrategy.cc.

References TcpTransport::isConnected().

◆ port()

quint16 TransportStrategy::port ( ) const
inline

Definition at line 31 of file TransportStrategy.h.

Referenced by setTarget().

◆ protocol()

Protocol TransportStrategy::protocol ( ) const
inline

Definition at line 29 of file TransportStrategy.h.

Referenced by setProtocol().

◆ reset()

void TransportStrategy::reset ( )

Reset transports (e.g. after host/port change).

Definition at line 47 of file TransportStrategy.cc.

References UdpTransport::close(), and TcpTransport::close().

Referenced by setTarget().

◆ send()

quint64 TransportStrategy::send ( const QByteArray &  data)

Send pre-formatted payload. Returns bytes sent (0 on failure/pending).

Definition at line 155 of file TransportStrategy.cc.

References TcpTransport::connectToHost(), TcpTransport::isConnected(), UdpTransport::send(), and TcpTransport::send().

◆ setProtocol()

void TransportStrategy::setProtocol ( Protocol  protocol)

◆ setTarget()

void TransportStrategy::setTarget ( const QString &  host,
quint16  port 
)

Definition at line 37 of file TransportStrategy.cc.

References host(), port(), and reset().

◆ setTlsCaCertificates()

void TransportStrategy::setTlsCaCertificates ( const QList< QSslCertificate > &  certs)

Definition at line 83 of file TransportStrategy.cc.

References TcpTransport::setTlsCaCertificates().

◆ setTlsClientCertificate()

void TransportStrategy::setTlsClientCertificate ( const QSslCertificate &  cert,
const QSslKey &  key 
)

Definition at line 91 of file TransportStrategy.cc.

References TcpTransport::setTlsClientCertificate().

◆ setTlsEnabled()

void TransportStrategy::setTlsEnabled ( bool  enabled)

Definition at line 65 of file TransportStrategy.cc.

References TcpTransport::close().

◆ setTlsVerifyPeer()

void TransportStrategy::setTlsVerifyPeer ( bool  verify)

Definition at line 74 of file TransportStrategy.cc.

References TcpTransport::close().

◆ tcpConnected()

bool TransportStrategy::tcpConnected ( ) const

Definition at line 192 of file TransportStrategy.cc.

References TcpTransport::isConnected().

◆ tlsEnabled()

bool TransportStrategy::tlsEnabled ( ) const
inline

Definition at line 32 of file TransportStrategy.h.

◆ tlsVerifyPeer()

bool TransportStrategy::tlsVerifyPeer ( ) const
inline

Definition at line 33 of file TransportStrategy.h.


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