1 Star 0 Fork 39

fish / drivers_peripheral_wlan

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 8.96 KB
一键复制 编辑 原始数据 按行查看 历史
joseph 提交于 2021-03-16 14:05 . Description:modify readme

WLAN

Introduction

This repository defines and implements the WLAN-related Hardware Driver Interfaces (HDIs) which provide the following functionalities:

  1. Creating and stopping a channel between the hardware abstraction layer (HAL) and the WLAN driver
  2. Obtaining the WLAN features supported by the device
  3. Creating a WLAN feature instance

Figure 1 WLAN driver module architecture

Directory Structure

The directory structure of the WLAN repository is as follows:

/drivers/peripheral/wlan
├── client             # Client that implements the communication between the user space and kernel space
│   └── include       # Client header files
│   └── src           # Client code
├── hal                # HAL code
│   └── include       # HAL header files
│   └── src           # HAL code implementation
├── interfaces         # APIs exposed externally
│   └── include       # Header files containing APIs exposed externally

Available APIs

The WLAN HAL module provides APIs for the Wi-Fi service, such as creating and destroying an IWiFi object and setting the MAC address.

Table 1 APIs provided by the WLAN HAL module

Header File

API

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.

Usage Guidelines

The following describes how to use the WLAN HAL module.

  1. Call the WifiConstruct function to create an IWiFi object.
  2. Use the created IWiFi object to call the start function to create a channel between the HAL and the driver and obtain the driver NIC information.
  3. Call the createFeature function to create an AP feature or station feature. You can call functions to perform operations on the created feature (use an AP feature as an example).
  4. Call functions to perform operations, such as calling the setMacAddress function to set the MAC address and calling the getDeviceMacAddress function to obtain the device MAC address.
  5. Call the destroyFeature function to destroy the created feature.
  6. Call the stop function to stop the channel between the HAL and the driver.
  7. Call the WifiDestruct function to destroy the IWiFi object.

The sample code is as follows:

#include "wifi_hal.h"
#include "wifi_hal_sta_feature.h"
#include "wifi_hal_ap_feature.h"
#include "wifi_hal_cmd.h"
#include "wifi_hal_event.h"

#define MAC_LEN 6

static void *hal_main()
{
    int ret;
    struct IWiFi *wifi;

    /* Create an IWiFi object. */
    ret = WifiConstruct(&wifi);
    if (ret != 0 || wifi == NULL) {
        return;
    }

    /* Create a channel between the HAL and the driver. */
    ret = wifi->start(wifi);
    if (ret != 0) {
        return;
    }

    /* Create an AP feature. */
    ret = wifi->createFeature(PROTOCOL_80211_IFTYPE_AP, (struct IWiFiBaseFeature **)&apFeature);
    if (ret != 0) {
        return;
    }

    /* Obtain the device MAC address. */
    unsigned char mac[MAC_LEN] = {0};
    ret = apFeature->baseFeature.getDeviceMacAddress((struct IWiFiBaseFeature *)apFeature, mac, MAC_LEN);
    if (ret != 0) {
        return;
    }

    /* Destroy the created AP feature. */
    ret = wifi->destroyFeature((struct IWiFiBaseFeature *)apFeature);
    if (ret != 0) {
        return;
    }

    /* Stop the created channel. */
    ret = wifi->stop(wifi);
    if (ret != 0) {
        return;
    }

    /* Destroy the created IWiFi object. */
    ret = WifiDestruct(&wifi);
    if (ret != 0) {
        return;
    }
    return;
}

Repositories Involved

Driver subsystem

drivers_framework

1
https://gitee.com/fish_neil/drivers_peripheral_wlan.git
git@gitee.com:fish_neil/drivers_peripheral_wlan.git
fish_neil
drivers_peripheral_wlan
drivers_peripheral_wlan
master

搜索帮助