From c38f7770913cdcce9322222d3f3feb2e38306d3c Mon Sep 17 00:00:00 2001 From: Raymond Wang Date: Thu, 5 Dec 2024 10:55:02 -0600 Subject: [PATCH 1/3] hardcoded download test file --- src/mavsdk/core/curl_wrapper.cpp | 4 ++++ src/mavsdk/core/mavsdk_impl.cpp | 12 ++++++++++++ src/mavsdk/plugins/camera/camera_impl.cpp | 2 ++ 3 files changed, 18 insertions(+) diff --git a/src/mavsdk/core/curl_wrapper.cpp b/src/mavsdk/core/curl_wrapper.cpp index 30ef52aa9..827e21903 100644 --- a/src/mavsdk/core/curl_wrapper.cpp +++ b/src/mavsdk/core/curl_wrapper.cpp @@ -29,6 +29,8 @@ bool CurlWrapper::download_text(const std::string& url, std::string& content) curl_easy_setopt(curl.get(), CURLOPT_URL, url.c_str()); curl_easy_setopt(curl.get(), CURLOPT_WRITEFUNCTION, write_callback); curl_easy_setopt(curl.get(), CURLOPT_WRITEDATA, &readBuffer); + curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYPEER, 1L); + curl_easy_setopt(curl.get(), CURLOPT_FOLLOWLOCATION, 1L); res = curl_easy_perform(curl.get()); content = readBuffer; @@ -108,6 +110,8 @@ bool CurlWrapper::download_file_to_path( curl_easy_setopt(curl.get(), CURLOPT_WRITEFUNCTION, NULL); curl_easy_setopt(curl.get(), CURLOPT_WRITEDATA, fp); curl_easy_setopt(curl.get(), CURLOPT_NOPROGRESS, 0L); + curl_easy_setopt(curl.get(), CURLOPT_SSL_VERIFYPEER, 1L); + curl_easy_setopt(curl.get(), CURLOPT_FOLLOWLOCATION, 1L); res = curl_easy_perform(curl.get()); fclose(fp); diff --git a/src/mavsdk/core/mavsdk_impl.cpp b/src/mavsdk/core/mavsdk_impl.cpp index a197ad8c3..5d698912b 100644 --- a/src/mavsdk/core/mavsdk_impl.cpp +++ b/src/mavsdk/core/mavsdk_impl.cpp @@ -15,6 +15,7 @@ #include "mavlink_channels.h" #include "callback_list.tpp" #include "hostname_to_ip.h" +#include "http_loader.h" namespace mavsdk { @@ -53,6 +54,17 @@ MavsdkImpl::MavsdkImpl(const Mavsdk::Configuration& configuration) : _process_user_callbacks_thread = new std::thread(&MavsdkImpl::process_user_callbacks_thread, this); + + + HttpLoader http_loader; + std::string uri = "https://github.com/Gremsy/Vio-Camera-Definition/releases/download/v2.0.3/vio_camera_f1_def.xml"; + LogInfo() << "RAWR Downloading camera definition from: " << uri; + std::string camera_definition_out = ""; + if (!http_loader.download_text_sync(uri, camera_definition_out)) { + LogErr() << "RAWR Failed to download camera definition."; + } else { + LogInfo() << "RAWR SUCCESS " << camera_definition_out; + } } MavsdkImpl::~MavsdkImpl() diff --git a/src/mavsdk/plugins/camera/camera_impl.cpp b/src/mavsdk/plugins/camera/camera_impl.cpp index a7acd3c9f..a8d6f42c9 100644 --- a/src/mavsdk/plugins/camera/camera_impl.cpp +++ b/src/mavsdk/plugins/camera/camera_impl.cpp @@ -1514,6 +1514,7 @@ void CameraImpl::process_camera_information(const mavlink_message_t& message) if (result == Camera::Result::Success) { LogDebug() << "Successfully loaded camera definition"; + LogDebug() << "RAWR: THE CONTENT IS " << content; if (_camera_definition_callback) { _system_impl->call_user_callback( @@ -1522,6 +1523,7 @@ void CameraImpl::process_camera_information(const mavlink_message_t& message) _camera_definition.reset(new CameraDefinition()); _camera_definition->load_string(content); + refresh_params(); } else if (result == Camera::Result::ProtocolUnsupported) { From 0b8db637d155923982632a4cb9b9a4bc41756cca Mon Sep 17 00:00:00 2001 From: Raymond Wang Date: Thu, 5 Dec 2024 11:28:14 -0600 Subject: [PATCH 2/3] readd the cert path --- third_party/curl/CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/third_party/curl/CMakeLists.txt b/third_party/curl/CMakeLists.txt index b5c83a149..7935b3e36 100644 --- a/third_party/curl/CMakeLists.txt +++ b/third_party/curl/CMakeLists.txt @@ -13,14 +13,17 @@ list(APPEND CMAKE_ARGS "-DCURL_USE_LIBSSH2=OFF" "-DBUILD_CURL_EXE=OFF" "-DBUILD_SHARED_LIBS=OFF" - "-DCURL_CA_PATH_SET=OFF" "-DCURL_ZLIB=OFF" "-DHTTP_ONLY=ON" "-DHAVE_POSIX_STRERROR_R=1" "-DBUILD_TESTING=OFF" ) -if(IOS) +if(ANDROID) + list(APPEND CMAKE_ARGS + "-DCURL_CA_PATH=/system/etc/security/cacerts" + ) +elseif(IOS) list(APPEND CMAKE_ARGS "-DPLATFORM=${PLATFORM}" "-DDEPLOYMENT_TARGET=${DEPLOYMENT_TARGET}" From 7115c9e62b91fd66823408b379c8fca6f4017caf Mon Sep 17 00:00:00 2001 From: Raymond Wang Date: Fri, 6 Dec 2024 09:23:13 -0600 Subject: [PATCH 3/3] remove test code --- src/mavsdk/core/mavsdk_impl.cpp | 12 ------------ src/mavsdk/plugins/camera/camera_impl.cpp | 2 -- 2 files changed, 14 deletions(-) diff --git a/src/mavsdk/core/mavsdk_impl.cpp b/src/mavsdk/core/mavsdk_impl.cpp index 5d698912b..a197ad8c3 100644 --- a/src/mavsdk/core/mavsdk_impl.cpp +++ b/src/mavsdk/core/mavsdk_impl.cpp @@ -15,7 +15,6 @@ #include "mavlink_channels.h" #include "callback_list.tpp" #include "hostname_to_ip.h" -#include "http_loader.h" namespace mavsdk { @@ -54,17 +53,6 @@ MavsdkImpl::MavsdkImpl(const Mavsdk::Configuration& configuration) : _process_user_callbacks_thread = new std::thread(&MavsdkImpl::process_user_callbacks_thread, this); - - - HttpLoader http_loader; - std::string uri = "https://github.com/Gremsy/Vio-Camera-Definition/releases/download/v2.0.3/vio_camera_f1_def.xml"; - LogInfo() << "RAWR Downloading camera definition from: " << uri; - std::string camera_definition_out = ""; - if (!http_loader.download_text_sync(uri, camera_definition_out)) { - LogErr() << "RAWR Failed to download camera definition."; - } else { - LogInfo() << "RAWR SUCCESS " << camera_definition_out; - } } MavsdkImpl::~MavsdkImpl() diff --git a/src/mavsdk/plugins/camera/camera_impl.cpp b/src/mavsdk/plugins/camera/camera_impl.cpp index a8d6f42c9..a7acd3c9f 100644 --- a/src/mavsdk/plugins/camera/camera_impl.cpp +++ b/src/mavsdk/plugins/camera/camera_impl.cpp @@ -1514,7 +1514,6 @@ void CameraImpl::process_camera_information(const mavlink_message_t& message) if (result == Camera::Result::Success) { LogDebug() << "Successfully loaded camera definition"; - LogDebug() << "RAWR: THE CONTENT IS " << content; if (_camera_definition_callback) { _system_impl->call_user_callback( @@ -1523,7 +1522,6 @@ void CameraImpl::process_camera_information(const mavlink_message_t& message) _camera_definition.reset(new CameraDefinition()); _camera_definition->load_string(content); - refresh_params(); } else if (result == Camera::Result::ProtocolUnsupported) {