From 3b472ccc17dc766498133721ab34c314d64d4c11 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 18 Jul 2017 18:55:06 +1000 Subject: [PATCH] GCS_MAVLink: move try_send_message mission handling up --- libraries/GCS_MAVLink/GCS.h | 1 + libraries/GCS_MAVLink/GCS_Common.cpp | 40 ++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/libraries/GCS_MAVLink/GCS.h b/libraries/GCS_MAVLink/GCS.h index 20c67790d5..66f6da3405 100644 --- a/libraries/GCS_MAVLink/GCS.h +++ b/libraries/GCS_MAVLink/GCS.h @@ -289,6 +289,7 @@ protected: // message sending functions: bool try_send_compass_message(enum ap_message id); + bool try_send_mission_message(enum ap_message id); private: diff --git a/libraries/GCS_MAVLink/GCS_Common.cpp b/libraries/GCS_MAVLink/GCS_Common.cpp index f164bab428..18f858e4fd 100644 --- a/libraries/GCS_MAVLink/GCS_Common.cpp +++ b/libraries/GCS_MAVLink/GCS_Common.cpp @@ -2054,6 +2054,38 @@ bool GCS_MAVLINK::try_send_compass_message(const enum ap_message id) return ret; } +bool GCS_MAVLINK::try_send_mission_message(const enum ap_message id) +{ + AP_Mission *mission = get_mission(); + if (mission == nullptr) { + return true; + } + + bool ret = true; + switch (id) { + case MSG_CURRENT_WAYPOINT: + CHECK_PAYLOAD_SIZE(MISSION_CURRENT); + mavlink_msg_mission_current_send(chan, mission->get_current_nav_index()); + ret = true; + break; + case MSG_MISSION_ITEM_REACHED: + CHECK_PAYLOAD_SIZE(MISSION_ITEM_REACHED); + mavlink_msg_mission_item_reached_send(chan, mission_item_reached_index); + ret = true; + break; + case MSG_NEXT_WAYPOINT: + CHECK_PAYLOAD_SIZE(MISSION_REQUEST); + queued_waypoint_send(); + ret = true; + break; + default: + ret = true; + break; + } + return ret; +} + + bool GCS_MAVLINK::try_send_message(const enum ap_message id) { if (telemetry_delayed()) { @@ -2064,6 +2096,14 @@ bool GCS_MAVLINK::try_send_message(const enum ap_message id) switch(id) { + case MSG_CURRENT_WAYPOINT: + /* fall through */ + case MSG_MISSION_ITEM_REACHED: + /* fall through */ + case MSG_NEXT_WAYPOINT: + ret = try_send_mission_message(id); + break; + case MSG_MAG_CAL_PROGRESS: /* fall through */ case MSG_MAG_CAL_REPORT: