add command POST at api/cmnd

This commit is contained in:
btsimonh
2022-03-04 21:27:04 +00:00
parent f98e5e79a8
commit 6fa8049892
5 changed files with 24 additions and 5 deletions

View File

@ -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

View File

@ -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");
}