mavlink: support mission transfer cancellation (#14139)

This adds support for MAV_MISSION_OPERATION_CANCELLED which can be used
to cancel an ongoing upload or download of mission/geofence/rally items.
This commit is contained in:
Julian Oes 2020-02-24 07:47:08 +01:00 committed by GitHub
parent 6c8f39c5d8
commit f3fefd7d93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -601,14 +601,16 @@ MavlinkMissionManager::handle_mission_ack(const mavlink_message_t *msg)
if (CHECK_SYSID_COMPID_MISSION(wpa)) {
if ((msg->sysid == _transfer_partner_sysid && msg->compid == _transfer_partner_compid)) {
if (_state == MAVLINK_WPM_STATE_SENDLIST && _mission_type == wpa.mission_type) {
_time_last_recv = hrt_absolute_time();
if (_transfer_seq == current_item_count()) {
if (wpa.type == MAV_MISSION_ACCEPTED && _transfer_seq == current_item_count()) {
PX4_DEBUG("WPM: MISSION_ACK OK all items sent, switch to state IDLE");
} else {
_mavlink->send_statustext_critical("WPM: ERR: not all items sent -> IDLE");
} else if (wpa.type == MAV_MISSION_OPERATION_CANCELLED) {
PX4_DEBUG("WPM: MISSION_ACK CANCELLED, switch to state IDLE");
} else {
PX4_DEBUG("WPM: MISSION_ACK ERROR: not all items sent, switch to state IDLE anyway");
}
@ -628,6 +630,11 @@ MavlinkMissionManager::handle_mission_ack(const mavlink_message_t *msg)
send_mission_request(_transfer_partner_sysid, _transfer_partner_compid, _transfer_seq);
}
} else if (wpa.type == MAV_MISSION_OPERATION_CANCELLED) {
PX4_DEBUG("WPM: MISSION_ACK CANCELLED, switch to state IDLE");
switch_to_idle_state();
_transfer_in_progress = false;
} else if (wpa.type != MAV_MISSION_ACCEPTED) {
PX4_WARN("Mission ack result was %d", wpa.type);
}