|
@@ -59,6 +59,7 @@
|
|
|
#define min(x,y) ((x)<(y)?(x):(y))
|
|
|
|
|
|
static unsigned received_bytes_count = 0;
|
|
|
+static char **error_ptr;
|
|
|
|
|
|
/** Close control or data pcb
|
|
|
* @param pointer to lwftp session data
|
|
@@ -117,8 +118,6 @@ static err_t lwftp_data_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, er
|
|
|
(void)err;
|
|
|
lwftp_session_t *s = (lwftp_session_t*)arg;
|
|
|
if (p) {
|
|
|
- // notify the web interface that we can proceed
|
|
|
- s->error = "1";
|
|
|
if (s->data_sink) {
|
|
|
struct pbuf *q;
|
|
|
for (q=p; q; q=q->next) {
|
|
@@ -352,7 +351,7 @@ anonymous:
|
|
|
s->control_state = LWFTP_XFERING;
|
|
|
} else if (response==550) {
|
|
|
s->control_state = LWFTP_QUIT;
|
|
|
- s->error = "Failed to open file"
|
|
|
+ s->error = "Failed to open file";
|
|
|
LWIP_DEBUGF(LWFTP_WARNING, ("lwftp: %s '%s'\n", error, s->settings->remote_path));
|
|
|
}
|
|
|
else {
|
|
@@ -470,6 +469,7 @@ static void lwftp_control_err(void *arg, err_t err)
|
|
|
LWIP_DEBUGF(LWFTP_WARNING, ("lwftp: %s (%s)\n",lwip_strerr(err)));
|
|
|
result = LWFTP_RESULT_ERR_CONNECT;
|
|
|
} else {
|
|
|
+ s->error = "connection closed by remote host";
|
|
|
LWIP_DEBUGF(LWFTP_WARNING, ("lwftp:connection closed by remote host\n"));
|
|
|
result = LWFTP_RESULT_ERR_CLOSED;
|
|
|
}
|
|
@@ -683,23 +683,27 @@ static unsigned data_sink(void *arg, const char* ptr, unsigned len)
|
|
|
return len;
|
|
|
}
|
|
|
|
|
|
-char *start_ftp_client(lwftp_session_t *s)
|
|
|
+void start_ftp_client(lwftp_session_t *s)
|
|
|
{
|
|
|
received_bytes_count = 0;
|
|
|
+ s->error = NULL;
|
|
|
+ error_ptr = &s->error;
|
|
|
s->data_sink = data_sink;
|
|
|
//s->done_fn = ftp_retr_callback;
|
|
|
lwftp_retr(s);
|
|
|
// FTP session will continue with the connection callback
|
|
|
- //// wait for the client to connect to the server and check whether the file exists
|
|
|
- //while (s->error == NULL) {
|
|
|
- // vTaskDelay(200);
|
|
|
- //}
|
|
|
- return "1";
|
|
|
}
|
|
|
|
|
|
-uint32_t get_ftp_progress()
|
|
|
+char *get_ftp_progress()
|
|
|
{
|
|
|
- return received_bytes_count * 100 / MAIN_FW_SIZE;
|
|
|
+ if (*error_ptr) {
|
|
|
+ return *error_ptr;
|
|
|
+ } else {
|
|
|
+ unsigned progress = received_bytes_count * 100 / MAIN_FW_SIZE;
|
|
|
+ static char progress_str_buf[4];
|
|
|
+ snprintf(progress_str_buf, sizeof(progress_str_buf), "%u", progress);
|
|
|
+ return progress_str_buf;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
#endif // !BT6702_SERVICE
|