mirror of
https://github.com/apache/nuttx.git
synced 2026-10-06 13:55:15 +00:00
arch/xtensa: refactor Wi-Fi driver for ESP32|S2|S3
Fixes low and inconsistent bandwidth issues. Adds new configuration options for buffer management. Moves code around to make the implementation cleaner and easier to debug. Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
This commit is contained in:
parent
903b6b168e
commit
20ff68bd65
23 changed files with 4748 additions and 12473 deletions
|
|
@ -1223,12 +1223,6 @@ menuconfig ESPRESSIF_WIFI_BT_COEXIST
|
||||||
menu "Wi-Fi Configuration"
|
menu "Wi-Fi Configuration"
|
||||||
depends on ESPRESSIF_WIFI
|
depends on ESPRESSIF_WIFI
|
||||||
|
|
||||||
config ESPRESSIF_WLAN
|
|
||||||
bool "WLAN"
|
|
||||||
default y
|
|
||||||
---help---
|
|
||||||
Enable WLAN support
|
|
||||||
|
|
||||||
menu "ESP WPA-Supplicant"
|
menu "ESP WPA-Supplicant"
|
||||||
|
|
||||||
config WPA_WAPI_PSK
|
config WPA_WAPI_PSK
|
||||||
|
|
@ -1241,8 +1235,8 @@ config WPA_WAPI_PSK
|
||||||
config WPA_SUITE_B_192
|
config WPA_SUITE_B_192
|
||||||
bool "Enable NSA suite B support with 192-bit key"
|
bool "Enable NSA suite B support with 192-bit key"
|
||||||
default n
|
default n
|
||||||
select ESP_WIFI_GCMP_SUPPORT
|
select ESPRESSIF_WIFI_GCMP_SUPPORT
|
||||||
select ESP_WIFI_GMAC_SUPPORT
|
select ESPRESSIF_WIFI_GMAC_SUPPORT
|
||||||
---help---
|
---help---
|
||||||
Select this option to enable 192-bit NSA suite-B.
|
Select this option to enable 192-bit NSA suite-B.
|
||||||
This is necessary to support WPA3 192-bit security.
|
This is necessary to support WPA3 192-bit security.
|
||||||
|
|
@ -1273,12 +1267,49 @@ config ESPRESSIF_WIFI_SOFTAP
|
||||||
config ESPRESSIF_WIFI_STATION_SOFTAP
|
config ESPRESSIF_WIFI_STATION_SOFTAP
|
||||||
bool "Station + SoftAP"
|
bool "Station + SoftAP"
|
||||||
|
|
||||||
endchoice # ESP Wi-Fi mode
|
endchoice # ESPRESSIF_WIFI_MODE
|
||||||
|
|
||||||
|
menu "SoftAP Configuration"
|
||||||
|
depends on ESPRESSIF_WIFI_SOFTAP || ESPRESSIF_WIFI_STATION_SOFTAP
|
||||||
|
|
||||||
|
config ESPRESSIF_WIFI_SOFTAP_DEFAULT_SSID
|
||||||
|
string "SoftAP default SSID"
|
||||||
|
default "NuttX"
|
||||||
|
---help---
|
||||||
|
Represents the default SSID configured for the SoftAP when the device is started.
|
||||||
|
|
||||||
|
config ESPRESSIF_WIFI_SOFTAP_DEFAULT_PASSWORD
|
||||||
|
string "SoftAP default password"
|
||||||
|
default "nuttx12345"
|
||||||
|
---help---
|
||||||
|
Represents the default password configured for the SoftAP when the device is started.
|
||||||
|
|
||||||
|
config ESPRESSIF_WIFI_SOFTAP_MAX_CONNECTIONS
|
||||||
|
int "SoftAP max connections"
|
||||||
|
default 3
|
||||||
|
---help---
|
||||||
|
Maximum number of stations connected to the SoftAP.
|
||||||
|
|
||||||
|
config ESPRESSIF_WIFI_SOFTAP_CHANNEL
|
||||||
|
int "SoftAP channel"
|
||||||
|
default 1
|
||||||
|
---help---
|
||||||
|
Channel number for the SoftAP.
|
||||||
|
|
||||||
|
endmenu # SoftAP Configuration
|
||||||
|
|
||||||
|
config ESPRESSIF_WIFI_ENABLE_WPA3_SAE
|
||||||
|
bool "Enable WPA3-Personal"
|
||||||
|
default y
|
||||||
|
---help---
|
||||||
|
Select this option to allow the device to establish a WPA3-Personal connection with eligible AP's.
|
||||||
|
PMF (Protected Management Frames) is a prerequisite feature for a WPA3 connection, it needs to be
|
||||||
|
explicitly configured before attempting connection. Please refer to the Wi-Fi Driver API Guide for details.
|
||||||
|
|
||||||
config ESPRESSIF_WIFI_ENABLE_SAE_PK
|
config ESPRESSIF_WIFI_ENABLE_SAE_PK
|
||||||
bool "Enable SAE-PK"
|
bool "Enable SAE-PK"
|
||||||
|
depends on ESPRESSIF_WIFI_ENABLE_WPA3_SAE
|
||||||
default y
|
default y
|
||||||
depends on ESP_WIFI_ENABLE_SAE_H2E
|
|
||||||
---help---
|
---help---
|
||||||
Select this option to enable SAE-PK
|
Select this option to enable SAE-PK
|
||||||
|
|
||||||
|
|
@ -1288,7 +1319,15 @@ config ESPRESSIF_WIFI_ENABLE_SAE_H2E
|
||||||
---help---
|
---help---
|
||||||
Select this option to enable SAE-H2E
|
Select this option to enable SAE-H2E
|
||||||
|
|
||||||
config ESP_WIFI_ENABLE_WPA3_OWE_STA
|
config ESPRESSIF_WIFI_SOFTAP_SAE_SUPPORT
|
||||||
|
bool "Enable WPA3 Personal(SAE) SoftAP"
|
||||||
|
default y
|
||||||
|
depends on ESPRESSIF_WIFI_ENABLE_WPA3_SAE
|
||||||
|
depends on ESPRESSIF_WIFI_SOFTAP || ESPRESSIF_WIFI_STATION_SOFTAP
|
||||||
|
---help---
|
||||||
|
Select this option to enable SAE support in softAP mode.
|
||||||
|
|
||||||
|
config ESPRESSIF_WIFI_ENABLE_WPA3_OWE_STA
|
||||||
bool "Enable OWE STA"
|
bool "Enable OWE STA"
|
||||||
default y
|
default y
|
||||||
---help---
|
---help---
|
||||||
|
|
@ -1296,41 +1335,166 @@ config ESP_WIFI_ENABLE_WPA3_OWE_STA
|
||||||
PMF (Protected Management Frames) is a prerequisite feature for a WPA3 connection, it needs to be
|
PMF (Protected Management Frames) is a prerequisite feature for a WPA3 connection, it needs to be
|
||||||
explicitly configured before attempting connection. Please refer to the Wi-Fi Driver API Guide for details.
|
explicitly configured before attempting connection. Please refer to the Wi-Fi Driver API Guide for details.
|
||||||
|
|
||||||
config ESPRESSIF_WIFI_STATIC_RXBUF_NUM
|
choice ESPRESSIF_WIFI_MGMT_RX_BUFFER
|
||||||
int "Wi-Fi static RX buffer number"
|
prompt "Type of WiFi RX MGMT buffers"
|
||||||
|
default ESPRESSIF_WIFI_STATIC_RX_MGMT_BUFFER
|
||||||
|
help
|
||||||
|
Select type of WiFi RX MGMT buffers:
|
||||||
|
|
||||||
|
If "Static" is selected, WiFi RX MGMT buffers are allocated when WiFi is initialized and released
|
||||||
|
when WiFi is de-initialized. The size of each static RX MGMT buffer is fixed to about 500 Bytes.
|
||||||
|
|
||||||
|
If "Dynamic" is selected, each WiFi RX MGMT buffer is allocated as needed when a MGMT data frame is
|
||||||
|
received. The MGMT buffer is freed after the MGMT data frame has been processed by the WiFi driver.
|
||||||
|
|
||||||
|
config ESPRESSIF_WIFI_STATIC_RX_MGMT_BUFFER
|
||||||
|
bool "Static"
|
||||||
|
config ESPRESSIF_WIFI_DYNAMIC_RX_MGMT_BUFFER
|
||||||
|
bool "Dynamic"
|
||||||
|
endchoice
|
||||||
|
|
||||||
|
config ESPRESSIF_WIFI_DYNAMIC_RX_MGMT_BUFFER_TYPE
|
||||||
|
int
|
||||||
|
default 0 if ESPRESSIF_WIFI_STATIC_RX_MGMT_BUFFER
|
||||||
|
default 1 if ESPRESSIF_WIFI_DYNAMIC_RX_MGMT_BUFFER
|
||||||
|
|
||||||
|
config ESPRESSIF_WIFI_STATIC_RX_BUFFER_NUM
|
||||||
|
int "Max number of WiFi static RX buffers"
|
||||||
|
range 2 25
|
||||||
default 10
|
default 10
|
||||||
|
---help---
|
||||||
|
Set the number of WiFi static RX buffers. Each buffer takes approximately 1.6KB of RAM.
|
||||||
|
The static rx buffers are allocated when esp_wifi_init is called, they are not freed
|
||||||
|
until esp_wifi_deinit is called.
|
||||||
|
|
||||||
config ESPRESSIF_WIFI_DYNAMIC_RXBUF_NUM
|
WiFi hardware use these buffers to receive all 802.11 frames.
|
||||||
int "Wi-Fi dynamic RX buffer number"
|
A higher number may allow higher throughput but increases memory use. If ESPRESSIF_WIFI_AMPDU_RX_ENABLED
|
||||||
|
is enabled, this value is recommended to set equal or bigger than ESPRESSIF_WIFI_RX_BA_WIN in order to
|
||||||
|
achieve better throughput and compatibility with both stations and APs.
|
||||||
|
|
||||||
|
config ESPRESSIF_WIFI_DYNAMIC_RX_BUFFER_NUM
|
||||||
|
int "Max number of WiFi dynamic RX buffers"
|
||||||
default 32
|
default 32
|
||||||
|
---help---
|
||||||
|
Set the number of WiFi dynamic RX buffers, 0 means unlimited RX buffers will be allocated
|
||||||
|
(provided sufficient free RAM). The size of each dynamic RX buffer depends on the size of
|
||||||
|
the received data frame.
|
||||||
|
|
||||||
config ESPRESSIF_WIFI_DYNAMIC_TXBUF_NUM
|
For each received data frame, the WiFi driver makes a copy to an RX buffer and then delivers
|
||||||
int "Wi-Fi dynamic TX buffer number"
|
it to the high layer TCP/IP stack. The dynamic RX buffer is freed after the higher layer has
|
||||||
|
successfully received the data frame.
|
||||||
|
|
||||||
|
For some applications, WiFi data frames may be received faster than the application can
|
||||||
|
process them. In these cases we may run out of memory if RX buffer number is unlimited (0).
|
||||||
|
|
||||||
|
If a dynamic RX buffer limit is set, it should be at least the number of static RX buffers.
|
||||||
|
|
||||||
|
choice ESPRESSIF_WIFI_TX_BUFFER
|
||||||
|
prompt "Type of WiFi TX buffers"
|
||||||
|
default ESPRESSIF_WIFI_DYNAMIC_TX_BUFFER
|
||||||
|
help
|
||||||
|
Select type of WiFi TX buffers:
|
||||||
|
|
||||||
|
If "Static" is selected, WiFi TX buffers are allocated when WiFi is initialized and released
|
||||||
|
when WiFi is de-initialized. The size of each static TX buffer is fixed to about 1.6KB.
|
||||||
|
|
||||||
|
If "Dynamic" is selected, each WiFi TX buffer is allocated as needed when a data frame is
|
||||||
|
delivered to the Wifi driver from the TCP/IP stack. The buffer is freed after the data frame
|
||||||
|
has been sent by the WiFi driver. The size of each dynamic TX buffer depends on the length
|
||||||
|
of each data frame sent by the TCP/IP layer.
|
||||||
|
|
||||||
|
If PSRAM is enabled, "Static" should be selected to guarantee enough WiFi TX buffers.
|
||||||
|
If PSRAM is disabled, "Dynamic" should be selected to improve the utilization of RAM.
|
||||||
|
|
||||||
|
TODO: There is a special dependency for Dynamic if SPIRAM is enabled.
|
||||||
|
|
||||||
|
config ESPRESSIF_WIFI_STATIC_TX_BUFFER
|
||||||
|
bool "Static"
|
||||||
|
config ESPRESSIF_WIFI_DYNAMIC_TX_BUFFER
|
||||||
|
bool "Dynamic"
|
||||||
|
endchoice
|
||||||
|
|
||||||
|
config ESPRESSIF_WIFI_TX_BUFFER_TYPE
|
||||||
|
int
|
||||||
|
default 0 if ESPRESSIF_WIFI_STATIC_TX_BUFFER
|
||||||
|
default 1 if ESPRESSIF_WIFI_DYNAMIC_TX_BUFFER
|
||||||
|
|
||||||
|
config ESPRESSIF_WIFI_STATIC_TX_BUFFER_NUM
|
||||||
|
int "Max number of WiFi static TX buffers"
|
||||||
|
range 2 64
|
||||||
|
default 16
|
||||||
|
---help---
|
||||||
|
Set the number of WiFi static TX buffers. Each buffer takes approximately 1.6KB of RAM.
|
||||||
|
The static RX buffers are allocated when esp_wifi_init() is called, they are not released
|
||||||
|
until esp_wifi_deinit() is called.
|
||||||
|
|
||||||
|
This value might be reduced to save memory if the application does not need to send
|
||||||
|
frames at a high rate.
|
||||||
|
|
||||||
|
For each transmitted data frame from the higher layer TCP/IP stack, the WiFi driver makes a
|
||||||
|
copy of it in a TX buffer. For some applications especially UDP applications, the upper
|
||||||
|
layer can deliver frames faster than WiFi layer can transmit. In these cases, we may run out
|
||||||
|
of TX buffers.
|
||||||
|
|
||||||
|
config ESPRESSIF_WIFI_DYNAMIC_TX_BUFFER_NUM
|
||||||
|
int "Max number of WiFi dynamic TX buffers"
|
||||||
|
range 1 128
|
||||||
default 32
|
default 32
|
||||||
|
---help---
|
||||||
|
Set the number of WiFi dynamic TX buffers. The size of each dynamic TX buffer is not fixed,
|
||||||
|
it depends on the size of each transmitted data frame.
|
||||||
|
|
||||||
config ESPRESSIF_WIFI_TX_AMPDU
|
For each transmitted frame from the higher layer TCP/IP stack, the WiFi driver makes a copy
|
||||||
|
of it in a TX buffer. For some applications, especially UDP applications, the upper layer
|
||||||
|
can deliver frames faster than WiFi layer can transmit. In these cases, we may run out of TX
|
||||||
|
buffers.
|
||||||
|
|
||||||
|
config ESPRESSIF_WIFI_RX_MGMT_BUF_NUM_DEF
|
||||||
|
int "Max number of WiFi RX MGMT buffers"
|
||||||
|
range 1 10
|
||||||
|
default 5
|
||||||
|
help
|
||||||
|
Set the number of WiFi RX_MGMT buffers.
|
||||||
|
For Management buffers, the number of dynamic and static management buffers is the same.
|
||||||
|
|
||||||
|
config ESPRESSIF_WIFI_AMPDU_TX_ENABLED
|
||||||
bool "Wi-Fi TX AMPDU"
|
bool "Wi-Fi TX AMPDU"
|
||||||
default y
|
default y
|
||||||
|
---help---
|
||||||
|
Select this option to enable AMPDU TX feature
|
||||||
|
|
||||||
config ESPRESSIF_WIFI_RX_AMPDU
|
config ESPRESSIF_WIFI_TX_BA_WIN
|
||||||
bool "Wi-Fi RX AMPDU"
|
int "WiFi AMPDU TX BA window size"
|
||||||
default y
|
depends on ESPRESSIF_WIFI_AMPDU_TX_ENABLED
|
||||||
|
range 2 32
|
||||||
config ESPRESSIF_WIFI_RXBA_AMPDU_WZ
|
|
||||||
int "Wi-Fi RX BA AMPDU windown size"
|
|
||||||
default 6
|
default 6
|
||||||
|
|
||||||
config ESPRESSIF_WLAN_PKTBUF_NUM
|
config ESPRESSIF_WIFI_AMPDU_RX_ENABLED
|
||||||
int "WLAN netcard packet buffer number per netcard"
|
bool "WiFi AMPDU RX"
|
||||||
default 16
|
default y
|
||||||
|
---help---
|
||||||
|
Select this option to enable AMPDU RX feature
|
||||||
|
|
||||||
config ESP_WIFI_GCMP_SUPPORT
|
config ESPRESSIF_WIFI_RX_BA_WIN
|
||||||
|
int "WiFi AMPDU RX BA window size"
|
||||||
|
depends on ESPRESSIF_WIFI_AMPDU_RX_ENABLED
|
||||||
|
range 2 32
|
||||||
|
default 6
|
||||||
|
---help---
|
||||||
|
Set the size of WiFi Block Ack RX window. Generally a bigger value means higher throughput and better
|
||||||
|
compatibility but more memory. Most of time we should NOT change the default value unless special
|
||||||
|
reason, e.g. test the maximum UDP RX throughput with iperf etc. For iperf test in shieldbox, the
|
||||||
|
recommended value is 9~12. If PSRAM is used and WiFi memory is preferred to allocate in PSRAM first,
|
||||||
|
the default and minimum value should be 16 to achieve better throughput and compatibility with both
|
||||||
|
stations and APs.
|
||||||
|
|
||||||
|
config ESPRESSIF_WIFI_GCMP_SUPPORT
|
||||||
bool "WiFi GCMP Support(GCMP128 and GCMP256)"
|
bool "WiFi GCMP Support(GCMP128 and GCMP256)"
|
||||||
default n
|
default n
|
||||||
---help---
|
---help---
|
||||||
Select this option to enable GCMP support. GCMP support is compulsory for WiFi Suite-B support.
|
Select this option to enable GCMP support. GCMP support is compulsory for WiFi Suite-B support.
|
||||||
|
|
||||||
config ESP_WIFI_GMAC_SUPPORT
|
config ESPRESSIF_WIFI_GMAC_SUPPORT
|
||||||
bool "WiFi GMAC Support(GMAC128 and GMAC256)"
|
bool "WiFi GMAC Support(GMAC128 and GMAC256)"
|
||||||
default n
|
default n
|
||||||
---help---
|
---help---
|
||||||
|
|
@ -1400,18 +1564,11 @@ config ESPRESSIF_WIFI_LISTEN_INTERVAL
|
||||||
For example, if beacon interval is 100 ms and listen interval is 3, the interval for station to listen
|
For example, if beacon interval is 100 ms and listen interval is 3, the interval for station to listen
|
||||||
to beacon is 300 ms.
|
to beacon is 300 ms.
|
||||||
|
|
||||||
config ESPRESSIF_WIFI_WLAN_BUFFER_OPTIMIZATION
|
|
||||||
bool "Enable optimization of WLAN driver buffer"
|
|
||||||
default n
|
|
||||||
depends on ARCH_CHIP_ESP32
|
|
||||||
---help---
|
|
||||||
Enable optimization of WLAN memory
|
|
||||||
|
|
||||||
endmenu # ESPRESSIF_WIFI
|
endmenu # ESPRESSIF_WIFI
|
||||||
|
|
||||||
config ESPRESSIF_ESPNOW_PKTRADIO
|
config ESPRESSIF_ESPNOW_PKTRADIO
|
||||||
bool "ESPNOW pktradio support"
|
bool "ESPNOW pktradio support"
|
||||||
depends on ESPRESSIF_WLAN
|
depends on ESPRESSIF_WIRELESS
|
||||||
depends on WIRELESS_PKTRADIO
|
depends on WIRELESS_PKTRADIO
|
||||||
default n
|
default n
|
||||||
---help---
|
---help---
|
||||||
|
|
|
||||||
|
|
@ -98,8 +98,10 @@ endif
|
||||||
ifeq ($(CONFIG_ESPRESSIF_WIRELESS),y)
|
ifeq ($(CONFIG_ESPRESSIF_WIRELESS),y)
|
||||||
CHIP_CSRCS += esp_wireless.c
|
CHIP_CSRCS += esp_wireless.c
|
||||||
CHIP_CSRCS += esp_wifi_utils.c
|
CHIP_CSRCS += esp_wifi_utils.c
|
||||||
ifeq ($(CONFIG_ESPRESSIF_WLAN),y)
|
ifeq ($(CONFIG_ESPRESSIF_WIFI),y)
|
||||||
CHIP_CSRCS += esp_wlan.c
|
CHIP_CSRCS += esp_wifi_event_handler.c
|
||||||
|
CHIP_CSRCS += esp_wlan_netdev.c
|
||||||
|
CHIP_CSRCS += esp_wifi_api.c
|
||||||
endif
|
endif
|
||||||
ifeq ($(CONFIG_ESPRESSIF_ESPNOW_PKTRADIO), y)
|
ifeq ($(CONFIG_ESPRESSIF_ESPNOW_PKTRADIO), y)
|
||||||
CHIP_CSRCS += esp_espnow_pktradio.c
|
CHIP_CSRCS += esp_espnow_pktradio.c
|
||||||
|
|
|
||||||
|
|
@ -152,11 +152,11 @@ ifeq ($(CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA),y)
|
||||||
CFLAGS += $(DEFINE_PREFIX)CONFIG_OWE_STA
|
CFLAGS += $(DEFINE_PREFIX)CONFIG_OWE_STA
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ESP_WIFI_GCMP_SUPPORT),y)
|
ifeq ($(CONFIG_ESPRESSIF_WIFI_GCMP_SUPPORT),y)
|
||||||
CFLAGS += $(DEFINE_PREFIX)CONFIG_GCMP
|
CFLAGS += $(DEFINE_PREFIX)CONFIG_GCMP
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ESP_WIFI_GMAC_SUPPORT),y)
|
ifeq ($(CONFIG_ESPRESSIF_WIFI_GMAC_SUPPORT),y)
|
||||||
CFLAGS += $(DEFINE_PREFIX)CONFIG_GMAC
|
CFLAGS += $(DEFINE_PREFIX)CONFIG_GMAC
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
@ -273,8 +273,13 @@ CHIP_CSRCS += tls_mbedtls.c
|
||||||
CHIP_CSRCS += aes-siv.c
|
CHIP_CSRCS += aes-siv.c
|
||||||
|
|
||||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_wifi$(DELIM)src$(DELIM)wifi_init.c
|
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_wifi$(DELIM)src$(DELIM)wifi_init.c
|
||||||
|
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_wifi$(DELIM)src$(DELIM)lib_printf.c
|
||||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_wifi$(DELIM)regulatory$(DELIM)esp_wifi_regulatory.c
|
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_wifi$(DELIM)regulatory$(DELIM)esp_wifi_regulatory.c
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_ESPRESSIF_WIFI_BT_COEXIST),y)
|
||||||
|
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_coex$(DELIM)src$(DELIM)lib_printf.c
|
||||||
|
endif
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Linker scripts
|
# Linker scripts
|
||||||
|
|
|
||||||
2158
arch/xtensa/src/common/espressif/esp_wifi_api.c
Normal file
2158
arch/xtensa/src/common/espressif/esp_wifi_api.c
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1,5 +1,7 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/xtensa/src/esp32s2/esp32s2_wifi_adapter.h
|
* arch/xtensa/src/common/espressif/esp_wifi_api.h
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
|
@ -18,173 +20,184 @@
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef __ARCH_XTENSA_SRC_ESP32S2_ESP32S2_WIFI_ADAPTER_H
|
#ifndef __ARCH_XTENSA_SRC_COMMON_ESPRESSIF_ESP_WIFI_API_H
|
||||||
#define __ARCH_XTENSA_SRC_ESP32S2_ESP32S2_WIFI_ADAPTER_H
|
#define __ARCH_XTENSA_SRC_COMMON_ESPRESSIF_ESP_WIFI_API_H
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <nuttx/wireless/wireless.h>
|
#include <nuttx/wireless/wireless.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include "esp_wlan_netdev.h"
|
||||||
|
|
||||||
#ifndef __ASSEMBLY__
|
|
||||||
|
|
||||||
#undef EXTERN
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
#define EXTERN extern "C"
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#else
|
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#define SSID_MAX_LEN (32)
|
|
||||||
#define PWD_MAX_LEN (64)
|
|
||||||
|
|
||||||
#define CONFIG_IDF_TARGET_ESP32S2 1
|
|
||||||
|
|
||||||
/* Define esp_err_t */
|
|
||||||
|
|
||||||
typedef int esp_err_t;
|
|
||||||
|
|
||||||
/* Wi-Fi event callback function */
|
|
||||||
|
|
||||||
typedef void (*wifi_evt_cb_t)(void *p);
|
|
||||||
|
|
||||||
/* Wi-Fi TX done callback function */
|
|
||||||
|
|
||||||
typedef void (*wifi_txdone_cb_t)(uint8_t *data, uint16_t *len, bool status);
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wifi_adapter_init
|
* Name: esp_wifi_api_adapter_deinit
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Initialize ESP32S2 Wi-Fi adapter
|
* De-initialize Wi-Fi adapter, freeing all resources allocated by
|
||||||
|
* esp_wifi_init. Also stops the Wi-Fi task.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* 0 if success or -1 if fail
|
* OK on success; Negated errno on failure.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int esp_wifi_adapter_init(void);
|
int esp_wifi_api_adapter_deinit(void);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wifi_free_eb
|
* Name: esp_wifi_api_adapter_init
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Free Wi-Fi receive callback input eb pointer
|
* Initialize the Wi-Fi driver, control structure, buffers and Wi-Fi task.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* eb - Wi-Fi receive callback input eb pointer
|
* None.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* OK on success; Negated errno on failure.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void esp_wifi_free_eb(void *eb);
|
int esp_wifi_api_adapter_init(void);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wifi_sta_start
|
* Name: esp_wifi_api_start
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Start Wi-Fi station.
|
* Start Wi-Fi station. This will start the proper Wi-Fi mode based on
|
||||||
|
* the AP/Station configuration.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* None
|
* start_mode - The Wi-Fi mode to start from
|
||||||
|
* nuttx/include/nuttx/wireless/wireless.h.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int esp_wifi_sta_start(void);
|
int esp_wifi_api_start(uint32_t start_mode);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wifi_sta_stop
|
* Name: esp_wifi_api_stop
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Stop Wi-Fi station.
|
* Stops Wi-Fi AP, Station or both.
|
||||||
|
*
|
||||||
|
* If AP + SoftAP are running, be aware that both will be stopped briefly,
|
||||||
|
* and then the remaining one will be restarted.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* None
|
* stop_mode - The Wi-Fi mode to stop from
|
||||||
|
* nuttx/include/nuttx/wireless/wireless.h.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int esp_wifi_sta_stop(void);
|
int esp_wifi_api_stop(uint32_t stop_mode);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp_wifi_api_sta_register_rx_callback
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Register a callback function for the Wi-Fi station interface.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK on success; Negated errno on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int esp_wifi_api_sta_register_rx_callback(void *cb);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp_wifi_api_softap_register_rx_callback
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Register a callback function for the Wi-Fi softAP interface.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK on success; Negated errno on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int esp_wifi_api_softap_register_rx_callback(void *cb);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp_wifi_api_registe_tx_done_callback
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Register a callback function for transmission done. Valid for
|
||||||
|
* both station and softAP and needs to be called only once on bringup.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK on success; Negated errno on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int esp_wifi_api_register_tx_done_callback(void *cb);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp_wifi_api_free_rx_buffer
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Free the RX buffer allocated by the Wi-Fi driver.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* eb - The event buffer to free
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void esp_wifi_api_free_rx_buffer(void *eb);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Station functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef ESP_WLAN_HAS_STA
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wifi_sta_send_data
|
* Name: esp_wifi_sta_send_data
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Use Wi-Fi station interface to send 802.3 frame
|
* Use Wi-Fi station interface to send 802.3 frame.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* pbuf - Packet buffer pointer
|
* pbuf - Packet buffer pointer
|
||||||
* len - Packet length
|
* len - Packet length
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int esp_wifi_sta_send_data(void *pbuf, size_t len);
|
int esp_wifi_sta_send_data(void *pbuf, size_t len);
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_register_recv_cb
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Regitser Wi-Fi station receive packet callback function
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* recv_cb - Receive callback function
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_register_recv_cb(int (*recv_cb)(void *buffer,
|
|
||||||
uint16_t len,
|
|
||||||
void *eb));
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_register_txdone_cb
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Register the station TX done callback function.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* cb - The callback function
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void esp_wifi_sta_register_txdone_cb(wifi_txdone_cb_t cb);
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wifi_sta_read_mac
|
* Name: esp_wifi_sta_read_mac
|
||||||
*
|
*
|
||||||
|
|
@ -202,18 +215,17 @@ void esp_wifi_sta_register_txdone_cb(wifi_txdone_cb_t cb);
|
||||||
int esp_wifi_sta_read_mac(uint8_t *mac);
|
int esp_wifi_sta_read_mac(uint8_t *mac);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wifi_set_password
|
* Name: esp_wifi_sta_password
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Set/Get Wi-Fi station password
|
* Set/Get Wi-Fi station password.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* iwr - The argument of the ioctl cmd
|
* iwr - The argument of the ioctl cmd
|
||||||
* set - true: set data; false: get data
|
* set - true: set data; false: get data
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -227,11 +239,10 @@ int esp_wifi_sta_password(struct iwreq *iwr, bool set);
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* iwr - The argument of the ioctl cmd
|
* iwr - The argument of the ioctl cmd
|
||||||
* set - true: set data; false: get data
|
* set - true: set data; false: get data
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -241,15 +252,14 @@ int esp_wifi_sta_essid(struct iwreq *iwr, bool set);
|
||||||
* Name: esp_wifi_sta_bssid
|
* Name: esp_wifi_sta_bssid
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Set/Get Wi-Fi station BSSID
|
* Set/Get Wi-Fi station BSSID.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* iwr - The argument of the ioctl cmd
|
* iwr - The argument of the ioctl cmd
|
||||||
* set - true: set data; false: get data
|
* set - true: set data; false: get data
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -259,14 +269,13 @@ int esp_wifi_sta_bssid(struct iwreq *iwr, bool set);
|
||||||
* Name: esp_wifi_sta_connect
|
* Name: esp_wifi_sta_connect
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Trigger Wi-Fi station connection action
|
* Trigger Wi-Fi station connection action.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -276,18 +285,17 @@ int esp_wifi_sta_connect(void);
|
||||||
* Name: esp_wifi_sta_disconnect
|
* Name: esp_wifi_sta_disconnect
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Trigger Wi-Fi station disconnection action
|
* Trigger Wi-Fi station disconnection action.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* None
|
* None.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int esp_wifi_sta_disconnect(void);
|
int esp_wifi_sta_disconnect(bool allow_reconnect);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wifi_sta_mode
|
* Name: esp_wifi_sta_mode
|
||||||
|
|
@ -300,8 +308,7 @@ int esp_wifi_sta_disconnect(void);
|
||||||
* set - true: set data; false: get data
|
* set - true: set data; false: get data
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -329,15 +336,14 @@ int esp_wifi_sta_auth(struct iwreq *iwr, bool set);
|
||||||
* Name: esp_wifi_sta_freq
|
* Name: esp_wifi_sta_freq
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Get station frequency.
|
* Set/Get station frequency.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* iwr - The argument of the ioctl cmd
|
* iwr - The argument of the ioctl cmd
|
||||||
* set - true: set data; false: get data
|
* set - true: set data; false: get data
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -354,33 +360,33 @@ int esp_wifi_sta_freq(struct iwreq *iwr, bool set);
|
||||||
* set - true: set data; false: get data
|
* set - true: set data; false: get data
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int esp_wifi_sta_bitrate(struct iwreq *iwr, bool set);
|
int esp_wifi_sta_bitrate(struct iwreq *iwr, bool set);
|
||||||
|
|
||||||
|
#endif /* ESP_WLAN_HAS_STA */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wifi_sta_get_txpower
|
* Name: esp_wifi_sta_txpower
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Get station transmit power (dBm).
|
* Get/Set station transmit power (dBm).
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* iwr - The argument of the ioctl cmd
|
* iwr - The argument of the ioctl cmd
|
||||||
* set - true: set data; false: get data
|
* set - true: set data; false: get data
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int esp_wifi_sta_txpower(struct iwreq *iwr, bool set);
|
int esp_wifi_sta_txpower(struct iwreq *iwr, bool set);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wifi_sta_get_channel_range
|
* Name: esp_wifi_sta_channel
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Get station range of channel parameters.
|
* Get station range of channel parameters.
|
||||||
|
|
@ -390,8 +396,7 @@ int esp_wifi_sta_txpower(struct iwreq *iwr, bool set);
|
||||||
* set - true: set data; false: get data
|
* set - true: set data; false: get data
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -408,13 +413,14 @@ int esp_wifi_sta_channel(struct iwreq *iwr, bool set);
|
||||||
* set - true: set data; false: get data
|
* set - true: set data; false: get data
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int esp_wifi_sta_country(struct iwreq *iwr, bool set);
|
int esp_wifi_sta_country(struct iwreq *iwr, bool set);
|
||||||
|
|
||||||
|
#ifdef ESP_WLAN_HAS_STA
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wifi_sta_rssi
|
* Name: esp_wifi_sta_rssi
|
||||||
*
|
*
|
||||||
|
|
@ -426,100 +432,37 @@ int esp_wifi_sta_country(struct iwreq *iwr, bool set);
|
||||||
* set - true: set data; false: get data
|
* set - true: set data; false: get data
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int esp_wifi_sta_rssi(struct iwreq *iwr, bool set);
|
int esp_wifi_sta_rssi(struct iwreq *iwr, bool set);
|
||||||
|
|
||||||
/****************************************************************************
|
#endif /* ESP_WLAN_HAS_STA */
|
||||||
* Name: esp_wifi_softap_start
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Start Wi-Fi softAP.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_start(void);
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wifi_softap_stop
|
* SoftAP functions
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Stop Wi-Fi softAP.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int esp_wifi_softap_stop(void);
|
#ifdef ESP_WLAN_HAS_SOFTAP
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wifi_softap_send_data
|
* Name: esp_wifi_softap_send_data
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Use Wi-Fi softAP interface to send 802.3 frame
|
* Use Wi-Fi SoftAP interface to send 802.3 frame
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* pbuf - Packet buffer pointer
|
* pbuf - Packet buffer pointer
|
||||||
* len - Packet length
|
* len - Packet length
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int esp_wifi_softap_send_data(void *pbuf, size_t len);
|
int esp_wifi_softap_send_data(void *pbuf, size_t len);
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_register_recv_cb
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Regitser Wi-Fi softAP receive packet callback function
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* recv_cb - Receive callback function
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_register_recv_cb(int (*recv_cb)(void *buffer,
|
|
||||||
uint16_t len,
|
|
||||||
void *eb));
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_register_txdone_cb
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Register the softAP TX done callback function.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* cb - The callback function
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void esp_wifi_softap_register_txdone_cb(wifi_txdone_cb_t cb);
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wifi_softap_read_mac
|
* Name: esp_wifi_softap_read_mac
|
||||||
*
|
*
|
||||||
|
|
@ -544,11 +487,10 @@ int esp_wifi_softap_read_mac(uint8_t *mac);
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* iwr - The argument of the ioctl cmd
|
* iwr - The argument of the ioctl cmd
|
||||||
* set - true: set data; false: get data
|
* set - true: set data; false: get data
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -565,8 +507,7 @@ int esp_wifi_softap_password(struct iwreq *iwr, bool set);
|
||||||
* set - true: set data; false: get data
|
* set - true: set data; false: get data
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -576,11 +517,11 @@ int esp_wifi_softap_essid(struct iwreq *iwr, bool set);
|
||||||
* Name: esp_wifi_softap_bssid
|
* Name: esp_wifi_softap_bssid
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Set/Get Wi-Fi softAP BSSID
|
* Set/Get Wi-Fi SoftAP BSSID
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* iwr - The argument of the ioctl cmd
|
* iwr - The argument of the ioctl cmd
|
||||||
* set - true: set data; false: get data
|
* set - true: set data; false: get data
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success (positive non-zero values are cmd-specific)
|
||||||
|
|
@ -594,14 +535,13 @@ int esp_wifi_softap_bssid(struct iwreq *iwr, bool set);
|
||||||
* Name: esp_wifi_softap_connect
|
* Name: esp_wifi_softap_connect
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Trigger Wi-Fi softAP accept connection action
|
* Trigger Wi-Fi SoftAP accept connection action.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* None
|
* config - The Wi-Fi config to set.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -611,14 +551,13 @@ int esp_wifi_softap_connect(void);
|
||||||
* Name: esp_wifi_softap_disconnect
|
* Name: esp_wifi_softap_disconnect
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Trigger Wi-Fi softAP drop connection action
|
* Trigger Wi-Fi SoftAP drop connection action
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -635,8 +574,7 @@ int esp_wifi_softap_disconnect(void);
|
||||||
* set - true: set data; false: get data
|
* set - true: set data; false: get data
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -646,7 +584,7 @@ int esp_wifi_softap_mode(struct iwreq *iwr, bool set);
|
||||||
* Name: esp_wifi_softap_auth
|
* Name: esp_wifi_softap_auth
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Set/Get authentication mode params.
|
* Set/get authentication mode params.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* iwr - The argument of the ioctl cmd
|
* iwr - The argument of the ioctl cmd
|
||||||
|
|
@ -679,7 +617,7 @@ int esp_wifi_softap_auth(struct iwreq *iwr, bool set);
|
||||||
int esp_wifi_softap_freq(struct iwreq *iwr, bool set);
|
int esp_wifi_softap_freq(struct iwreq *iwr, bool set);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wifi_softap_get_bitrate
|
* Name: esp_wifi_softap_bitrate
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Get SoftAP default bit rate (Mbps).
|
* Get SoftAP default bit rate (Mbps).
|
||||||
|
|
@ -689,8 +627,7 @@ int esp_wifi_softap_freq(struct iwreq *iwr, bool set);
|
||||||
* set - true: set data; false: get data
|
* set - true: set data; false: get data
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -707,8 +644,7 @@ int esp_wifi_softap_bitrate(struct iwreq *iwr, bool set);
|
||||||
* set - true: set data; false: get data
|
* set - true: set data; false: get data
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -725,8 +661,7 @@ int esp_wifi_softap_txpower(struct iwreq *iwr, bool set);
|
||||||
* set - true: set data; false: get data
|
* set - true: set data; false: get data
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -743,8 +678,7 @@ int esp_wifi_softap_channel(struct iwreq *iwr, bool set);
|
||||||
* set - true: set data; false: get data
|
* set - true: set data; false: get data
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -761,33 +695,12 @@ int esp_wifi_softap_country(struct iwreq *iwr, bool set);
|
||||||
* set - true: set data; false: get data
|
* set - true: set data; false: get data
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success; Negated errno returned on failure.
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int esp_wifi_softap_rssi(struct iwreq *iwr, bool set);
|
int esp_wifi_softap_rssi(struct iwreq *iwr, bool set);
|
||||||
|
|
||||||
/****************************************************************************
|
#endif /* ESP_WLAN_HAS_SOFTAP */
|
||||||
* Name: esp_wifi_stop_callback
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Callback to stop Wi-Fi
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void esp_wifi_stop_callback(void);
|
#endif /* __ARCH_XTENSA_SRC_COMMON_ESPRESSIF_ESP_WIFI_API_H */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#undef EXTERN
|
|
||||||
|
|
||||||
#endif /* __ASSEMBLY__ */
|
|
||||||
#endif /* __ARCH_XTENSA_SRC_ESP32S2_ESP32S2_WIFI_ADAPTER_H */
|
|
||||||
359
arch/xtensa/src/common/espressif/esp_wifi_event_handler.c
Normal file
359
arch/xtensa/src/common/espressif/esp_wifi_event_handler.c
Normal file
|
|
@ -0,0 +1,359 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* arch/xtensa/src/common/espressif/esp_wifi_event_handler.c
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <debug.h>
|
||||||
|
#include <nuttx/spinlock.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
|
|
||||||
|
#include "esp_wifi.h"
|
||||||
|
|
||||||
|
#include "esp_wifi_utils.h"
|
||||||
|
#include "esp_wifi_api.h"
|
||||||
|
|
||||||
|
#ifndef CONFIG_SCHED_LPWORK
|
||||||
|
# error "CONFIG_SCHED_LPWORK must be defined"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* CONFIG_POWER_SAVE_MODEM */
|
||||||
|
|
||||||
|
#if defined(CONFIG_ESPRESSIF_POWER_SAVE_MIN_MODEM)
|
||||||
|
# define DEFAULT_PS_MODE WIFI_PS_MIN_MODEM
|
||||||
|
#elif defined(CONFIG_ESPRESSIF_POWER_SAVE_MAX_MODEM)
|
||||||
|
# define DEFAULT_PS_MODE WIFI_PS_MAX_MODEM
|
||||||
|
#elif defined(CONFIG_ESPRESSIF_POWER_SAVE_NONE)
|
||||||
|
# define DEFAULT_PS_MODE WIFI_PS_NONE
|
||||||
|
#else
|
||||||
|
# define DEFAULT_PS_MODE WIFI_PS_NONE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* Wi-Fi event notification private data */
|
||||||
|
|
||||||
|
struct wifi_notify
|
||||||
|
{
|
||||||
|
bool assigned; /* Flag indicate if it is used */
|
||||||
|
pid_t pid; /* Signal's target thread PID */
|
||||||
|
struct sigevent event; /* Signal event private data */
|
||||||
|
struct sigwork_s work; /* Signal work private data */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Wi-Fi event private data */
|
||||||
|
|
||||||
|
struct evt_adpt
|
||||||
|
{
|
||||||
|
sq_entry_t entry; /* Sequence entry */
|
||||||
|
wifi_event_t id; /* Event ID */
|
||||||
|
uint8_t buf[0]; /* Event private data */
|
||||||
|
};
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static struct wifi_notify g_wifi_notify[WIFI_EVENT_MAX];
|
||||||
|
static struct work_s g_wifi_evt_work;
|
||||||
|
static sq_queue_t g_wifi_evt_queue;
|
||||||
|
static spinlock_t g_lock;
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp_reconnect_work_cb
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Function called by a work queue to reconnect to Wi-Fi in case of
|
||||||
|
* a disconnection event and WIFI_REASON_ASSOC_LEAVE reason.
|
||||||
|
* Must check if the failure_retry_cnt is not 0, otherwise it may
|
||||||
|
* reconnect when not desired, such as when the user has actually
|
||||||
|
* asked to disconnect from the AP.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* arg - Not used.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef ESP_WLAN_HAS_STA
|
||||||
|
static void esp_reconnect_work_cb(void *arg)
|
||||||
|
{
|
||||||
|
UNUSED(arg);
|
||||||
|
int ret;
|
||||||
|
wifi_config_t wifi_config;
|
||||||
|
|
||||||
|
esp_wifi_get_config(WIFI_IF_STA, &wifi_config);
|
||||||
|
if (wifi_config.sta.failure_retry_cnt == 0)
|
||||||
|
{
|
||||||
|
wlinfo("Reconnect to Wi-Fi on callback: failure_retry_cnt is 0\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = esp_wifi_sta_connect();
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
wlerr("Failed to reconnect to Wi-Fi on callback\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* ESP_WLAN_HAS_STA */
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp_evt_work_cb
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Process Wi-Fi events.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* arg - Not used.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static void esp_evt_work_cb(void *arg)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
irqstate_t flags;
|
||||||
|
struct evt_adpt *evt_adpt;
|
||||||
|
struct wifi_notify *notify;
|
||||||
|
wifi_ps_type_t ps_type = DEFAULT_PS_MODE;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
flags = spin_lock_irqsave(&g_lock);
|
||||||
|
evt_adpt = (struct evt_adpt *)sq_remfirst(&g_wifi_evt_queue);
|
||||||
|
spin_unlock_irqrestore(&g_lock, flags);
|
||||||
|
if (evt_adpt == NULL)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Some of the following logic (eg. esp_wlan_sta_set_linkstatus)
|
||||||
|
* can take net_lock(). To maintain the consistent locking order,
|
||||||
|
* we take net_lock() here before taking esp_wifi_lock. Note that
|
||||||
|
* net_lock() is a recursive lock.
|
||||||
|
*/
|
||||||
|
|
||||||
|
net_lock();
|
||||||
|
esp_wifi_lock(true);
|
||||||
|
|
||||||
|
switch (evt_adpt->id)
|
||||||
|
{
|
||||||
|
#ifdef ESP_WLAN_DEVS
|
||||||
|
case WIFI_EVENT_SCAN_DONE:
|
||||||
|
esp_wifi_scan_event_parse();
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
case WIFI_EVENT_HOME_CHANNEL_CHANGE:
|
||||||
|
wlinfo("Wi-Fi home channel change\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
#ifdef ESP_WLAN_HAS_STA
|
||||||
|
case WIFI_EVENT_STA_START:
|
||||||
|
wlinfo("Wi-Fi sta start\n");
|
||||||
|
|
||||||
|
ret = esp_wifi_set_ps(ps_type);
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
wlerr("Failed to set power save type\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WIFI_EVENT_STA_STOP:
|
||||||
|
wlinfo("Wi-Fi station stopped\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WIFI_EVENT_STA_CONNECTED:
|
||||||
|
wlinfo("Wi-Fi station connected\n");
|
||||||
|
esp_wlan_sta_connect_success_hook();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WIFI_EVENT_STA_DISCONNECTED:
|
||||||
|
wifi_event_sta_disconnected_t *event =
|
||||||
|
(wifi_event_sta_disconnected_t *)evt_adpt->buf;
|
||||||
|
wifi_err_reason_t reason = event->reason;
|
||||||
|
|
||||||
|
wlinfo("Wi-Fi station disconnected, reason: %u\n", reason);
|
||||||
|
esp_wlan_sta_disconnect_hook();
|
||||||
|
if (reason == WIFI_REASON_ASSOC_LEAVE)
|
||||||
|
{
|
||||||
|
work_queue(LPWORK, &g_wifi_evt_work, esp_reconnect_work_cb,
|
||||||
|
NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WIFI_EVENT_STA_AUTHMODE_CHANGE:
|
||||||
|
wlinfo("Wi-Fi station auth mode change\n");
|
||||||
|
break;
|
||||||
|
#endif /* ESP_WLAN_HAS_STA */
|
||||||
|
|
||||||
|
#ifdef ESP_WLAN_HAS_SOFTAP
|
||||||
|
case WIFI_EVENT_AP_START:
|
||||||
|
wlinfo("INFO: Wi-Fi softap start\n");
|
||||||
|
esp_wlan_softap_connect_success_hook();
|
||||||
|
ret = esp_wifi_set_ps(ps_type);
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
wlerr("Failed to set power save type\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WIFI_EVENT_AP_STOP:
|
||||||
|
wlinfo("Wi-Fi softap stop\n");
|
||||||
|
esp_wlan_softap_disconnect_hook();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WIFI_EVENT_AP_STACONNECTED:
|
||||||
|
wlinfo("Wi-Fi station joined AP\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WIFI_EVENT_AP_STADISCONNECTED:
|
||||||
|
wlinfo("Wi-Fi station left AP\n");
|
||||||
|
break;
|
||||||
|
#endif /* ESP_WLAN_HAS_SOFTAP */
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
notify = &g_wifi_notify[evt_adpt->id];
|
||||||
|
if (notify->assigned)
|
||||||
|
{
|
||||||
|
notify->event.sigev_value.sival_ptr = evt_adpt->buf;
|
||||||
|
|
||||||
|
ret = nxsig_notification(notify->pid, ¬ify->event,
|
||||||
|
SI_QUEUE, ¬ify->work);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
wlwarn("nxsig_notification event ID=%d failed: %d\n",
|
||||||
|
evt_adpt->id, ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
esp_wifi_lock(false);
|
||||||
|
net_unlock();
|
||||||
|
|
||||||
|
kmm_free(evt_adpt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp_event_post
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Posts an event to the event loop system. The event is queued in a FIFO
|
||||||
|
* and processed asynchronously in the low-priority work queue.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* event_base - Identifier for the event category (e.g. WIFI_EVENT)
|
||||||
|
* event_id - Event ID within the event base category
|
||||||
|
* event_data - Pointer to event data structure
|
||||||
|
* event_data_size - Size of event data structure
|
||||||
|
* ticks - Number of ticks to wait (currently unused)
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* 0 on success
|
||||||
|
* -1 on failure with following error conditions:
|
||||||
|
* - Invalid event ID
|
||||||
|
* - Memory allocation failure
|
||||||
|
*
|
||||||
|
* Assumptions/Limitations:
|
||||||
|
* - Event data is copied into a new buffer, so the original can be freed
|
||||||
|
* - Events are processed in FIFO order in the low priority work queue
|
||||||
|
* - The function is thread-safe and can be called from interrupt context
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int esp_event_post(const char *event_base,
|
||||||
|
int32_t event_id,
|
||||||
|
void *event_data,
|
||||||
|
size_t event_data_size,
|
||||||
|
uint32_t ticks)
|
||||||
|
{
|
||||||
|
size_t size;
|
||||||
|
int32_t id;
|
||||||
|
irqstate_t flags;
|
||||||
|
struct evt_adpt *evt_adpt;
|
||||||
|
|
||||||
|
wlinfo("Event: base=%s id=%ld data=%p data_size=%u ticks=%lu\n",
|
||||||
|
event_base, event_id, event_data, event_data_size, ticks);
|
||||||
|
|
||||||
|
size = event_data_size + sizeof(struct evt_adpt);
|
||||||
|
evt_adpt = kmm_malloc(size);
|
||||||
|
if (evt_adpt == NULL)
|
||||||
|
{
|
||||||
|
wlerr("ERROR: Failed to alloc %d memory\n", size);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
evt_adpt->id = event_id;
|
||||||
|
memcpy(evt_adpt->buf, event_data, event_data_size);
|
||||||
|
|
||||||
|
flags = enter_critical_section();
|
||||||
|
sq_addlast(&evt_adpt->entry, &g_wifi_evt_queue);
|
||||||
|
leave_critical_section(flags);
|
||||||
|
|
||||||
|
work_queue(LPWORK, &g_wifi_evt_work, esp_evt_work_cb, NULL, 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp_evt_work_init
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize the event work queue
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void esp_evt_work_init(void)
|
||||||
|
{
|
||||||
|
sq_init(&g_wifi_evt_queue);
|
||||||
|
}
|
||||||
|
|
@ -27,53 +27,21 @@
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <netinet/arp.h>
|
#include <netinet/arp.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/wireless/wireless.h>
|
#include <nuttx/wireless/wireless.h>
|
||||||
#include <nuttx/signal.h>
|
|
||||||
#include <nuttx/spinlock.h>
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_CHIP_ESP32
|
|
||||||
#include "esp32_wifi_adapter.h"
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_ARCH_CHIP_ESP32S2
|
|
||||||
#include "esp32s2_wifi_adapter.h"
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_ARCH_CHIP_ESP32S3
|
|
||||||
#include "esp32s3_wifi_adapter.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_ESPRESSIF_BLE
|
|
||||||
# ifdef CONFIG_ARCH_CHIP_ESP32
|
|
||||||
# include "esp32_ble_adapter.h"
|
|
||||||
# endif
|
|
||||||
# ifdef CONFIG_ARCH_CHIP_ESP32S3
|
|
||||||
# include "esp32s3_ble_adapter.h"
|
|
||||||
# endif
|
|
||||||
# ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST
|
|
||||||
# include "private/esp_coexist_internal.h"
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "espressif/esp_wlan.h"
|
|
||||||
|
|
||||||
#include "esp_wifi_utils.h"
|
|
||||||
#include "esp_wireless.h"
|
|
||||||
|
|
||||||
#include "esp_log.h"
|
|
||||||
#include "esp_mac.h"
|
|
||||||
#include "esp_private/phy.h"
|
|
||||||
#include "esp_private/wifi.h"
|
|
||||||
#include "esp_random.h"
|
|
||||||
#include "esp_timer.h"
|
#include "esp_timer.h"
|
||||||
#ifdef CONFIG_ESPRESSIF_WIFI
|
#include "esp_wifi_utils.h"
|
||||||
# include "esp_wpa.h"
|
#include "esp_wlan_netdev.h"
|
||||||
#endif
|
|
||||||
#include "rom/ets_sys.h"
|
#include "esp_wifi.h"
|
||||||
#include "soc/soc_caps.h"
|
#include "esp_err.h"
|
||||||
|
#include "esp_wifi_types_generic.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
|
|
@ -96,18 +64,6 @@
|
||||||
|
|
||||||
#define CHANNEL_MAX_NUM (14)
|
#define CHANNEL_MAX_NUM (14)
|
||||||
|
|
||||||
/* CONFIG_POWER_SAVE_MODEM */
|
|
||||||
|
|
||||||
#if defined(CONFIG_ESPRESSIF_POWER_SAVE_MIN_MODEM)
|
|
||||||
# define DEFAULT_PS_MODE WIFI_PS_MIN_MODEM
|
|
||||||
#elif defined(CONFIG_ESPRESSIF_POWER_SAVE_MAX_MODEM)
|
|
||||||
# define DEFAULT_PS_MODE WIFI_PS_MAX_MODEM
|
|
||||||
#elif defined(CONFIG_ESPRESSIF_POWER_SAVE_NONE)
|
|
||||||
# define DEFAULT_PS_MODE WIFI_PS_NONE
|
|
||||||
#else
|
|
||||||
# define DEFAULT_PS_MODE WIFI_PS_NONE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
@ -129,70 +85,10 @@ struct wifi_scan_result
|
||||||
unsigned int scan_result_size; /* Current size of temp buffer */
|
unsigned int scan_result_size; /* Current size of temp buffer */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Wi-Fi event ID */
|
|
||||||
|
|
||||||
enum wifi_adpt_evt_e
|
|
||||||
{
|
|
||||||
WIFI_ADPT_EVT_SCAN_DONE = 0,
|
|
||||||
WIFI_ADPT_EVT_STA_START,
|
|
||||||
WIFI_ADPT_EVT_STA_CONNECT,
|
|
||||||
WIFI_ADPT_EVT_STA_DISCONNECT,
|
|
||||||
WIFI_ADPT_EVT_STA_AUTHMODE_CHANGE,
|
|
||||||
WIFI_ADPT_EVT_STA_STOP,
|
|
||||||
WIFI_ADPT_EVT_AP_START,
|
|
||||||
WIFI_ADPT_EVT_AP_STOP,
|
|
||||||
WIFI_ADPT_EVT_AP_STACONNECTED,
|
|
||||||
WIFI_ADPT_EVT_AP_STADISCONNECTED,
|
|
||||||
WIFI_ADPT_EVT_MAX,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Wi-Fi event callback function */
|
|
||||||
|
|
||||||
typedef void (*wifi_evt_cb_t)(void *p);
|
|
||||||
|
|
||||||
/* Wi-Fi event private data */
|
|
||||||
|
|
||||||
struct evt_adpt
|
|
||||||
{
|
|
||||||
sq_entry_t entry; /* Sequence entry */
|
|
||||||
int32_t id; /* Event ID */
|
|
||||||
uint8_t buf[0]; /* Event private data */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Wi-Fi event notification private data */
|
|
||||||
|
|
||||||
struct wifi_notify
|
|
||||||
{
|
|
||||||
bool assigned; /* Flag indicate if it is used */
|
|
||||||
pid_t pid; /* Signal's target thread PID */
|
|
||||||
struct sigevent event; /* Signal event private data */
|
|
||||||
struct sigwork_s work; /* Signal work private data */
|
|
||||||
};
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Function Prototypes
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static int esp_event_id_map(int event_id);
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* Wi-Fi interface configuration */
|
|
||||||
|
|
||||||
#ifdef ESPRESSIF_WLAN_HAS_STA
|
|
||||||
|
|
||||||
extern wifi_config_t g_sta_wifi_cfg;
|
|
||||||
|
|
||||||
#endif /* ESPRESSIF_WLAN_HAS_STA */
|
|
||||||
|
|
||||||
#ifdef ESPRESSIF_WLAN_HAS_SOFTAP
|
|
||||||
|
|
||||||
extern wifi_config_t g_softap_wifi_cfg;
|
|
||||||
|
|
||||||
#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
@ -204,95 +100,107 @@ static struct wifi_scan_result g_scan_priv =
|
||||||
static uint8_t g_channel_num;
|
static uint8_t g_channel_num;
|
||||||
static uint8_t g_channel_list[CHANNEL_MAX_NUM];
|
static uint8_t g_channel_list[CHANNEL_MAX_NUM];
|
||||||
|
|
||||||
/* Wi-Fi event private data */
|
|
||||||
|
|
||||||
static spinlock_t g_lock_event;
|
|
||||||
static struct work_s g_wifi_evt_work;
|
|
||||||
static sq_queue_t g_wifi_evt_queue;
|
|
||||||
static struct wifi_notify g_wifi_notify[WIFI_ADPT_EVT_MAX];
|
|
||||||
|
|
||||||
static mutex_t g_wifiexcl_lock = NXMUTEX_INITIALIZER;
|
static mutex_t g_wifiexcl_lock = NXMUTEX_INITIALIZER;
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_event_id_map
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Transform from esp-idf event ID to Wi-Fi adapter event ID
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* event_id - esp-idf event ID
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* Wi-Fi adapter event ID
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static int esp_event_id_map(int event_id)
|
|
||||||
{
|
|
||||||
int id;
|
|
||||||
|
|
||||||
switch (event_id)
|
|
||||||
{
|
|
||||||
case WIFI_EVENT_SCAN_DONE:
|
|
||||||
id = WIFI_ADPT_EVT_SCAN_DONE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
#ifdef ESPRESSIF_WLAN_HAS_STA
|
|
||||||
case WIFI_EVENT_STA_START:
|
|
||||||
id = WIFI_ADPT_EVT_STA_START;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WIFI_EVENT_STA_CONNECTED:
|
|
||||||
id = WIFI_ADPT_EVT_STA_CONNECT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WIFI_EVENT_STA_DISCONNECTED:
|
|
||||||
id = WIFI_ADPT_EVT_STA_DISCONNECT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WIFI_EVENT_STA_AUTHMODE_CHANGE:
|
|
||||||
id = WIFI_ADPT_EVT_STA_AUTHMODE_CHANGE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WIFI_EVENT_STA_STOP:
|
|
||||||
id = WIFI_ADPT_EVT_STA_STOP;
|
|
||||||
break;
|
|
||||||
#endif /* ESPRESSIF_WLAN_HAS_STA */
|
|
||||||
|
|
||||||
#ifdef ESPRESSIF_WLAN_HAS_SOFTAP
|
|
||||||
case WIFI_EVENT_AP_START:
|
|
||||||
id = WIFI_ADPT_EVT_AP_START;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WIFI_EVENT_AP_STOP:
|
|
||||||
id = WIFI_ADPT_EVT_AP_STOP;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WIFI_EVENT_AP_STACONNECTED:
|
|
||||||
id = WIFI_ADPT_EVT_AP_STACONNECTED;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WIFI_EVENT_AP_STADISCONNECTED:
|
|
||||||
id = WIFI_ADPT_EVT_AP_STADISCONNECTED;
|
|
||||||
break;
|
|
||||||
#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */
|
|
||||||
|
|
||||||
default:
|
|
||||||
wlerr("ERROR: Unknown event ID: %d\n", event_id);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESPRESSIF_WIFI
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp_wifi_mode_translate
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Translate wireless mode constants to ESP Wi-Fi mode constants.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* wireless_mode - Wireless mode from wireless.h (IW_MODE_*)
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* ESP Wi-Fi mode (WIFI_MODE_*) on success
|
||||||
|
* -EINVAL on failure
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
wifi_mode_t esp_wifi_mode_translate(uint32_t wireless_mode)
|
||||||
|
{
|
||||||
|
switch (wireless_mode)
|
||||||
|
{
|
||||||
|
case IW_MODE_INFRA:
|
||||||
|
return WIFI_MODE_STA;
|
||||||
|
|
||||||
|
case IW_MODE_MASTER:
|
||||||
|
return WIFI_MODE_AP;
|
||||||
|
|
||||||
|
default:
|
||||||
|
wlerr("Invalid wireless mode=%ld\n", wireless_mode);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp_freq_to_channel
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Converts Wi-Fi frequency to channel.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* freq - Wi-Fi frequency
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Wi-Fi channel
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int esp_freq_to_channel(uint16_t freq)
|
||||||
|
{
|
||||||
|
int channel = 0;
|
||||||
|
if (freq >= 2412 && freq <= 2484)
|
||||||
|
{
|
||||||
|
if (freq == 2484)
|
||||||
|
{
|
||||||
|
channel = 14;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
channel = freq - 2407;
|
||||||
|
if (channel % 5)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
channel /= 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (freq >= 5005 && freq < 5900)
|
||||||
|
{
|
||||||
|
if (freq % 5)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
channel = (freq - 5000) / 5;
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (freq >= 4905 && freq < 5000)
|
||||||
|
{
|
||||||
|
if (freq % 5)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
channel = (freq - 4000) / 5;
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wifi_start_scan
|
* Name: esp_wifi_start_scan
|
||||||
*
|
*
|
||||||
|
|
@ -316,8 +224,8 @@ int esp_wifi_start_scan(struct iwreq *iwr)
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int i;
|
int i;
|
||||||
uint8_t target_mac[MAC_LEN];
|
uint8_t target_mac[MAC_LEN];
|
||||||
uint8_t target_ssid[SSID_MAX_LEN + 1];
|
uint8_t target_ssid[IW_ESSID_MAX_SIZE + 1];
|
||||||
memset(target_ssid, 0x0, sizeof(SSID_MAX_LEN + 1));
|
memset(target_ssid, 0x0, sizeof(IW_ESSID_MAX_SIZE + 1));
|
||||||
|
|
||||||
if (iwr == NULL)
|
if (iwr == NULL)
|
||||||
{
|
{
|
||||||
|
|
@ -395,7 +303,6 @@ int esp_wifi_start_scan(struct iwreq *iwr)
|
||||||
config->scan_type = WIFI_SCAN_TYPE_ACTIVE; /* Active scan */
|
config->scan_type = WIFI_SCAN_TYPE_ACTIVE; /* Active scan */
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_wifi_start();
|
|
||||||
ret = esp_wifi_scan_start(config, false);
|
ret = esp_wifi_scan_start(config, false);
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
|
|
@ -440,10 +347,10 @@ int esp_wifi_start_scan(struct iwreq *iwr)
|
||||||
* Name: esp_wifi_get_scan_results
|
* Name: esp_wifi_get_scan_results
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Get scan result
|
* Get Wi-Fi scan results.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* iwr - The argument of the ioctl cmd
|
* iwr - The argument of the ioctl cmd.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success (positive non-zero values are cmd-specific)
|
||||||
|
|
@ -544,13 +451,13 @@ exit_failed:
|
||||||
* Name: esp_wifi_scan_event_parse
|
* Name: esp_wifi_scan_event_parse
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Parse scan information
|
* Parse scan information Wi-Fi AP scan results.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* None
|
* None.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* None.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
@ -639,7 +546,8 @@ void esp_wifi_scan_event_parse(void)
|
||||||
/* Copy ESSID */
|
/* Copy ESSID */
|
||||||
|
|
||||||
essid_len = MIN(strlen((const char *)
|
essid_len = MIN(strlen((const char *)
|
||||||
ap_list_buffer[bss_count].ssid), SSID_MAX_LEN);
|
ap_list_buffer[bss_count].ssid),
|
||||||
|
IW_ESSID_MAX_SIZE);
|
||||||
essid_len_aligned = (essid_len + 3) & -4;
|
essid_len_aligned = (essid_len + 3) & -4;
|
||||||
if (result_size < ESP_IW_EVENT_SIZE(essid) + essid_len_aligned)
|
if (result_size < ESP_IW_EVENT_SIZE(essid) + essid_len_aligned)
|
||||||
{
|
{
|
||||||
|
|
@ -762,277 +670,85 @@ scan_result_full:
|
||||||
priv->scan_status = ESP_SCAN_DONE;
|
priv->scan_status = ESP_SCAN_DONE;
|
||||||
nxsem_post(&priv->scan_signal);
|
nxsem_post(&priv->scan_signal);
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_ESPRESSIF_WIFI */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_evt_work_cb
|
* Name: esp_wifi_to_errno
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Process the cached event
|
* Transform from ESP Wi-Fi error code to NuttX error code.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* arg - No mean
|
* err - ESP Wi-Fi error code.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* NuttX error code defined in errno.h
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void esp_evt_work_cb(void *arg)
|
int32_t esp_wifi_to_errno(int err)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
irqstate_t flags;
|
|
||||||
struct evt_adpt *evt_adpt;
|
|
||||||
struct wifi_notify *notify;
|
|
||||||
wifi_ps_type_t ps_type = DEFAULT_PS_MODE;
|
|
||||||
|
|
||||||
while (1)
|
if (err < ESP_ERR_WIFI_BASE)
|
||||||
{
|
{
|
||||||
flags = spin_lock_irqsave(&g_lock_event);
|
/* Unmask component error bits */
|
||||||
evt_adpt = (struct evt_adpt *)sq_remfirst(&g_wifi_evt_queue);
|
|
||||||
spin_unlock_irqrestore(&g_lock_event, flags);
|
ret = err & 0xfff;
|
||||||
if (!evt_adpt)
|
|
||||||
|
switch (ret)
|
||||||
{
|
{
|
||||||
break;
|
case ESP_OK:
|
||||||
}
|
ret = OK;
|
||||||
|
break;
|
||||||
/* Some of the following logic (eg. esp32s3_wlan_sta_set_linkstatus)
|
case ESP_ERR_NO_MEM:
|
||||||
* can take net_lock(). To maintain the consistent locking order,
|
ret = -ENOMEM;
|
||||||
* we take net_lock() here before taking esp_wifi_lock. Note that
|
|
||||||
* net_lock() is a recursive lock.
|
|
||||||
*/
|
|
||||||
|
|
||||||
net_lock();
|
|
||||||
esp_wifi_lock(true);
|
|
||||||
|
|
||||||
switch (evt_adpt->id)
|
|
||||||
{
|
|
||||||
case WIFI_ADPT_EVT_SCAN_DONE:
|
|
||||||
esp_wifi_scan_event_parse();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef ESPRESSIF_WLAN_HAS_STA
|
case ESP_ERR_INVALID_ARG:
|
||||||
case WIFI_ADPT_EVT_STA_START:
|
ret = -EINVAL;
|
||||||
wlinfo("Wi-Fi sta start\n");
|
|
||||||
|
|
||||||
g_sta_connected = false;
|
|
||||||
|
|
||||||
#ifdef CONFIG_ESPRESSIF_BLE
|
|
||||||
if (esp_bt_controller_get_status() !=
|
|
||||||
ESP_BT_CONTROLLER_STATUS_IDLE)
|
|
||||||
{
|
|
||||||
if (ps_type == WIFI_PS_NONE)
|
|
||||||
{
|
|
||||||
ps_type = WIFI_PS_MIN_MODEM;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ret = esp_wifi_set_ps(ps_type);
|
|
||||||
|
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
wlerr("Failed to set power save type\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wlinfo("INFO: Set ps type=%d\n", ps_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = esp_wifi_get_config(WIFI_IF_STA, &g_sta_wifi_cfg);
|
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
wlerr("Failed to get Wi-Fi config data ret=%d\n", ret);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WIFI_ADPT_EVT_STA_CONNECT:
|
case ESP_ERR_INVALID_STATE:
|
||||||
wlinfo("Wi-Fi sta connect\n");
|
ret = -EIO;
|
||||||
g_sta_connected = true;
|
|
||||||
ret = esp_wlan_sta_set_linkstatus(true);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
wlerr("ERROR: Failed to set Wi-Fi station link status\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WIFI_ADPT_EVT_STA_DISCONNECT:
|
case ESP_ERR_INVALID_SIZE:
|
||||||
wlinfo("Wi-Fi sta disconnect\n");
|
ret = -EINVAL;
|
||||||
g_sta_connected = false;
|
|
||||||
ret = esp_wlan_sta_set_linkstatus(false);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
wlerr("ERROR: Failed to set Wi-Fi station link status\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_sta_reconnect)
|
|
||||||
{
|
|
||||||
ret = esp_wifi_connect();
|
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
wlerr("Failed to connect AP error=%d\n", ret);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WIFI_ADPT_EVT_STA_STOP:
|
case ESP_ERR_NOT_FOUND:
|
||||||
wlinfo("Wi-Fi sta stop\n");
|
ret = -ENOSYS;
|
||||||
g_sta_connected = false;
|
|
||||||
break;
|
|
||||||
#endif /* ESPRESSIF_WLAN_HAS_STA */
|
|
||||||
|
|
||||||
#ifdef ESPRESSIF_WLAN_HAS_SOFTAP
|
|
||||||
case WIFI_ADPT_EVT_AP_START:
|
|
||||||
wlinfo("INFO: Wi-Fi softap start\n");
|
|
||||||
|
|
||||||
#ifdef CONFIG_ESPRESSIF_BLE
|
|
||||||
if (esp_bt_controller_get_status() !=
|
|
||||||
ESP_BT_CONTROLLER_STATUS_IDLE)
|
|
||||||
{
|
|
||||||
if (ps_type == WIFI_PS_NONE)
|
|
||||||
{
|
|
||||||
ps_type = WIFI_PS_MIN_MODEM;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ret = esp_wifi_set_ps(ps_type);
|
|
||||||
|
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
wlerr("Failed to set power save type\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wlinfo("INFO: Set ps type=%d\n", ps_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = esp_wifi_get_config(WIFI_IF_AP, &g_softap_wifi_cfg);
|
|
||||||
if (ret)
|
|
||||||
{
|
|
||||||
wlerr("Failed to get Wi-Fi config data ret=%d\n", ret);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WIFI_ADPT_EVT_AP_STOP:
|
case ESP_ERR_NOT_SUPPORTED:
|
||||||
wlinfo("INFO: Wi-Fi softap stop\n");
|
ret = -ENOSYS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WIFI_ADPT_EVT_AP_STACONNECTED:
|
case ESP_ERR_TIMEOUT:
|
||||||
wlinfo("INFO: Wi-Fi station join\n");
|
ret = -ETIMEDOUT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WIFI_ADPT_EVT_AP_STADISCONNECTED:
|
case ESP_ERR_INVALID_MAC:
|
||||||
wlinfo("INFO: Wi-Fi station leave\n");
|
ret = -EINVAL;
|
||||||
break;
|
break;
|
||||||
#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */
|
|
||||||
default:
|
default:
|
||||||
|
ret = ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
notify = &g_wifi_notify[evt_adpt->id];
|
|
||||||
if (notify->assigned)
|
|
||||||
{
|
|
||||||
notify->event.sigev_value.sival_ptr = evt_adpt->buf;
|
|
||||||
|
|
||||||
ret = nxsig_notification(notify->pid, ¬ify->event,
|
|
||||||
SI_QUEUE, ¬ify->work);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
wlwarn("nxsig_notification event ID=%" PRId32 " failed: %d\n",
|
|
||||||
evt_adpt->id, ret);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_wifi_lock(false);
|
|
||||||
net_unlock();
|
|
||||||
|
|
||||||
kmm_free(evt_adpt);
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_event_post
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Active work queue and let the work to process the cached event
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* event_base - Event set name
|
|
||||||
* event_id - Event ID
|
|
||||||
* event_data - Event private data
|
|
||||||
* event_data_size - Event data size
|
|
||||||
* ticks - Waiting system ticks
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* 0 if success or -1 if fail
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_event_post(esp_event_base_t event_base,
|
|
||||||
int32_t event_id,
|
|
||||||
void *event_data,
|
|
||||||
size_t event_data_size,
|
|
||||||
uint32_t ticks)
|
|
||||||
{
|
|
||||||
size_t size;
|
|
||||||
int32_t id;
|
|
||||||
irqstate_t flags;
|
|
||||||
struct evt_adpt *evt_adpt;
|
|
||||||
|
|
||||||
wlinfo("Event: base=%s id=%" PRId32 " data=%p data_size=%d "
|
|
||||||
"ticks=%" PRIu32 "\n",
|
|
||||||
event_base, event_id, event_data, event_data_size, ticks);
|
|
||||||
|
|
||||||
id = esp_event_id_map(event_id);
|
|
||||||
if (id < 0)
|
|
||||||
{
|
{
|
||||||
wlinfo("No process event %" PRId32 "\n", event_id);
|
ret = ERROR;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size = event_data_size + sizeof(struct evt_adpt);
|
if (ret != OK)
|
||||||
evt_adpt = kmm_malloc(size);
|
|
||||||
if (!evt_adpt)
|
|
||||||
{
|
{
|
||||||
wlerr("Failed to alloc %d memory\n", size);
|
wlerr("ERROR: %s\n", esp_err_to_name(err));
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
evt_adpt->id = id;
|
return ret;
|
||||||
memcpy(evt_adpt->buf, event_data, event_data_size);
|
|
||||||
|
|
||||||
flags = spin_lock_irqsave(&g_lock_event);
|
|
||||||
sq_addlast(&evt_adpt->entry, &g_wifi_evt_queue);
|
|
||||||
spin_unlock_irqrestore(&g_lock_event, flags);
|
|
||||||
|
|
||||||
work_queue(LPWORK, &g_wifi_evt_work, esp_evt_work_cb, NULL, 0);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_init_event_queue
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Initialize the Wi-Fi event queue that holds pending events to be
|
|
||||||
* processed. This queue is used to store Wi-Fi events like scan
|
|
||||||
* completion, station connect/disconnect etc. before they are handled by
|
|
||||||
* the event work callback.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void esp_init_event_queue(void)
|
|
||||||
{
|
|
||||||
sq_init(&g_wifi_evt_queue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|
@ -1072,94 +788,3 @@ int esp_wifi_lock(bool lock)
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_notify_subscribe
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Enable event notification
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* pid - Task PID
|
|
||||||
* event - Signal event data pointer
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* 0 if success or -1 if fail
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_notify_subscribe(pid_t pid, struct sigevent *event)
|
|
||||||
{
|
|
||||||
int id;
|
|
||||||
struct wifi_notify *notify;
|
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
wlinfo("PID=%d event=%p\n", pid, event);
|
|
||||||
|
|
||||||
esp_wifi_lock(true);
|
|
||||||
|
|
||||||
if (event->sigev_notify == SIGEV_SIGNAL)
|
|
||||||
{
|
|
||||||
id = esp_event_id_map(event->sigev_signo);
|
|
||||||
if (id < 0)
|
|
||||||
{
|
|
||||||
wlerr("No process event %d\n", event->sigev_signo);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
notify = &g_wifi_notify[id];
|
|
||||||
|
|
||||||
if (notify->assigned)
|
|
||||||
{
|
|
||||||
wlerr("sigev_signo %d has subscribed\n",
|
|
||||||
event->sigev_signo);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (pid == 0)
|
|
||||||
{
|
|
||||||
pid = nxsched_gettid();
|
|
||||||
wlinfo("Actual PID=%d\n", pid);
|
|
||||||
}
|
|
||||||
|
|
||||||
notify->pid = pid;
|
|
||||||
notify->event = *event;
|
|
||||||
notify->assigned = true;
|
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (event->sigev_notify == SIGEV_NONE)
|
|
||||||
{
|
|
||||||
id = esp_event_id_map(event->sigev_signo);
|
|
||||||
if (id < 0)
|
|
||||||
{
|
|
||||||
wlerr("No process event %d\n", event->sigev_signo);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
notify = &g_wifi_notify[id];
|
|
||||||
|
|
||||||
if (!notify->assigned)
|
|
||||||
{
|
|
||||||
wlerr("sigev_signo %d has not subscribed\n",
|
|
||||||
event->sigev_signo);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
notify->assigned = false;
|
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wlerr("sigev_notify %d is invalid\n", event->sigev_signo);
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_wifi_lock(false);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -29,13 +29,15 @@
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include <nuttx/net/netdev.h>
|
#include <nuttx/net/netdev.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
|
|
||||||
#include "esp_private/wifi.h"
|
#include "esp_wifi_types_generic.h"
|
||||||
|
|
||||||
#ifndef __ASSEMBLY__
|
#ifndef __ASSEMBLY__
|
||||||
# include <stdint.h>
|
|
||||||
#endif /* __ASSEMBLY__ */
|
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
#define EXTERN extern "C"
|
#define EXTERN extern "C"
|
||||||
extern "C"
|
extern "C"
|
||||||
|
|
@ -44,10 +46,71 @@ extern "C"
|
||||||
#define EXTERN extern
|
#define EXTERN extern
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define MAC_LEN (6)
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Inline Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nuttx_err_to_common_err
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Transform from Nuttx OS error code to low level API error code.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* ret - NuttX error code
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Wi-Fi adapter error code
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESPRESSIF_WIFI
|
||||||
|
static inline int32_t nuttx_err_to_common_err(int ret)
|
||||||
|
{
|
||||||
|
return ret >= 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_ESPRESSIF_WIFI
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp_freq_to_channel
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Converts Wi-Fi frequency to channel.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* freq - Wi-Fi frequency
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Wi-Fi channel
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int esp_freq_to_channel(uint16_t freq);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp_evt_work_init
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize the event work queue
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void esp_evt_work_init(void);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wifi_start_scan
|
* Name: esp_wifi_start_scan
|
||||||
*
|
*
|
||||||
|
|
@ -72,7 +135,7 @@ int esp_wifi_start_scan(struct iwreq *iwr);
|
||||||
* Get scan result
|
* Get scan result
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* req The argument of the ioctl cmd
|
* iwr - The argument of the ioctl cmd
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
* OK on success (positive non-zero values are cmd-specific)
|
||||||
|
|
@ -86,76 +149,52 @@ int esp_wifi_get_scan_results(struct iwreq *iwr);
|
||||||
* Name: esp_wifi_scan_event_parse
|
* Name: esp_wifi_scan_event_parse
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Parse scan information
|
* Parse scan information Wi-Fi AP scan results.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* None
|
* None.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* None.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void esp_wifi_scan_event_parse(void);
|
void esp_wifi_scan_event_parse(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_evt_work_cb
|
* Name: esp_wifi_to_errno
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Process the cached event
|
* Transform from ESP Wi-Fi error code to NuttX error code
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* arg - No mean
|
* err - ESP Wi-Fi error code
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* NuttX error code defined in errno.h
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void esp_evt_work_cb(void *arg);
|
int32_t esp_wifi_to_errno(int err);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_event_post
|
* Name: esp_wifi_mode_translate
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Active work queue and let the work to process the cached event
|
* Translate wireless mode constants to ESP Wi-Fi mode constants.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* event_base - Event set name
|
* wireless_mode - Wireless mode from wireless.h (IW_MODE_*)
|
||||||
* event_id - Event ID
|
|
||||||
* event_data - Event private data
|
|
||||||
* event_data_size - Event data size
|
|
||||||
* ticks - Waiting system ticks
|
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* 0 if success or -1 if fail
|
* ESP Wi-Fi mode (WIFI_MODE_*) on success
|
||||||
|
* -EINVAL on failure
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int esp_event_post(const char *event_base,
|
wifi_mode_t esp_wifi_mode_translate(uint32_t wireless_mode);
|
||||||
int32_t event_id,
|
|
||||||
void *event_data,
|
|
||||||
size_t event_data_size,
|
|
||||||
uint32_t ticks);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_init_event_queue
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Initialize the Wi-Fi event queue that holds pending events to be
|
|
||||||
* processed. This queue is used to store Wi-Fi events like scan
|
|
||||||
* completion, station connect/disconnect etc. before they are handled by
|
|
||||||
* the event work callback.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void esp_init_event_queue(void);
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wifi_lock
|
* Name: esp_wifi_lock
|
||||||
|
|
@ -174,25 +213,42 @@ void esp_init_event_queue(void);
|
||||||
int esp_wifi_lock(bool lock);
|
int esp_wifi_lock(bool lock);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wifi_notify_subscribe
|
* Name: esp_event_post
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Enable event notification
|
* Posts an event to the event loop system. The event is queued in a FIFO
|
||||||
|
* and processed asynchronously in the low-priority work queue.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* pid - Task PID
|
* event_base - Identifier for the event category (e.g. WIFI_EVENT)
|
||||||
* event - Signal event data pointer
|
* event_id - Event ID within the event base category
|
||||||
|
* event_data - Pointer to event data structure
|
||||||
|
* event_data_size - Size of event data structure
|
||||||
|
* ticks - Number of ticks to wait (currently unused)
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* 0 if success or -1 if fail
|
* 0 on success
|
||||||
|
* -1 on failure with following error conditions:
|
||||||
|
* - Invalid event ID
|
||||||
|
* - Memory allocation failure
|
||||||
|
*
|
||||||
|
* Assumptions/Limitations:
|
||||||
|
* - Event data is copied into a new buffer, so the original can be freed
|
||||||
|
* - Events are processed in FIFO order in the low priority work queue
|
||||||
|
* - The function is thread-safe and can be called from interrupt context
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int esp_wifi_notify_subscribe(pid_t pid, struct sigevent *event);
|
int esp_event_post(const char *event_base,
|
||||||
|
int32_t event_id,
|
||||||
|
void *event_data,
|
||||||
|
size_t event_data_size,
|
||||||
|
uint32_t ticks);
|
||||||
|
|
||||||
#undef EXTERN
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#undef EXTERN
|
||||||
|
|
||||||
|
#endif /* __ASSEMBLY__ */
|
||||||
#endif /* __ARCH_XTENSA_SRC_COMMON_ESPRESSIF_ESP_WIFI_UTILS_H */
|
#endif /* __ARCH_XTENSA_SRC_COMMON_ESPRESSIF_ESP_WIFI_UTILS_H */
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@
|
||||||
#include "phy_init_data.h"
|
#include "phy_init_data.h"
|
||||||
|
|
||||||
#include "esp_wireless.h"
|
#include "esp_wireless.h"
|
||||||
|
#include "esp_wifi_utils.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
|
|
@ -365,87 +366,6 @@ static int esp_swi_irq(int irq, void *context, void *arg)
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_to_errno
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Transform from ESP Wi-Fi error code to NuttX error code
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* err - ESP Wi-Fi error code
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* NuttX error code defined in errno.h
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef CONFIG_ARCH_CHIP_ESP32S2
|
|
||||||
int32_t esp_wifi_to_errno(int err)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (err < ESP_ERR_WIFI_BASE)
|
|
||||||
{
|
|
||||||
/* Unmask component error bits */
|
|
||||||
|
|
||||||
ret = err & 0xfff;
|
|
||||||
|
|
||||||
switch (ret)
|
|
||||||
{
|
|
||||||
case ESP_OK:
|
|
||||||
ret = OK;
|
|
||||||
break;
|
|
||||||
case ESP_ERR_NO_MEM:
|
|
||||||
ret = -ENOMEM;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ESP_ERR_INVALID_ARG:
|
|
||||||
ret = -EINVAL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ESP_ERR_INVALID_STATE:
|
|
||||||
ret = -EIO;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ESP_ERR_INVALID_SIZE:
|
|
||||||
ret = -EINVAL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ESP_ERR_NOT_FOUND:
|
|
||||||
ret = -ENOSYS;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ESP_ERR_NOT_SUPPORTED:
|
|
||||||
ret = -ENOSYS;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ESP_ERR_TIMEOUT:
|
|
||||||
ret = -ETIMEDOUT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ESP_ERR_INVALID_MAC:
|
|
||||||
ret = -EINVAL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
ret = ERROR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ret = ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret != OK)
|
|
||||||
{
|
|
||||||
wlerr("ERROR: %s\n", esp_err_to_name(err));
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Functions needed by libphy.a
|
* Functions needed by libphy.a
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
@ -1047,7 +967,7 @@ int esp_timer_create(const esp_timer_create_args_t *create_args,
|
||||||
rt_timer_args.callback = create_args->callback;
|
rt_timer_args.callback = create_args->callback;
|
||||||
|
|
||||||
ret = rt_timer_create(&rt_timer_args, &rt_timer);
|
ret = rt_timer_create(&rt_timer_args, &rt_timer);
|
||||||
if (ret)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
wlerr("Failed to create rt_timer error=%d\n", ret);
|
wlerr("Failed to create rt_timer error=%d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
1405
arch/xtensa/src/common/espressif/esp_wlan_netdev.c
Normal file
1405
arch/xtensa/src/common/espressif/esp_wlan_netdev.c
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1,5 +1,5 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/xtensa/src/common/espressif/esp_wlan.h
|
* arch/xtensa/src/common/espressif/esp_wlan_netdev.h
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
|
|
@ -20,8 +20,8 @@
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef __ARCH_XTENSA_SRC_COMMON_ESPRESSIF_ESP_WLAN_H
|
#ifndef __ARCH_XTENSA_SRC_COMMON_ESPRESSIF_ESP_WLAN_NETDEV_H
|
||||||
#define __ARCH_XTENSA_SRC_COMMON_ESPRESSIF_ESP_WLAN_H
|
#define __ARCH_XTENSA_SRC_COMMON_ESPRESSIF_ESP_WLAN_NETDEV_H
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
|
|
@ -29,16 +29,6 @@
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_CHIP_ESP32
|
|
||||||
# include "esp32_wifi_adapter.h"
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_ARCH_CHIP_ESP32S2
|
|
||||||
# include "esp32s2_wifi_adapter.h"
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_ARCH_CHIP_ESP32S3
|
|
||||||
# include "esp32s3_wifi_adapter.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __ASSEMBLY__
|
#ifndef __ASSEMBLY__
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
|
|
@ -50,119 +40,147 @@ extern "C"
|
||||||
#define EXTERN extern
|
#define EXTERN extern
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_ESPRESSIF_WIFI
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_ESPRESSIF_WIFI_STATION)
|
#if defined(CONFIG_ESPRESSIF_WIFI_STATION)
|
||||||
# define ESPRESSIF_WLAN_HAS_STA
|
# define ESP_WLAN_HAS_STA
|
||||||
# define ESPRESSIF_WLAN_STA_DEVNO 0
|
# define ESP_WLAN_STA_DEVNO 0
|
||||||
# define ESPRESSIF_WLAN_DEVS 1
|
# define ESP_WLAN_DEVS 1
|
||||||
#elif defined(CONFIG_ESPRESSIF_WIFI_SOFTAP)
|
#elif defined(CONFIG_ESPRESSIF_WIFI_SOFTAP)
|
||||||
# define ESPRESSIF_WLAN_HAS_SOFTAP
|
# define ESP_WLAN_HAS_SOFTAP
|
||||||
# define ESPRESSIF_WLAN_SOFTAP_DEVNO 0
|
# define ESP_WLAN_SOFTAP_DEVNO 0
|
||||||
# define ESPRESSIF_WLAN_DEVS 1
|
# define ESP_WLAN_DEVS 1
|
||||||
#elif defined(CONFIG_ESPRESSIF_WIFI_STATION_SOFTAP)
|
#elif defined(CONFIG_ESPRESSIF_WIFI_STATION_SOFTAP)
|
||||||
# define ESPRESSIF_WLAN_HAS_STA
|
# define ESP_WLAN_HAS_STA
|
||||||
# define ESPRESSIF_WLAN_HAS_SOFTAP
|
# define ESP_WLAN_HAS_SOFTAP
|
||||||
# define ESPRESSIF_WLAN_STA_DEVNO 0
|
# define ESP_WLAN_HAS_APSTA
|
||||||
# define ESPRESSIF_WLAN_SOFTAP_DEVNO 1
|
# define ESP_WLAN_STA_DEVNO 0
|
||||||
# define ESPRESSIF_WLAN_DEVS 2
|
# define ESP_WLAN_SOFTAP_DEVNO 1
|
||||||
|
# define ESP_WLAN_DEVS 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef ESPRESSIF_WLAN_HAS_STA
|
|
||||||
|
|
||||||
/* If reconnect automatically */
|
|
||||||
|
|
||||||
extern volatile bool g_sta_reconnect;
|
|
||||||
|
|
||||||
/* If Wi-Fi sta starts */
|
|
||||||
|
|
||||||
extern volatile bool g_sta_started;
|
|
||||||
|
|
||||||
/* If Wi-Fi sta connected */
|
|
||||||
|
|
||||||
extern volatile bool g_sta_connected;
|
|
||||||
|
|
||||||
#endif /* ESPRESSIF_WLAN_HAS_STA */
|
|
||||||
|
|
||||||
#ifdef ESPRESSIF_WLAN_HAS_SOFTAP
|
|
||||||
|
|
||||||
/* If Wi-Fi SoftAP starts */
|
|
||||||
|
|
||||||
extern volatile bool g_softap_started;
|
|
||||||
|
|
||||||
#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wlan_sta_set_linkstatus
|
* Name: esp_wlan_sta_connect_success_hook
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Set Wi-Fi station link status
|
* Notify the networking layer that connection has succeeded.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Input Parameters:
|
||||||
* linkstatus - true Notifies the networking layer about an available
|
* None.
|
||||||
* carrier, false Notifies the networking layer about an
|
|
||||||
* disappeared carrier.
|
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success; Negated errno on failure.
|
* None.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int esp_wlan_sta_set_linkstatus(bool linkstatus);
|
#ifdef ESP_WLAN_HAS_STA
|
||||||
|
void esp_wlan_sta_connect_success_hook(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp_wlan_sta_disconnect_hook
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Notify the networking layer that connection has been disconnected.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef ESP_WLAN_HAS_STA
|
||||||
|
void esp_wlan_sta_disconnect_hook(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp_wlan_softap_connect_success_hook
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Notify the networking layer that connection has succeeded.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef ESP_WLAN_HAS_SOFTAP
|
||||||
|
void esp_wlan_softap_connect_success_hook(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: esp_wlan_softap_disconnect_hook
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Notify the networking layer that connection has been disconnected.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef ESP_WLAN_HAS_SOFTAP
|
||||||
|
void esp_wlan_softap_disconnect_hook(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wlan_sta_initialize
|
* Name: esp_wlan_sta_initialize
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Initialize the ESP32|S2|S3 WLAN station netcard driver
|
* Initialize the Wi-Fi adapter for station mode.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* None
|
* None.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success; Negated errno on failure.
|
* OK on success; Negated errno on failure.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef ESP_WLAN_HAS_STA
|
||||||
int esp_wlan_sta_initialize(void);
|
int esp_wlan_sta_initialize(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wlan_softap_initialize
|
* Name: esp_wlan_softap_initialize
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Initialize the ESP32|S2|S3 WLAN softAP netcard driver
|
* Initialize the Wi-Fi adapter for SoftAP mode.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* None
|
* None.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success; Negated errno on failure.
|
* OK on success; Negated errno on failure.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef ESP_WLAN_HAS_SOFTAP
|
||||||
int esp_wlan_softap_initialize(void);
|
int esp_wlan_softap_initialize(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* CONFIG_ESPRESSIF_WIFI */
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
|
|
||||||
#endif /* __ASSEMBLY__ */
|
#endif /* __ASSEMBLY__ */
|
||||||
#endif /* __ARCH_XTENSA_SRC_COMMON_ESPRESSIF_ESP_WLAN_H */
|
#endif /* __ARCH_XTENSA_SRC_COMMON_ESPRESSIF_ESP_WLAN_NETDEV_H */
|
||||||
|
|
@ -223,7 +223,7 @@ endif
|
||||||
|
|
||||||
ESP_HAL_3RDPARTY_REPO = esp-hal-3rdparty
|
ESP_HAL_3RDPARTY_REPO = esp-hal-3rdparty
|
||||||
ifndef ESP_HAL_3RDPARTY_VERSION
|
ifndef ESP_HAL_3RDPARTY_VERSION
|
||||||
ESP_HAL_3RDPARTY_VERSION = 96185c5348c747d2e15baef639d0b2a842ecd504
|
ESP_HAL_3RDPARTY_VERSION = b6fa6c9098318007a61acc7c9f0f180443bb80c2
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifndef ESP_HAL_3RDPARTY_URL
|
ifndef ESP_HAL_3RDPARTY_URL
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@
|
||||||
#include "utils/memory_reserve.h"
|
#include "utils/memory_reserve.h"
|
||||||
#include "esp32_rt_timer.h"
|
#include "esp32_rt_timer.h"
|
||||||
#include "espressif/esp_wireless.h"
|
#include "espressif/esp_wireless.h"
|
||||||
|
#include "espressif/esp_wifi_utils.h"
|
||||||
#include "esp32_irq.h"
|
#include "esp32_irq.h"
|
||||||
#include "esp32_spicache.h"
|
#include "esp32_spicache.h"
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -45,741 +45,10 @@ extern "C"
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define SSID_MAX_LEN (32)
|
|
||||||
#define PWD_MAX_LEN (64)
|
|
||||||
|
|
||||||
#define CONFIG_IDF_TARGET_ESP32 1
|
|
||||||
|
|
||||||
/* Define esp_err_t */
|
|
||||||
|
|
||||||
typedef int esp_err_t;
|
|
||||||
|
|
||||||
enum coex_log_level_e
|
|
||||||
{
|
|
||||||
COEX_LOG_NONE = 0,
|
|
||||||
COEX_LOG_ERROR,
|
|
||||||
COEX_LOG_WARN,
|
|
||||||
COEX_LOG_INFO,
|
|
||||||
COEX_LOG_DEBUG,
|
|
||||||
COEX_LOG_VERBOSE
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Wi-Fi event callback function */
|
|
||||||
|
|
||||||
typedef void (*wifi_evt_cb_t)(void *p);
|
|
||||||
|
|
||||||
/* Wi-Fi TX done callback function */
|
|
||||||
|
|
||||||
typedef void (*wifi_txdone_cb_t)(uint8_t *data, uint16_t *len, bool status);
|
|
||||||
|
|
||||||
#define COEX_ADAPTER_FUNCS_TIME_BLOCKING 0xffffffff
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_adapter_init
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Initialize ESP32 Wi-Fi adapter
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* 0 if success or -1 if fail
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_adapter_init(void);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_free_eb
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Free Wi-Fi receive callback input eb pointer
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* eb - Wi-Fi receive callback input eb pointer
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void esp_wifi_free_eb(void *eb);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_start
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Start Wi-Fi station.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_start(void);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_stop
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Stop Wi-Fi station.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_stop(void);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_send_data
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Use Wi-Fi station interface to send 802.3 frame
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* pbuf - Packet buffer pointer
|
|
||||||
* len - Packet length
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_send_data(void *pbuf, size_t len);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_register_recv_cb
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Regitser Wi-Fi station receive packet callback function
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* recv_cb - Receive callback function
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_register_recv_cb(int (*recv_cb)(void *buffer,
|
|
||||||
uint16_t len,
|
|
||||||
void *eb));
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_register_txdone_cb
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Register the station TX done callback function.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* cb - The callback function
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void esp_wifi_sta_register_txdone_cb(wifi_txdone_cb_t cb);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_read_mac
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Read station interface MAC address from efuse
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* mac - MAC address buffer pointer
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* 0 if success or -1 if fail
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_read_mac(uint8_t *mac);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_set_password
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set/Get Wi-Fi station password
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_password(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_essid
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set/Get Wi-Fi station ESSID
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_essid(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_bssid
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set/Get Wi-Fi station BSSID
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_bssid(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_connect
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Trigger Wi-Fi station connection action
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_connect(void);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_disconnect
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Trigger Wi-Fi station disconnection action
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_disconnect(void);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_mode
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set/Get Wi-Fi Station mode code.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_mode(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_auth
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set/Get station authentication mode params.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_auth(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_freq
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get station frequency.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_freq(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_bitrate
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get station default bit rate (Mbps).
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_bitrate(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_get_txpower
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get station transmit power (dBm).
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_txpower(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_get_channel_range
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get station range of channel parameters.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_channel(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_country
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Configure country info.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_country(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_rssi
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get Wi-Fi sensitivity (dBm).
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_rssi(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_start
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Start Wi-Fi softAP.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_start(void);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_stop
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Stop Wi-Fi softAP.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_stop(void);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_send_data
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Use Wi-Fi softAP interface to send 802.3 frame
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* pbuf - Packet buffer pointer
|
|
||||||
* len - Packet length
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_send_data(void *pbuf, size_t len);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_register_recv_cb
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Regitser Wi-Fi softAP receive packet callback function
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* recv_cb - Receive callback function
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_register_recv_cb(int (*recv_cb)(void *buffer,
|
|
||||||
uint16_t len,
|
|
||||||
void *eb));
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_register_txdone_cb
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Register the softAP TX done callback function.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* cb - The callback function
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void esp_wifi_softap_register_txdone_cb(wifi_txdone_cb_t cb);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_read_mac
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Read softAP interface MAC address from efuse
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* mac - MAC address buffer pointer
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* 0 if success or -1 if fail
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_read_mac(uint8_t *mac);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_password
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set/Get Wi-Fi SoftAP password
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_password(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_essid
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set/Get Wi-Fi SoftAP ESSID
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_essid(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_bssid
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set/Get Wi-Fi softAP BSSID
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_bssid(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_connect
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Trigger Wi-Fi softAP accept connection action
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_connect(void);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_disconnect
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Trigger Wi-Fi softAP drop connection action
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_disconnect(void);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_mode
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set/Get Wi-Fi SoftAP mode code.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_mode(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_auth
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set/Get authentication mode params.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_auth(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_freq
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set/Get SoftAP frequency.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_freq(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_get_bitrate
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get SoftAP default bit rate (Mbps).
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_bitrate(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_txpower
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get SoftAP transmit power (dBm).
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_txpower(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_channel
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get SoftAP range of channel parameters.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_channel(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_country
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Configure country info.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_country(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_rssi
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get Wi-Fi sensitivity (dBm).
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_rssi(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp32_wifi_bt_coexist_init
|
* Name: esp32_wifi_bt_coexist_init
|
||||||
*
|
*
|
||||||
|
|
@ -797,25 +66,8 @@ int esp_wifi_softap_rssi(struct iwreq *iwr, bool set);
|
||||||
|
|
||||||
#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST
|
#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST
|
||||||
int esp32_wifi_bt_coexist_init(void);
|
int esp32_wifi_bt_coexist_init(void);
|
||||||
void coex_dbg_set_log_level(int level);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_stop_callback
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Callback to stop Wi-Fi
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void esp_wifi_stop_callback(void);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)efus
|
||||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_adc$(DELIM)adc_cali.c
|
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_adc$(DELIM)adc_cali.c
|
||||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_adc$(DELIM)$(CHIP_SERIES)$(DELIM)adc_cali_line_fitting.c
|
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_adc$(DELIM)$(CHIP_SERIES)$(DELIM)adc_cali_line_fitting.c
|
||||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_app_format$(DELIM)esp_app_desc.c
|
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_app_format$(DELIM)esp_app_desc.c
|
||||||
|
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_common$(DELIM)src$(DELIM)esp_err_to_name.c
|
||||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hw_support$(DELIM)adc_share_hw_ctrl.c
|
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hw_support$(DELIM)adc_share_hw_ctrl.c
|
||||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hw_support$(DELIM)clk_ctrl_os.c
|
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hw_support$(DELIM)clk_ctrl_os.c
|
||||||
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hw_support$(DELIM)cpu.c
|
CHIP_CSRCS += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hw_support$(DELIM)cpu.c
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ endif
|
||||||
|
|
||||||
ESP_HAL_3RDPARTY_REPO = esp-hal-3rdparty
|
ESP_HAL_3RDPARTY_REPO = esp-hal-3rdparty
|
||||||
ifndef ESP_HAL_3RDPARTY_VERSION
|
ifndef ESP_HAL_3RDPARTY_VERSION
|
||||||
ESP_HAL_3RDPARTY_VERSION = 96185c5348c747d2e15baef639d0b2a842ecd504
|
ESP_HAL_3RDPARTY_VERSION = b6fa6c9098318007a61acc7c9f0f180443bb80c2
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifndef ESP_HAL_3RDPARTY_URL
|
ifndef ESP_HAL_3RDPARTY_URL
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -207,7 +207,7 @@ endif
|
||||||
|
|
||||||
ESP_HAL_3RDPARTY_REPO = esp-hal-3rdparty
|
ESP_HAL_3RDPARTY_REPO = esp-hal-3rdparty
|
||||||
ifndef ESP_HAL_3RDPARTY_VERSION
|
ifndef ESP_HAL_3RDPARTY_VERSION
|
||||||
ESP_HAL_3RDPARTY_VERSION = 96185c5348c747d2e15baef639d0b2a842ecd504
|
ESP_HAL_3RDPARTY_VERSION = b6fa6c9098318007a61acc7c9f0f180443bb80c2
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifndef ESP_HAL_3RDPARTY_URL
|
ifndef ESP_HAL_3RDPARTY_URL
|
||||||
|
|
|
||||||
|
|
@ -3163,6 +3163,71 @@ uint32_t get_ble_controller_free_heap_size(void)
|
||||||
* Other Functions
|
* Other Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
int32_t esp_ble_to_errno(int err)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (err < ESP_ERR_WIFI_BASE)
|
||||||
|
{
|
||||||
|
/* Unmask component error bits */
|
||||||
|
|
||||||
|
ret = err & 0xfff;
|
||||||
|
|
||||||
|
switch (ret)
|
||||||
|
{
|
||||||
|
case ESP_OK:
|
||||||
|
ret = OK;
|
||||||
|
break;
|
||||||
|
case ESP_ERR_NO_MEM:
|
||||||
|
ret = -ENOMEM;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ESP_ERR_INVALID_ARG:
|
||||||
|
ret = -EINVAL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ESP_ERR_INVALID_STATE:
|
||||||
|
ret = -EIO;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ESP_ERR_INVALID_SIZE:
|
||||||
|
ret = -EINVAL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ESP_ERR_NOT_FOUND:
|
||||||
|
ret = -ENOSYS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ESP_ERR_NOT_SUPPORTED:
|
||||||
|
ret = -ENOSYS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ESP_ERR_TIMEOUT:
|
||||||
|
ret = -ETIMEDOUT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ESP_ERR_INVALID_MAC:
|
||||||
|
ret = -EINVAL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
ret = ERROR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret != OK)
|
||||||
|
{
|
||||||
|
wlerr("ERROR: %s\n", esp_err_to_name(err));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp32s3_bt_controller_init
|
* Name: esp32s3_bt_controller_init
|
||||||
*
|
*
|
||||||
|
|
@ -3318,7 +3383,7 @@ error:
|
||||||
|
|
||||||
bt_controller_deinit_internal ();
|
bt_controller_deinit_internal ();
|
||||||
|
|
||||||
return esp_wifi_to_errno(err);
|
return esp_ble_to_errno(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -26,9 +26,6 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include <nuttx/wireless/wireless.h>
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#ifndef __ASSEMBLY__
|
#ifndef __ASSEMBLY__
|
||||||
|
|
||||||
|
|
@ -45,725 +42,10 @@ extern "C"
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define SSID_MAX_LEN (32)
|
|
||||||
#define PWD_MAX_LEN (64)
|
|
||||||
|
|
||||||
#define CONFIG_IDF_TARGET_ESP32S3 1
|
|
||||||
|
|
||||||
/* Define esp_err_t */
|
|
||||||
|
|
||||||
typedef int esp_err_t;
|
|
||||||
|
|
||||||
/* Wi-Fi TX done callback function */
|
|
||||||
|
|
||||||
typedef void (*wifi_txdone_cb_t)(uint8_t *data, uint16_t *len, bool status);
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_adapter_init
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Initialize ESP32S3 Wi-Fi adapter
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* 0 if success or -1 if fail
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_adapter_init(void);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_free_eb
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Free Wi-Fi receive callback input eb pointer
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* eb - Wi-Fi receive callback input eb pointer
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void esp_wifi_free_eb(void *eb);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_start
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Start Wi-Fi station.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_start(void);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_stop
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Stop Wi-Fi station.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_stop(void);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_send_data
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Use Wi-Fi station interface to send 802.3 frame
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* pbuf - Packet buffer pointer
|
|
||||||
* len - Packet length
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_send_data(void *pbuf, size_t len);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_register_recv_cb
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Regitser Wi-Fi station receive packet callback function
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* recv_cb - Receive callback function
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_register_recv_cb(int (*recv_cb)(void *buffer,
|
|
||||||
uint16_t len,
|
|
||||||
void *eb));
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_register_txdone_cb
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Register the station TX done callback function.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* cb - The callback function
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void esp_wifi_sta_register_txdone_cb(wifi_txdone_cb_t cb);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_read_mac
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Read station interface MAC address from efuse
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* mac - MAC address buffer pointer
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* 0 if success or -1 if fail
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_read_mac(uint8_t *mac);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_set_password
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set/Get Wi-Fi station password
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_password(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_essid
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set/Get Wi-Fi station ESSID
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_essid(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_bssid
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set/Get Wi-Fi station BSSID
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_bssid(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_connect
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Trigger Wi-Fi station connection action
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_connect(void);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_disconnect
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Trigger Wi-Fi station disconnection action
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_disconnect(void);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_mode
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set/Get Wi-Fi Station mode code.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_mode(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_auth
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set/Get station authentication mode params.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_auth(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_freq
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get station frequency.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_freq(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_bitrate
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get station default bit rate (Mbps).
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_bitrate(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_get_txpower
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get station transmit power (dBm).
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_txpower(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_get_channel_range
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get station range of channel parameters.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_channel(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_country
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Configure country info.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_country(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_sta_rssi
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get Wi-Fi sensitivity (dBm).
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_sta_rssi(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_start
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Start Wi-Fi softAP.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_start(void);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_stop
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Stop Wi-Fi softAP.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_stop(void);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_send_data
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Use Wi-Fi softAP interface to send 802.3 frame
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* pbuf - Packet buffer pointer
|
|
||||||
* len - Packet length
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_send_data(void *pbuf, size_t len);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_register_recv_cb
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Regitser Wi-Fi softAP receive packet callback function
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* recv_cb - Receive callback function
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_register_recv_cb(int (*recv_cb)(void *buffer,
|
|
||||||
uint16_t len,
|
|
||||||
void *eb));
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_register_txdone_cb
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Register the softAP TX done callback function.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* cb - The callback function
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void esp_wifi_softap_register_txdone_cb(wifi_txdone_cb_t cb);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_read_mac
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Read softAP interface MAC address from efuse
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* mac - MAC address buffer pointer
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* 0 if success or -1 if fail
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_read_mac(uint8_t *mac);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_password
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set/Get Wi-Fi SoftAP password
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_password(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_essid
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set/Get Wi-Fi SoftAP ESSID
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_essid(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_bssid
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set/Get Wi-Fi softAP BSSID
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_bssid(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_connect
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Trigger Wi-Fi softAP accept connection action
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_connect(void);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_disconnect
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Trigger Wi-Fi softAP drop connection action
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_disconnect(void);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_mode
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set/Get Wi-Fi SoftAP mode code.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_mode(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_auth
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set/Get authentication mode params.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_auth(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_freq
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Set/Get SoftAP frequency.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_freq(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_get_bitrate
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get SoftAP default bit rate (Mbps).
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_bitrate(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_txpower
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get SoftAP transmit power (dBm).
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_txpower(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_channel
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get SoftAP range of channel parameters.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_channel(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_country
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Configure country info.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_country(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_softap_rssi
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get Wi-Fi sensitivity (dBm).
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* iwr - The argument of the ioctl cmd
|
|
||||||
* set - true: set data; false: get data
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK on success (positive non-zero values are cmd-specific)
|
|
||||||
* Negated errno returned on failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int esp_wifi_softap_rssi(struct iwreq *iwr, bool set);
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: esp_wifi_bt_coexist_init
|
* Name: esp_wifi_bt_coexist_init
|
||||||
*
|
*
|
||||||
|
|
@ -783,22 +65,6 @@ int esp_wifi_softap_rssi(struct iwreq *iwr, bool set);
|
||||||
int esp_wifi_bt_coexist_init(void);
|
int esp_wifi_bt_coexist_init(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: esp_wifi_stop_callback
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Callback to stop Wi-Fi
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* None
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void esp_wifi_stop_callback(void);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue