mirror of
https://github.com/apache/nuttx.git
synced 2026-05-22 13:52:22 +08: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:
committed by
Xiang Xiao
parent
903b6b168e
commit
20ff68bd65
@@ -1223,12 +1223,6 @@ menuconfig ESPRESSIF_WIFI_BT_COEXIST
|
||||
menu "Wi-Fi Configuration"
|
||||
depends on ESPRESSIF_WIFI
|
||||
|
||||
config ESPRESSIF_WLAN
|
||||
bool "WLAN"
|
||||
default y
|
||||
---help---
|
||||
Enable WLAN support
|
||||
|
||||
menu "ESP WPA-Supplicant"
|
||||
|
||||
config WPA_WAPI_PSK
|
||||
@@ -1241,8 +1235,8 @@ config WPA_WAPI_PSK
|
||||
config WPA_SUITE_B_192
|
||||
bool "Enable NSA suite B support with 192-bit key"
|
||||
default n
|
||||
select ESP_WIFI_GCMP_SUPPORT
|
||||
select ESP_WIFI_GMAC_SUPPORT
|
||||
select ESPRESSIF_WIFI_GCMP_SUPPORT
|
||||
select ESPRESSIF_WIFI_GMAC_SUPPORT
|
||||
---help---
|
||||
Select this option to enable 192-bit NSA suite-B.
|
||||
This is necessary to support WPA3 192-bit security.
|
||||
@@ -1273,12 +1267,49 @@ config ESPRESSIF_WIFI_SOFTAP
|
||||
config ESPRESSIF_WIFI_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
|
||||
bool "Enable SAE-PK"
|
||||
depends on ESPRESSIF_WIFI_ENABLE_WPA3_SAE
|
||||
default y
|
||||
depends on ESP_WIFI_ENABLE_SAE_H2E
|
||||
---help---
|
||||
Select this option to enable SAE-PK
|
||||
|
||||
@@ -1288,7 +1319,15 @@ config ESPRESSIF_WIFI_ENABLE_SAE_H2E
|
||||
---help---
|
||||
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"
|
||||
default y
|
||||
---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
|
||||
explicitly configured before attempting connection. Please refer to the Wi-Fi Driver API Guide for details.
|
||||
|
||||
config ESPRESSIF_WIFI_STATIC_RXBUF_NUM
|
||||
int "Wi-Fi static RX buffer number"
|
||||
choice ESPRESSIF_WIFI_MGMT_RX_BUFFER
|
||||
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
|
||||
---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
|
||||
int "Wi-Fi dynamic RX buffer number"
|
||||
WiFi hardware use these buffers to receive all 802.11 frames.
|
||||
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
|
||||
---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
|
||||
int "Wi-Fi dynamic TX buffer number"
|
||||
For each received data frame, the WiFi driver makes a copy to an RX buffer and then delivers
|
||||
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
|
||||
---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"
|
||||
default y
|
||||
---help---
|
||||
Select this option to enable AMPDU TX feature
|
||||
|
||||
config ESPRESSIF_WIFI_RX_AMPDU
|
||||
bool "Wi-Fi RX AMPDU"
|
||||
default y
|
||||
|
||||
config ESPRESSIF_WIFI_RXBA_AMPDU_WZ
|
||||
int "Wi-Fi RX BA AMPDU windown size"
|
||||
config ESPRESSIF_WIFI_TX_BA_WIN
|
||||
int "WiFi AMPDU TX BA window size"
|
||||
depends on ESPRESSIF_WIFI_AMPDU_TX_ENABLED
|
||||
range 2 32
|
||||
default 6
|
||||
|
||||
config ESPRESSIF_WLAN_PKTBUF_NUM
|
||||
int "WLAN netcard packet buffer number per netcard"
|
||||
default 16
|
||||
config ESPRESSIF_WIFI_AMPDU_RX_ENABLED
|
||||
bool "WiFi AMPDU RX"
|
||||
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)"
|
||||
default n
|
||||
---help---
|
||||
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)"
|
||||
default n
|
||||
---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
|
||||
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
|
||||
|
||||
config ESPRESSIF_ESPNOW_PKTRADIO
|
||||
bool "ESPNOW pktradio support"
|
||||
depends on ESPRESSIF_WLAN
|
||||
depends on ESPRESSIF_WIRELESS
|
||||
depends on WIRELESS_PKTRADIO
|
||||
default n
|
||||
---help---
|
||||
|
||||
@@ -98,8 +98,10 @@ endif
|
||||
ifeq ($(CONFIG_ESPRESSIF_WIRELESS),y)
|
||||
CHIP_CSRCS += esp_wireless.c
|
||||
CHIP_CSRCS += esp_wifi_utils.c
|
||||
ifeq ($(CONFIG_ESPRESSIF_WLAN),y)
|
||||
CHIP_CSRCS += esp_wlan.c
|
||||
ifeq ($(CONFIG_ESPRESSIF_WIFI),y)
|
||||
CHIP_CSRCS += esp_wifi_event_handler.c
|
||||
CHIP_CSRCS += esp_wlan_netdev.c
|
||||
CHIP_CSRCS += esp_wifi_api.c
|
||||
endif
|
||||
ifeq ($(CONFIG_ESPRESSIF_ESPNOW_PKTRADIO), y)
|
||||
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
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESP_WIFI_GCMP_SUPPORT),y)
|
||||
ifeq ($(CONFIG_ESPRESSIF_WIFI_GCMP_SUPPORT),y)
|
||||
CFLAGS += $(DEFINE_PREFIX)CONFIG_GCMP
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESP_WIFI_GMAC_SUPPORT),y)
|
||||
ifeq ($(CONFIG_ESPRESSIF_WIFI_GMAC_SUPPORT),y)
|
||||
CFLAGS += $(DEFINE_PREFIX)CONFIG_GMAC
|
||||
endif
|
||||
|
||||
@@ -273,8 +273,13 @@ CHIP_CSRCS += tls_mbedtls.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)lib_printf.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
|
||||
|
||||
# Linker scripts
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+164
-251
File diff suppressed because it is too large
Load Diff
@@ -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);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -29,13 +29,15 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/net/netdev.h>
|
||||
#include <nuttx/signal.h>
|
||||
|
||||
#include "esp_private/wifi.h"
|
||||
#include "esp_wifi_types_generic.h"
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
# include <stdint.h>
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
@@ -44,10 +46,71 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#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
|
||||
****************************************************************************/
|
||||
|
||||
#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
|
||||
*
|
||||
@@ -72,7 +135,7 @@ int esp_wifi_start_scan(struct iwreq *iwr);
|
||||
* Get scan result
|
||||
*
|
||||
* Input Parameters:
|
||||
* req The argument of the ioctl cmd
|
||||
* iwr - The argument of the ioctl cmd
|
||||
*
|
||||
* Returned Value:
|
||||
* 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
|
||||
*
|
||||
* Description:
|
||||
* Parse scan information
|
||||
* Parse scan information Wi-Fi AP scan results.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
* None.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
* None.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void esp_wifi_scan_event_parse(void);
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp_evt_work_cb
|
||||
* Name: esp_wifi_to_errno
|
||||
*
|
||||
* Description:
|
||||
* Process the cached event
|
||||
* Transform from ESP Wi-Fi error code to NuttX error code
|
||||
*
|
||||
* Input Parameters:
|
||||
* arg - No mean
|
||||
* err - ESP Wi-Fi error code
|
||||
*
|
||||
* 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:
|
||||
* Active work queue and let the work to process the cached event
|
||||
* Translate wireless mode constants to ESP Wi-Fi mode constants.
|
||||
*
|
||||
* 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
|
||||
* wireless_mode - Wireless mode from wireless.h (IW_MODE_*)
|
||||
*
|
||||
* 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,
|
||||
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);
|
||||
wifi_mode_t esp_wifi_mode_translate(uint32_t wireless_mode);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp_wifi_lock
|
||||
@@ -174,25 +213,42 @@ void esp_init_event_queue(void);
|
||||
int esp_wifi_lock(bool lock);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp_wifi_notify_subscribe
|
||||
* Name: esp_event_post
|
||||
*
|
||||
* 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:
|
||||
* pid - Task PID
|
||||
* event - Signal event data pointer
|
||||
* 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 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
|
||||
}
|
||||
#endif
|
||||
#undef EXTERN
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __ARCH_XTENSA_SRC_COMMON_ESPRESSIF_ESP_WIFI_UTILS_H */
|
||||
|
||||
@@ -72,6 +72,7 @@
|
||||
#include "phy_init_data.h"
|
||||
|
||||
#include "esp_wireless.h"
|
||||
#include "esp_wifi_utils.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@@ -365,87 +366,6 @@ static int esp_swi_irq(int irq, void *context, void *arg)
|
||||
* 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
|
||||
****************************************************************************/
|
||||
@@ -1047,7 +967,7 @@ int esp_timer_create(const esp_timer_create_args_t *create_args,
|
||||
rt_timer_args.callback = create_args->callback;
|
||||
|
||||
ret = rt_timer_create(&rt_timer_args, &rt_timer);
|
||||
if (ret)
|
||||
if (ret != 0)
|
||||
{
|
||||
wlerr("Failed to create rt_timer error=%d\n", ret);
|
||||
return ret;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+86
-68
@@ -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
|
||||
*
|
||||
@@ -20,8 +20,8 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_XTENSA_SRC_COMMON_ESPRESSIF_ESP_WLAN_H
|
||||
#define __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_NETDEV_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
@@ -29,16 +29,6 @@
|
||||
|
||||
#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__
|
||||
|
||||
#undef EXTERN
|
||||
@@ -50,119 +40,147 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESPRESSIF_WIFI
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_ESPRESSIF_WIFI_STATION)
|
||||
# define ESPRESSIF_WLAN_HAS_STA
|
||||
# define ESPRESSIF_WLAN_STA_DEVNO 0
|
||||
# define ESPRESSIF_WLAN_DEVS 1
|
||||
# define ESP_WLAN_HAS_STA
|
||||
# define ESP_WLAN_STA_DEVNO 0
|
||||
# define ESP_WLAN_DEVS 1
|
||||
#elif defined(CONFIG_ESPRESSIF_WIFI_SOFTAP)
|
||||
# define ESPRESSIF_WLAN_HAS_SOFTAP
|
||||
# define ESPRESSIF_WLAN_SOFTAP_DEVNO 0
|
||||
# define ESPRESSIF_WLAN_DEVS 1
|
||||
# define ESP_WLAN_HAS_SOFTAP
|
||||
# define ESP_WLAN_SOFTAP_DEVNO 0
|
||||
# define ESP_WLAN_DEVS 1
|
||||
#elif defined(CONFIG_ESPRESSIF_WIFI_STATION_SOFTAP)
|
||||
# define ESPRESSIF_WLAN_HAS_STA
|
||||
# define ESPRESSIF_WLAN_HAS_SOFTAP
|
||||
# define ESPRESSIF_WLAN_STA_DEVNO 0
|
||||
# define ESPRESSIF_WLAN_SOFTAP_DEVNO 1
|
||||
# define ESPRESSIF_WLAN_DEVS 2
|
||||
# define ESP_WLAN_HAS_STA
|
||||
# define ESP_WLAN_HAS_SOFTAP
|
||||
# define ESP_WLAN_HAS_APSTA
|
||||
# define ESP_WLAN_STA_DEVNO 0
|
||||
# define ESP_WLAN_SOFTAP_DEVNO 1
|
||||
# define ESP_WLAN_DEVS 2
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* 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
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp_wlan_sta_set_linkstatus
|
||||
* Name: esp_wlan_sta_connect_success_hook
|
||||
*
|
||||
* Description:
|
||||
* Set Wi-Fi station link status
|
||||
* Notify the networking layer that connection has succeeded.
|
||||
*
|
||||
* Parameters:
|
||||
* linkstatus - true Notifies the networking layer about an available
|
||||
* carrier, false Notifies the networking layer about an
|
||||
* disappeared carrier.
|
||||
* Input Parameters:
|
||||
* None.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* Description:
|
||||
* Initialize the ESP32|S2|S3 WLAN station netcard driver
|
||||
* Initialize the Wi-Fi adapter for station mode.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
* None.
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success; Negated errno on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef ESP_WLAN_HAS_STA
|
||||
int esp_wlan_sta_initialize(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp_wlan_softap_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the ESP32|S2|S3 WLAN softAP netcard driver
|
||||
* Initialize the Wi-Fi adapter for SoftAP mode.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
* None.
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success; Negated errno on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef ESP_WLAN_HAS_SOFTAP
|
||||
int esp_wlan_softap_initialize(void);
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_ESPRESSIF_WIFI */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#undef EXTERN
|
||||
|
||||
#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
|
||||
ifndef ESP_HAL_3RDPARTY_VERSION
|
||||
ESP_HAL_3RDPARTY_VERSION = 96185c5348c747d2e15baef639d0b2a842ecd504
|
||||
ESP_HAL_3RDPARTY_VERSION = b6fa6c9098318007a61acc7c9f0f180443bb80c2
|
||||
endif
|
||||
|
||||
ifndef ESP_HAL_3RDPARTY_URL
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#include "utils/memory_reserve.h"
|
||||
#include "esp32_rt_timer.h"
|
||||
#include "espressif/esp_wireless.h"
|
||||
#include "espressif/esp_wifi_utils.h"
|
||||
#include "esp32_irq.h"
|
||||
#include "esp32_spicache.h"
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -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)$(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_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)clk_ctrl_os.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
|
||||
ifndef ESP_HAL_3RDPARTY_VERSION
|
||||
ESP_HAL_3RDPARTY_VERSION = 96185c5348c747d2e15baef639d0b2a842ecd504
|
||||
ESP_HAL_3RDPARTY_VERSION = b6fa6c9098318007a61acc7c9f0f180443bb80c2
|
||||
endif
|
||||
|
||||
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
|
||||
ifndef ESP_HAL_3RDPARTY_VERSION
|
||||
ESP_HAL_3RDPARTY_VERSION = 96185c5348c747d2e15baef639d0b2a842ecd504
|
||||
ESP_HAL_3RDPARTY_VERSION = b6fa6c9098318007a61acc7c9f0f180443bb80c2
|
||||
endif
|
||||
|
||||
ifndef ESP_HAL_3RDPARTY_URL
|
||||
|
||||
@@ -3163,6 +3163,71 @@ uint32_t get_ble_controller_free_heap_size(void)
|
||||
* 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
|
||||
*
|
||||
@@ -3318,7 +3383,7 @@ error:
|
||||
|
||||
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
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user