From 8f87c7bbcb2abda81623635a249cd25fbdc953bb Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Wed, 10 Feb 2016 15:09:40 -0800 Subject: [PATCH] Add autoDisconnect support --- src/Vehicle/Vehicle.cc | 4 ++++ src/Vehicle/Vehicle.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index a0ace46f0..f8a4a2a57 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -97,6 +97,7 @@ Vehicle::Vehicle(LinkInterface* link, , _updateCount(0) , _rcRSSI(0) , _rcRSSIstore(100.0) + , _autoDisconnect(false) , _connectionLost(false) , _connectionLostEnabled(true) , _missionManager(NULL) @@ -1316,6 +1317,9 @@ void Vehicle::_connectionLostTimeout(void) _heardFrom = false; emit connectionLostChanged(true); _say(QString("connection lost to vehicle %1").arg(id()), GAudioOutput::AUDIO_SEVERITY_NOTICE); + if (_autoDisconnect) { + disconnectInactiveVehicle(); + } } } diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h index 4f35bc05a..0e299ac79 100644 --- a/src/Vehicle/Vehicle.h +++ b/src/Vehicle/Vehicle.h @@ -124,6 +124,7 @@ public: Q_PROPERTY(uint messagesLost READ messagesLost NOTIFY messagesLostChanged) Q_PROPERTY(bool fixedWing READ fixedWing CONSTANT) Q_PROPERTY(bool multiRotor READ multiRotor CONSTANT) + Q_PROPERTY(bool autoDisconnect MEMBER _autoDisconnect NOTIFY autoDisconnectChanged) /// Resets link status counters Q_INVOKABLE void resetCounters (); @@ -318,6 +319,7 @@ signals: void missingParametersChanged(bool missingParameters); void connectionLostChanged(bool connectionLost); void connectionLostEnabledChanged(bool connectionLostEnabled); + void autoDisconnectChanged(bool autoDisconnectChanged); void messagesReceivedChanged (); void messagesSentChanged (); @@ -480,6 +482,7 @@ private: QString _formatedMessage; int _rcRSSI; double _rcRSSIstore; + bool _autoDisconnect; ///< true: Automatically disconnect vehicle when last connection goes away or lost heartbeat // Lost connection handling bool _connectionLost; -- 2.22.0