From 9f48f4eef1399deb745662bb5c4339f6d16a3a9b Mon Sep 17 00:00:00 2001 From: Sander Speetjens Date: Thu, 30 Nov 2023 21:56:58 +0100 Subject: [PATCH] tcp_cmd make some functions static add static function declaration --- project/Core/Inc/tcp_cmd.h | 3 --- project/Core/Src/tcp_cmd.c | 27 +++++++++++++++++---------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/project/Core/Inc/tcp_cmd.h b/project/Core/Inc/tcp_cmd.h index 0d9a56b..f1ee0fd 100644 --- a/project/Core/Inc/tcp_cmd.h +++ b/project/Core/Inc/tcp_cmd.h @@ -21,10 +21,7 @@ #include #include - void tcp_cmd_init(void); -void tcp_cmd_write(struct tcp_pcb* pcb, const char* str); -void tcp_cmd_print_help(struct tcp_pcb* pcb); err_t tcp_cmd_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err_t err); #endif /* INC_TCP_CMD_H_ */ diff --git a/project/Core/Src/tcp_cmd.c b/project/Core/Src/tcp_cmd.c index 626f509..57a2ac8 100644 --- a/project/Core/Src/tcp_cmd.c +++ b/project/Core/Src/tcp_cmd.c @@ -13,26 +13,26 @@ static const char* TAG = "tcp_cmd"; static uint32_t color_txt = 0xff000000; // Store text color static uint32_t color_bg = 0xff000000; // Store background color -static void tcp_cmd_close(struct tcp_pcb* pcb) { - tcp_arg(pcb, NULL); - tcp_sent(pcb, NULL); - tcp_recv(pcb, NULL); - tcp_close(pcb); -} +static void tcp_cmd_write(struct tcp_pcb* pcb, const char* str); +static void tcp_cmd_print_header(struct tcp_pcb* pcb); +static void tcp_cmd_print_help(struct tcp_pcb* pcb); +static bool tcp_cmd_parser(struct tcp_pcb* pcb, int argc, char** argv); +static err_t tcp_cmd_accept(void* arg, struct tcp_pcb* pcb, err_t err); +static void tcp_cmd_close(struct tcp_pcb* pcb); -void tcp_cmd_write(struct tcp_pcb* pcb, const char* str) { +static void tcp_cmd_write(struct tcp_pcb* pcb, const char* str) { tcp_write(pcb, str, strlen(str), TCP_WRITE_FLAG_COPY | TCP_WRITE_FLAG_MORE); tcp_output(pcb); } -void tcp_cmd_print_header(struct tcp_pcb* pcb) { +static void tcp_cmd_print_header(struct tcp_pcb* pcb) { tcp_cmd_write(pcb, " Welcome to the TCP CMD interface\r\n" "(Type help for a list of the commands! exit to close)\r\n" "============================================================\r\n" "$>"); } -void tcp_cmd_print_help(struct tcp_pcb* pcb) { +static void tcp_cmd_print_help(struct tcp_pcb* pcb) { tcp_cmd_write(pcb, "help : shows a list of commands\r\n" "text \"\" : puts text on the lcd\r\n" @@ -113,7 +113,7 @@ char* get_next_token(char* input, const char* delimiters, char** next) { * @return true Connection should be closed * @return false Connection should be kept open */ -bool tcp_cmd_parser(struct tcp_pcb* pcb, int argc, char** argv) { +static bool tcp_cmd_parser(struct tcp_pcb* pcb, int argc, char** argv) { char* ext; if (argc == 0) { LOG_WARN(TAG, "No command given"); @@ -292,6 +292,13 @@ static err_t tcp_cmd_accept(void* arg, struct tcp_pcb* pcb, err_t err) { return ERR_OK; } +static void tcp_cmd_close(struct tcp_pcb* pcb) { + tcp_arg(pcb, NULL); + tcp_sent(pcb, NULL); + tcp_recv(pcb, NULL); + tcp_close(pcb); +} + void tcp_cmd_init(void) { struct tcp_pcb* tcp_pcb; tcp_pcb = tcp_new();