[bsp][gd32]:gd32vw553h-eval add wifi support#11175
@@ -19,6 +19,15 @@ devices.i2c:
|
||||
- CONFIG_BSP_HW_I2C1_PIN_PB12_PB13=y
|
||||
- CONFIG_BSP_HW_I2C1_CLK=100
|
||||
|
||||
devices.wlan:
|
||||
kconfig:
|
||||
- CONFIG_BSP_USING_WLAN=y
|
||||
- CONFIG_RT_NAME_MAX=24
|
||||
- CONFIG_RT_WLAN_PROT_ENABLE=n
|
||||
- CONFIG_RT_USING_LWIP212=y
|
||||
|
||||
|
||||
|
||||
# ------ peripheral CI ------
|
||||
peripheral.at24c02:
|
||||
kconfig:
|
||||
|
||||
@@ -170,7 +170,51 @@ msh >
|
||||
|
||||
完成上述配置后即可点击调试选项进行调试,调试时boot管脚均置为低电平即可,调试时同样会进行固件下载。
|
||||
|
||||
## 4 注意事项
|
||||
## 4.WIFI使用
|
||||
|
||||
使用ENV,menuconfig,修改和使能下面的配置
|
||||
|
||||
* 修改 RT_NAME_MAX为24
|
||||
|
||||

|
||||
|
||||
* 使能 BSP_USING_WLAN
|
||||
|
||||

|
||||
|
||||
* 修改LWIP的版本为V2.1.2
|
||||
|
||||

|
||||
|
||||
* 关闭 RT_WLAN_PROT_ENABLE
|
||||
|
||||

|
||||
|
||||
进行编译 scons -jx ,下载。
|
||||
|
||||

|
||||
|
||||
可以使用help查看wifi指令,下面演示连接wifi以及ping
|
||||
|
||||

|
||||
|
||||
### 使用NETDEV
|
||||
|
||||
* 使能 RT_USING_NETDEV
|
||||
|
||||

|
||||
|
||||
重新编译,下载。
|
||||
|
||||
* wifi 连接以及ping
|
||||
|
||||

|
||||
|
||||
* ifconfig:
|
||||
|
||||

|
||||
|
||||
## 5 注意事项
|
||||
|
||||
- Cortex-Debug插件优先选用v1.4.4版本,高版本可能会出现与GDB版本不匹配的问题。
|
||||
|
||||
|
||||
@@ -13,6 +13,34 @@ config SOC_GD32VW553H
|
||||
|
||||
menu "Onboard Peripheral Drivers"
|
||||
|
||||
menuconfig BSP_USING_WLAN
|
||||
bool "Enable WiFi (GD32VW553H Internal)"
|
||||
select RT_USING_WIFI
|
||||
select PKG_USING_GD32VW55X_WIFI
|
||||
select RT_USING_MEMHEAP
|
||||
select RT_USING_SYSTEM_WORKQUEUE
|
||||
default n
|
||||
|
||||
if BSP_USING_WLAN
|
||||
config BSP_WLAN_SSID_MAX_LENGTH
|
||||
int "WiFi SSID max length"
|
||||
range 1 32
|
||||
default 32
|
||||
|
||||
config BSP_WLAN_PASSWORD_MAX_LENGTH
|
||||
int "WiFi password max length"
|
||||
range 8 64
|
||||
default 64
|
||||
|
||||
config BSP_WLAN_SCAN_CACHE_NUM
|
||||
int "WiFi scan result cache number"
|
||||
range 4 32
|
||||
default 16
|
||||
|
||||
# Include GD32VW55x WIFI package configuration
|
||||
osource "$(BSP_DIR)/packages/gd32vw55x-wifi/Kconfig"
|
||||
endif
|
||||
|
||||
endmenu
|
||||
|
||||
menu "On-chip Peripheral Drivers"
|
||||
|
||||
@@ -12,12 +12,18 @@ board.c
|
||||
trap_gcc.S
|
||||
''')
|
||||
|
||||
# add WiFi driver
|
||||
if GetDepend(['BSP_USING_WLAN']):
|
||||
src += ['drv_wlan.c']
|
||||
src += ['wifi.c']
|
||||
|
||||
path = [cwd]
|
||||
|
||||
# add startup txt path
|
||||
startup_path_prefix = os.getcwd() + '/../'
|
||||
|
||||
if rtconfig.PLATFORM in ['gcc']:
|
||||
# Use standard peripheral library startup files for compatibility
|
||||
src += [startup_path_prefix + '/packages/gd32-riscv-series-latest/GD32VW55x/RISCV/env_Eclipse/start.S']
|
||||
src += [startup_path_prefix + '/packages/gd32-riscv-series-latest/GD32VW55x/RISCV/env_Eclipse/entry.S']
|
||||
|
||||
|
||||
515
bsp/gd32/risc-v/gd32vw553h-eval/board/drv_wlan.c
Normal file
18
bsp/gd32/risc-v/gd32vw553h-eval/board/drv_wlan.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2025, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2025-12-25 RT-Thread first version
|
||||
*/
|
||||
|
||||
#ifndef __DRV_WIFI_H__
|
||||
#define __DRV_WIFI_H__
|
||||
|
||||
#ifdef RT_USING_WIFI
|
||||
int rt_hw_wlan_init(void);
|
||||
#endif /* RT_USING_WIFI */
|
||||
|
||||
#endif /* __DRV_WIFI_H__ */
|
||||
@@ -2,18 +2,20 @@
|
||||
#include "riscv_encoding.h"
|
||||
|
||||
.macro SAVE_CSR_CONTEXT
|
||||
csrrwi x0, CSR_PUSHMCAUSE, 11
|
||||
csrrwi x0, CSR_PUSHMEPC, 12
|
||||
csrrwi x0, CSR_PUSHMSUBM, 13
|
||||
addi sp, sp, -16
|
||||
csrrwi x0, CSR_PUSHMCAUSE, 1
|
||||
csrrwi x0, CSR_PUSHMEPC, 2
|
||||
csrrwi x0, CSR_PUSHMSUBM, 3
|
||||
.endm
|
||||
|
||||
.macro RESTORE_CSR_CONTEXT
|
||||
LOAD x5, 13*REGBYTES(sp)
|
||||
LOAD x5, 3*REGBYTES(sp)
|
||||
csrw CSR_MSUBM, x5
|
||||
LOAD x5, 12*REGBYTES(sp)
|
||||
LOAD x5, 2*REGBYTES(sp)
|
||||
csrw CSR_MEPC, x5
|
||||
LOAD x5, 11*REGBYTES(sp)
|
||||
LOAD x5, 1*REGBYTES(sp)
|
||||
csrw CSR_MCAUSE, x5
|
||||
addi sp, sp, 16
|
||||
.endm
|
||||
|
||||
.macro DISABLE_MIE
|
||||
@@ -42,4 +44,4 @@ rt_hw_do_after_save_above:
|
||||
|
||||
LOAD ra, 0 * REGBYTES(sp)
|
||||
addi sp, sp, 4
|
||||
ret
|
||||
ret
|
||||
99
bsp/gd32/risc-v/gd32vw553h-eval/board/wifi.c
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2026, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2026-02-25 CYFS first version
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include <board.h>
|
||||
#include "gd32vw55x_platform.h"
|
||||
#include "wrapper_os.h"
|
||||
#include "wifi_management.h"
|
||||
#include "wifi_init.h"
|
||||
#include "user_setting.h"
|
||||
#include "util.h"
|
||||
|
||||
#ifdef RT_USING_WIFI
|
||||
#define START_TASK_STACK_SIZE 512
|
||||
#define START_TASK_PRIO 4
|
||||
|
||||
static void application_init(void)
|
||||
{
|
||||
util_init();
|
||||
|
||||
user_setting_init();
|
||||
|
||||
if (wifi_init())
|
||||
{
|
||||
rt_kprintf("wifi init failed\r\n");
|
||||
} else {
|
||||
/* rt_kprintf("wifi init success\r\n"); */
|
||||
}
|
||||
}
|
||||
|
||||
static rt_sem_t init_done_sem = RT_NULL;
|
||||
|
||||
static void start_task(void *param)
|
||||
{
|
||||
(void)param;
|
||||
|
||||
application_init();
|
||||
/* rt_kprintf("Start task completed, exiting.\n"); */
|
||||
|
||||
/* Note: In RT-Thread, task should exit by returning, not by calling sys_task_delete(NULL).
|
||||
* When the task function returns, RT-Thread will automatically clean up the task.
|
||||
*/
|
||||
|
||||
rt_sem_release(init_done_sem);
|
||||
}
|
||||
|
||||
#endif /* RT_USING_WIFI */
|
||||
|
||||
int wifi_app_init(void)
|
||||
{
|
||||
|
||||
#ifdef RT_USING_WIFI
|
||||
/* Create semaphore for synchronization */
|
||||
init_done_sem = rt_sem_create("init_done", 0, RT_IPC_FLAG_PRIO);
|
||||
if (init_done_sem == RT_NULL)
|
||||
{
|
||||
rt_kprintf("Failed to create semaphore\n");
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
if (sys_task_create_dynamic((const uint8_t *)"start_task",
|
||||
START_TASK_STACK_SIZE, OS_TASK_PRIORITY(START_TASK_PRIO), start_task, NULL) == NULL)
|
||||
{
|
||||
rt_kprintf("Create start task failed\r\n");
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
/* rt_kprintf("Waiting for initialization to complete...\n"); */
|
||||
/* Wait for initialization task to complete */
|
||||
rt_sem_take(init_done_sem, RT_WAITING_FOREVER);
|
||||
/* rt_kprintf("Initialization completed, continuing...\n"); */
|
||||
|
||||
/* Clean up semaphore */
|
||||
rt_sem_delete(init_done_sem);
|
||||
init_done_sem = RT_NULL;
|
||||
|
||||
/* set wifi work mode */
|
||||
rt_wlan_set_mode(RT_WLAN_DEVICE_STA_NAME, RT_WLAN_STATION);
|
||||
rt_wlan_set_mode(RT_WLAN_DEVICE_AP_NAME, RT_WLAN_AP);
|
||||
#ifdef RT_USING_NETDEV
|
||||
rt_thread_mdelay(1000);
|
||||
extern int wifi_netdev_register(void);
|
||||
wifi_netdev_register();
|
||||
#endif /* RT_USING_NETDEV */
|
||||
#endif /* RT_USING_WIFI */
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
INIT_APP_EXPORT(wifi_app_init);
|
||||
|
||||
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 59 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 54 KiB |
@@ -43,14 +43,26 @@ if PLATFORM == 'gcc':
|
||||
OBJDUMP = PREFIX + 'objdump'
|
||||
OBJCPY = PREFIX + 'objcopy'
|
||||
|
||||
DEVICE = ' -march=rv32imafdc -mcmodel=medany -msmall-data-limit=8 -mdiv -mabi=ilp32d -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections '
|
||||
# 使用单精度硬件浮点ABI以匹配预编译的WiFi库 (libwifi.a, libwpas.a, librf.a)
|
||||
# 预编译库架构: rv32imafcbp (包含单精度浮点 'f' 扩展)
|
||||
# 原配置: -march=rv32imafdc -mabi=ilp32d (硬件双精度浮点)
|
||||
# 修改为: -march=rv32imafc -mabi=ilp32f (硬件单精度浮点)
|
||||
# 注意: GCC 8.2.0 不支持 -mpriv-spec 选项,链接时使用 --no-warn-mismatch 忽略特权规范版本差异
|
||||
DEVICE = ' -march=rv32imafc -mcmodel=medany -msmall-data-limit=8 -mabi=ilp32f -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections '
|
||||
|
||||
# C Compilation Parameters
|
||||
CFLAGS = DEVICE + ' -std=gnu11 -DUSE_STDPERIPH_DRIVE -save-temps=obj'
|
||||
# Assembly Compilation Parameters
|
||||
AFLAGS = DEVICE + '-c'+ ' -x assembler-with-cpp'
|
||||
# Linking Parameters
|
||||
LFLAGS = DEVICE + ' -nostartfiles -Xlinker --gc-sections --specs=nano.specs --specs=nosys.specs ' + ' -T ' + LINK_FILE + ' -Wl,-Map=' + MAP_FILE
|
||||
# 添加 --no-warn-mismatch 以忽略预编译库与当前工具链的特权规范版本差异
|
||||
# 添加 WiFi ROM 符号表
|
||||
wifi_pkg_path = os.path.join(os.path.dirname(__file__), 'packages', 'gd32vw55x-wifi-latest')
|
||||
rom_symbol = os.path.join(wifi_pkg_path, 'rom_export', 'symbol', 'rom_symbol_m.gcc')
|
||||
rom_symbol_flag = ''
|
||||
if os.path.exists(rom_symbol):
|
||||
rom_symbol_flag = ' -Wl,--just-symbols=' + rom_symbol
|
||||
LFLAGS = DEVICE + ' -nostartfiles -Xlinker --gc-sections -Xlinker --no-warn-mismatch --specs=nano.specs --specs=nosys.specs ' + rom_symbol_flag + ' -T ' + LINK_FILE + ' -Wl,-Map=' + MAP_FILE
|
||||
|
||||
CPATH = ''
|
||||
LPATH = ''
|
||||
@@ -61,7 +73,7 @@ if PLATFORM == 'gcc':
|
||||
else:
|
||||
CFLAGS += ' -O2'
|
||||
|
||||
CXXFLAGS = CFLAGS
|
||||
CXXFLAGS = CFLAGS
|
||||
|
||||
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
|
||||
|
||||
|
||||
@@ -56,33 +56,35 @@ static int wifi_debug_set_autoconnect(int argc, char *argv[]);
|
||||
#endif
|
||||
|
||||
/* cmd table */
|
||||
static const struct wifi_cmd_des cmd_tab[] =
|
||||
{
|
||||
{"scan", wifi_scan},
|
||||
{"help", wifi_help},
|
||||
{"status", wifi_status},
|
||||
{"join", wifi_join},
|
||||
{"ap", wifi_ap},
|
||||
{"list_sta", wifi_list_sta},
|
||||
{"disc", wifi_disconnect},
|
||||
{"ap_stop", wifi_ap_stop},
|
||||
{"smartconfig", RT_NULL},
|
||||
static const struct wifi_cmd_des cmd_tab[] = {
|
||||
{ "scan", wifi_scan },
|
||||
{ "help", wifi_help },
|
||||
{ "status", wifi_status },
|
||||
{ "join", wifi_join },
|
||||
{ "ap", wifi_ap },
|
||||
{ "list_sta", wifi_list_sta },
|
||||
{ "disc", wifi_disconnect },
|
||||
{ "ap_stop", wifi_ap_stop },
|
||||
{ "smartconfig", RT_NULL },
|
||||
#ifdef RT_WLAN_CMD_DEBUG
|
||||
{"-d", wifi_debug},
|
||||
{ "-d", wifi_debug },
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef RT_WLAN_CMD_DEBUG
|
||||
/* debug cmd table */
|
||||
static const struct wifi_cmd_des debug_tab[] =
|
||||
{
|
||||
{"save_cfg", wifi_debug_save_cfg},
|
||||
{"dump_cfg", wifi_debug_dump_cfg},
|
||||
{"clear_cfg", wifi_debug_clear_cfg},
|
||||
{"dump_prot", wifi_debug_dump_prot},
|
||||
{"mode", wifi_debug_set_mode},
|
||||
{"prot", wifi_debug_set_prot},
|
||||
{"auto", wifi_debug_set_autoconnect},
|
||||
static const struct wifi_cmd_des debug_tab[] = {
|
||||
{ "save_cfg", wifi_debug_save_cfg },
|
||||
{ "dump_cfg", wifi_debug_dump_cfg },
|
||||
{ "clear_cfg", wifi_debug_clear_cfg },
|
||||
#ifdef RT_WLAN_PROT_ENABLE
|
||||
{ "dump_prot", wifi_debug_dump_prot },
|
||||
{ "mode", wifi_debug_set_mode },
|
||||
{ "prot", wifi_debug_set_prot },
|
||||
#else
|
||||
{ "mode", wifi_debug_set_mode },
|
||||
#endif /* RT_WLAN_PROT_ENABLE */
|
||||
{ "auto", wifi_debug_set_autoconnect },
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -171,7 +173,7 @@ static rt_bool_t wifi_info_isequ(struct rt_wlan_info *info1, struct rt_wlan_info
|
||||
is_equ &= rt_memcmp(&info2->ssid.val[0], &info1->ssid.val[0], info1->ssid.len) == 0;
|
||||
}
|
||||
if (is_equ && (rt_memcmp(&info1->bssid[0], bssid_zero, RT_WLAN_BSSID_MAX_LENGTH)) &&
|
||||
(rt_memcmp(&info2->bssid[0], bssid_zero, RT_WLAN_BSSID_MAX_LENGTH)))
|
||||
(rt_memcmp(&info2->bssid[0], bssid_zero, RT_WLAN_BSSID_MAX_LENGTH)))
|
||||
{
|
||||
is_equ &= rt_memcmp(&info1->bssid[0], &info2->bssid[0], RT_WLAN_BSSID_MAX_LENGTH) == 0;
|
||||
}
|
||||
@@ -197,10 +199,11 @@ static rt_err_t wifi_scan_result_cache(struct rt_wlan_info *info)
|
||||
int i, insert = -1;
|
||||
rt_base_t level;
|
||||
|
||||
if ((info == RT_NULL) || (info->ssid.len == 0)) return -RT_EINVAL;
|
||||
if ((info == RT_NULL) || (info->ssid.len == 0))
|
||||
return -RT_EINVAL;
|
||||
|
||||
LOG_D("ssid:%s len:%d mac:%02x:%02x:%02x:%02x:%02x:%02x", info->ssid.val, info->ssid.len,
|
||||
info->bssid[0], info->bssid[1], info->bssid[2], info->bssid[3], info->bssid[4], info->bssid[5]);
|
||||
info->bssid[0], info->bssid[1], info->bssid[2], info->bssid[3], info->bssid[4], info->bssid[5]);
|
||||
|
||||
/* scanning result filtering */
|
||||
level = rt_hw_interrupt_disable();
|
||||
@@ -222,7 +225,7 @@ static rt_err_t wifi_scan_result_cache(struct rt_wlan_info *info)
|
||||
for (i = 0; i < scan_result.num; i++)
|
||||
{
|
||||
if ((info->ssid.len == scan_result.info[i].ssid.len) &&
|
||||
(rt_memcmp(&info->bssid[0], &scan_result.info[i].bssid[0], RT_WLAN_BSSID_MAX_LENGTH) == 0))
|
||||
(rt_memcmp(&info->bssid[0], &scan_result.info[i].bssid[0], RT_WLAN_BSSID_MAX_LENGTH) == 0))
|
||||
{
|
||||
return RT_EOK;
|
||||
}
|
||||
@@ -283,7 +286,7 @@ static rt_err_t wifi_scan_result_cache(struct rt_wlan_info *info)
|
||||
LOG_E("wlan info malloc failed!");
|
||||
return -RT_ENOMEM;
|
||||
}
|
||||
scan_result.num ++;
|
||||
scan_result.num++;
|
||||
|
||||
/* copy info */
|
||||
for (i = 0; i < scan_result.num; i++)
|
||||
@@ -307,10 +310,8 @@ static rt_err_t wifi_scan_result_cache(struct rt_wlan_info *info)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void wifi_scan_result_clean(void)
|
||||
{
|
||||
|
||||
/* If there is data */
|
||||
if (scan_result.num)
|
||||
{
|
||||
@@ -320,68 +321,66 @@ static void wifi_scan_result_clean(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void print_ap_info(struct rt_wlan_info *info,int index)
|
||||
static void print_ap_info(struct rt_wlan_info *info, int index)
|
||||
{
|
||||
char *security;
|
||||
char *security;
|
||||
|
||||
if(index == 0)
|
||||
if (index == 0)
|
||||
{
|
||||
rt_kprintf(" SSID MAC security rssi chn Mbps\n");
|
||||
rt_kprintf("------------------------------- ----------------- -------------- ---- --- ----\n");
|
||||
}
|
||||
|
||||
{
|
||||
rt_kprintf("%-32.32s", &(info->ssid.val[0]));
|
||||
rt_kprintf("%02x:%02x:%02x:%02x:%02x:%02x ",
|
||||
info->bssid[0],
|
||||
info->bssid[1],
|
||||
info->bssid[2],
|
||||
info->bssid[3],
|
||||
info->bssid[4],
|
||||
info->bssid[5]);
|
||||
switch (info->security)
|
||||
{
|
||||
rt_kprintf(" SSID MAC security rssi chn Mbps\n");
|
||||
rt_kprintf("------------------------------- ----------------- -------------- ---- --- ----\n");
|
||||
case SECURITY_OPEN:
|
||||
security = "OPEN";
|
||||
break;
|
||||
case SECURITY_WEP_PSK:
|
||||
security = "WEP_PSK";
|
||||
break;
|
||||
case SECURITY_WEP_SHARED:
|
||||
security = "WEP_SHARED";
|
||||
break;
|
||||
case SECURITY_WPA_TKIP_PSK:
|
||||
security = "WPA_TKIP_PSK";
|
||||
break;
|
||||
case SECURITY_WPA_AES_PSK:
|
||||
security = "WPA_AES_PSK";
|
||||
break;
|
||||
case SECURITY_WPA2_AES_PSK:
|
||||
security = "WPA2_AES_PSK";
|
||||
break;
|
||||
case SECURITY_WPA2_TKIP_PSK:
|
||||
security = "WPA2_TKIP_PSK";
|
||||
break;
|
||||
case SECURITY_WPA2_MIXED_PSK:
|
||||
security = "WPA2_MIXED_PSK";
|
||||
break;
|
||||
case SECURITY_WPS_OPEN:
|
||||
security = "WPS_OPEN";
|
||||
break;
|
||||
case SECURITY_WPS_SECURE:
|
||||
security = "WPS_SECURE";
|
||||
break;
|
||||
default:
|
||||
security = "UNKNOWN";
|
||||
break;
|
||||
}
|
||||
|
||||
{
|
||||
rt_kprintf("%-32.32s", &(info->ssid.val[0]));
|
||||
rt_kprintf("%02x:%02x:%02x:%02x:%02x:%02x ",
|
||||
info->bssid[0],
|
||||
info->bssid[1],
|
||||
info->bssid[2],
|
||||
info->bssid[3],
|
||||
info->bssid[4],
|
||||
info->bssid[5]
|
||||
);
|
||||
switch (info->security)
|
||||
{
|
||||
case SECURITY_OPEN:
|
||||
security = "OPEN";
|
||||
break;
|
||||
case SECURITY_WEP_PSK:
|
||||
security = "WEP_PSK";
|
||||
break;
|
||||
case SECURITY_WEP_SHARED:
|
||||
security = "WEP_SHARED";
|
||||
break;
|
||||
case SECURITY_WPA_TKIP_PSK:
|
||||
security = "WPA_TKIP_PSK";
|
||||
break;
|
||||
case SECURITY_WPA_AES_PSK:
|
||||
security = "WPA_AES_PSK";
|
||||
break;
|
||||
case SECURITY_WPA2_AES_PSK:
|
||||
security = "WPA2_AES_PSK";
|
||||
break;
|
||||
case SECURITY_WPA2_TKIP_PSK:
|
||||
security = "WPA2_TKIP_PSK";
|
||||
break;
|
||||
case SECURITY_WPA2_MIXED_PSK:
|
||||
security = "WPA2_MIXED_PSK";
|
||||
break;
|
||||
case SECURITY_WPS_OPEN:
|
||||
security = "WPS_OPEN";
|
||||
break;
|
||||
case SECURITY_WPS_SECURE:
|
||||
security = "WPS_SECURE";
|
||||
break;
|
||||
default:
|
||||
security = "UNKNOWN";
|
||||
break;
|
||||
}
|
||||
rt_kprintf("%-14.14s ", security);
|
||||
rt_kprintf("%-4d ", info->rssi);
|
||||
rt_kprintf("%3d ", info->channel);
|
||||
rt_kprintf("%4d\n", info->datarate / 1000000);
|
||||
}
|
||||
|
||||
rt_kprintf("%-14.14s ", security);
|
||||
rt_kprintf("%-4d ", info->rssi);
|
||||
rt_kprintf("%3d ", info->channel);
|
||||
rt_kprintf("%4d\n", info->datarate / 1000000);
|
||||
}
|
||||
}
|
||||
|
||||
static void user_ap_info_callback(int event, struct rt_wlan_buff *buff, void *parameter)
|
||||
@@ -399,25 +398,24 @@ static void user_ap_info_callback(int event, struct rt_wlan_buff *buff, void *pa
|
||||
index = *((int *)(parameter));
|
||||
|
||||
ret = wifi_scan_result_cache(info);
|
||||
if(ret == RT_EOK)
|
||||
if (ret == RT_EOK)
|
||||
{
|
||||
if(scan_filter == RT_NULL ||
|
||||
(scan_filter != RT_NULL &&
|
||||
scan_filter->ssid.len == info->ssid.len &&
|
||||
rt_memcmp(&scan_filter->ssid.val[0], &info->ssid.val[0], scan_filter->ssid.len) == 0))
|
||||
if (scan_filter == RT_NULL ||
|
||||
(scan_filter != RT_NULL &&
|
||||
scan_filter->ssid.len == info->ssid.len &&
|
||||
rt_memcmp(&scan_filter->ssid.val[0], &info->ssid.val[0], scan_filter->ssid.len) == 0))
|
||||
{
|
||||
/*Check whether a new ap is added*/
|
||||
if (last_num < scan_result.num)
|
||||
{
|
||||
/*Print the info*/
|
||||
print_ap_info(info,index);
|
||||
print_ap_info(info, index);
|
||||
}
|
||||
|
||||
index++;
|
||||
*((int *)(parameter)) = index;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
static int wifi_scan(int argc, char *argv[])
|
||||
{
|
||||
@@ -436,14 +434,14 @@ static int wifi_scan(int argc, char *argv[])
|
||||
info = &filter;
|
||||
}
|
||||
|
||||
ret = rt_wlan_register_event_handler(RT_WLAN_EVT_SCAN_REPORT,user_ap_info_callback,&i);
|
||||
if(ret != RT_EOK)
|
||||
ret = rt_wlan_register_event_handler(RT_WLAN_EVT_SCAN_REPORT, user_ap_info_callback, &i);
|
||||
if (ret != RT_EOK)
|
||||
{
|
||||
LOG_E("Scan register user callback error:%d!\n",ret);
|
||||
LOG_E("Scan register user callback error:%d!\n", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(info)
|
||||
if (info)
|
||||
{
|
||||
scan_filter = info;
|
||||
}
|
||||
@@ -451,14 +449,14 @@ static int wifi_scan(int argc, char *argv[])
|
||||
|
||||
/*Todo: what can i do for it return val */
|
||||
ret = rt_wlan_scan_with_info(info);
|
||||
if(ret != RT_EOK)
|
||||
if (ret != RT_EOK)
|
||||
{
|
||||
LOG_E("Scan with info error:%d!\n",ret);
|
||||
LOG_E("Scan with info error:%d!\n", ret);
|
||||
}
|
||||
|
||||
/* clean scan result */
|
||||
wifi_scan_result_clean();
|
||||
if(info)
|
||||
if (info)
|
||||
{
|
||||
scan_filter = RT_NULL;
|
||||
}
|
||||
@@ -472,7 +470,7 @@ static int wifi_join(int argc, char *argv[])
|
||||
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 */
|
||||
@@ -678,7 +676,12 @@ static int wifi_debug_dump_prot(int argc, char *argv[])
|
||||
{
|
||||
if (argc == 1)
|
||||
{
|
||||
#ifdef RT_WLAN_PROT_ENABLE
|
||||
rt_wlan_prot_dump();
|
||||
#else
|
||||
rt_kprintf("wlan protocol disabled\r\n");
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -720,7 +723,12 @@ static int wifi_debug_set_prot(int argc, char *argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef RT_WLAN_PROT_ENABLE
|
||||
rt_wlan_prot_attach(argv[2], argv[1]);
|
||||
#else
|
||||
rt_kprintf("wlan protocol disabled\r\n");
|
||||
return -1;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,10 @@ path = [cwd]
|
||||
|
||||
src = Glob('*.c')
|
||||
|
||||
# 如果使用了GD32 WiFi包,则排除sys_arch.c(GD32有自己的实现)
|
||||
if GetDepend(['PKG_USING_GD32VW55X_WIFI']):
|
||||
src = [f for f in src if not str(f).endswith('sys_arch.c')]
|
||||
|
||||
group = DefineGroup('lwIP', src, depend = ['RT_USING_LWIP'], CPPPATH = path)
|
||||
|
||||
Return('group')
|
||||
|
||||