TFTP
Add tftp_custom_write and test functions
This commit is contained in:
@@ -53,7 +53,7 @@ include_directories(LWIP/App LWIP/Target Core/Inc Middlewares/Third_Party/LwIP/s
|
||||
|
||||
add_definitions(-DDEBUG -DUSE_HAL_DRIVER -DSTM32F746xx)
|
||||
|
||||
#file(GLOB_RECURSE SOURCES "Core/*.*" "LWIP/*.*" "Middlewares/*.*" "Drivers/*.*")
|
||||
#file(GLOB_RECURSE SOURCES "Core/*.*" "Drivers/*.*" "LWIP/*.*" "Middlewares/*.*")
|
||||
file(GLOB_RECURSE SOURCES "Core/Src/*.*" "Core/Startup/*.*" "LWIP/*.*" "Middlewares/*.*" "Drivers/*.*")
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
#ifndef PROJECT_TFTP_H
|
||||
#define PROJECT_TFTP_H
|
||||
#include <tftp_server.h>
|
||||
#ifndef TESTING
|
||||
#include "lcd_api.h"
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -30,7 +33,7 @@ void tftp_server_init(void);
|
||||
void tftp_server_deinit(void);
|
||||
void tftp_custom_fseek(tftp_custom_file_t* handle, size_t offset, int whence);
|
||||
size_t tftp_custom_fread(void* buf, size_t bytes, tftp_custom_file_t* handle);
|
||||
size_t tftp_custom_fwrite(void* buf, size_t bytes, tftp_custom_file_t* handle);
|
||||
size_t tftp_custom_fwrite(const void* buf, size_t bytes, tftp_custom_file_t* handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ size_t tftp_custom_fread(void* buf, size_t bytes, tftp_custom_file_t* handle) {
|
||||
* @param handle The handle to the file to write to
|
||||
* @return The number of bytes written
|
||||
*/
|
||||
size_t tftp_custom_fwrite(void* buf, size_t bytes, tftp_custom_file_t* handle) {
|
||||
size_t tftp_custom_fwrite(const void* buf, size_t bytes, tftp_custom_file_t* handle) {
|
||||
if (handle->ofset + bytes > handle->len) {
|
||||
bytes = handle->len - handle->ofset;
|
||||
}
|
||||
@@ -145,6 +145,11 @@ void tftp_close(void* handle) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (handle == &virt_file[2]) {
|
||||
// TODO: Clear display
|
||||
lcd_display_text((uint8_t*)virt_file[2].data, 0, 0, LCD_COLOR_BLACK, LCD_COLOR_WHITE, LCD_FONT16);
|
||||
}
|
||||
|
||||
if (handle == &virt_file[0] || handle == &virt_file[1] || handle == &virt_file[2]) {
|
||||
((tftp_custom_file_t*)handle)->ofset = 0;
|
||||
return;
|
||||
@@ -202,6 +207,11 @@ int tftp_read(void* handle, void* buf, int bytes) {
|
||||
int tftp_write(void* handle, struct pbuf* p) {
|
||||
LOG_INFO(TAG, "Writing file");
|
||||
LOG_DEBUG(TAG, "Not implemented yet");
|
||||
tftp_custom_file_t *file = (tftp_custom_file_t*)handle;
|
||||
if (file == &virt_file[1] || file == &virt_file[2]) {
|
||||
return tftp_custom_fwrite(p->payload, p->len, file);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user