ports logs and javascript app to xr809, clear up logging from duplicate log functions

This commit is contained in:
openshwprojects
2022-03-07 14:01:15 +01:00
parent 03d869de2e
commit c1c5757574
8 changed files with 91 additions and 132 deletions

View File

@ -10,8 +10,10 @@
#ifdef WINDOWS
// nothing
#elif PLATFORM_XR809
#include "../logging/logging.h"
#include <image/flash.h>
#elif defined(PLATFORM_BK7231N)
#include "../logging/logging.h"
// tuya-iotos-embeded-sdk-wifi-ble-bk7231n/sdk/include/tuya_hal_storage.h
#include "tuya_hal_storage.h"
#include "BkDriverFlash.h"
@ -453,7 +455,8 @@ int http_fn_cfg_loglevel_set(http_request_t *request) {
poststr(request,htmlHeader);
poststr(request,g_header);
if(http_getArg(request->url,"loglevel",tmpA,sizeof(tmpA))) {
#if PLATFORM_BK7231T
#if WINDOWS
#else
loglevel = atoi(tmpA);
#endif
poststr(request,"LOG level changed.");
@ -462,7 +465,8 @@ int http_fn_cfg_loglevel_set(http_request_t *request) {
<label for=\"loglevel\">loglevel:</label><br>\
<input type=\"text\" id=\"loglevel\" name=\"loglevel\" value=\"");
tmpA[0] = 0;
#if PLATFORM_BK7231T
#if WINDOWS
#else
hprintf128(request,"%i",loglevel);
#endif
poststr(request,"\"><br><br>\

View File

@ -13,42 +13,30 @@
#if PLATFORM_XR809
#define DISABLE_SEPARATE_THREAD_FOR_EACH_TCP_CLIENT 1
static OS_Thread_t g_http_thread;
#define close lwip_close
#else
#include "str_pub.h"
#endif
#if PLATFORM_XR809
#define DISABLE_SEPARATE_THREAD_FOR_EACH_TCP_CLIENT 1
#endif
static void tcp_server_thread( beken_thread_arg_t arg );
static void tcp_client_thread( beken_thread_arg_t arg );
#define HTTP_SERVER_PORT 80 /*set up a tcp server,port at 20000*/
xTaskHandle g_http_thread = NULL;
void start_tcp_http()
{
OSStatus err = kNoErr;
#if PLATFORM_XR809
err = OS_ThreadCreate(&g_http_thread,
"TCP_server",
tcp_server_thread,
NULL,
OS_THREAD_PRIO_CONSOLE,
0x800);
#else
err = rtos_create_thread( NULL, BEKEN_APPLICATION_PRIORITY,
err = rtos_create_thread( &g_http_thread, BEKEN_APPLICATION_PRIORITY,
"TCP_server",
(beken_thread_function_t)tcp_server_thread,
0x800,
(beken_thread_arg_t)0 );
#endif
if(err != kNoErr)
{
ADDLOG_ERROR(LOG_FEATURE_HTTP, "create \"TCP_server\" thread failed!\r\n");
@ -124,13 +112,9 @@ exit:
close( fd );;
#if DISABLE_SEPARATE_THREAD_FOR_EACH_TCP_CLIENT
#else
#if PLATFORM_XR809
OS_ThreadDelete( NULL );
#else
rtos_delete_thread( NULL );
#endif
#endif
}
/* TCP server listener thread */
@ -212,9 +196,7 @@ static void tcp_server_thread( beken_thread_arg_t arg )
ADDLOG_ERROR(LOG_FEATURE_HTTP, "Server listerner thread exit with err: %d", err );
close( tcp_listen_fd );
#if PLATFORM_XR809
OS_ThreadDelete( NULL );
#else
rtos_delete_thread( NULL );
#endif
}

View File

@ -12,13 +12,22 @@
#include "../littlefs/our_lfs.h"
#endif
#include "lwip/sockets.h"
#if PLATFORM_XR809
#include <image/flash.h>
#else
#include "../flash_config/flash_config.h"
#endif
#include "../new_cfg.h"
#include "../flash_config/flash_vars_vars.h"
#include "../flash_config/flash_vars.h"
#include "../new_cmd.h"
#if PLATFORM_XR809
uint32_t flash_read(uint32_t flash, uint32_t addr,void *buf, uint32_t size);
#define FLASH_INDEX_XR809 0
#else
extern UINT32 flash_read(char *user_buf, UINT32 count, UINT32 address);
#endif
static int http_rest_error(http_request_t *request, int code, char *msg);
@ -770,6 +779,9 @@ static int http_rest_error(http_request_t *request, int code, char *msg){
static int http_rest_post_flash(http_request_t *request, int startaddr){
#if PLATFORM_XR809
#else
int total = 0;
int towrite;
char *writebuf;
@ -810,6 +822,7 @@ static int http_rest_post_flash(http_request_t *request, int startaddr){
close_ota();
poststr(request,NULL);
#endif
return 0;
}
@ -861,7 +874,13 @@ static int http_rest_get_flash(http_request_t *request, int startaddr, int len){
if (readlen > 1024){
readlen = 1024;
}
#if PLATFORM_XR809
//uint32_t flash_read(uint32_t flash, uint32_t addr,void *buf, uint32_t size)
#define FLASH_INDEX_XR809 0
res = flash_read(FLASH_INDEX_XR809, startaddr, buffer, readlen);
#else
res = flash_read((char *)buffer, readlen, startaddr);
#endif
startaddr += readlen;
len -= readlen;
postany(request, buffer, readlen);
@ -873,7 +892,10 @@ static int http_rest_get_flash(http_request_t *request, int startaddr, int len){
static int http_rest_get_dumpconfig(http_request_t *request){
#if PLATFORM_XR809
#else
config_dump_table();
#endif
http_setup(request, httpMimeTypeText);
poststr(request, NULL);
@ -882,6 +904,7 @@ static int http_rest_get_dumpconfig(http_request_t *request){
#ifdef TESTCONFIG_ENABLE
// added for OpenBK7231T
typedef struct item_new_test_config
{
@ -890,6 +913,7 @@ typedef struct item_new_test_config
}ITEM_NEW_TEST_CONFIG,*ITEM_NEW_TEST_CONFIG_PTR;
ITEM_NEW_TEST_CONFIG testconfig;
#endif
static int http_rest_get_testconfig(http_request_t *request){
#ifdef TESTCONFIG_ENABLE
@ -960,6 +984,9 @@ static int http_rest_get_testconfig(http_request_t *request){
}
static int http_rest_get_flash_vars_test(http_request_t *request){
#if PLATFORM_XR809
return http_rest_error(request, 400, "flash vars unsupported");
#else
#ifndef DISABLE_FLASH_VARS_VARS
char *params = request->url + 17;
int increment = 0;
@ -997,6 +1024,7 @@ static int http_rest_get_flash_vars_test(http_request_t *request){
#else
return http_rest_error(request, 400, "flash vars unsupported");
#endif
#endif
}