mavsdk::MavlinkFTP Class Reference

#include: mavlink_ftp.h


The MavlinkFTP class provides file uploading and downloading using MAVLink FTP.

Public Types

Type Description
enum Result Possible results returned for requests.
std::function< void(Result)> result_callback_t Result callback type for async ftp calls.
std::function< void(uint32_t bytes_read, uint32_t total_bytes)> progress_callback_t Progress callback type for async ftp calls.
std::function< void(Result, std::vector< std::string >)> directory_items_and_result_callback_t Callback type for list_directory_async() call to get directory items and result.
std::function< void(Result, uint32_t)> file_crc32_result_callback_t Callback type for calc_file_crc32_async() call to get file CRC32.

Public Member Functions

Type Name Description
  MavlinkFTP (System & system) Constructor. Creates the plugin for a specific System.
  ~MavlinkFTP () Destructor (internal use only).
  MavlinkFTP (const MavlinkFTP &)=delete Copy Constructor (object is not copyable).
std::string result_str (Result result) Returns a human-readable English string for MavlinkFTP::Result.
void reset_async (result_callback_t callback) Resets FTP server in case there are stale open sessions (asynchronous).
void download_async (const std::string & remote_file_path, const std::string & local_folder, progress_callback_t progress_callback, result_callback_t result_callback) Downloads a file to local folder (asynchronous).
void upload_async (const std::string & local_file_path, const std::string & remote_folder, progress_callback_t progress_callback, result_callback_t result_callback) Uploads local file to remote folder (asynchronous).
void list_directory_async (const std::string & path, directory_items_and_result_callback_t callback) Downloads a vector of directory items from the system (asynchronous).
void create_directory_async (const std::string & path, result_callback_t callback) Creates directory (asynchronous).
void remove_directory_async (const std::string & path, result_callback_t callback) Removes directory (asynchronous).
void remove_file_async (const std::string & path, result_callback_t callback) Removes file (asynchronous).
void rename_async (const std::string & from_path, const std::string & to_path, result_callback_t callback) Renames fromPath to toPath (asynchronous).
void calc_file_crc32_async (const std::string & path, file_crc32_result_callback_t callback) Calculate CRC32 for file (asynchronous).
MavlinkFTP::Result calc_local_file_crc32 (const std::string & path, uint32_t & checksum) Calculate CRC32 for local file.
void set_timeout (uint32_t timeout) Set timeout for Mavlink FTP operation.
void set_retries (uint32_t retries) Set number of retries after timeout for Mavlink FTP operation.
void set_root_dir (const std::string & root_dir) Set root dir for Mavlink FTP server.
void set_target_component_id (uint8_t component_id) Set target component id. By default it is the autopilot.
uint8_t get_our_compid () const Get our own component ID.
const MavlinkFTP & operator= (const MavlinkFTP &)=delete Equality operator (object is not copyable).

Constructor & Destructor Documentation

mavsdk::MavlinkFTP::MavlinkFTP(System &system)

Constructor. Creates the plugin for a specific System.

The plugin is typically created as shown below:

auto mavlink_ftp = std::make_shared<MavlinkFTP>(system);

Parameters

  • System& system - The specific system associated with this plugin.
mavsdk::MavlinkFTP::~MavlinkFTP()

Destructor (internal use only).

mavsdk::MavlinkFTP::MavlinkFTP(const MavlinkFTP &)=delete

Copy Constructor (object is not copyable).

Parameters

Member Typdef Documentation

typedef std::function<void(Result)> mavsdk::MavlinkFTP::result_callback_t

Result callback type for async ftp calls.

typedef std::function<void(uint32_t bytes_read, uint32_t total_bytes)> mavsdk::MavlinkFTP::progress_callback_t

Progress callback type for async ftp calls.

typedef std::function<void(Result, std::vector<std::string>)> mavsdk::MavlinkFTP::directory_items_and_result_callback_t

Callback type for list_directory_async() call to get directory items and result.

typedef std::function<void(Result, uint32_t)> mavsdk::MavlinkFTP::file_crc32_result_callback_t

Callback type for calc_file_crc32_async() call to get file CRC32.

Member Enumeration Documentation

Possible results returned for requests.

Value Description
SUCCESS
TIMEOUT Timeout.
IN_PROGRESS Operation is already in progress.
FILE_IO_ERROR File IO operation error.
FILE_EXISTS File exists already.
FILE_DOES_NOT_EXIST File does not exist.
FILE_PROTECTED File is write protected.
INVALID_PARAMETER Invalid parameter.
UNSUPPORTED Unsupported command.
PROTOCOL_ERROR General protocol error.

Member Function Documentation

std::string mavsdk::MavlinkFTP::result_str(Result result)

Returns a human-readable English string for MavlinkFTP::Result.

Parameters

  • Result result - The enum value for which a human readable string is required.

Returns

 std::string - Human readable string for the MavlinkFTP::Result.

void mavsdk::MavlinkFTP::reset_async(result_callback_t callback)

Resets FTP server in case there are stale open sessions (asynchronous).

Parameters

void mavsdk::MavlinkFTP::download_async(const std::string &remote_file_path, const std::string &local_folder, progress_callback_t progress_callback, result_callback_t result_callback)

Downloads a file to local folder (asynchronous).

Parameters

  • const std::string& remote_file_path - Remote file to download
  • const std::string& local_folder - Local folder where downloaded file will be stored
  • progress_callback_t progress_callback - Callback to receive progress of this request.
  • result_callback_t result_callback - Callback to receive result of this request.
void mavsdk::MavlinkFTP::upload_async(const std::string &local_file_path, const std::string &remote_folder, progress_callback_t progress_callback, result_callback_t result_callback)

Uploads local file to remote folder (asynchronous).

Parameters

  • const std::string& local_file_path - Local file to upload
  • const std::string& remote_folder - Remote folder where uploaded file will be stored
  • progress_callback_t progress_callback - Callback to receive progress of this request.
  • result_callback_t result_callback - Callback to receive result of this request.
void mavsdk::MavlinkFTP::list_directory_async(const std::string &path, directory_items_and_result_callback_t callback)

Downloads a vector of directory items from the system (asynchronous).

Parameters

void mavsdk::MavlinkFTP::create_directory_async(const std::string &path, result_callback_t callback)

Creates directory (asynchronous).

Parameters

  • const std::string& path - Path of a directory to create
  • result_callback_t callback - Callback to receive result of this request.
void mavsdk::MavlinkFTP::remove_directory_async(const std::string &path, result_callback_t callback)

Removes directory (asynchronous).

Parameters

  • const std::string& path - Path of a directory to remove
  • result_callback_t callback - Callback to receive result of this request.
void mavsdk::MavlinkFTP::remove_file_async(const std::string &path, result_callback_t callback)

Removes file (asynchronous).

Parameters

  • const std::string& path - Path of a file to remove
  • result_callback_t callback - Callback to receive result of this request.
void mavsdk::MavlinkFTP::rename_async(const std::string &from_path, const std::string &to_path, result_callback_t callback)

Renames fromPath to toPath (asynchronous).

Parameters

  • const std::string& from_path - Path to rename
  • const std::string& to_path - Destination path
  • result_callback_t callback - Callback to receive result of this request.
void mavsdk::MavlinkFTP::calc_file_crc32_async(const std::string &path, file_crc32_result_callback_t callback)

Calculate CRC32 for file (asynchronous).

Parameters

  • const std::string& path - Path to file for which CRC32 is calculated.
  • file_crc32_result_callback_t callback - Callback to receive result of this request.
MavlinkFTP::Result mavsdk::MavlinkFTP::calc_local_file_crc32(const std::string &path, uint32_t &checksum)

Calculate CRC32 for local file.

Parameters

  • const std::string& path - Path to local file for which CRC32 is calculated.
  • uint32_t& checksum - CRC32 of the file

Returns

MavlinkFTP::Result - Result of the operation

void mavsdk::MavlinkFTP::set_timeout(uint32_t timeout)

Set timeout for Mavlink FTP operation.

Parameters

  • uint32_t timeout - Timeout in milliseconds
void mavsdk::MavlinkFTP::set_retries(uint32_t retries)

Set number of retries after timeout for Mavlink FTP operation.

Parameters

  • uint32_t retries - Number of retries before ERR_TIMEOUT is issued
void mavsdk::MavlinkFTP::set_root_dir(const std::string &root_dir)

Set root dir for Mavlink FTP server.

Parameters

  • const std::string& root_dir - Root dir for
void mavsdk::MavlinkFTP::set_target_component_id(uint8_t component_id)

Set target component id. By default it is the autopilot.

Parameters

  • uint8_t component_id - Target component id
uint8_t mavsdk::MavlinkFTP::get_our_compid() const

Get our own component ID.

Returns

 uint8_t - our own component ID.

const MavlinkFTP& mavsdk::MavlinkFTP::operator=(const MavlinkFTP &)=delete

Equality operator (object is not copyable).

Parameters

Returns

 const MavlinkFTP & -

© Dronecode 2017-2019. License: CC BY 4.0            Updated: 2019-11-05 22:22:21

results matching ""

    No results matching ""