tcp_cmd
make some functions static add static function declaration
This commit is contained in:
@@ -21,10 +21,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
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_ */
|
||||
|
||||
@@ -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 \"<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();
|
||||
|
||||
Reference in New Issue
Block a user