1 Star 0 Fork 5.1K

youguilin / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
WLAN开发概述.md 16.81 KB
一键复制 编辑 原始数据 按行查看 历史
mamingshuai 提交于 2021-06-02 01:00 . update OpenHarmony 2.0 Canary

WLAN开发概述

简介

WLAN是基于HDF(Hardware Driver Foundation)驱动框架开发的模块,该模块可实现跨操作系统迁移,自适应器件差异,模块化拼装编译等功能。各WLAN厂商驱动开发人员可根据WLAN模块提供的向下统一接口适配各自的驱动代码,实现如下能力:建立/关闭WLAN热点、扫描、关联WLAN热点等;对HDI层向上提供能力如下:设置MAC地址、设置发射功率、获取设备的MAC地址等。WLAN模块框架图如下:

图 1 WLAN框架

WLAN驱动接口架构

WLAN模块有三部分对外开放的API接口,如下图2所示:

  1. 对HDI层提供的能力接口。

  2. 驱动直接调用WLAN模块能力接口。

  3. 提供给各厂商实现的能力接口。

图 2 WLAN模块开放能力分布图

接口说明

WLAN驱动模块提供给驱动开发人员可直接调用的能力接口,主要功能有:创建/释放WifiModule、关联/取消关联、申请/释放NetBuf、lwip的pbuf和NetBuf的相互转换等。提供的部分接口说明如表1所示:

表 1 可直接调用的接口

头文件

接口名称

功能描述

wifi_module.h

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

基于HDF开发WLAN驱动时,创建一个WifiModule。

void WifiModuleDelete(struct WifiModule *module);

基于HDF开发WLAN驱动时,删除并释放WifiModule所有数据。

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

基于HDF开发WLAN驱动时,从WifiModule删除一个功能组件。

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

基于HDF开发WLAN驱动时,注册一个功能组件到WifiModule。

wifi_mac80211_ops.h

int32_t (*startAp)(NetDevice *netDev);

启动AP。

int32_t (*stopAp)(NetDevice *netDev);

停止AP。

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

开始关联。

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

取消关联。

hdf_netbuf.h

static inline void NetBufQueueInit(struct NetBufQueue *q);

初始化NetBuf队列。

struct NetBuf *NetBufAlloc(uint32_t size);

申请NetBuf。

void NetBufFree(struct NetBuf *nb);

释放NetBuf。

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

lwip的pbuf转换为NetBuf。

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

NetBuf转换为lwip的pbuf。

同时WLAN驱动模块也提供了需要驱动开发人员实现的能力接口,主要功能有:初始化/注销NetDevice、打开/关闭NetDevice、获取NetDevice的状态等。提供的部分接口说明如表2所示:

表 2 需要开发人员实现的接口

头文件

接口名称

功能描述

net_device.h

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

初始化NetDevice。

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

获取NetDevice的状态。

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

设置Mac地址。

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

注销NetDevice。

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

打开NetDevice。

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

关闭NetDevice。

WLAN驱动模块对HDI层提供的能力接口,主要功能有:创建/销毁 IWiFi对象、设置MAC地址等。提供的部分接口说明如表3所示:

表 3 HAL层对外接口

头文件

接口名称

功能描述

wifi_hal.h

int32_t WifiConstruct(struct IWiFi **wifiInstance);

创建IWiFi对象,提供IWiFi基本能力。

int32_t WifiDestruct(struct IWiFi **wifiInstance);

销毁IWiFi对象。

int32_t (*start)(struct IWiFi *);

创建HAL和驱动之间的通道及获取驱动支持的网卡信息。

int32_t (*stop)(struct IWiFi *);

销毁通道。

wifi_hal_base_feature.h

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

获取特性的类型。

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

设置MAC地址。

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

获取设备持久化的MAC地址。

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

设置发射功率。

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

搜索帮助