Merge remote-tracking branch 'origin/main' into littlefs

This commit is contained in:
btsimonh
2022-02-12 17:58:32 +00:00
7 changed files with 121 additions and 12 deletions

View File

@ -5,7 +5,17 @@
#include "lwip/inet.h"
#include "../logging/logging.h"
#include "new_http.h"
#if PLATFORM_XR809
#define kNoErr 0 //! No error occurred.
typedef void *beken_thread_arg_t;
typedef int OSStatus;
static OS_Thread_t g_http_thread;
#else
#include "str_pub.h"
#endif
static void tcp_server_thread( beken_thread_arg_t arg );
static void tcp_client_thread( beken_thread_arg_t arg );
@ -16,11 +26,20 @@ 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,
"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");
@ -93,8 +112,12 @@ exit:
if ( reply != NULL )
os_free( reply );
close( fd );
rtos_delete_thread( NULL );
close( fd );;
#if PLATFORM_XR809
OS_ThreadDelete( NULL );
#else
rtos_delete_thread( NULL );
#endif
}
/* TCP server listener thread */
@ -131,12 +154,24 @@ static void tcp_server_thread( beken_thread_arg_t arg )
{
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 );
if ( kNoErr
!= rtos_create_thread( NULL, BEKEN_APPLICATION_PRIORITY,
if ( kNoErr !=
#if PLATFORM_XR809
OS_ThreadCreate(&g_http_thread,
"TCP Clients",
tcp_client_thread,
client_fd,
OS_THREAD_PRIO_CONSOLE,
0x800)
#else
rtos_create_thread( NULL, BEKEN_APPLICATION_PRIORITY,
"TCP Clients",
(beken_thread_function_t)tcp_client_thread,
0x800,
(beken_thread_arg_t)client_fd ) )
(beken_thread_arg_t)client_fd )
#endif
)
{
close( client_fd );
client_fd = -1;
@ -149,5 +184,9 @@ 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

@ -2,13 +2,16 @@
#include "../new_common.h"
#include "ctype.h"
#ifndef WINDOWS
#include "lwip/sockets.h"
#include "str_pub.h"
#else
#if WINDOWS
//#include <windows.h>
#include <winsock2.h>
//#include <ws2tcpip.h>
#elif PLATFORM_XR809
#include <stdarg.h>
#else
#include "lwip/sockets.h"
#include "str_pub.h"
#endif
#include "new_http.h"
#include "../new_pins.h"
@ -16,6 +19,8 @@
#include "../ota/ota.h"
#ifdef WINDOWS
#elif PLATFORM_XR809
#elif defined(PLATFORM_BK7231N)
// tuya-iotos-embeded-sdk-wifi-ble-bk7231n/sdk/include/tuya_hal_storage.h
#include "tuya_hal_storage.h"
@ -658,6 +663,9 @@ int HTTP_ProcessPacket(http_request_t *request) {
#ifdef WINDOWS
poststr(request,"Not available on Windows<br>");
#elif PLATFORM_XR809
poststr(request,"TODO XR809<br>");
#else
AP_IF_S *ar;
uint32_t num;

View File

@ -55,7 +55,7 @@ void misc_formatUpTimeString(int totalSeconds, char *o);
// poststr with format - for results LESS THAN 128
int hprintf128(http_request_t *request, const char *fmt, ...);
enum {
typedef enum {
HTTP_ANY = -1,
HTTP_GET = 0,
HTTP_PUT = 1,