From dbc1c03d4989cf00f0aa92da9152b2ae873aa01c Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Mon, 29 Sep 2014 18:47:29 +0900 Subject: [PATCH] Tracker: use handle_set_mode() --- AntennaTracker/GCS_Mavlink.pde | 25 +------------------------ AntennaTracker/system.pde | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/AntennaTracker/GCS_Mavlink.pde b/AntennaTracker/GCS_Mavlink.pde index 92d693ff42..899ad7e5e7 100644 --- a/AntennaTracker/GCS_Mavlink.pde +++ b/AntennaTracker/GCS_Mavlink.pde @@ -854,30 +854,7 @@ mission_failed: case MAVLINK_MSG_ID_SET_MODE: { - // decode - mavlink_set_mode_t packet; - mavlink_msg_set_mode_decode(msg, &packet); - if (g.proxy_mode == true && proxy_vehicle.initialised) { - // Also proxy it to the remote - if (comm_get_txspace(proxy_vehicle.chan) > ((uint16_t)msg->len) + MAVLINK_NUM_NON_PAYLOAD_BYTES) - _mavlink_resend_uart(proxy_vehicle.chan, msg); - } - - if (!(packet.base_mode & MAV_MODE_FLAG_CUSTOM_MODE_ENABLED)) { - // we ignore base_mode as there is no sane way to map - // from that bitmap to a APM flight mode. We rely on - // custom_mode instead. - break; - } - switch (packet.custom_mode) { - case MANUAL: - case STOP: - case SCAN: - case AUTO: - set_mode((enum ControlMode)packet.custom_mode); - break; - } - + handle_set_mode(msg, mavlink_set_mode); break; } diff --git a/AntennaTracker/system.pde b/AntennaTracker/system.pde index df99ae1550..2104fc0745 100644 --- a/AntennaTracker/system.pde +++ b/AntennaTracker/system.pde @@ -212,6 +212,22 @@ static void set_mode(enum ControlMode mode) } } +/* + set_mode() wrapper for MAVLink SET_MODE + */ +static bool mavlink_set_mode(uint8_t mode) +{ + switch (mode) { + case AUTO: + case MANUAL: + case SCAN: + case STOP: + set_mode((enum ControlMode)mode); + return true; + } + return false; +} + static void check_usb_mux(void) { bool usb_check = hal.gpio->usb_connected();