1 Star 0 Fork 4.9K

bill / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
wlanoverview.md 18.90 KB
一键复制 编辑 原始数据 按行查看 历史
NEEN 提交于 2021-03-12 17:59 . !197 Docs Update version 1.0.1

WLAN Overview

Introduction

The WLAN module is developed based on the Hardware Driver Foundation (HDF). It supports cross-OS migration, component adaptation, and modular assembly and compilation. Based on the unified APIs provided by the WLAN module, driver developers of WLAN vendors can adapt their driver code and are capable of creating, disabling, scanning, and connecting to WLAN hotspots. The WLAN driver provides the Hardware Driver Interface (HDI) layer with the capabilities of setting and obtaining the device MAC address and setting the transmit power. The following figure shows the framework of the WLAN module:

Figure 1 WLAN framework

WLAN Driver API Architecture

The WLAN module provides the following three types of APIs:

  1. Capability APIs for the HDI layer

  2. Capability APIs directly invoked by drivers

  3. Capability APIs for vendors

Figure 2 Available APIs of the WLAN module

Available APIs

The WLAN driver module provides APIs that can be directly called by driver developers, such as creating/releasing a WifiModule, connecting to/disconnecting from a WLAN hotspot, applying for/releasing a NetBuf, and converting between the pbuf structure of Lightweight IP (lwIP) and a NetBuf. Table 1 provides some APIs.

Table 1 APIs that can be directly called by driver developers

File

Function

Description

wifi_module.h

struct WifiModule *WifiModuleCreate(const struct HdfConfigWifiModuleConfig *config);

Creates a WifiModule.

void WifiModuleDelete(struct WifiModule *module);

Deletes and releases data of a WifiModule.

int32_t DelFeature(struct WifiModule *module, uint16_t featureType);

Deletes a feature from a WifiModule.

int32_t AddFeature(struct WifiModule *module, uint16_t featureType, struct WifiFeature *featureData);

Adds a feature to a WifiModule.

wifi_mac80211_ops.h

int32_t (*startAp)(NetDevice *netDev);

Starts an AP.

int32_t (*stopAp)(NetDevice *netDev);

Stops an AP.

int32_t (*connect)(NetDevice *netDev, WifiConnectParams *param);

Connects to a hotspot.

int32_t (*disconnect)(NetDevice *netDev, uint16_t reasonCode);

Disconnects from a hotspot.

hdf_netbuf.h

static inline void NetBufQueueInit(struct NetBufQueue *q);

Initializes a NetBuf queue.

struct NetBuf *NetBufAlloc(uint32_t size);

Applies for a NetBuf.

void NetBufFree(struct NetBuf *nb);

Releases a NetBuf.

struct NetBuf *Pbuf2NetBuf(const struct NetDevice *netdev, struct pbuf *lwipBuf);

Converts the pbuf structure of lwIP to a NetBuf.

struct pbuf *NetBuf2Pbuf(const struct NetBuf *nb);

Converts a NetBuf to the pbuf structure of lwIP.

The WLAN driver module provides APIs for driver developers, such as initializing/deregistering, opening/stopping a NetDevice, and obtaining the state of a NetDevice. Table 2 provides some APIs.

Table 2 APIs for driver developers of WLAN vendors to implement

File

Function

Description

net_device.h

int32_t (*init)(struct NetDevice *netDev);

Initializes a NetDevice.

struct NetDevStats *(*getStats)(struct NetDevice *netDev);

Obtains the state of a NetDevice.

int32_t (*setMacAddr)(struct NetDevice *netDev, void *addr);

Sets the MAC address.

void (*deInit)(struct NetDevice *netDev);

Deinitializes a NetDevice.

int32_t (*open)(struct NetDevice *netDev);

Opens a NetDevice.

int32_t (*stop)(struct NetDevice *netDev);

Stops a NetDevice.

The WLAN driver provides the HDI layer with the APIs for creating and destroying an IWiFi object and setting the MAC address. Table 3 provides some APIs.

Table 3 APIs provided by the WLAN HAL module

Header File

Function

Description

wifi_hal.h

int32_t WifiConstruct(struct IWiFi **wifiInstance);

Creates an IWiFi object with basic capabilities.

int32_t WifiDestruct(struct IWiFi **wifiInstance);

Destroys an IWiFi object.

int32_t (*start)(struct IWiFi *);

Creates a channel between the HAL and the driver and obtains the NIC supported by the driver.

int32_t (*stop)(struct IWiFi *);

Stops the channel between the HAL and the driver.

wifi_hal_base_feature.h

int32_t (*getFeatureType)(const struct IWiFiBaseFeature *);

Obtains the feature type.

int32_t (*setMacAddress)(const struct IWiFiBaseFeature *, unsigned char *, uint8_t);

Sets the MAC address.

int32_t (*getDeviceMacAddress)(const struct IWiFiBaseFeature *, unsigned char *, uint8_t);

Obtains the device MAC address.

int32_t (*setTxPower)(const struct IWiFiBaseFeature *, int32_t);

Sets the transmit power.

1
https://gitee.com/ximeibaba/docs.git
git@gitee.com:ximeibaba/docs.git
ximeibaba
docs
docs
master

搜索帮助