Commit b0f341d6 authored by DonLakeFlyer's avatar DonLakeFlyer

10 sec timeout on vehicle

parent 2f7deb1b
......@@ -2631,11 +2631,21 @@ bool Vehicle::autoDisarm(void)
void Vehicle::_handleADSBVehicle(const mavlink_message_t& message)
{
mavlink_adsb_vehicle_t adsbVehicle;
static const int maxTimeSinceLastSeen = 10;
mavlink_msg_adsb_vehicle_decode(&message, &adsbVehicle);
if (adsbVehicle.flags | ADSB_FLAGS_VALID_COORDS) {
if (_adsbICAOMap.contains(adsbVehicle.ICAO_address)) {
_adsbICAOMap[adsbVehicle.ICAO_address]->update(adsbVehicle);
if (adsbVehicle.tslc > maxTimeSinceLastSeen) {
ADSBVehicle* vehicle = _adsbICAOMap[adsbVehicle.ICAO_address];
_adsbVehicles.removeOne(vehicle);
_adsbICAOMap.remove(adsbVehicle.ICAO_address);
vehicle->deleteLater();
} else {
if (adsbVehicle.tslc <= maxTimeSinceLastSeen) {
_adsbICAOMap[adsbVehicle.ICAO_address]->update(adsbVehicle);
}
}
} else {
ADSBVehicle* vehicle = new ADSBVehicle(adsbVehicle, this);
_adsbICAOMap[adsbVehicle.ICAO_address] = vehicle;
......
......@@ -1278,8 +1278,8 @@ void MockLink::_sendADSBVehicles(void)
_mavlinkChannel,
&responseMsg,
12345, // ICAO address
(_vehicleLatitude + 0.001) * qPow(10.0, 7.0),
(_vehicleLongitude + 0.001) * qPow(10.0, 7.0),
(_vehicleLatitude + 0.001) * 1e7,
(_vehicleLongitude + 0.001) * 1e7,
ADSB_ALTITUDE_TYPE_GEOMETRIC,
100 * 1000, // Altitude in millimeters
10 * 100, // Heading in centidegress
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment