mavsdk::Ftp Class Reference

#include: ftp.h


Implements file transfer functionality using MAVLink FTP.

Data Structures

struct ProgressData

Public Types

Type Description
enum Result Possible results returned for FTP commands.
std::function< void(Result)> ResultCallback Callback type for asynchronous Ftp calls.
std::function< void(Ftp::Result, ProgressData)> DownloadCallback Callback type for download_async.
std::function< void(Ftp::Result, ProgressData)> UploadCallback Callback type for upload_async.
std::function< void(Result, std::vector< std::string >)> ListDirectoryCallback Callback type for list_directory_async.
std::function< void(Result, bool)> AreFilesIdenticalCallback Callback type for are_files_identical_async.

Public Member Functions

Type Name Description
  Ftp (System & system) Constructor. Creates the plugin for a specific System.
  ~Ftp () Destructor (internal use only).
  Ftp (const Ftp &)=delete Copy constructor (object is not copyable).
void reset_async (const ResultCallback callback) Resets FTP server in case there are stale open sessions.
void download_async (std::string remote_file_path, std::string local_dir, DownloadCallback callback) Downloads a file to local directory.
void upload_async (std::string local_file_path, std::string remote_dir, UploadCallback callback) Uploads local file to remote directory.
void list_directory_async (std::string remote_dir, const ListDirectoryCallback callback) Lists items from a remote directory.
std::pair< Result, std::vector< std::string > > list_directory (std::string remote_dir)const Lists items from a remote directory.
void create_directory_async (std::string remote_dir, const ResultCallback callback) Creates a remote directory.
Result create_directory (std::string remote_dir)const Creates a remote directory.
void remove_directory_async (std::string remote_dir, const ResultCallback callback) Removes a remote directory.
Result remove_directory (std::string remote_dir)const Removes a remote directory.
void remove_file_async (std::string remote_file_path, const ResultCallback callback) Removes a remote file.
Result remove_file (std::string remote_file_path)const Removes a remote file.
void rename_async (std::string remote_from_path, std::string remote_to_path, const ResultCallback callback) Renames a remote file or remote directory.
Result rename (std::string remote_from_path, std::string remote_to_path)const Renames a remote file or remote directory.
void are_files_identical_async (std::string local_file_path, std::string remote_file_path, const AreFilesIdenticalCallback callback) Compares a local file to a remote file using a CRC32 checksum.
std::pair< Result, bool > are_files_identical (std::string local_file_path, std::string remote_file_path)const Compares a local file to a remote file using a CRC32 checksum.
Result set_root_directory (std::string root_dir)const Set root directory for MAVLink FTP server.
Result set_target_compid (uint32_t compid)const Set target component ID. By default it is the autopilot.
uint32_t get_our_compid () const Get our own component ID.
const Ftp & operator= (const Ftp &)=delete Equality operator (object is not copyable).

Constructor & Destructor Documentation

Ftp()

mavsdk::Ftp::Ftp(System &system)

Constructor. Creates the plugin for a specific System.

The plugin is typically created as shown below:

auto ftp = std::make_shared<Ftp>(system);

Parameters

  • System& system - The specific system associated with this plugin.

~Ftp()

mavsdk::Ftp::~Ftp()

Destructor (internal use only).

Ftp()

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

Copy constructor (object is not copyable).

Parameters

Member Typdef Documentation

typedef ResultCallback

using mavsdk::Ftp::ResultCallback =  std::function<void(Result)>

Callback type for asynchronous Ftp calls.

typedef DownloadCallback

using mavsdk::Ftp::DownloadCallback =  std::function<void(Ftp::Result, ProgressData)>

Callback type for download_async.

typedef UploadCallback

using mavsdk::Ftp::UploadCallback =  std::function<void(Ftp::Result, ProgressData)>

Callback type for upload_async.

typedef ListDirectoryCallback

using mavsdk::Ftp::ListDirectoryCallback =  std::function<void(Result, std::vector<std::string>)>

Callback type for list_directory_async.

typedef AreFilesIdenticalCallback

using mavsdk::Ftp::AreFilesIdenticalCallback =  std::function<void(Result, bool)>

Callback type for are_files_identical_async.

Member Enumeration Documentation

enum Result

Possible results returned for FTP commands.

Value Description
Unknown Unknown result.
Success Success.
Next Intermediate message showing progress.
Timeout Timeout.
Busy Operation is already in progress.
FileIoError File IO operation error.
FileExists File exists already.
FileDoesNotExist File does not exist.
FileProtected File is write protected.
InvalidParameter Invalid parameter.
Unsupported Unsupported command.
ProtocolError General protocol error.

Member Function Documentation

reset_async()

void mavsdk::Ftp::reset_async(const ResultCallback callback)

Resets FTP server in case there are stale open sessions.

This function is non-blocking.

Parameters

download_async()

void mavsdk::Ftp::download_async(std::string remote_file_path, std::string local_dir, DownloadCallback callback)

Downloads a file to local directory.

Parameters

  • std::string remote_file_path -
  • std::string local_dir -
  • DownloadCallback callback -

upload_async()

void mavsdk::Ftp::upload_async(std::string local_file_path, std::string remote_dir, UploadCallback callback)

Uploads local file to remote directory.

Parameters

  • std::string local_file_path -
  • std::string remote_dir -
  • UploadCallback callback -

list_directory_async()

void mavsdk::Ftp::list_directory_async(std::string remote_dir, const ListDirectoryCallback callback)

Lists items from a remote directory.

This function is non-blocking. See 'list_directory' for the blocking counterpart.

Parameters

list_directory()

std::pair<Result, std::vector<std::string> > mavsdk::Ftp::list_directory(std::string remote_dir) const

Lists items from a remote directory.

This function is blocking. See 'list_directory_async' for the non-blocking counterpart.

Parameters

  • std::string remote_dir -

Returns

 std::pair< Result, std::vector< std::string > > - Result of request.

create_directory_async()

void mavsdk::Ftp::create_directory_async(std::string remote_dir, const ResultCallback callback)

Creates a remote directory.

This function is non-blocking. See 'create_directory' for the blocking counterpart.

Parameters

create_directory()

Result mavsdk::Ftp::create_directory(std::string remote_dir) const

Creates a remote directory.

This function is blocking. See 'create_directory_async' for the non-blocking counterpart.

Parameters

  • std::string remote_dir -

Returns

Result - Result of request.

remove_directory_async()

void mavsdk::Ftp::remove_directory_async(std::string remote_dir, const ResultCallback callback)

Removes a remote directory.

This function is non-blocking. See 'remove_directory' for the blocking counterpart.

Parameters

remove_directory()

Result mavsdk::Ftp::remove_directory(std::string remote_dir) const

Removes a remote directory.

This function is blocking. See 'remove_directory_async' for the non-blocking counterpart.

Parameters

  • std::string remote_dir -

Returns

Result - Result of request.

remove_file_async()

void mavsdk::Ftp::remove_file_async(std::string remote_file_path, const ResultCallback callback)

Removes a remote file.

This function is non-blocking. See 'remove_file' for the blocking counterpart.

Parameters

remove_file()

Result mavsdk::Ftp::remove_file(std::string remote_file_path) const

Removes a remote file.

This function is blocking. See 'remove_file_async' for the non-blocking counterpart.

Parameters

  • std::string remote_file_path -

Returns

Result - Result of request.

rename_async()

void mavsdk::Ftp::rename_async(std::string remote_from_path, std::string remote_to_path, const ResultCallback callback)

Renames a remote file or remote directory.

This function is non-blocking. See 'rename' for the blocking counterpart.

Parameters

  • std::string remote_from_path -
  • std::string remote_to_path -
  • const ResultCallback callback -

rename()

Result mavsdk::Ftp::rename(std::string remote_from_path, std::string remote_to_path) const

Renames a remote file or remote directory.

This function is blocking. See 'rename_async' for the non-blocking counterpart.

Parameters

  • std::string remote_from_path -
  • std::string remote_to_path -

Returns

Result - Result of request.

are_files_identical_async()

void mavsdk::Ftp::are_files_identical_async(std::string local_file_path, std::string remote_file_path, const AreFilesIdenticalCallback callback)

Compares a local file to a remote file using a CRC32 checksum.

This function is non-blocking. See 'are_files_identical' for the blocking counterpart.

Parameters

are_files_identical()

std::pair<Result, bool> mavsdk::Ftp::are_files_identical(std::string local_file_path, std::string remote_file_path) const

Compares a local file to a remote file using a CRC32 checksum.

This function is blocking. See 'are_files_identical_async' for the non-blocking counterpart.

Parameters

  • std::string local_file_path -
  • std::string remote_file_path -

Returns

 std::pair< Result, bool > - Result of request.

set_root_directory()

Result mavsdk::Ftp::set_root_directory(std::string root_dir) const

Set root directory for MAVLink FTP server.

This function is blocking.

Parameters

  • std::string root_dir -

Returns

Result - Result of request.

set_target_compid()

Result mavsdk::Ftp::set_target_compid(uint32_t compid) const

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

This function is blocking.

Parameters

  • uint32_t compid -

Returns

Result - Result of request.

get_our_compid()

uint32_t mavsdk::Ftp::get_our_compid() const

Get our own component ID.

This function is blocking.

Returns

 uint32_t - Result of request.

operator=()

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

Equality operator (object is not copyable).

Parameters

Returns

 const Ftp & -

© Dronecode 2017-2020. License: CC BY 4.0            Updated: 2020-10-17 17:05:17

results matching ""

    No results matching ""