9#include <QtQml/QQmlEngine>
17 QQmlEngine::setObjectOwnership(
this, QQmlEngine::CppOwnership);
22 if (_vehicleReferenceCount != 0) {
23 qCWarning(LinkInterfaceLog) <<
"still have vehicle references:" << _vehicleReferenceCount;
32 qCWarning(LinkInterfaceLog) <<
"mavlinkChannelIsSet() == false";
35 return _mavlinkChannel;
48 qCWarning(LinkInterfaceLog) <<
"already have" << _mavlinkChannel;
55 qCWarning(LinkInterfaceLog) <<
"failed";
59 qCDebug(LinkInterfaceLog) <<
"_allocateMavlinkChannel" << _mavlinkChannel;
61 mavlink_set_proto_version(_mavlinkChannel, MAVLINK_VERSION);
63 _signingController = std::make_unique<SigningController>(
static_cast<mavlink_channel_t>(_mavlinkChannel));
64 _signingController->clearSigning();
66 qCDebug(LinkInterfaceLog) <<
"SigningController created for channel" << _mavlinkChannel
74 qCDebug(LinkInterfaceLog) << _mavlinkChannel;
81 _signingController.reset();
85 status->signing =
nullptr;
86 status->signing_streams =
nullptr;
87 mavlink_reset_channel_status(_mavlinkChannel);
95 const QByteArray data(bytes, length);
96 (void) QMetaObject::invokeMethod(
this,
"_writeBytes", Qt::AutoConnection, data);
104 if (_signingController) {
105 (void) _signingController->signOutgoing(message);
108 uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
109 const int len = mavlink_msg_to_send_buffer(buffer, &message);
115 if (_vehicleReferenceCount != 0) {
116 _vehicleReferenceCount--;
119 qCWarning(LinkInterfaceLog) <<
"called with no vehicle references";
125 if (_vehicleReferenceCount == 0) {
135 if (!_mavlinkV1TrafficReported) {
136 _mavlinkV1TrafficReported =
true;
139 const QString linkName = linkConfig ? linkConfig->name() : QStringLiteral(
"unknown");
140 qCWarning(LinkInterfaceLog) <<
"MAVLink v1 traffic detected on link" << linkName;
141 const QString message = tr(
"MAVLink v1 traffic detected on link '%1'. "
142 "%2 only supports MAVLink v2. "
143 "Please ensure your vehicle is configured to use MAVLink v2.")
144 .arg(linkName).arg(
qgcApp()->applicationName());
std::shared_ptr< LinkConfiguration > SharedLinkConfigurationPtr
mavlink_status_t * mavlink_get_channel_status(uint8_t chan)
struct __mavlink_message mavlink_message_t
#define QGC_LOGGING_CATEGORY(name, categoryStr)
The link interface defines the interface for all links used to communicate with the ground station ap...
uint8_t mavlinkChannel() const
virtual void _freeMavlinkChannel()
virtual Q_INVOKABLE void disconnect()=0
void sendMessageThreadSafe(mavlink_message_t &message)
void reportMavlinkV1Traffic()
void _connectionRemoved()
bool mavlinkChannelIsSet() const
virtual bool _allocateMavlinkChannel()
void removeVehicleReference()
virtual bool isSecureConnection() const
Returns true if the connection is secure (e.g. USB, wired ethernet)
void writeBytesThreadSafe(const char *bytes, int length)
SharedLinkConfigurationPtr linkConfiguration()
SharedLinkConfigurationPtr _config
uint8_t allocateMavlinkChannel()
static LinkManager * instance()
void freeMavlinkChannel(uint8_t channel)
static constexpr uint8_t invalidMavlinkChannel()
void showAppMessage(const QString &message, const QString &title)
Modal application message. Queued if the UI isn't ready yet.