From 315871af607d9045ec1ca7a94c3d1d6b7d36da3f Mon Sep 17 00:00:00 2001 From: Sander Speetjens Date: Mon, 6 Nov 2023 21:44:18 +0100 Subject: [PATCH] TFTP Add logger and checks for initialising --- project/Core/Inc/tftp.h | 2 ++ project/Core/Src/tftp.c | 27 ++++++++++++++------------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/project/Core/Inc/tftp.h b/project/Core/Inc/tftp.h index 3ff4cbb..6446e4e 100644 --- a/project/Core/Inc/tftp.h +++ b/project/Core/Inc/tftp.h @@ -4,6 +4,8 @@ #ifndef PROJECT_TFTP_H #define PROJECT_TFTP_H +#define LOGGER_LEVEL_ALL +#include "log.h" #include extern struct tftp_context tftpContext_s; diff --git a/project/Core/Src/tftp.c b/project/Core/Src/tftp.c index 8c880c4..9876e9c 100644 --- a/project/Core/Src/tftp.c +++ b/project/Core/Src/tftp.c @@ -4,34 +4,35 @@ #include "tftp.h" -void *tftp_open(const char *fname, const char *mode, u8_t write) -{ +static const char* TAG = "tftp_server"; + +void *tftp_open(const char *fname, const char *mode, u8_t write) { } -void tftp_close(void *handle) -{ +void tftp_close(void *handle) { } -int tftp_read(void* handle, void* buf, int bytes) -{ +int tftp_read(void* handle, void* buf, int bytes) { } -int tftp_write(void* handle, struct pbuf* p) -{ +int tftp_write(void* handle, struct pbuf* p) { } -struct tftp_context tftpContext_s = - { +struct tftp_context tftpContext_s = { tftp_open, tftp_close, tftp_read, tftp_write }; -void tftp_server_init(void) -{ - tftp_init(&tftpContext_s); +void tftp_server_init(void) { + LOG_INFO(TAG, "Initializing tftp server"); + if (tftp_init(&tftpContext_s) != ERR_OK) { + LOG_FATAL(TAG, "Could not initialize tftp server"); + return; + } + LOG_INFO(TAG, "tftp server initialized successfully"); } \ No newline at end of file