From 20937e755e6391a1478ca74adf310248497768fa Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Thu, 13 Jul 2017 10:48:56 +1000 Subject: [PATCH] Sub: move rally-point handling up --- ArduSub/GCS_Mavlink.cpp | 71 ++++++----------------------------------- ArduSub/GCS_Mavlink.h | 2 ++ 2 files changed, 11 insertions(+), 62 deletions(-) diff --git a/ArduSub/GCS_Mavlink.cpp b/ArduSub/GCS_Mavlink.cpp index b8c5cd9f64..06fca7c1a1 100644 --- a/ArduSub/GCS_Mavlink.cpp +++ b/ArduSub/GCS_Mavlink.cpp @@ -1644,68 +1644,6 @@ void GCS_MAVLINK_Sub::handleMessage(mavlink_message_t* msg) #endif break; -#if AC_RALLY == ENABLED - // receive a rally point from GCS and store in EEPROM - case MAVLINK_MSG_ID_RALLY_POINT: { - mavlink_rally_point_t packet; - mavlink_msg_rally_point_decode(msg, &packet); - - if (packet.idx >= sub.rally.get_rally_total() || - packet.idx >= sub.rally.get_rally_max()) { - send_text(MAV_SEVERITY_NOTICE,"Bad rally point message ID"); - break; - } - - if (packet.count != sub.rally.get_rally_total()) { - send_text(MAV_SEVERITY_NOTICE,"Bad rally point message count"); - break; - } - - // sanity check location - if (!check_latlng(packet.lat, packet.lng)) { - break; - } - - RallyLocation rally_point; - rally_point.lat = packet.lat; - rally_point.lng = packet.lng; - rally_point.alt = packet.alt; - rally_point.break_alt = packet.break_alt; - rally_point.land_dir = packet.land_dir; - rally_point.flags = packet.flags; - - if (!sub.rally.set_rally_point_with_index(packet.idx, rally_point)) { - send_text(MAV_SEVERITY_CRITICAL, "Error setting rally point"); - } - - break; - } - - //send a rally point to the GCS - case MAVLINK_MSG_ID_RALLY_FETCH_POINT: { - mavlink_rally_fetch_point_t packet; - mavlink_msg_rally_fetch_point_decode(msg, &packet); - - if (packet.idx > sub.rally.get_rally_total()) { - send_text(MAV_SEVERITY_NOTICE, "Bad rally point index"); - break; - } - - RallyLocation rally_point; - if (!sub.rally.get_rally_point_with_index(packet.idx, rally_point)) { - send_text(MAV_SEVERITY_NOTICE, "Failed to set rally point"); - break; - } - - mavlink_msg_rally_point_send_buf(msg, - chan, msg->sysid, msg->compid, packet.idx, - sub.rally.get_rally_total(), rally_point.lat, rally_point.lng, - rally_point.alt, rally_point.break_alt, rally_point.land_dir, - rally_point.flags); - break; - } -#endif // AC_RALLY == ENABLED - case MAVLINK_MSG_ID_AUTOPILOT_VERSION_REQUEST: send_autopilot_version(FIRMWARE_VERSION); break; @@ -1814,3 +1752,12 @@ AP_Mission *GCS_MAVLINK_Sub::get_mission() { return &sub.mission; } + +AP_Rally *GCS_MAVLINK_Sub::get_rally() const +{ +#if AC_RALLY == ENABLED + return &sub.rally; +#else + return nullptr; +#endif +} diff --git a/ArduSub/GCS_Mavlink.h b/ArduSub/GCS_Mavlink.h index 28f1c0fdfd..845021c4fa 100644 --- a/ArduSub/GCS_Mavlink.h +++ b/ArduSub/GCS_Mavlink.h @@ -15,6 +15,8 @@ protected: }; AP_Mission *get_mission() override; + AP_Rally *get_rally() const override; + uint8_t sysid_my_gcs() const override; private: