From cac3a2216d673d9abe173e10e5462507cc8df521 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Thu, 18 Jan 2024 15:37:06 +1100 Subject: [PATCH] GCS_MAVLink: make mavlink-required methods available even if not HAL_GCS_ENABLED --- libraries/GCS_MAVLink/GCS_MAVLink.cpp | 40 ++++++++++++++++----------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/libraries/GCS_MAVLink/GCS_MAVLink.cpp b/libraries/GCS_MAVLink/GCS_MAVLink.cpp index c4f531822d..ffbc50207f 100644 --- a/libraries/GCS_MAVLink/GCS_MAVLink.cpp +++ b/libraries/GCS_MAVLink/GCS_MAVLink.cpp @@ -41,6 +41,30 @@ extern const AP_HAL::HAL& hal; #pragma GCC diagnostic pop #endif +mavlink_message_t* mavlink_get_channel_buffer(uint8_t chan) { +#if HAL_GCS_ENABLED + GCS_MAVLINK *link = gcs().chan(chan); + if (link == nullptr) { + return nullptr; + } + return link->channel_buffer(); +#else + return nullptr; +#endif +} + +mavlink_status_t* mavlink_get_channel_status(uint8_t chan) { +#if HAL_GCS_ENABLED + GCS_MAVLINK *link = gcs().chan(chan); + if (link == nullptr) { + return nullptr; + } + return link->channel_status(); +#else + return nullptr; +#endif +} + #endif // HAL_MAVLINK_BINDINGS_ENABLED #if HAL_GCS_ENABLED @@ -65,22 +89,6 @@ GCS_MAVLINK *GCS_MAVLINK::find_by_mavtype_and_compid(uint8_t mav_type, uint8_t c return gcs().chan(channel); } -mavlink_message_t* mavlink_get_channel_buffer(uint8_t chan) { - GCS_MAVLINK *link = gcs().chan(chan); - if (link == nullptr) { - return nullptr; - } - return link->channel_buffer(); -} - -mavlink_status_t* mavlink_get_channel_status(uint8_t chan) { - GCS_MAVLINK *link = gcs().chan(chan); - if (link == nullptr) { - return nullptr; - } - return link->channel_status(); -} - // set a channel as private. Private channels get sent heartbeats, but // don't get broadcast packets or forwarded packets void GCS_MAVLINK::set_channel_private(mavlink_channel_t _chan)