|
@@ -72,6 +72,7 @@ char *send_file(char *filename, char *pnonmatch, struct fs_file *file, uint16_t
|
|
|
static uint32_t Parse_Header(char *data, uint32_t len, const char *field, uint32_t flen, char *value);
|
|
|
bool GetFileName(char *inStr, char *fileName, uint8_t *fileNameLen);
|
|
|
static char *HTTP_FTPFWUpdate(uint32_t reqNum, char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *lenBufOut);
|
|
|
+static char *HTTP_FTPFWState(uint32_t reqNum, char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *lenBufOut);
|
|
|
|
|
|
#define NUM_LOCKS 3
|
|
|
static void *locks[NUM_LOCKS];
|
|
@@ -192,6 +193,7 @@ web_func_handler_t process_web_funcs[] = {
|
|
|
{ "GET /fw_update.cgi", 18, COMMON_ANSWER, TIME_ACCESS, HTTP_ConfirmBootPwd },
|
|
|
#ifdef HARDWARE_BT6711
|
|
|
{ X("POST /ftp_fw_update.cgi"), COMMON_ANSWER, TIME_ACCESS, HTTP_FTPFWUpdate },
|
|
|
+ { X("GET /fw_dl_state.cgi"), COMMON_ANSWER, TIME_ACCESS, HTTP_FTPFWState },
|
|
|
#endif // HARDWARE_BT6711
|
|
|
{ "GET", 3, COMMON_ANSWER, ALL_ACCESS, HTTP_GetRequest },
|
|
|
{ "", 0, COMMON_ANSWER, ALL_ACCESS, HTTP_NoFound },
|
|
@@ -1429,13 +1431,19 @@ static char *HTTP_FTPFWUpdate(uint32_t reqNum, char *bufIn, char *bufOut, uint16
|
|
|
strcpy(settings->pass, "guest");
|
|
|
}
|
|
|
|
|
|
- start_ftp_client(&ftpcfg);
|
|
|
- // TODO write the settings to NVRAM
|
|
|
- // TODO wait for the client to connect to the server and check whether the file exists
|
|
|
-
|
|
|
- strcpy(bufOut, HTTP_200_OK);
|
|
|
- *lenBufOut = strlen(bufOut);
|
|
|
+ HTTP_SaveSettings();
|
|
|
+ char *error = start_ftp_client(&ftpcfg);
|
|
|
+ *lenBufOut = sprintf(bufOut, "HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\n\r\n%s", error);
|
|
|
+ return bufOut;
|
|
|
+}
|
|
|
|
|
|
+static char *HTTP_FTPFWState(uint32_t reqNum, char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *lenBufOut)
|
|
|
+{
|
|
|
+ (void)bufIn;
|
|
|
+ (void)lenBufIn;
|
|
|
+ (void)reqNum;
|
|
|
+ unsigned percentage = get_ftp_progress();
|
|
|
+ *lenBufOut = sprintf(bufOut, "HTTP/1.1 200 OK\r\nContent-Type:text/plain\r\n\r\n%u", percentage);
|
|
|
return bufOut;
|
|
|
}
|
|
|
#endif // HARDWARE_BT6711
|