From 6eca18c08bd93b57aa2c2dacf58f579567798a9d Mon Sep 17 00:00:00 2001 From: Hwurzburg Date: Fri, 13 Nov 2020 19:54:07 -0600 Subject: [PATCH] GCS_MAVLink: add Board option to disable MAVftp in low mem bds/apps --- libraries/GCS_MAVLink/GCS_Common.cpp | 6 ++++-- libraries/GCS_MAVLink/GCS_FTP.cpp | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libraries/GCS_MAVLink/GCS_Common.cpp b/libraries/GCS_MAVLink/GCS_Common.cpp index f4bc4e147c..774a97ac27 100644 --- a/libraries/GCS_MAVLink/GCS_Common.cpp +++ b/libraries/GCS_MAVLink/GCS_Common.cpp @@ -5065,8 +5065,10 @@ uint64_t GCS_MAVLINK::capabilities() const ret |= MAV_PROTOCOL_CAPABILITY_MISSION_FENCE; } - ret |= MAV_PROTOCOL_CAPABILITY_FTP; - + if (!AP_BoardConfig::ftp_disabled()){ //if ftp disable board option is not set + ret |= MAV_PROTOCOL_CAPABILITY_FTP; + } + return ret; } diff --git a/libraries/GCS_MAVLink/GCS_FTP.cpp b/libraries/GCS_MAVLink/GCS_FTP.cpp index 89194f3966..cdd396a711 100644 --- a/libraries/GCS_MAVLink/GCS_FTP.cpp +++ b/libraries/GCS_MAVLink/GCS_FTP.cpp @@ -20,6 +20,7 @@ #include #include +#include extern const AP_HAL::HAL& hal; @@ -29,7 +30,14 @@ struct GCS_MAVLINK::ftp_state GCS_MAVLINK::ftp; #define FTP_SESSION_TIMEOUT 3000 bool GCS_MAVLINK::ftp_init(void) { + + // check if ftp is disabled for memory savings + if (AP_BoardConfig::ftp_disabled()) { + goto failed; + } + // we can simply check if we allocated everything we need + if (ftp.requests != nullptr) { return true; }