diff --git a/src/driver/drv_ntp.c b/src/driver/drv_ntp.c index cc8082074..618a73d59 100644 --- a/src/driver/drv_ntp.c +++ b/src/driver/drv_ntp.c @@ -3,26 +3,9 @@ // https://www.elektroda.pl/rtvforum/topic3712112.html #include "../new_common.h" -#include // Commands register, execution API and cmd tokenizer #include "../cmnds/cmd_public.h" -#ifdef WINDOWS - -#undef UNICODE - -#define WIN32_LEAN_AND_MEAN - -#include -#include -#include -#include -#include - -#else -#include "lwip/sockets.h" - -#endif #include "../logging/logging.h" @@ -99,7 +82,7 @@ void NTP_Shutdown() { #if WINDOWS closesocket(g_ntp_socket); #else - close(g_ntp_socket); + lwip_close(g_ntp_socket); #endif } g_ntp_socket = 0; diff --git a/src/flash_config/flash_config.c b/src/flash_config/flash_config.c index f022ff156..a4f0e79a0 100644 --- a/src/flash_config/flash_config.c +++ b/src/flash_config/flash_config.c @@ -1,6 +1,5 @@ -#include "include.h" -#include "mem_pub.h" +#include "../new_common.h" #include "drv_model_pub.h" #include "net_param_pub.h" #include "flash_pub.h" diff --git a/src/hal/hal_main_bk7231.c b/src/hal/hal_main_bk7231.c index ae0227be6..5a8a3609b 100644 --- a/src/hal/hal_main_bk7231.c +++ b/src/hal/hal_main_bk7231.c @@ -3,8 +3,6 @@ #include "../logging/logging.h" -#include "mem_pub.h" -#include "str_pub.h" #include "../../beken378/app/config/param_config.h" diff --git a/src/hal/hal_wifi_bk7231.c b/src/hal/hal_wifi_bk7231.c index afea608ca..7dc087c44 100644 --- a/src/hal/hal_wifi_bk7231.c +++ b/src/hal/hal_wifi_bk7231.c @@ -1,9 +1,7 @@ -#include "hal_wifi.h" +#include "hal_wifi.h" #define LOG_FEATURE LOG_FEATURE_MAIN -#include "mem_pub.h" -#include "str_pub.h" #include "wlan_ui_pub.h" #include "ethernet_intf.h" #include "../new_common.h" diff --git a/src/httpserver/http_fns.c b/src/httpserver/http_fns.c index 1a947109e..878a19351 100644 --- a/src/httpserver/http_fns.c +++ b/src/httpserver/http_fns.c @@ -1,5 +1,4 @@ #include "../new_common.h" -#include "ctype.h" #include "http_fns.h" #include "../new_pins.h" #include "../new_cfg.h" diff --git a/src/httpserver/http_tcp_server.c b/src/httpserver/http_tcp_server.c index 11a7ea16b..c65e16400 100644 --- a/src/httpserver/http_tcp_server.c +++ b/src/httpserver/http_tcp_server.c @@ -1,7 +1,3 @@ -#if PLATFORM_XR809 -#define LWIP_COMPAT_SOCKETS 1 -#define LWIP_POSIX_SOCKETS_IO_NAMES 1 -#endif #include "../new_common.h" #include "ctype.h" @@ -20,13 +16,12 @@ #elif PLATFORM_BL602 #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 ); -#define HTTP_SERVER_PORT 80 /*set up a tcp server,port at 20000*/ +#define HTTP_SERVER_PORT 80 xTaskHandle g_http_thread = NULL; @@ -115,7 +110,7 @@ exit: if ( reply != NULL ) os_free( reply ); - close( fd );; + lwip_close( fd );; #if DISABLE_SEPARATE_THREAD_FOR_EACH_TCP_CLIENT #else @@ -190,7 +185,7 @@ static void tcp_server_thread( beken_thread_arg_t arg ) ) { ADDLOG_DEBUG(LOG_FEATURE_HTTP, "TCP Client %s:%d thread creation failed! fd: %d", client_ip_str, client_addr.sin_port, client_fd ); - close( client_fd ); + lwip_close( client_fd ); client_fd = -1; } #endif @@ -201,7 +196,7 @@ static void tcp_server_thread( beken_thread_arg_t arg ) if ( err != kNoErr ) ADDLOG_ERROR(LOG_FEATURE_HTTP, "Server listerner thread exit with err: %d", err ); - close( tcp_listen_fd ); + lwip_close( tcp_listen_fd ); rtos_delete_thread( NULL ); diff --git a/src/httpserver/new_http.c b/src/httpserver/new_http.c index f5a86414f..116f92d33 100644 --- a/src/httpserver/new_http.c +++ b/src/httpserver/new_http.c @@ -3,21 +3,6 @@ #include "../new_common.h" #include "../logging/logging.h" #include "ctype.h" -#if WINDOWS -//#include -#include -//#include -#elif PLATFORM_XR809 -#include "lwip/sockets.h" -#include -#elif PLATFORM_BL602 -#include "lwip/sockets.h" -#include - -#else -#include "lwip/sockets.h" -#include "str_pub.h" -#endif #include "new_http.h" #include "http_fns.h" #include "../new_pins.h" diff --git a/src/httpserver/rest_interface.c b/src/httpserver/rest_interface.c index 1bb14ef65..24b7921a4 100644 --- a/src/httpserver/rest_interface.c +++ b/src/httpserver/rest_interface.c @@ -3,7 +3,6 @@ #include "../new_common.h" #include "../logging/logging.h" #include "../httpserver/new_http.h" -//#include "str_pub.h" #include "../new_pins.h" #include "../jsmn/jsmn_h.h" #include "../ota/ota.h" diff --git a/src/logging/logging.c b/src/logging/logging.c index 3220c92ad..cf6e768e0 100644 --- a/src/logging/logging.c +++ b/src/logging/logging.c @@ -14,7 +14,6 @@ #include "lwip/inet.h" #else -#include "str_pub.h" #endif #include "../logging/logging.h" diff --git a/src/mqtt/new_mqtt.c b/src/mqtt/new_mqtt.c index 16f49b5f6..438e911f5 100644 --- a/src/mqtt/new_mqtt.c +++ b/src/mqtt/new_mqtt.c @@ -1,21 +1,13 @@ #include "new_mqtt.h" +#include "../new_common.h" #include "../new_pins.h" #include "../new_cfg.h" -#include "../logging/logging.h" -#include +#include "../logging/logging.h" // Commands register, execution API and cmd tokenizer #include "../cmnds/cmd_public.h" -#undef os_printf -#undef PR_DEBUG -#undef Malloc -#undef Free - -#define Malloc os_malloc -#define Free os_free - #ifndef LWIP_MQTT_EXAMPLE_IPADDR_INIT #if LWIP_IPV4 diff --git a/src/new_common.c b/src/new_common.c index dc8fad07a..ca2897082 100644 --- a/src/new_common.c +++ b/src/new_common.c @@ -1,5 +1,4 @@ #include "new_common.h" -#include "ctype.h" // returns amount of space left in buffer (0=overflow happened) int strcat_safe(char *tg, const char *src, int tgMaxLen) { diff --git a/src/new_common.h b/src/new_common.h index 46233561b..cea33699d 100644 --- a/src/new_common.h +++ b/src/new_common.h @@ -1,12 +1,16 @@ #ifndef __NEW_COMMON_H__ #define __NEW_COMMON_H__ +#include +#include +#include +#include +#include +#include + #if WINDOWS -#include -#include - typedef int bool; #define true 1 @@ -21,9 +25,6 @@ typedef unsigned short uint16_t; #elif PLATFORM_BL602 -#include -#include -#include #include #include @@ -95,30 +96,19 @@ OSStatus rtos_create_thread( beken_thread_t* thread, beken_thread_function_t function, uint32_t stack_size, beken_thread_arg_t arg ); -#include -#include -#include -#include + #include "common/framework/platform_init.h" #include "kernel/os/os.h" #else -#define _TUYA_DEVICE_GLOBAL -/* Includes ------------------------------------------------------------------*/ -#include "uni_log.h" -#include "tuya_iot_wifi_api.h" -#include "tuya_hal_system.h" -#include "tuya_iot_com_api.h" -#include "tuya_cloud_com_defs.h" #include "gw_intf.h" -#include "gpio_test.h" -#include "tuya_gpio.h" -#include "tuya_key.h" -#include "tuya_led.h" -#include "wlan_ui_pub.h" +#include "wlan_ui_pub.h" +#include "mem_pub.h" +#include "str_pub.h" +#include "drv_model_pub.h" #include "lwip/sockets.h" #include "lwip/ip_addr.h" @@ -136,6 +126,30 @@ typedef unsigned char byte; #endif +#if PLATFORM_XR809 +#define LWIP_COMPAT_SOCKETS 1 +#define LWIP_POSIX_SOCKETS_IO_NAMES 1 +#endif + + + +#if WINDOWS + +#undef UNICODE + +#define WIN32_LEAN_AND_MEAN + +#include +#include +#include + +#else + +#include "lwip/sockets.h" + +#endif + + // stricmp fix #if WINDOWS diff --git a/src/user_main.c b/src/user_main.c index aaef4152c..1705a24d0 100644 --- a/src/user_main.c +++ b/src/user_main.c @@ -1,26 +1,17 @@ /* - * @Author: yj - * @email: shiliu.yang@tuya.com - * @LastEditors: yj - * @file name: tuya_device.c - * @Description: template demo for SDK WiFi & BLE for BK7231T - * @Copyright: HANGZHOU TUYA INFORMATION TECHNOLOGY CO.,LTD - * @Company: http://www.tuya.com - * @Date: 2021-01-23 16:33:00 - * @LastEditTime: 2021-01-27 17:00:00 + */ // #include "hal/hal_wifi.h" #include "hal/hal_generic.h" +#include "new_common.h" #if PLATFORM_XR809 #elif PLATFORM_BL602 #else -#include "mem_pub.h" -#include "str_pub.h" #include "../../beken378/app/config/param_config.h" #endif #include "driver/drv_public.h" diff --git a/windowsTest_msvc2008.vcproj b/windowsTest_msvc2008.vcproj index c21646597..65216eafe 100644 --- a/windowsTest_msvc2008.vcproj +++ b/windowsTest_msvc2008.vcproj @@ -163,10 +163,6 @@ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > - - @@ -812,6 +808,14 @@ RelativePath=".\src\hal\hal_generic_xr809.c" > + + + +