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
MavlinkFTP()
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.
~MavlinkFTP()
mavsdk::MavlinkFTP::~MavlinkFTP()
Destructor (internal use only).
MavlinkFTP()
mavsdk::MavlinkFTP::MavlinkFTP(const MavlinkFTP &)=delete
Copy Constructor (object is not copyable).
Parameters
- const MavlinkFTP& -
Member Typdef Documentation
typedef result_callback_t
typedef std::function<void(Result)> mavsdk::MavlinkFTP::result_callback_t
Result callback type for async ftp calls.
typedef progress_callback_t
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 directory_items_and_result_callback_t
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 file_crc32_result_callback_t
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
enum Result
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
result_str()
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.
reset_async()
void mavsdk::MavlinkFTP::reset_async(result_callback_t callback)
Resets FTP server in case there are stale open sessions (asynchronous).
Parameters
- result_callback_t callback - Callback to receive result of this request.
download_async()
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.
upload_async()
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.
list_directory_async()
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
- const std::string& path - Path of a directory to list
- directory_items_and_result_callback_t callback - Callback to receive directory entries and result of this request.
create_directory_async()
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.
remove_directory_async()
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.
remove_file_async()
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.
rename_async()
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.
calc_file_crc32_async()
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.
calc_local_file_crc32()
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
set_timeout()
void mavsdk::MavlinkFTP::set_timeout(uint32_t timeout)
Set timeout for Mavlink FTP operation.
Parameters
- uint32_t timeout - Timeout in milliseconds
set_retries()
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
set_root_dir()
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
set_target_component_id()
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
get_our_compid()
uint8_t mavsdk::MavlinkFTP::get_our_compid() const
Get our own component ID.
Returns
uint8_t - our own component ID.
operator=()
const MavlinkFTP& mavsdk::MavlinkFTP::operator=(const MavlinkFTP &)=delete
Equality operator (object is not copyable).
Parameters
- const MavlinkFTP& -
Returns
const MavlinkFTP & -