diff options
author | あく <alleteam@gmail.com> | 2021-10-09 11:07:16 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-09 11:07:16 +0300 |
commit | da67562d1b0fa654aa21fcc8a0815f34dfafff60 (patch) | |
tree | cc426b74d666a033fc0e4d5a8cc8a8e5b138b839 | |
parent | 5d6125ae0d6229b4dfecc41d064f4f80f5a5e90a (diff) | |
parent | 53f1fe36728e630cb54d2800b22359255067e6af (diff) |
[FL-1792] Add protobuf RPC #1
-rw-r--r-- | flipper.options | 2 | ||||
-rw-r--r-- | flipper.proto | 52 | ||||
-rw-r--r-- | status.proto | 10 | ||||
-rw-r--r-- | storage.options | 16 | ||||
-rw-r--r-- | storage.proto | 50 |
5 files changed, 121 insertions, 9 deletions
diff --git a/flipper.options b/flipper.options new file mode 100644 index 0000000..8f2653b --- /dev/null +++ b/flipper.options @@ -0,0 +1,2 @@ +PB.Main submsg_callback:true + diff --git a/flipper.proto b/flipper.proto index 8d84c0f..061ddd1 100644 --- a/flipper.proto +++ b/flipper.proto @@ -1,2 +1,52 @@ syntax = "proto3"; -import "storage.proto";
\ No newline at end of file +import "storage.proto"; +import "status.proto"; + +package PB; + +enum CommandStatus { + OK = 0; + ERROR = 1; /**< Unknown error */ + ERROR_DECODE = 2; /**< Command can't be decoded successfully - command_id in response may be wrong! */ + ERROR_NOT_IMPLEMENTED = 3; /**< Command succesfully decoded, but not implemented (deprecated or not yet implemented) */ + ERROR_BUSY = 4; /**< Somebody took global lock, so not all commands are available */ + ERROR_CONTINUOUS_COMMAND_INTERRUPTED = 14; /**< Not received not_last == 0 */ + ERROR_INVALID_PARAMETERS = 15; /**< not provided (or provided invalid) crucial parameters to perform rpc */ + ERROR_STORAGE_NOT_READY = 5; /**< FS not ready */ + ERROR_STORAGE_EXIST = 6; /**< File/Dir alrady exist */ + ERROR_STORAGE_NOT_EXIST = 7; /**< File/Dir does not exist */ + ERROR_STORAGE_INVALID_PARAMETER = 8; /**< Invalid API parameter */ + ERROR_STORAGE_DENIED = 9; /**< Access denied */ + ERROR_STORAGE_INVALID_NAME = 10; /**< Invalid name/path */ + ERROR_STORAGE_INTERNAL = 11; /**< Internal error */ + ERROR_STORAGE_NOT_IMPLEMENTED = 12; /**< Functon not implemented */ + ERROR_STORAGE_ALREADY_OPEN = 13; /**< File/Dir already opened */ +} + +/* There are Server commands (e.g. Storage_write), which have no body message + * in response. But 'oneof' obligate to have at least 1 encoded message + * in scope. For this needs Empty message is implemented. + */ +message Empty { +} + +message Main { + uint32 command_id = 1; + CommandStatus command_status = 2; + bool not_last = 3; + oneof content { + Empty empty = 4; + .PB_Status.PingRequest ping_request = 5; + .PB_Status.PingResponse ping_response = 6; + .PB_Storage.ListRequest storage_list_request = 7; + .PB_Storage.ListResponse storage_list_response = 8; + .PB_Storage.ReadRequest storage_read_request = 9; + .PB_Storage.ReadResponse storage_read_response = 10; + .PB_Storage.WriteRequest storage_write_request = 11; + .PB_Storage.DeleteRequest storage_delete_request = 12; + .PB_Storage.MkdirRequest storage_mkdir_request = 13; + .PB_Storage.Md5sumRequest storage_md5sum_request = 14; + .PB_Storage.Md5sumResponse storage_md5sum_response = 15; + } +} + diff --git a/status.proto b/status.proto new file mode 100644 index 0000000..4880b82 --- /dev/null +++ b/status.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package PB_Status; + +message PingRequest { +} + +message PingResponse { +} + diff --git a/storage.options b/storage.options new file mode 100644 index 0000000..2334206 --- /dev/null +++ b/storage.options @@ -0,0 +1,16 @@ +PB_Storage.File.name type:FT_POINTER +PB_Storage.File.data type:FT_POINTER +PB_Storage.ListRequest.path type:FT_POINTER +PB_Storage.ReadRequest.path type:FT_POINTER +PB_Storage.WriteRequest.path type:FT_POINTER +PB_Storage.DeleteRequest.path type:FT_POINTER + +PB_Storage.MkdirRequest.path type:FT_POINTER +PB_Storage.Md5sumRequest.path type:FT_POINTER + +PB_Storage.ListResponse.file max_count:8 + +// not used by nanopb, better server should keep in mind this max size +PB_Storage.File.data max_size:4096 +PB_Storage.Md5sumResponse.md5sum max_length:32 + diff --git a/storage.proto b/storage.proto index c4b7aad..f9bbb85 100644 --- a/storage.proto +++ b/storage.proto @@ -1,18 +1,52 @@ syntax = "proto3"; -message StorageListRequest { - string path = 1; -} +package PB_Storage; -message StorageListAnswer { +message File { enum FileType { - FILE = 0; + FILE = 0; // default value DIR = 1; } FileType type = 1; string name = 2; - optional uint64 size = 3; + uint32 size = 3; + bytes data = 4; +} + +message ListRequest { + string path = 1; +} + +message ListResponse { + repeated File file = 1; +} + +message ReadRequest { + string path = 1; +} + +message ReadResponse { + File file = 1; +} + +message WriteRequest { + string path = 1; + File file = 2; +} + +message DeleteRequest { + string path = 1; +} + +message MkdirRequest { + string path = 1; +} + +message Md5sumRequest { + string path = 1; +} + +message Md5sumResponse { + string md5sum = 1; } -message StorageListEOF { -}
\ No newline at end of file |