Skip to content

Commit 442828a

Browse files
authored
Merge pull request #1 from mysterywolf/winsock
[simulator][sal] improve code
2 parents face98b + d3e9145 commit 442828a

6 files changed

Lines changed: 20 additions & 13 deletions

File tree

bsp/simulator/Kconfig

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ menu "Peripheral Drivers"
4949
select SAL_USING_WINSOCK
5050
default y
5151

52-
config SAL_USING_WINSOCK
53-
bool "Docking with Windows socket (winsock)"
54-
default n
55-
5652
config BSP_USING_LVGL
5753
bool "Enable LVGL for LCD"
5854
select PKG_USING_LVGL

bsp/simulator/drivers/SConscript

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ else:
4040

4141
if GetDepend('BSP_USING_RTC') == False:
4242
SrcRemove(src, 'drv_rtc.c')
43+
if GetDepend('BSP_USING_SOCKET') == False:
44+
SrcRemove(src, 'drv_win_eth.c')
4345
if GetDepend('RT_USING_DFS') == False or GetDepend('RT_USING_DFS_ELMFAT') == False:
4446
SrcRemove(src, 'sd_sim.c')
4547
if GetDepend('RT_USING_DFS') == False or GetDepend('RT_USING_MTD_NAND') == False:
@@ -50,8 +52,6 @@ if GetDepend('RT_USING_DFS') == False or GetDepend('RT_USING_DFS_WINSHAREDIR') =
5052
SrcRemove(src, 'dfs_win32.c')
5153
if GetDepend('RT_USING_DFS') == False or GetDepend('RT_USING_MODULE') == False:
5254
SrcRemove(src, ['module_win32.c'])
53-
if GetDepend('SAL_USING_WINSOCK') == False:
54-
SrcRemove(src, 'af_inet_winsock.c')
5555
if sys.platform[0:5]=="linux": #check whether under linux
5656
SrcRemove(src, ['module_win32.c', 'dfs_win32.c'])
5757

components/net/sal/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ if RT_USING_SAL
2121
bool "Docking with AT commands stack"
2222
default n
2323

24+
config SAL_USING_WINSOCK
25+
bool "Docking with Windows socket (winsock)"
26+
default n
27+
2428
config SAL_USING_TLS
2529
bool "Docking with MbedTLS protocol"
2630
default n

components/net/sal/SConscript

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ src += ['socket/net_netdb.c']
1010
CPPPATH = [cwd + '/include']
1111
CPPPATH += [cwd + '/include/socket']
1212

13-
if GetDepend('SAL_USING_LWIP') or GetDepend('SAL_USING_AT'):
13+
if GetDepend('SAL_USING_LWIP') or \
14+
GetDepend('SAL_USING_AT') or \
15+
GetDepend('SAL_USING_WINSOCK'):
1416
CPPPATH += [cwd + '/impl']
1517

1618
if GetDepend('SAL_USING_LWIP'):
@@ -19,6 +21,9 @@ if GetDepend('SAL_USING_LWIP'):
1921
if GetDepend('SAL_USING_AT'):
2022
src += ['impl/af_inet_at.c']
2123

24+
if GetDepend('SAL_USING_WINSOCK'):
25+
src += ['impl/af_inet_winsock.c']
26+
2227
if GetDepend('SAL_USING_TLS'):
2328
src += ['impl/proto_mbedtls.c']
2429

components/net/sal/impl/af_inet.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,21 @@
1717
extern "C" {
1818
#endif
1919

20-
#ifdef SAL_USING_LWIP
21-
2220
/* Set lwIP network interface device protocol family information */
21+
#ifdef SAL_USING_LWIP
2322
int sal_lwip_netdev_set_pf_info(struct netdev *netdev);
24-
2523
#endif /* SAL_USING_LWIP */
2624

27-
#ifdef SAL_USING_AT
28-
2925
/* Set AT network interface device protocol family information */
26+
#ifdef SAL_USING_AT
3027
int sal_at_netdev_set_pf_info(struct netdev *netdev);
31-
3228
#endif /* SAL_USING_AT */
3329

30+
/* Set lwIP network interface device protocol family information */
31+
#ifdef SAL_USING_WINSOCK
32+
int sal_win_netdev_set_pf_info(struct netdev* netdev)
33+
#endif /* SAL_USING_WINSOCK */
34+
3435
#ifdef __cplusplus
3536
}
3637
#endif
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* 2022-05-26 xiangxistu first version
99
*/
1010

11+
/* Do NOT include sys/time.h in this file */
1112
#include <WinSock2.h>
1213
#include <rtthread.h>
1314
#include <sal_low_lvl.h>

0 commit comments

Comments
 (0)