Skip to content

Commit

Permalink
Split Ftp plugin into Ftp and FtpServer (#319)
Browse files Browse the repository at this point in the history
* Add FtpServer plugin

This is the part that can serve directories with files.

Signed-off-by: Julian Oes <[email protected]>

* ftp: Set root dir, not individual files

Signed-off-by: Julian Oes <[email protected]>

* ftp: remove reset and compid getter

We shouldn't need that.

Signed-off-by: Julian Oes <[email protected]>

* ftp: enable bulk download

Signed-off-by: Julian Oes <[email protected]>

---------

Signed-off-by: Julian Oes <[email protected]>
  • Loading branch information
julianoes authored Oct 14, 2023
1 parent 53df8f4 commit 84d4529
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 29 deletions.
30 changes: 1 addition & 29 deletions protos/ftp/ftp.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -53,28 +49,16 @@ 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 {
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;
Expand Down Expand Up @@ -136,25 +120,13 @@ 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.
}
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.
Expand Down
43 changes: 43 additions & 0 deletions protos/ftp_server/ftp_server.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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 {
/*
* 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 SetRootDir(SetRootDirRequest) returns(SetRootDirResponse) { option (mavsdk.options.async_type) = SYNC; }
}

message SetRootDirRequest {
string path = 1; // Absolute path of folder
}

message SetRootDirResponse {
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_DOES_NOT_EXIST = 2; // Directory does not exist
RESULT_BUSY = 3; // Operations in progress
}

Result result = 1; // Result enum value
string result_str = 2; // Human-readable English string describing the result
}

0 comments on commit 84d4529

Please sign in to comment.