From 211d4c6c49807b51d4c3da7c55135fad51aee267 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Tue, 23 May 2023 14:12:45 +1200 Subject: [PATCH 1/4] Add FtpServer plugin This is the part that can serve directories with files. Signed-off-by: Julian Oes --- protos/ftp_server/ftp_server.proto | 38 ++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 protos/ftp_server/ftp_server.proto diff --git a/protos/ftp_server/ftp_server.proto b/protos/ftp_server/ftp_server.proto new file mode 100644 index 00000000..b4ae502f --- /dev/null +++ b/protos/ftp_server/ftp_server.proto @@ -0,0 +1,38 @@ +syntax = "proto3"; + +package mavsdk.rpc.ftp_server; + +import "mavsdk_options.proto"; + +option java_package = "io.mavsdk.ftp_server"; +option java_outer_classname = "FtpServerProto"; + +// Provide files or directories to transfer. +service FtpServerService { + /* + * Provide a file. + */ + rpc ProvideDirectory(ProvideDirectoryRequest) returns(ProvideDirectoryResponse) { option (mavsdk.options.async_type) = SYNC; } +} + +message ProvideDirectoryRequest { + string path = 1; // Absolute path of folder +} + +message ProvideDirectoryResponse { + FtpServerResult ftp_server_result = 1; +} + +// Result type. +message FtpServerResult { + // Possible results returned for FTP server requests. + enum Result { + RESULT_UNKNOWN = 0; // Unknown result + RESULT_SUCCESS = 1; // Request succeeded + RESULT_NOT_FOUND = 2; // Not Found + RESULT_DUPLICATE = 3; // Directory already exists + } + + Result result = 1; // Result enum value + string result_str = 2; // Human-readable English string describing the result +} From 160912db7dc898aef0478db8fb3356b95987cc8e Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 24 May 2023 17:24:51 +1200 Subject: [PATCH 2/4] ftp: Set root dir, not individual files Signed-off-by: Julian Oes --- protos/ftp_server/ftp_server.proto | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/protos/ftp_server/ftp_server.proto b/protos/ftp_server/ftp_server.proto index b4ae502f..3696e986 100644 --- a/protos/ftp_server/ftp_server.proto +++ b/protos/ftp_server/ftp_server.proto @@ -10,16 +10,21 @@ option java_outer_classname = "FtpServerProto"; // Provide files or directories to transfer. service FtpServerService { /* - * Provide a file. + * Set root directory. + * + * This is the directory that can then be accessed by a client. + * The directory needs to exist when this is called. + * The permissions are the same as the file permission for the user running the server. + * The root directory can't be changed while an FTP process is in progress. */ - rpc ProvideDirectory(ProvideDirectoryRequest) returns(ProvideDirectoryResponse) { option (mavsdk.options.async_type) = SYNC; } + rpc SetRootDir(SetRootDirRequest) returns(SetRootDirResponse) { option (mavsdk.options.async_type) = SYNC; } } -message ProvideDirectoryRequest { +message SetRootDirRequest { string path = 1; // Absolute path of folder } -message ProvideDirectoryResponse { +message SetRootDirResponse { FtpServerResult ftp_server_result = 1; } @@ -29,8 +34,8 @@ message FtpServerResult { enum Result { RESULT_UNKNOWN = 0; // Unknown result RESULT_SUCCESS = 1; // Request succeeded - RESULT_NOT_FOUND = 2; // Not Found - RESULT_DUPLICATE = 3; // Directory already exists + RESULT_DOES_NOT_EXIST = 2; // Directory does not exist + RESULT_BUSY = 3; // Operations in progress } Result result = 1; // Result enum value From 442b49b67ac4bc606cec433ed88582f09564bf28 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Fri, 21 Jul 2023 21:04:09 +0200 Subject: [PATCH 3/4] ftp: remove reset and compid getter We shouldn't need that. Signed-off-by: Julian Oes --- protos/ftp/ftp.proto | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/protos/ftp/ftp.proto b/protos/ftp/ftp.proto index 3ae14386..012949e2 100644 --- a/protos/ftp/ftp.proto +++ b/protos/ftp/ftp.proto @@ -11,10 +11,6 @@ option java_outer_classname = "FtpProto"; * Implements file transfer functionality using MAVLink FTP. */ service FtpService { - /* - * Resets FTP server in case there are stale open sessions. - */ - rpc Reset(ResetRequest) returns(ResetResponse) { option (mavsdk.options.async_type) = ASYNC; } /* * Downloads a file to local directory. */ @@ -53,23 +49,10 @@ service FtpService { * Compares a local file to a remote file using a CRC32 checksum. */ rpc AreFilesIdentical(AreFilesIdenticalRequest) returns(AreFilesIdenticalResponse) {} - /* - * Set root directory for MAVLink FTP server. - */ - rpc SetRootDirectory(SetRootDirectoryRequest) returns(SetRootDirectoryResponse) { option (mavsdk.options.async_type) = SYNC; } /* * Set target component ID. By default it is the autopilot. */ rpc SetTargetCompid(SetTargetCompidRequest) returns(SetTargetCompidResponse) { option (mavsdk.options.async_type) = SYNC; } - /* - * Get our own component ID. - */ - rpc GetOurCompid(GetOurCompidRequest) returns(GetOurCompidResponse) { option (mavsdk.options.async_type) = SYNC; } -} - -message ResetRequest {} -message ResetResponse { - FtpResult ftp_result = 1; } message SubscribeDownloadRequest { @@ -136,13 +119,6 @@ message AreFilesIdenticalResponse { bool are_identical = 2; // Whether the files are identical. } -message SetRootDirectoryRequest { - string root_dir = 1; // The root directory to set. -} -message SetRootDirectoryResponse { - FtpResult ftp_result = 1; -} - message SetTargetCompidRequest { uint32 compid = 1; // The component ID to set. } @@ -150,11 +126,6 @@ message SetTargetCompidResponse { FtpResult ftp_result = 1; } -message GetOurCompidRequest {} -message GetOurCompidResponse { - uint32 compid = 1; // Our component ID. -} - // Progress data type for file transfer. message ProgressData { uint32 bytes_transferred = 1; // The number of bytes already transferred. From 522dddbd36656fe6403321270efd0a24ebf95b12 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Fri, 6 Oct 2023 15:13:36 +1300 Subject: [PATCH 4/4] ftp: enable bulk download Signed-off-by: Julian Oes --- protos/ftp/ftp.proto | 1 + 1 file changed, 1 insertion(+) diff --git a/protos/ftp/ftp.proto b/protos/ftp/ftp.proto index 012949e2..2dd0296d 100644 --- a/protos/ftp/ftp.proto +++ b/protos/ftp/ftp.proto @@ -58,6 +58,7 @@ service FtpService { message SubscribeDownloadRequest { string remote_file_path = 1; // The path of the remote file to download. string local_dir = 2; // The local directory to download to. + bool use_burst = 3; // Use burst for faster downloading. } message DownloadResponse { FtpResult ftp_result = 1;