mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 20:08:15 +08:00
wifi: Support the wifi operations based on the bss file.
Add support for BSS file-based WiFi simulation. Signed-off-by: liqinhui <liqinhui@xiaomi.com>
This commit is contained in:
+23
-1
@@ -284,16 +284,38 @@ config SIM_NETDEV_NUMBER
|
|||||||
Note that only one network device will be brought up by netinit automatically,
|
Note that only one network device will be brought up by netinit automatically,
|
||||||
others will be kept in DOWN state by default.
|
others will be kept in DOWN state by default.
|
||||||
|
|
||||||
|
if SIM_NETDEV && DRIVERS_IEEE80211 && NETDEV_WIRELESS_HANDLER
|
||||||
|
|
||||||
config SIM_WIFIDEV_NUMBER
|
config SIM_WIFIDEV_NUMBER
|
||||||
int "Number of Simulated WiFi Device"
|
int "Number of Simulated WiFi Device"
|
||||||
default 0
|
default 0
|
||||||
range 0 SIM_NETDEV_NUMBER
|
range 0 SIM_NETDEV_NUMBER
|
||||||
depends on SIM_NETDEV && DRIVERS_IEEE80211 && NETDEV_WIRELESS_HANDLER
|
|
||||||
---help---
|
---help---
|
||||||
The number of simulated wifi network devices.
|
The number of simulated wifi network devices.
|
||||||
|
|
||||||
Note that only one network device will be brought up by netinit automatically,
|
Note that only one network device will be brought up by netinit automatically,
|
||||||
others will be kept in DOWN state by default.
|
others will be kept in DOWN state by default.
|
||||||
|
|
||||||
|
choice
|
||||||
|
prompt "Select SimWiFi Platform"
|
||||||
|
depends on SIM_WIFIDEV_NUMBER != 0
|
||||||
|
default SIM_WIFIDEV_HOST
|
||||||
|
|
||||||
|
config SIM_WIFIDEV_HOST
|
||||||
|
bool "Use the host Wi-Fi interfaces"
|
||||||
|
---help---
|
||||||
|
Use the host Wi-Fi interfaces, which are either simulated by
|
||||||
|
hwsim or the real wireless network cards.
|
||||||
|
|
||||||
|
config SIM_WIFIDEV_PSEUDO
|
||||||
|
bool "Use the Simulated Wi-Fi devices"
|
||||||
|
depends on DRIVERS_WIFI_SIM
|
||||||
|
---help---
|
||||||
|
Use the the Simulated Wi-Fi devices, which are supported by the bss file.
|
||||||
|
endchoice
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
config SIM_NETDEV_VPNKIT_PATH
|
config SIM_NETDEV_VPNKIT_PATH
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ ifeq ($(CONFIG_FS_FAT),y)
|
|||||||
STDLIBS += -lz
|
STDLIBS += -lz
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(CONFIG_SIM_WIFIDEV_NUMBER),0)
|
ifeq ($(CONFIG_SIM_WIFIDEV_HOST),y)
|
||||||
CFLAGS += -DTOPDIR=\"$(TOPDIR)\"
|
CFLAGS += -DTOPDIR=\"$(TOPDIR)\"
|
||||||
CSRCS += sim_wifihost.c
|
CSRCS += sim_wifihost.c
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ if(CONFIG_SIM_X11FB)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT ${CONFIG_SIM_WIFIDEV_NUMBER} EQUAL 0)
|
if(CONFIG_SIM_WIFIDEV_HOST)
|
||||||
add_compile_options(-DTOPDIR=$(TOPDIR))
|
add_compile_options(-DTOPDIR=$(TOPDIR))
|
||||||
list(APPEND SRCS sim_wifihost.c)
|
list(APPEND SRCS sim_wifihost.c)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -70,6 +70,7 @@
|
|||||||
#include <nuttx/net/net.h>
|
#include <nuttx/net/net.h>
|
||||||
#include <nuttx/net/netdev_lowerhalf.h>
|
#include <nuttx/net/netdev_lowerhalf.h>
|
||||||
#include <nuttx/net/pkt.h>
|
#include <nuttx/net/pkt.h>
|
||||||
|
#include <nuttx/net/wifi_sim.h>
|
||||||
|
|
||||||
#include "sim_internal.h"
|
#include "sim_internal.h"
|
||||||
#include "sim_wifihost.h"
|
#include "sim_wifihost.h"
|
||||||
@@ -99,8 +100,10 @@
|
|||||||
|
|
||||||
struct sim_netdev_s
|
struct sim_netdev_s
|
||||||
{
|
{
|
||||||
#if CONFIG_SIM_WIFIDEV_NUMBER != 0
|
#if defined(CONFIG_SIM_WIFIDEV_HOST)
|
||||||
struct sim_wifihost_lowerhalf_s dev;
|
struct sim_wifihost_lowerhalf_s dev;
|
||||||
|
#elif defined(CONFIG_SIM_WIFIDEV_PSEUDO)
|
||||||
|
struct wifi_sim_lowerhalf_s dev;
|
||||||
#else
|
#else
|
||||||
struct netdev_lowerhalf_s dev;
|
struct netdev_lowerhalf_s dev;
|
||||||
#endif
|
#endif
|
||||||
@@ -214,7 +217,11 @@ static int netdriver_ifup(struct netdev_lowerhalf_s *dev)
|
|||||||
#if CONFIG_SIM_WIFIDEV_NUMBER != 0
|
#if CONFIG_SIM_WIFIDEV_NUMBER != 0
|
||||||
if (DEVIDX(dev) < CONFIG_SIM_WIFIDEV_NUMBER)
|
if (DEVIDX(dev) < CONFIG_SIM_WIFIDEV_NUMBER)
|
||||||
{
|
{
|
||||||
|
# if defined(CONFIG_SIM_WIFIDEV_HOST)
|
||||||
if (sim_wifihost_connected((struct sim_wifihost_lowerhalf_s *)dev))
|
if (sim_wifihost_connected((struct sim_wifihost_lowerhalf_s *)dev))
|
||||||
|
# elif defined(CONFIG_SIM_WIFIDEV_PSEUDO)
|
||||||
|
if (wifi_sim_connected((struct wifi_sim_lowerhalf_s *)dev))
|
||||||
|
# endif
|
||||||
{
|
{
|
||||||
netdev_lower_carrier_on(dev);
|
netdev_lower_carrier_on(dev);
|
||||||
}
|
}
|
||||||
@@ -303,8 +310,17 @@ int sim_netdriver_init(void)
|
|||||||
#if CONFIG_SIM_WIFIDEV_NUMBER != 0
|
#if CONFIG_SIM_WIFIDEV_NUMBER != 0
|
||||||
if (devidx < CONFIG_SIM_WIFIDEV_NUMBER)
|
if (devidx < CONFIG_SIM_WIFIDEV_NUMBER)
|
||||||
{
|
{
|
||||||
|
int ret =
|
||||||
|
# if defined(CONFIG_SIM_WIFIDEV_HOST)
|
||||||
sim_wifihost_init((struct sim_wifihost_lowerhalf_s *)dev,
|
sim_wifihost_init((struct sim_wifihost_lowerhalf_s *)dev,
|
||||||
devidx);
|
devidx);
|
||||||
|
# elif defined(CONFIG_SIM_WIFIDEV_PSEUDO)
|
||||||
|
wifi_sim_init((struct wifi_sim_lowerhalf_s *)dev);
|
||||||
|
# endif
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1977,6 +1977,8 @@ int wifi_sim_init(FAR struct wifi_sim_lowerhalf_s *netdev)
|
|||||||
priv->lower = &netdev->lower;
|
priv->lower = &netdev->lower;
|
||||||
netdev->wifi = priv;
|
netdev->wifi = priv;
|
||||||
|
|
||||||
|
priv->mode = IW_MODE_AUTO;
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1996,3 +1998,23 @@ void wifi_sim_remove(FAR struct wifi_sim_lowerhalf_s *netdev)
|
|||||||
kmm_free(netdev->wifi);
|
kmm_free(netdev->wifi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: wifi_sim_connected
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
bool wifi_sim_connected(FAR struct wifi_sim_lowerhalf_s *dev)
|
||||||
|
{
|
||||||
|
FAR struct wifi_sim_s *wifidev = (FAR struct wifi_sim_s *)dev->wifi;
|
||||||
|
|
||||||
|
if (wifidev->mode == IW_MODE_MASTER)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (wifidev->mode == IW_MODE_INFRA)
|
||||||
|
{
|
||||||
|
return wifidev->state == WLAN_STA_STATE_CONNECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ struct wifi_sim_lowerhalf_s
|
|||||||
|
|
||||||
int wifi_sim_init(FAR struct wifi_sim_lowerhalf_s *netdev);
|
int wifi_sim_init(FAR struct wifi_sim_lowerhalf_s *netdev);
|
||||||
void wifi_sim_remove(FAR struct wifi_sim_lowerhalf_s *netdev);
|
void wifi_sim_remove(FAR struct wifi_sim_lowerhalf_s *netdev);
|
||||||
|
bool wifi_sim_connected(FAR struct wifi_sim_lowerhalf_s *dev);
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
Reference in New Issue
Block a user