diff --git a/src/httpserver/http_tcp_server.c b/src/httpserver/http_tcp_server.c index 108065507..9279a7878 100644 --- a/src/httpserver/http_tcp_server.c +++ b/src/httpserver/http_tcp_server.c @@ -110,7 +110,7 @@ static void tcp_client_thread( beken_thread_arg_t arg ) // returns length to be sent if any int lenret = HTTP_ProcessPacket(&request); if (lenret > 0){ - ADDLOG_DEBUG(LOG_FEATURE_HTTP, "TCP sending reply len %i\n",lenret ); + //ADDLOG_DEBUG(LOG_FEATURE_HTTP, "TCP sending reply len %i\n",lenret ); send( fd, reply, lenret, 0 ); } @@ -177,7 +177,7 @@ static void tcp_server_thread( beken_thread_arg_t arg ) #endif #endif os_strcpy( client_ip_str, inet_ntoa( client_addr.sin_addr ) ); - ADDLOG_DEBUG(LOG_FEATURE_HTTP, "TCP Client %s:%d connected, fd: %d", client_ip_str, client_addr.sin_port, client_fd ); + // ADDLOG_DEBUG(LOG_FEATURE_HTTP, "TCP Client %s:%d connected, fd: %d", client_ip_str, client_addr.sin_port, client_fd ); #if DISABLE_SEPARATE_THREAD_FOR_EACH_TCP_CLIENT // Use main server thread (blocking all other clients) // right now, I am getting OS_ThreadCreate everytime on XR809 platform diff --git a/src/httpserver/rest_interface.c b/src/httpserver/rest_interface.c index 4e1ad7320..adfc52932 100644 --- a/src/httpserver/rest_interface.c +++ b/src/httpserver/rest_interface.c @@ -16,6 +16,7 @@ #include "../new_cfg.h" #include "../flash_config/flash_vars_vars.h" #include "../flash_config/flash_vars.h" +#include "../new_cmd.h" extern UINT32 flash_read(char *user_buf, UINT32 count, UINT32 address); @@ -55,6 +56,7 @@ static int http_rest_get_channels(http_request_t *request); static int http_rest_get_flash_vars_test(http_request_t *request); +static int http_rest_post_cmd(http_request_t *request); void init_rest(){ @@ -184,6 +186,11 @@ static int http_rest_post(http_request_t *request){ return http_rest_post_flash_advanced(request); } + if (!strcmp(request->url, "api/cmnd")){ + return http_rest_post_cmd(request); + } + + #ifdef BK_LITTLEFS if (!strcmp(request->url, "api/fsblock")){ if (lfs_present()){ @@ -1072,3 +1079,11 @@ static int http_rest_post_channels(http_request_t *request){ return http_rest_error(request, 200, "OK"); return 0; } + + +static int http_rest_post_cmd(http_request_t *request){ + char *cmd = request->bodystart; + CMD_ExecuteCommand(cmd); + return http_rest_error(request, 200, "OK"); +} + diff --git a/src/logging/logging.c b/src/logging/logging.c index d46031a0d..27902a067 100644 --- a/src/logging/logging.c +++ b/src/logging/logging.c @@ -358,7 +358,7 @@ void log_server_thread( beken_thread_arg_t arg ) if ( client_fd >= 0 ) { os_strcpy( client_ip_str, inet_ntoa( client_addr.sin_addr ) ); - addLog( "TCP Log Client %s:%d connected, fd: %d", client_ip_str, client_addr.sin_port, client_fd ); + //addLog( "TCP Log Client %s:%d connected, fd: %d", client_ip_str, client_addr.sin_port, client_fd ); if ( kNoErr != rtos_create_thread( NULL, BEKEN_APPLICATION_PRIORITY, "TCP Clients", @@ -398,7 +398,7 @@ static void log_client_thread( beken_thread_arg_t arg ) rtos_delay_milliseconds(10); } - addLog( "TCP client thread exit with err: %d", len ); + //addLog( "TCP client thread exit with err: %d", len ); close( fd ); rtos_delete_thread( NULL ); diff --git a/src/logging/logging.h b/src/logging/logging.h index 9b51c0a4c..941e47bb4 100644 --- a/src/logging/logging.h +++ b/src/logging/logging.h @@ -55,8 +55,9 @@ typedef enum { LOG_FEATURE_GENERAL = 7, LOG_FEATURE_API = 8, LOG_FEATURE_LFS = 9, + LOG_FEATURE_CMD = 10, // add in here - but also in names in logging.c - LOG_FEATURE_MAX = 10, + LOG_FEATURE_MAX = 11, } log_features; #endif \ No newline at end of file diff --git a/src/new_cmd.c b/src/new_cmd.c index 4bdb67b78..668163ae9 100644 --- a/src/new_cmd.c +++ b/src/new_cmd.c @@ -1,6 +1,7 @@ #include "new_cmd.h" #include "new_pins.h" #include "new_cfg.h" +#include "logging/logging.h" #include #define HASH_SIZE 128 @@ -85,6 +86,8 @@ int CMD_ExecuteCommand(const char *s) { int i; command_t *newCmd; + ADDLOG_DEBUG(LOG_FEATURE_CMD, "cmd [%s]", s); + while(isWhiteSpace(*s)) { s++; }