ソースを参照

update:适配SDK自带lwip

alienwalker 2 年 前
コミット
3b542b584d

+ 15 - 10
components/ethernet/common/dns_client.c

@@ -24,18 +24,23 @@
 #define DNS_TO_BASE (900)
 #define DNS_TRY_MAX	(3)
 
-//extern void DBG_Printf(const char* format, ...);
-//extern void DBG_HexPrintf(void *Data, unsigned int len);
-//#ifdef LUAT_LOG_NO_NEWLINE
-//#define DBG(x,y...)		DBG_Printf("%s %d:"x, __FUNCTION__,__LINE__,##y)
-//#define DBG_ERR(x,y...)		DBG_Printf("%s %d:"x, __FUNCTION__,__LINE__,##y)
-//#else
-//#define DBG(x,y...)		DBG_Printf("%s %d:"x"\r\n", __FUNCTION__,__LINE__,##y)
-//#define DBG_ERR(x,y...)		DBG_Printf("%s %d:"x"\r\n", __FUNCTION__,__LINE__,##y)
-//#endif
+#ifdef LUAT_USE_STD_STRING
+extern void DBG_Printf(const char* format, ...);
+#ifdef LUAT_LOG_NO_NEWLINE
+#define DBG(x,y...)		DBG_Printf("%s %d:"x, __FUNCTION__,__LINE__,##y)
+#define DBG_ERR(x,y...)		DBG_Printf("%s %d:"x, __FUNCTION__,__LINE__,##y)
+#else
+#define DBG(x,y...)		DBG_Printf("%s %d:"x"\r\n", __FUNCTION__,__LINE__,##y)
+#define DBG_ERR(x,y...)		DBG_Printf("%s %d:"x"\r\n", __FUNCTION__,__LINE__,##y)
+#endif
+#define LLOGD	DBG
+#define LLOGI	DBG
+#define LLOGE	DBG
+#define LLOGE	DBG
+#else
 #define LUAT_LOG_TAG "DNS"
 #include "luat_log.h"
-
+#endif
 
 typedef struct
 {

+ 6 - 2
components/ethernet/common/platform_def.h

@@ -9,7 +9,7 @@
 
 #define platform_create_task	luat_rtos_task_create
 #define platform_get_current_task luat_get_current_task
-#define platform_task_sleep	luat_timer_mdelay
+#define platform_task_sleep	luat_rtos_task_sleep
 #define platform_create_timer	luat_create_rtos_timer
 #define platform_start_timer	luat_start_rtos_timer
 #define platform_stop_timer	luat_stop_rtos_timer
@@ -20,10 +20,14 @@
 #define platform_unlock_mutex	luat_mutex_unlock
 #define platform_release_mutex	luat_mutex_release
 
+#ifdef __LUATOS__
 #define malloc 	luat_heap_malloc
 #define free 	luat_heap_free
 #define zalloc	luat_heap_zalloc
-#define msleep	luat_timer_mdelay
+#else
+#define zalloc(x)	calloc(1, x)
+#endif
+#define msleep	luat_rtos_task_sleep
 
 #define OS_LOCK	luat_task_suspend_all()
 #define OS_UNLOCK luat_task_resume_all()

+ 0 - 2
components/network/adapter/luat_network_adapter.c

@@ -9,8 +9,6 @@
 #include "platform_def.h"
 #include "ctype.h"
 #include "luat_network_adapter.h"
-#define LUAT_LOG_TAG "adapter"
-#include "luat_log.h"
 
 #ifndef LWIP_NUM_SOCKETS
 #define LWIP_NUM_SOCKETS 8

+ 3 - 2
components/network/lwip/port/lwipopts.h

@@ -1,7 +1,8 @@
 
 #ifndef LWIP_HDR_LWIPOPTS_H
 #define LWIP_HDR_LWIPOPTS_H
-
+#ifdef __USE_SDK_LWIP__
+#else
 #include "stdlib.h"
 #ifndef __BSP_COMMON_H__
 #include "c_common.h"
@@ -295,5 +296,5 @@ typedef uint32_t sys_prot_t;
 #ifdef LWIP_USER_CONFIG_FILE
 #include LWIP_USER_CONFIG_FILE
 #endif
-
+#endif
 #endif /* LWIP_HDR_LWIPOPTS_H */

ファイルの差分が大きいため隠しています
+ 288 - 489
components/network/lwip_with_sdk/net_lwip.c


+ 14 - 3
components/network/lwip_with_sdk/net_lwip.h

@@ -1,7 +1,12 @@
+/**
+ * 尽量适配第三方SDK的lwip
+ */
 #ifdef __USE_SDK_LWIP__
 #ifndef __NET_LWIP_H__
 #define __NET_LWIP_H__
-#include "bsp_common.h"
+#ifndef __BSP_COMMON_H__
+#include "c_common.h"
+#endif
 enum
 {
 	EV_LWIP_EVENT_START = USER_EVENT_ID_START + 0x2000000,
@@ -9,7 +14,7 @@ enum
 	EV_LWIP_NETIF_INPUT,
 	EV_LWIP_RUN_USER_API,
 //	EV_LWIP_TCP_TIMER,
-//	EV_LWIP_COMMON_TIMER,
+	EV_LWIP_COMMON_TIMER,
 	EV_LWIP_SOCKET_RX_DONE,
 	EV_LWIP_SOCKET_CREATE,
 	EV_LWIP_SOCKET_CONNECT,
@@ -27,8 +32,9 @@ enum
 
 void net_lwip_register_adapter(uint8_t adapter_index);
 void net_lwip_init(void);
+void net_lwip_set_dns_adapter(uint8_t adapter_index);
 int net_lwip_check_all_ack(int socket_id);
-void net_lwip_set_netif(uint8_t adapter_index, struct netif *netif, void *init, uint8_t is_default);
+void net_lwip_set_netif(uint8_t adapter_index, struct netif *netif);
 struct netif * net_lwip_get_netif(uint8_t adapter_index);
 void net_lwip_input_packets(struct netif *netif, struct pbuf *p);
 void net_lwip_ping_response(struct netif *inp, struct pbuf *p, uint8_t type);
@@ -48,5 +54,10 @@ int net_lwip_set_static_ip(ip_addr_t *ip, ip_addr_t *submask, ip_addr_t *gateway
 void net_lwip_set_rx_fast_ack(uint8_t adapter_index, uint8_t onoff);
 //设置TCP接收窗口大小,影响接收速度,tcp_mss_num越大越快,但是同样会消耗更多ram
 void net_lwip_set_tcp_rx_cache(uint8_t adapter_index, uint16_t tcp_mss_num);
+//传递给SDK的lwip任务的消息,需要由sdk发送
+void net_lwip_sdk_send_event(uint32_t id, uint32_t param1, uint32_t param2, uint32_t param3);
+void net_lwip_do_event(OS_EVENT event);
+//是否在SDK的lwip任务内
+uint8_t net_lwip_check_in_sdk_task(void);
 #endif
 #endif

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません