-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serialftp.h
48 lines (41 loc) · 1.08 KB
/
serialftp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* SPDX-License-Identifier: MIT */
/*
* TODO:
* - allow changing start/end words (default XFS/XSE)
* - use checksum also for file upload
* - add standalone tools for file upload / download
* - don't limit to using only Serial
* - provide way to use second serial port for messages
*/
#pragma once
#define SERIALFTP_MAX_PATH_LEN 256
#define SERIALFTP_MAX_FILE_SIZE 4096
struct SerialFTP
{
enum Mode {
MODE_FS,
MODE_SERIAL
};
SerialFTP(void);
void begin(void);
void ls(void);
void help(void);
void put(char *buf, size_t len);
void cd(char *buf, size_t len);
void rm(char *buf, size_t len);
void get(char *buf, size_t len);
void loop(char *buf, size_t len);
void run(void);
protected:
void handle_line(char *buf, size_t len);
void write_size(size_t size);
void write_checksum(char *buf, size_t size);
void write_file(char *buf, size_t size);
void set_cwd(const char *buf, size_t len);
bool mkpath(char *buf, size_t len, char *path, size_t pathlen);
public:
char cwd[SERIALFTP_MAX_PATH_LEN];
size_t cwd_len;
enum Mode mode;
char file_buffer[SERIALFTP_MAX_FILE_SIZE];
};