Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaobo07
rt-thread
提交
38750d29
R
rt-thread
项目概览
Xiaobo07
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
38750d29
编写于
7月 17, 2019
作者:
B
Bernard Xiong
提交者:
GitHub
7月 17, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2861 from enkiller/wlan
[components][drivers][wlan] 功能可裁剪
上级
3d022a68
46498d5d
变更
12
展开全部
隐藏空白更改
内联
并排
Showing
12 changed file
with
476 addition
and
177 deletion
+476
-177
components/drivers/Kconfig
components/drivers/Kconfig
+94
-45
components/drivers/wlan/SConscript
components/drivers/wlan/SConscript
+23
-1
components/drivers/wlan/wlan_cfg.c
components/drivers/wlan/wlan_cfg.c
+4
-0
components/drivers/wlan/wlan_cmd.c
components/drivers/wlan/wlan_cmd.c
+28
-5
components/drivers/wlan/wlan_dev.c
components/drivers/wlan/wlan_dev.c
+22
-2
components/drivers/wlan/wlan_dev.h
components/drivers/wlan/wlan_dev.h
+6
-0
components/drivers/wlan/wlan_lwip.c
components/drivers/wlan/wlan_lwip.c
+27
-4
components/drivers/wlan/wlan_mgnt.c
components/drivers/wlan/wlan_mgnt.c
+253
-109
components/drivers/wlan/wlan_mgnt.h
components/drivers/wlan/wlan_mgnt.h
+4
-0
components/drivers/wlan/wlan_prot.c
components/drivers/wlan/wlan_prot.c
+11
-9
components/drivers/wlan/wlan_prot.h
components/drivers/wlan/wlan_prot.h
+0
-2
components/drivers/wlan/wlan_workqueue.c
components/drivers/wlan/wlan_workqueue.c
+4
-0
未找到文件。
components/drivers/Kconfig
浏览文件 @
38750d29
...
@@ -254,9 +254,8 @@ config RT_USING_TOUCH
...
@@ -254,9 +254,8 @@ config RT_USING_TOUCH
bool "Using Touch device drivers"
bool "Using Touch device drivers"
default n
default n
menu "Using Hardware Crypto drivers"
menuconfig RT_USING_HWCRYPTO
config RT_USING_HWCRYPTO
bool "Using Hardware Crypto drivers"
bool "Using Hardware Crypto"
default n
default n
if RT_USING_HWCRYPTO
if RT_USING_HWCRYPTO
...
@@ -420,69 +419,120 @@ menu "Using Hardware Crypto drivers"
...
@@ -420,69 +419,120 @@ menu "Using Hardware Crypto drivers"
default n
default n
endif
endif
endif
endif
endmenu
menu "Using WiFi"
menuconfig RT_USING_WIFI
config RT_USING_WIFI
bool "Using Wi-Fi framework"
bool "Using Wi-Fi framework"
default n
default n
if RT_USING_WIFI
if RT_USING_WIFI
config RT_WLAN_DEVICE_STA_NAME
config RT_WLAN_DEVICE_STA_NAME
string "The
WiFi
device name for station"
string "The device name for station"
default "wlan0"
default "wlan0"
config RT_WLAN_DEVICE_AP_NAME
config RT_WLAN_DEVICE_AP_NAME
string "The
WiFi
device name for ap"
string "The device name for ap"
default "wlan1"
default "wlan1"
config RT_WLAN_DEFAULT_PROT
string "Default transport protocol"
default "lwip"
config RT_WLAN_SCAN_WAIT_MS
int "Set scan timeout time(ms)"
default 10000
config RT_WLAN_CONNECT_WAIT_MS
int "Set connect timeout time(ms)"
default 10000
config RT_WLAN_SSID_MAX_LENGTH
config RT_WLAN_SSID_MAX_LENGTH
int "SSID
name
maximum length"
int "SSID maximum length"
default 32
default 32
config RT_WLAN_PASSWORD_MAX_LENGTH
config RT_WLAN_PASSWORD_MAX_LENGTH
int "
Maximum password
length"
int "
Password maximum
length"
default 32
default 32
config RT_WLAN_SCAN_SORT
config RT_WLAN_DEV_EVENT_NUM
bool "Automatic sorting of scan results"
int "Driver events maxcount"
default 2
config RT_WLAN_MANAGE_ENABLE
bool "Connection management Enable"
default y
default y
config RT_WLAN_CFG_INFO_MAX
if RT_WLAN_MANAGE_ENABLE
int "Maximum number of WiFi information automatically saved"
config RT_WLAN_SCAN_WAIT_MS
default 3
int "Set scan timeout time(ms)"
default 10000
config RT_WLAN_WORKQUEUE_THREAD_NAME
config RT_WLAN_CONNECT_WAIT_MS
string "WiFi work queue thread name
"
int "Set connect timeout time(ms)
"
default "wlan_job"
default 10000
config RT_WLAN_WORKQUEUE_THREAD_SIZE
config RT_WLAN_SCAN_SORT
int "wifi work queue thread size
"
bool "Automatic sorting of scan results
"
default 2048
default y
config RT_WLAN_WORKQUEUE_THREAD_PRIO
config RT_WLAN_MSH_CMD_ENABLE
int "WiFi work queue thread priority
"
bool "MSH command Enable
"
default 22
default y
config RT_WLAN_DEV_EVENT_NUM
config RT_WLAN_AUTO_CONNECT_ENABLE
int "Maximum number of driver events"
bool "Auto connect Enable"
default 2
select RT_WLAN_CFG_ENABLE
select RT_WLAN_WORK_THREAD_ENABLE
default y
endif
config RT_WLAN_PROT_LWIP_PBUF_FORCE
config RT_WLAN_CFG_ENABLE
bool "Forced use of PBUF transmission"
bool "WiFi information automatically saved Enable"
default n
default y
if RT_WLAN_CFG_ENABLE
config RT_WLAN_CFG_INFO_MAX
int "Maximum number of WiFi information automatically saved"
default 3
endif
config RT_WLAN_PROT_ENABLE
bool "Transport protocol manage Enable"
default y
if RT_WLAN_PROT_ENABLE
config RT_WLAN_PROT_NAME_LEN
int "Transport protocol name length"
default 8
config RT_WLAN_PROT_MAX
int "Transport protocol maxcount"
default 2
config RT_WLAN_DEFAULT_PROT
string "Default transport protocol"
default "lwip"
config RT_WLAN_PROT_LWIP_ENABLE
bool "LWIP transport protocol Enable"
select RT_USING_LWIP
default y
if RT_WLAN_PROT_LWIP_ENABLE
config RT_WLAN_PROT_LWIP_NAME
string "LWIP transport protocol name"
default "lwip"
config RT_WLAN_PROT_LWIP_PBUF_FORCE
bool "Forced use of PBUF transmission"
default n
endif
endif
config RT_WLAN_WORK_THREAD_ENABLE
bool "WLAN work queue thread Enable"
default y
if RT_WLAN_WORK_THREAD_ENABLE
config RT_WLAN_WORKQUEUE_THREAD_NAME
string "WLAN work queue thread name"
default "wlan"
config RT_WLAN_WORKQUEUE_THREAD_SIZE
int "WLAN work queue thread size"
default 2048
config RT_WLAN_WORKQUEUE_THREAD_PRIO
int "WLAN work queue thread priority"
default 15
endif
menuconfig RT_WLAN_DEBUG
menuconfig RT_WLAN_DEBUG
bool "Enable WLAN Debugging Options"
bool "Enable WLAN Debugging Options"
...
@@ -514,7 +564,6 @@ menu "Using WiFi"
...
@@ -514,7 +564,6 @@ menu "Using WiFi"
default n
default n
endif
endif
endif
endif
endmenu
menu "Using USB"
menu "Using USB"
config RT_USING_USB_HOST
config RT_USING_USB_HOST
...
...
components/drivers/wlan/SConscript
浏览文件 @
38750d29
from
building
import
*
from
building
import
*
cwd
=
GetCurrentDir
()
cwd
=
GetCurrentDir
()
src
=
Glob
(
'*.c'
)
CPPPATH
=
[
cwd
]
CPPPATH
=
[
cwd
]
src
=
Split
(
'''
wlan_dev.c
'''
)
if
GetDepend
([
'RT_WLAN_MANAGE_ENABLE'
]):
src
+=
[
'wlan_mgnt.c'
]
if
GetDepend
([
'RT_WLAN_MSH_CMD_ENABLE'
]):
src
+=
[
'wlan_cmd.c'
]
if
GetDepend
([
'RT_WLAN_PROT_ENABLE'
]):
src
+=
[
'wlan_prot.c'
]
if
GetDepend
([
'RT_WLAN_PROT_LWIP_ENABLE'
]):
src
+=
[
'wlan_lwip.c'
]
if
GetDepend
([
'RT_WLAN_CFG_ENABLE'
]):
src
+=
[
'wlan_cfg.c'
]
if
GetDepend
([
'RT_WLAN_WORK_THREAD_ENABLE'
]):
src
+=
[
'wlan_workqueue.c'
]
group
=
DefineGroup
(
'DeviceDrivers'
,
src
,
depend
=
[
'RT_USING_WIFI'
],
CPPPATH
=
CPPPATH
)
group
=
DefineGroup
(
'DeviceDrivers'
,
src
,
depend
=
[
'RT_USING_WIFI'
],
CPPPATH
=
CPPPATH
)
Return
(
'group'
)
Return
(
'group'
)
components/drivers/wlan/wlan_cfg.c
浏览文件 @
38750d29
...
@@ -19,6 +19,8 @@
...
@@ -19,6 +19,8 @@
#endif
/* RT_WLAN_CFG_DEBUG */
#endif
/* RT_WLAN_CFG_DEBUG */
#include <rtdbg.h>
#include <rtdbg.h>
#ifdef RT_WLAN_CFG_ENABLE
#define WLAN_CFG_LOCK() (rt_mutex_take(&cfg_mutex, RT_WAITING_FOREVER))
#define WLAN_CFG_LOCK() (rt_mutex_take(&cfg_mutex, RT_WAITING_FOREVER))
#define WLAN_CFG_UNLOCK() (rt_mutex_release(&cfg_mutex))
#define WLAN_CFG_UNLOCK() (rt_mutex_release(&cfg_mutex))
...
@@ -462,3 +464,5 @@ void rt_wlan_cfg_dump(void)
...
@@ -462,3 +464,5 @@ void rt_wlan_cfg_dump(void)
rt_kprintf
(
"%3d
\n
"
,
info
->
channel
);
rt_kprintf
(
"%3d
\n
"
,
info
->
channel
);
}
}
}
}
#endif
components/drivers/wlan/wlan_cmd.c
浏览文件 @
38750d29
...
@@ -13,6 +13,8 @@
...
@@ -13,6 +13,8 @@
#include <wlan_cfg.h>
#include <wlan_cfg.h>
#include <wlan_prot.h>
#include <wlan_prot.h>
#if defined(RT_WLAN_MANAGE_ENABLE) && defined(RT_WLAN_MSH_CMD_ENABLE)
struct
wifi_cmd_des
struct
wifi_cmd_des
{
{
const
char
*
cmd
;
const
char
*
cmd
;
...
@@ -75,7 +77,7 @@ static int wifi_help(int argc, char *argv[])
...
@@ -75,7 +77,7 @@ static int wifi_help(int argc, char *argv[])
{
{
rt_kprintf
(
"wifi
\n
"
);
rt_kprintf
(
"wifi
\n
"
);
rt_kprintf
(
"wifi help
\n
"
);
rt_kprintf
(
"wifi help
\n
"
);
rt_kprintf
(
"wifi scan
\n
"
);
rt_kprintf
(
"wifi scan
[SSID]
\n
"
);
rt_kprintf
(
"wifi join [SSID] [PASSWORD]
\n
"
);
rt_kprintf
(
"wifi join [SSID] [PASSWORD]
\n
"
);
rt_kprintf
(
"wifi ap SSID [PASSWORD]
\n
"
);
rt_kprintf
(
"wifi ap SSID [PASSWORD]
\n
"
);
rt_kprintf
(
"wifi disc
\n
"
);
rt_kprintf
(
"wifi disc
\n
"
);
...
@@ -143,12 +145,23 @@ static int wifi_status(int argc, char *argv[])
...
@@ -143,12 +145,23 @@ static int wifi_status(int argc, char *argv[])
static
int
wifi_scan
(
int
argc
,
char
*
argv
[])
static
int
wifi_scan
(
int
argc
,
char
*
argv
[])
{
{
struct
rt_wlan_scan_result
*
scan_result
=
RT_NULL
;
struct
rt_wlan_scan_result
*
scan_result
=
RT_NULL
;
struct
rt_wlan_info
*
info
=
RT_NULL
;
struct
rt_wlan_info
filter
;
if
(
argc
>
2
)
if
(
argc
>
3
)
return
-
1
;
return
-
1
;
if
(
argc
==
3
)
{
INVALID_INFO
(
&
filter
);
SSID_SET
(
&
filter
,
argv
[
2
]);
info
=
&
filter
;
}
/* clean scan result */
rt_wlan_scan_result_clean
();
/* scan ap info */
/* scan ap info */
scan_result
=
rt_wlan_scan_
sync
(
);
scan_result
=
rt_wlan_scan_
with_info
(
info
);
if
(
scan_result
)
if
(
scan_result
)
{
{
int
index
,
num
;
int
index
,
num
;
...
@@ -224,8 +237,10 @@ static int wifi_join(int argc, char *argv[])
...
@@ -224,8 +237,10 @@ static int wifi_join(int argc, char *argv[])
const
char
*
key
=
RT_NULL
;
const
char
*
key
=
RT_NULL
;
struct
rt_wlan_cfg_info
cfg_info
;
struct
rt_wlan_cfg_info
cfg_info
;
rt_memset
(
&
cfg_info
,
0
,
sizeof
(
cfg_info
));
if
(
argc
==
2
)
if
(
argc
==
2
)
{
{
#ifdef RT_WLAN_CFG_ENABLE
/* get info to connect */
/* get info to connect */
if
(
rt_wlan_cfg_read_index
(
&
cfg_info
,
0
)
==
1
)
if
(
rt_wlan_cfg_read_index
(
&
cfg_info
,
0
)
==
1
)
{
{
...
@@ -234,8 +249,9 @@ static int wifi_join(int argc, char *argv[])
...
@@ -234,8 +249,9 @@ static int wifi_join(int argc, char *argv[])
key
=
(
char
*
)(
&
cfg_info
.
key
.
val
[
0
]);
key
=
(
char
*
)(
&
cfg_info
.
key
.
val
[
0
]);
}
}
else
else
#endif
{
{
rt_kprintf
(
"not find info
\n
"
);
rt_kprintf
(
"not find
connect
info
\n
"
);
}
}
}
}
else
if
(
argc
==
3
)
else
if
(
argc
==
3
)
...
@@ -387,8 +403,9 @@ static int wifi_debug_save_cfg(int argc, char *argv[])
...
@@ -387,8 +403,9 @@ static int wifi_debug_save_cfg(int argc, char *argv[])
rt_memcpy
(
&
cfg_info
.
key
.
val
[
0
],
password
,
len
);
rt_memcpy
(
&
cfg_info
.
key
.
val
[
0
],
password
,
len
);
cfg_info
.
key
.
len
=
len
;
cfg_info
.
key
.
len
=
len
;
}
}
#ifdef RT_WLAN_CFG_ENABLE
rt_wlan_cfg_save
(
&
cfg_info
);
rt_wlan_cfg_save
(
&
cfg_info
);
#endif
return
0
;
return
0
;
}
}
...
@@ -396,7 +413,9 @@ static int wifi_debug_dump_cfg(int argc, char *argv[])
...
@@ -396,7 +413,9 @@ static int wifi_debug_dump_cfg(int argc, char *argv[])
{
{
if
(
argc
==
1
)
if
(
argc
==
1
)
{
{
#ifdef RT_WLAN_CFG_ENABLE
rt_wlan_cfg_dump
();
rt_wlan_cfg_dump
();
#endif
}
}
else
else
{
{
...
@@ -409,8 +428,10 @@ static int wifi_debug_clear_cfg(int argc, char *argv[])
...
@@ -409,8 +428,10 @@ static int wifi_debug_clear_cfg(int argc, char *argv[])
{
{
if
(
argc
==
1
)
if
(
argc
==
1
)
{
{
#ifdef RT_WLAN_CFG_ENABLE
rt_wlan_cfg_delete_all
();
rt_wlan_cfg_delete_all
();
rt_wlan_cfg_cache_save
();
rt_wlan_cfg_cache_save
();
#endif
}
}
else
else
{
{
...
@@ -564,3 +585,5 @@ static int wifi_msh(int argc, char *argv[])
...
@@ -564,3 +585,5 @@ static int wifi_msh(int argc, char *argv[])
#if defined(RT_USING_FINSH) && defined(FINSH_USING_MSH)
#if defined(RT_USING_FINSH) && defined(FINSH_USING_MSH)
FINSH_FUNCTION_EXPORT_ALIAS
(
wifi_msh
,
__cmd_wifi
,
wifi
command
.);
FINSH_FUNCTION_EXPORT_ALIAS
(
wifi_msh
,
__cmd_wifi
,
wifi
command
.);
#endif
#endif
#endif
components/drivers/wlan/wlan_dev.c
浏览文件 @
38750d29
...
@@ -21,6 +21,8 @@
...
@@ -21,6 +21,8 @@
#endif
/* RT_WLAN_DEV_DEBUG */
#endif
/* RT_WLAN_DEV_DEBUG */
#include <rtdbg.h>
#include <rtdbg.h>
#if defined(RT_USING_WIFI) || defined(RT_USING_WLAN)
#ifndef RT_DEVICE
#ifndef RT_DEVICE
#define RT_DEVICE(__device) ((rt_device_t)__device)
#define RT_DEVICE(__device) ((rt_device_t)__device)
#endif
#endif
...
@@ -56,6 +58,17 @@ rt_err_t rt_wlan_dev_init(struct rt_wlan_device *device, rt_wlan_mode_t mode)
...
@@ -56,6 +58,17 @@ rt_err_t rt_wlan_dev_init(struct rt_wlan_device *device, rt_wlan_mode_t mode)
return
-
RT_ERROR
;
return
-
RT_ERROR
;
}
}
if
(
mode
==
RT_WLAN_AP
&&
device
->
flags
&
RT_WLAN_FLAG_STA_ONLY
)
{
LOG_E
(
"F:%s L:%d This wlan device can only be set to sta mode!"
,
__FUNCTION__
,
__LINE__
);
return
-
RT_ERROR
;
}
else
if
(
mode
==
RT_WLAN_STATION
&&
device
->
flags
&
RT_WLAN_FLAG_AP_ONLY
)
{
LOG_E
(
"F:%s L:%d This wlan device can only be set to ap mode!"
,
__FUNCTION__
,
__LINE__
);
return
-
RT_ERROR
;
}
result
=
rt_device_init
(
RT_DEVICE
(
device
));
result
=
rt_device_init
(
RT_DEVICE
(
device
));
if
(
result
!=
RT_EOK
)
if
(
result
!=
RT_EOK
)
{
{
...
@@ -545,7 +558,11 @@ rt_err_t rt_wlan_dev_scan_stop(struct rt_wlan_device *device)
...
@@ -545,7 +558,11 @@ rt_err_t rt_wlan_dev_scan_stop(struct rt_wlan_device *device)
rt_err_t
rt_wlan_dev_report_data
(
struct
rt_wlan_device
*
device
,
void
*
buff
,
int
len
)
rt_err_t
rt_wlan_dev_report_data
(
struct
rt_wlan_device
*
device
,
void
*
buff
,
int
len
)
{
{
#ifdef RT_WLAN_PROT_ENABLE
return
rt_wlan_dev_transfer_prot
(
device
,
buff
,
len
);
return
rt_wlan_dev_transfer_prot
(
device
,
buff
,
len
);
#else
return
-
RT_ERROR
;
#endif
}
}
static
rt_err_t
_rt_wlan_dev_init
(
rt_device_t
dev
)
static
rt_err_t
_rt_wlan_dev_init
(
rt_device_t
dev
)
...
@@ -768,14 +785,15 @@ rt_err_t rt_wlan_dev_register(struct rt_wlan_device *wlan, const char *name, con
...
@@ -768,14 +785,15 @@ rt_err_t rt_wlan_dev_register(struct rt_wlan_device *wlan, const char *name, con
{
{
rt_err_t
err
=
RT_EOK
;
rt_err_t
err
=
RT_EOK
;
if
((
wlan
==
RT_NULL
)
||
(
name
==
RT_NULL
)
||
(
ops
==
RT_NULL
))
if
((
wlan
==
RT_NULL
)
||
(
name
==
RT_NULL
)
||
(
ops
==
RT_NULL
)
||
(
flag
&
RT_WLAN_FLAG_STA_ONLY
&&
flag
&
RT_WLAN_FLAG_AP_ONLY
))
{
{
LOG_E
(
"F:%s L:%d parameter Wrongful"
,
__FUNCTION__
,
__LINE__
);
LOG_E
(
"F:%s L:%d parameter Wrongful"
,
__FUNCTION__
,
__LINE__
);
return
RT_NULL
;
return
RT_NULL
;
}
}
rt_memset
(
wlan
,
0
,
sizeof
(
struct
rt_wlan_device
));
rt_memset
(
wlan
,
0
,
sizeof
(
struct
rt_wlan_device
));
#ifdef RT_USING_DEVICE_OPS
#ifdef RT_USING_DEVICE_OPS
wlan
->
device
.
ops
=
&
wlan_ops
;
wlan
->
device
.
ops
=
&
wlan_ops
;
#else
#else
...
@@ -801,3 +819,5 @@ rt_err_t rt_wlan_dev_register(struct rt_wlan_device *wlan, const char *name, con
...
@@ -801,3 +819,5 @@ rt_err_t rt_wlan_dev_register(struct rt_wlan_device *wlan, const char *name, con
return
err
;
return
err
;
}
}
#endif
components/drivers/wlan/wlan_dev.h
浏览文件 @
38750d29
...
@@ -381,6 +381,11 @@ typedef struct rt_wlan_key rt_wlan_key_t;
...
@@ -381,6 +381,11 @@ typedef struct rt_wlan_key rt_wlan_key_t;
(_info)->channel = -1; \
(_info)->channel = -1; \
} while(0)
} while(0)
#define SSID_SET(_info, _ssid) do { \
rt_strncpy((char *)(_info)->ssid.val, (_ssid), RT_WLAN_SSID_MAX_LENGTH); \
(_info)->ssid.len = rt_strlen((char *)(_info)->ssid.val); \
} while(0)
struct
rt_wlan_info
struct
rt_wlan_info
{
{
/* security type */
/* security type */
...
@@ -442,6 +447,7 @@ struct rt_wlan_device
...
@@ -442,6 +447,7 @@ struct rt_wlan_device
rt_wlan_pormisc_callback_t
pormisc_callback
;
rt_wlan_pormisc_callback_t
pormisc_callback
;
const
struct
rt_wlan_dev_ops
*
ops
;
const
struct
rt_wlan_dev_ops
*
ops
;
rt_uint32_t
flags
;
rt_uint32_t
flags
;
struct
netdev
*
netdev
;
void
*
prot
;
void
*
prot
;
void
*
user_data
;
void
*
user_data
;
};
};
...
...
components/drivers/wlan/wlan_lwip.c
浏览文件 @
38750d29
...
@@ -14,12 +14,17 @@
...
@@ -14,12 +14,17 @@
#include <wlan_prot.h>
#include <wlan_prot.h>
#include <wlan_workqueue.h>
#include <wlan_workqueue.h>
#if defined(RT_WLAN_PROT_ENABLE) && defined(RT_WLAN_PROT_LWIP_ENABLE)
#ifdef RT_USING_LWIP
#ifdef RT_USING_LWIP
#include <netif/ethernetif.h>
#include <netif/ethernetif.h>
#include <lwip/netifapi.h>
#include <lwip/netifapi.h>
#ifdef LWIP_USING_DHCPD
#ifdef LWIP_USING_DHCPD
#include <dhcp_server.h>
#include <dhcp_server.h>
#endif
#endif
#ifdef RT_USING_NETDEV
#include <netdev.h>
#endif
#define DBG_TAG "WLAN.lwip"
#define DBG_TAG "WLAN.lwip"
#ifdef RT_WLAN_LWIP_DEBUG
#ifdef RT_WLAN_LWIP_DEBUG
...
@@ -33,6 +38,10 @@
...
@@ -33,6 +38,10 @@
#define IPADDR_STRLEN_MAX (32)
#define IPADDR_STRLEN_MAX (32)
#endif
#endif
#ifndef RT_WLAN_PROT_LWIP_NAME
#define RT_WLAN_PROT_LWIP_NAME ("lwip")
#endif
struct
lwip_prot_des
struct
lwip_prot_des
{
{
struct
rt_wlan_prot
prot
;
struct
rt_wlan_prot
prot
;
...
@@ -100,12 +109,16 @@ static void netif_is_ready(struct rt_work *work, void *parameter)
...
@@ -100,12 +109,16 @@ static void netif_is_ready(struct rt_work *work, void *parameter)
LOG_I
(
"Got IP address : %s"
,
str
);
LOG_I
(
"Got IP address : %s"
,
str
);
exit:
exit:
level
=
rt_hw_interrupt_disable
();
level
=
rt_hw_interrupt_disable
();
rt_memset
(
work
,
0
,
sizeof
(
struct
rt_work
));
if
(
work
)
{
rt_memset
(
work
,
0
,
sizeof
(
struct
rt_work
));
}
rt_hw_interrupt_enable
(
level
);
rt_hw_interrupt_enable
(
level
);
}
}
static
void
timer_callback
(
void
*
parameter
)
static
void
timer_callback
(
void
*
parameter
)
{
{
#ifdef RT_WLAN_WORK_THREAD_ENABLE
struct
rt_workqueue
*
workqueue
;
struct
rt_workqueue
*
workqueue
;
struct
rt_wlan_device
*
wlan
=
parameter
;
struct
rt_wlan_device
*
wlan
=
parameter
;
struct
lwip_prot_des
*
lwip_prot
=
(
struct
lwip_prot_des
*
)
wlan
->
prot
;
struct
lwip_prot_des
*
lwip_prot
=
(
struct
lwip_prot_des
*
)
wlan
->
prot
;
...
@@ -125,6 +138,10 @@ static void timer_callback(void *parameter)
...
@@ -125,6 +138,10 @@ static void timer_callback(void *parameter)
rt_hw_interrupt_enable
(
level
);
rt_hw_interrupt_enable
(
level
);
}
}
}
}
#else
netif_is_ready
(
RT_NULL
,
parameter
);
#endif
}
}
static
void
netif_set_connected
(
void
*
parameter
)
static
void
netif_set_connected
(
void
*
parameter
)
...
@@ -238,8 +255,11 @@ static void rt_wlan_lwip_event_handle(struct rt_wlan_prot *port, struct rt_wlan_
...
@@ -238,8 +255,11 @@ static void rt_wlan_lwip_event_handle(struct rt_wlan_prot *port, struct rt_wlan_
}
}
if
(
flag_old
!=
lwip_prot
->
connected_flag
)
if
(
flag_old
!=
lwip_prot
->
connected_flag
)
{
{
#ifdef RT_WLAN_WORK_THREAD_ENABLE
rt_wlan_workqueue_dowork
(
netif_set_connected
,
wlan
);
rt_wlan_workqueue_dowork
(
netif_set_connected
,
wlan
);
// netif_set_connected(wlan);
#else
netif_set_connected
(
wlan
);
#endif
}
}
}
}
...
@@ -460,7 +480,9 @@ static struct rt_wlan_prot *rt_wlan_lwip_protocol_register(struct rt_wlan_prot *
...
@@ -460,7 +480,9 @@ static struct rt_wlan_prot *rt_wlan_lwip_protocol_register(struct rt_wlan_prot *
}
}
netif_set_up
(
eth
->
netif
);
netif_set_up
(
eth
->
netif
);
LOG_I
(
"eth device init ok name:%s"
,
eth_name
);
LOG_I
(
"eth device init ok name:%s"
,
eth_name
);
#ifdef RT_USING_NETDEV
wlan
->
netdev
=
netdev_get_by_name
(
eth_name
);
#endif
return
&
lwip_prot
->
prot
;
return
&
lwip_prot
->
prot
;
}
}
...
@@ -483,7 +505,7 @@ int rt_wlan_lwip_init(void)
...
@@ -483,7 +505,7 @@ int rt_wlan_lwip_init(void)
rt_wlan_prot_event_t
event
;
rt_wlan_prot_event_t
event
;
rt_memset
(
&
prot
,
0
,
sizeof
(
prot
));
rt_memset
(
&
prot
,
0
,
sizeof
(
prot
));
rt_strncpy
(
&
prot
.
name
[
0
],
RT_WLAN_PROT_LWIP
,
RT_WLAN_PROT_NAME_LEN
);
rt_strncpy
(
&
prot
.
name
[
0
],
RT_WLAN_PROT_LWIP
_NAME
,
RT_WLAN_PROT_NAME_LEN
);
prot
.
ops
=
&
ops
;
prot
.
ops
=
&
ops
;
if
(
rt_wlan_prot_regisetr
(
&
prot
)
!=
RT_EOK
)
if
(
rt_wlan_prot_regisetr
(
&
prot
)
!=
RT_EOK
)
...
@@ -502,3 +524,4 @@ int rt_wlan_lwip_init(void)
...
@@ -502,3 +524,4 @@ int rt_wlan_lwip_init(void)
INIT_PREV_EXPORT
(
rt_wlan_lwip_init
);
INIT_PREV_EXPORT
(
rt_wlan_lwip_init
);
#endif
#endif
#endif
components/drivers/wlan/wlan_mgnt.c
浏览文件 @
38750d29
此差异已折叠。
点击以展开。
components/drivers/wlan/wlan_mgnt.h
浏览文件 @
38750d29
...
@@ -37,6 +37,10 @@ extern "C" {
...
@@ -37,6 +37,10 @@ extern "C" {
#define RT_WLAN_EBOX_NUM (10)
#define RT_WLAN_EBOX_NUM (10)
#endif
#endif
#ifndef RT_WLAN_SCAN_RETRY_CNT
#define RT_WLAN_SCAN_RETRY_CNT (3)
#endif
/*state fot station*/
/*state fot station*/
#define RT_WLAN_STATE_CONNECT (1UL << 0)
#define RT_WLAN_STATE_CONNECT (1UL << 0)
#define RT_WLAN_STATE_CONNECTING (1UL << 1)
#define RT_WLAN_STATE_CONNECTING (1UL << 1)
...
...
components/drivers/wlan/wlan_prot.c
浏览文件 @
38750d29
...
@@ -21,6 +21,8 @@
...
@@ -21,6 +21,8 @@
#endif
/* RT_WLAN_PROT_DEBUG */
#endif
/* RT_WLAN_PROT_DEBUG */
#include <rtdbg.h>
#include <rtdbg.h>
#ifdef RT_WLAN_PROT_ENABLE
#if RT_WLAN_PROT_NAME_LEN < 4
#if RT_WLAN_PROT_NAME_LEN < 4
#error "The name is too short"
#error "The name is too short"
#endif
#endif
...
@@ -160,7 +162,7 @@ rt_err_t rt_wlan_prot_attach_dev(struct rt_wlan_device *wlan, const char *prot_n
...
@@ -160,7 +162,7 @@ rt_err_t rt_wlan_prot_attach_dev(struct rt_wlan_device *wlan, const char *prot_n
{
{
int
i
=
0
;
int
i
=
0
;
struct
rt_wlan_prot
*
prot
=
wlan
->
prot
;
struct
rt_wlan_prot
*
prot
=
wlan
->
prot
;
rt_wlan_dev_event_
t
event
;
rt_wlan_dev_event_
handler
handler
=
rt_wlan_prot_event_handle
;
if
(
wlan
==
RT_NULL
)
if
(
wlan
==
RT_NULL
)
{
{
...
@@ -180,7 +182,7 @@ rt_err_t rt_wlan_prot_attach_dev(struct rt_wlan_device *wlan, const char *prot_n
...
@@ -180,7 +182,7 @@ rt_err_t rt_wlan_prot_attach_dev(struct rt_wlan_device *wlan, const char *prot_n
rt_wlan_prot_detach_dev
(
wlan
);
rt_wlan_prot_detach_dev
(
wlan
);
#ifdef RT_WLAN_PROT_LWIP_PBUF_FORCE
#ifdef RT_WLAN_PROT_LWIP_PBUF_FORCE
if
(
rt_strcmp
(
RT_WLAN_PROT_LWIP
,
prot_name
)
!=
0
)
if
(
rt_strcmp
(
RT_WLAN_PROT_LWIP
_NAME
,
prot_name
)
!=
0
)
{
{
return
-
RT_ERROR
;
return
-
RT_ERROR
;
}
}
...
@@ -202,13 +204,12 @@ rt_err_t rt_wlan_prot_attach_dev(struct rt_wlan_device *wlan, const char *prot_n
...
@@ -202,13 +204,12 @@ rt_err_t rt_wlan_prot_attach_dev(struct rt_wlan_device *wlan, const char *prot_n
return
-
RT_ERROR
;
return
-
RT_ERROR
;
}
}
for
(
event
=
RT_WLAN_DEV_EVT_INIT_DONE
;
event
<
RT_WLAN_DEV_EVT_MAX
;
event
++
)
rt_wlan_dev_register_event_handler
(
wlan
,
RT_WLAN_DEV_EVT_CONNECT
,
handler
,
RT_NULL
);
{
rt_wlan_dev_register_event_handler
(
wlan
,
RT_WLAN_DEV_EVT_DISCONNECT
,
handler
,
RT_NULL
);
if
(
rt_wlan_dev_register_event_handler
(
wlan
,
event
,
rt_wlan_prot_event_handle
,
RT_NULL
)
!=
RT_EOK
)
rt_wlan_dev_register_event_handler
(
wlan
,
RT_WLAN_DEV_EVT_AP_START
,
handler
,
RT_NULL
);
{
rt_wlan_dev_register_event_handler
(
wlan
,
RT_WLAN_DEV_EVT_AP_STOP
,
handler
,
RT_NULL
);
LOG_E
(
"prot register event filed:%d"
,
event
);
rt_wlan_dev_register_event_handler
(
wlan
,
RT_WLAN_DEV_EVT_AP_ASSOCIATED
,
handler
,
RT_NULL
);
}
rt_wlan_dev_register_event_handler
(
wlan
,
RT_WLAN_DEV_EVT_AP_DISASSOCIATED
,
handler
,
RT_NULL
);
}
return
RT_EOK
;
return
RT_EOK
;
}
}
...
@@ -360,3 +361,4 @@ void rt_wlan_prot_dump(void)
...
@@ -360,3 +361,4 @@ void rt_wlan_prot_dump(void)
}
}
}
}
}
}
#endif
components/drivers/wlan/wlan_prot.h
浏览文件 @
38750d29
...
@@ -25,8 +25,6 @@ extern "C" {
...
@@ -25,8 +25,6 @@ extern "C" {
#define RT_LWAN_ID_PREFIX (0x5054)
#define RT_LWAN_ID_PREFIX (0x5054)
#define RT_WLAN_PROT_LWIP ("lwip")
typedef
enum
typedef
enum
{
{
RT_WLAN_PROT_EVT_INIT_DONE
=
0
,
RT_WLAN_PROT_EVT_INIT_DONE
=
0
,
...
...
components/drivers/wlan/wlan_workqueue.c
浏览文件 @
38750d29
...
@@ -17,6 +17,8 @@
...
@@ -17,6 +17,8 @@
#define DBG_LVL DBG_INFO
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#include <rtdbg.h>
#ifdef RT_WLAN_WORK_THREAD_ENABLE
struct
rt_wlan_work
struct
rt_wlan_work
{
{
struct
rt_work
work
;
struct
rt_work
work
;
...
@@ -95,3 +97,5 @@ int rt_wlan_workqueue_init(void)
...
@@ -95,3 +97,5 @@ int rt_wlan_workqueue_init(void)
return
0
;
return
0
;
}
}
INIT_PREV_EXPORT
(
rt_wlan_workqueue_init
);
INIT_PREV_EXPORT
(
rt_wlan_workqueue_init
);
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录