Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
31d214ff
R
rt-thread
项目概览
BaiXuePrincess
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
31d214ff
编写于
11月 15, 2014
作者:
wuyangyong
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #375 from aozima/pulls
update RW009 driver: add softAP support.
上级
4586e48c
92fac29f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
105 addition
and
7 deletion
+105
-7
components/drivers/spi/spi_wifi_rw009.c
components/drivers/spi/spi_wifi_rw009.c
+54
-7
components/drivers/spi/spi_wifi_rw009.h
components/drivers/spi/spi_wifi_rw009.h
+51
-0
未找到文件。
components/drivers/spi/spi_wifi_rw009.c
浏览文件 @
31d214ff
...
...
@@ -126,6 +126,7 @@ static void resp_handler(struct rw009_wifi *wifi_device, struct rw009_resp *resp
//dump
if
(
1
)
{
#ifdef WIFI_DEBUG_ON
rw009_ap_info
*
ap_info
=
&
resp
->
resp
.
ap_info
;
WIFI_DEBUG
(
"SCAN SSID:%-32.32s
\n
"
,
ap_info
->
ssid
);
WIFI_DEBUG
(
"SCAN BSSID:%02X-%02X-%02X-%02X-%02X-%02X
\n
"
,
...
...
@@ -139,6 +140,7 @@ static void resp_handler(struct rw009_wifi *wifi_device, struct rw009_resp *resp
WIFI_DEBUG
(
"SCAN rate:%dMbps
\n
"
,
ap_info
->
max_data_rate
/
1000
);
WIFI_DEBUG
(
"SCAN channel:%d
\n
"
,
ap_info
->
channel
);
WIFI_DEBUG
(
"SCAN security:%08X
\n\n
"
,
ap_info
->
security
);
#endif
/* WIFI_DEBUG_ON */
}
wifi_device
->
ap_scan_count
++
;
...
...
@@ -148,7 +150,6 @@ static void resp_handler(struct rw009_wifi *wifi_device, struct rw009_resp *resp
return
;
/* wait for next ap */
}
break
;
case
RW009_CMD_JOIN
:
case
RW009_CMD_EASY_JOIN
:
WIFI_DEBUG
(
"resp_handler RW009_CMD_EASY_JOIN
\n
"
);
...
...
@@ -170,6 +171,7 @@ static void resp_handler(struct rw009_wifi *wifi_device, struct rw009_resp *resp
//dupm
if
(
1
)
{
#ifdef WIFI_DEBUG_ON
rw009_ap_info
*
ap_info
=
&
resp
->
resp
.
ap_info
;
WIFI_DEBUG
(
"JOIN SSID:%-32.32s
\n
"
,
ap_info
->
ssid
);
WIFI_DEBUG
(
"JOIN BSSID:%02X-%02X-%02X-%02X-%02X-%02X
\n
"
,
...
...
@@ -183,17 +185,34 @@ static void resp_handler(struct rw009_wifi *wifi_device, struct rw009_resp *resp
WIFI_DEBUG
(
"JOIN rate:%dMbps
\n
"
,
ap_info
->
max_data_rate
/
1000
);
WIFI_DEBUG
(
"JOIN channel:%d
\n
"
,
ap_info
->
channel
);
WIFI_DEBUG
(
"JOIN security:%08X
\n\n
"
,
ap_info
->
security
);
#endif
/* WIFI_DEBUG_ON */
}
break
;
case
RW009_CMD_RSSI
:
// TODO: client RSSI.
{
rw009_ap_info
*
ap_info
=
&
resp
->
resp
.
ap_info
;
wifi_device
->
ap_info
.
rssi
=
ap_info
->
rssi
;
WIFI_DEBUG
(
"current RSSI: %d
\n
"
,
wifi_device
->
ap_info
.
rssi
);
}
break
;
case
RW009_CMD_SOFTAP
:
{
if
(
resp
->
result
==
0
)
{
rw009_ap_info
*
ap_info
=
&
resp
->
resp
.
ap_info
;
wifi_device
->
a
p_info
.
rssi
=
ap_info
->
rssi
;
WIFI_DEBUG
(
"current RSSI: %d
\n
"
,
wifi_device
->
ap_info
.
rssi
);
;
wifi_device
->
a
ctive
=
1
;
eth_device_linkchange
(
&
wifi_device
->
parent
,
RT_TRUE
);
}
break
;
else
{
WIFI_DEBUG
(
"RW009_CMD_EASY_JOIN result: %d
\n
"
,
resp
->
result
);
}
}
break
;
default:
WIFI_DEBUG
(
"resp_handler %d
\n
"
,
resp
->
cmd
);
...
...
@@ -258,6 +277,10 @@ static rt_err_t rw009_cmd(struct rw009_wifi *wifi_device, uint32_t cmd, void *ar
{
wifi_cmd
->
len
=
sizeof
(
rw009_cmd_rssi
);
}
else
if
(
cmd
==
RW009_CMD_SOFTAP
)
{
wifi_cmd
->
len
=
sizeof
(
rw009_cmd_softap
);
}
else
{
WIFI_DEBUG
(
"unkown RW009 CMD %d
\n
"
,
cmd
);
...
...
@@ -603,7 +626,7 @@ static void spi_wifi_data_thread_entry(void *parameter)
}
}
rt_err_t
rt_hw_wifi_init
(
const
char
*
spi_device_name
)
rt_err_t
rt_hw_wifi_init
(
const
char
*
spi_device_name
,
wifi_mode_t
mode
)
{
/* align and struct size check. */
RT_ASSERT
(
(
SPI_MAX_DATA_LEN
&
0x03
)
==
0
);
...
...
@@ -689,10 +712,12 @@ rt_err_t rt_hw_wifi_init(const char *spi_device_name)
/* init: get mac address */
{
rw009_cmd_init
init
;
init
.
mode
=
mode
;
WIFI_DEBUG
(
"wifi_control RW009_CMD_INIT
\n
"
);
rw009_wifi_control
((
rt_device_t
)
&
rw009_wifi_device
,
RW009_CMD_INIT
,
(
void
*
)
1
);
// 0: firmware, 1: STA, 2:AP
(
void
*
)
&
init
);
// 0: firmware, 1: STA, 2:AP
}
...
...
@@ -736,6 +761,28 @@ rt_err_t rw009_join(const char * SSID, const char * passwd)
return
result
;
}
rt_err_t
rw009_softap
(
const
char
*
SSID
,
const
char
*
passwd
,
uint32_t
security
,
uint32_t
channel
)
{
rt_err_t
result
;
rt_device_t
wifi_device
;
rw009_cmd_softap
softap
;
wifi_device
=
rt_device_find
(
"w0"
);
if
(
wifi_device
==
RT_NULL
)
return
-
RT_ENOSYS
;
strncpy
(
softap
.
ssid
,
SSID
,
sizeof
(
softap
.
ssid
)
);
strncpy
(
softap
.
passwd
,
passwd
,
sizeof
(
softap
.
passwd
)
);
softap
.
security
=
security
;
softap
.
channel
=
channel
;
result
=
rt_device_control
(
wifi_device
,
RW009_CMD_SOFTAP
,
(
void
*
)
&
softap
);
return
result
;
}
int32_t
rw009_rssi
(
void
)
{
rt_err_t
result
;
...
...
components/drivers/spi/spi_wifi_rw009.h
浏览文件 @
31d214ff
...
...
@@ -83,6 +83,12 @@ struct spi_data_packet
#define SSID_NAME_LENGTH_MAX (32)
#define PASSWORD_LENGTH_MAX (64)
typedef
enum
{
MODE_STATION
=
0
,
MODE_SOFTAP
=
1
,
}
wifi_mode_t
;
typedef
struct
_rw009_ap_info
{
char
ssid
[
SSID_NAME_LENGTH_MAX
];
...
...
@@ -122,6 +128,15 @@ typedef struct _rw009_cmd_rssi
uint8_t
bssid
[
8
];
// 6byte + 2byte PAD.
}
rw009_cmd_rssi
;
typedef
struct
_rw009_cmd_softap
{
char
ssid
[
SSID_NAME_LENGTH_MAX
];
char
passwd
[
PASSWORD_LENGTH_MAX
];
uint32_t
security
;
/* Security type. */
uint32_t
channel
;
/* Radio channel that the AP beacon was received on */
}
rw009_cmd_softap
;
typedef
struct
_rw009_resp_join
{
rw009_ap_info
ap_info
;
...
...
@@ -139,6 +154,7 @@ struct rw009_cmd
rw009_cmd_easy_join
easy_join
;
rw009_cmd_join
join
;
rw009_cmd_rssi
rssi
;
rw009_cmd_softap
softap
;
}
params
;
};
...
...
@@ -162,6 +178,39 @@ struct rw009_resp
#define RW009_CMD_JOIN 130
#define RW009_CMD_EASY_JOIN 131
#define RW009_CMD_RSSI 132
#define RW009_CMD_SOFTAP 133
/** cond !ADDTHIS*/
#define SHARED_ENABLED 0x00008000
#define WPA_SECURITY 0x00200000
#define WPA2_SECURITY 0x00400000
#define WPS_ENABLED 0x10000000
#define WEP_ENABLED 0x0001
#define TKIP_ENABLED 0x0002
#define AES_ENABLED 0x0004
#define WSEC_SWFLAG 0x0008
/** endcond */
/**
* Enumeration of Wi-Fi security modes
*/
typedef
enum
{
SECURITY_OPEN
=
0
,
/**< Open security */
SECURITY_WEP_PSK
=
WEP_ENABLED
,
/**< WEP Security with open authentication */
SECURITY_WEP_SHARED
=
(
WEP_ENABLED
|
SHARED_ENABLED
),
/**< WEP Security with shared authentication */
SECURITY_WPA_TKIP_PSK
=
(
WPA_SECURITY
|
TKIP_ENABLED
),
/**< WPA Security with TKIP */
SECURITY_WPA_AES_PSK
=
(
WPA_SECURITY
|
AES_ENABLED
),
/**< WPA Security with AES */
SECURITY_WPA2_AES_PSK
=
(
WPA2_SECURITY
|
AES_ENABLED
),
/**< WPA2 Security with AES */
SECURITY_WPA2_TKIP_PSK
=
(
WPA2_SECURITY
|
TKIP_ENABLED
),
/**< WPA2 Security with TKIP */
SECURITY_WPA2_MIXED_PSK
=
(
WPA2_SECURITY
|
AES_ENABLED
|
TKIP_ENABLED
),
/**< WPA2 Security with AES & TKIP */
SECURITY_WPS_OPEN
=
WPS_ENABLED
,
/**< WPS with open security */
SECURITY_WPS_SECURE
=
(
WPS_ENABLED
|
AES_ENABLED
),
/**< WPS with AES security */
SECURITY_UNKNOWN
=
-
1
,
/**< May be returned by scan function if security is unknown. Do not pass this to the join function! */
SECURITY_FORCE_32_BIT
=
0x7fffffff
/**< Exists only to force wiced_security_t type to 32 bits */
}
security_t
;
/* porting */
extern
void
spi_wifi_hw_init
(
void
);
...
...
@@ -169,7 +218,9 @@ extern void spi_wifi_int_cmd(rt_bool_t cmd);
extern
rt_bool_t
spi_wifi_is_busy
(
void
);
/* export API. */
extern
rt_err_t
rt_hw_wifi_init
(
const
char
*
spi_device_name
,
wifi_mode_t
mode
);
extern
int32_t
rw009_rssi
(
void
);
extern
rt_err_t
rw009_join
(
const
char
*
SSID
,
const
char
*
passwd
);
extern
rt_err_t
rw009_softap
(
const
char
*
SSID
,
const
char
*
passwd
,
uint32_t
security
,
uint32_t
channel
);
#endif // SPI_WIFI_H_INCLUDED
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录