diff --git a/src/comm/HeartbeatTimer.cc b/src/comm/HeartbeatTimer.cc index 7090b736701685f346f3787bfeaf563ca500a464..ec1843a651e163eb8b74c9ad6c3ecc28bc54a60a 100644 --- a/src/comm/HeartbeatTimer.cc +++ b/src/comm/HeartbeatTimer.cc @@ -17,7 +17,11 @@ HeartbeatTimer::HeartbeatTimer(int vehicle_id, bool high_latency) : _vehicleID(vehicle_id), _high_latency(high_latency) { - if (!high_latency) { +} + +void HeartbeatTimer::init() +{ + if (!_high_latency) { _timer->setInterval(_heartbeatReceivedTimeoutMSecs); _timer->setSingleShot(true); _timer->start(); @@ -26,7 +30,9 @@ HeartbeatTimer::HeartbeatTimer(int vehicle_id, bool high_latency) : QObject::connect(_timer, &QTimer::timeout, this, &HeartbeatTimer::timerTimeout); } -HeartbeatTimer::~HeartbeatTimer() { + +HeartbeatTimer::~HeartbeatTimer() +{ if (_timer) { QObject::disconnect(_timer, &QTimer::timeout, this, &HeartbeatTimer::timerTimeout); _timer->stop(); diff --git a/src/comm/HeartbeatTimer.h b/src/comm/HeartbeatTimer.h index c62a63f695d43e9d370a021e391fd632cefbad10..ea166873c8b47a18202731eaeabe4b3f3c408ec2 100644 --- a/src/comm/HeartbeatTimer.h +++ b/src/comm/HeartbeatTimer.h @@ -36,6 +36,13 @@ public: */ HeartbeatTimer(int vehicle_id, bool high_latency); + /** + * @brief init + * + * Starts the timer and emits the signal that the link is active for this vehicle ID + */ + void init(); + ~HeartbeatTimer(); /** diff --git a/src/comm/LinkInterface.cc b/src/comm/LinkInterface.cc index 13da6a8508bee26ab22d69e082a70febe9279111..d2c1923cb7e058eb4d889fe2ab05942e6006b1af 100644 --- a/src/comm/LinkInterface.cc +++ b/src/comm/LinkInterface.cc @@ -195,6 +195,7 @@ void LinkInterface::startHeartbeatTimer(int vehicle_id) { } else { _heartbeatTimers.insert(vehicle_id, new HeartbeatTimer(vehicle_id, _highLatency)); QObject::connect(_heartbeatTimers.value(vehicle_id), &HeartbeatTimer::activeChanged, this, &LinkInterface::_activeChanged); + _heartbeatTimers.value(vehicle_id)->init(); } }