Merge branch 'bugfix/fix_wifi_bugs_v4.4' into 'release/v4.4'

esp_wifi: fix wifi bugs (Backport v4.4)

See merge request espressif/esp-idf!16278
This commit is contained in:
Jiang Jiang Jian 2021-12-08 15:46:40 +00:00
commit e104dd7f27
21 changed files with 186 additions and 161 deletions

View File

@ -1,16 +1,8 @@
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed 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.
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "esp_netif.h"
#include "esp_wifi_default.h"
@ -31,7 +23,9 @@
//
const esp_netif_inherent_config_t _g_esp_netif_inherent_sta_config = ESP_NETIF_INHERENT_DEFAULT_WIFI_STA();
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
const esp_netif_inherent_config_t _g_esp_netif_inherent_ap_config = ESP_NETIF_INHERENT_DEFAULT_WIFI_AP();
#endif
const esp_netif_inherent_config_t _g_esp_netif_inherent_eth_config = ESP_NETIF_INHERENT_DEFAULT_ETH();

View File

@ -1,16 +1,8 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed 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.
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _ESP_NETIF_DEFAULTS_H
#define _ESP_NETIF_DEFAULTS_H
@ -37,6 +29,7 @@ extern "C" {
.route_prio = 100 \
} \
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
#define ESP_NETIF_INHERENT_DEFAULT_WIFI_AP() \
{ \
.flags = (esp_netif_flags_t)(ESP_NETIF_DHCP_SERVER | ESP_NETIF_FLAG_AUTOUP), \
@ -48,6 +41,7 @@ extern "C" {
.if_desc = "ap", \
.route_prio = 10 \
};
#endif
#define ESP_NETIF_INHERENT_DEFAULT_ETH() \
{ \
@ -108,6 +102,7 @@ extern "C" {
.stack = ESP_NETIF_NETSTACK_DEFAULT_ETH, \
}
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
/**
* @brief Default configuration reference of WIFI AP
*/
@ -117,6 +112,7 @@ extern "C" {
.driver = NULL, \
.stack = ESP_NETIF_NETSTACK_DEFAULT_WIFI_AP, \
}
#endif
/**
* @brief Default configuration reference of WIFI STA
@ -154,10 +150,12 @@ extern "C" {
*/
#define ESP_NETIF_BASE_DEFAULT_WIFI_STA &_g_esp_netif_inherent_sta_config
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
/**
* @brief Default base config (esp-netif inherent) of WIFI AP
*/
#define ESP_NETIF_BASE_DEFAULT_WIFI_AP &_g_esp_netif_inherent_ap_config
#endif
/**
* @brief Default base config (esp-netif inherent) of ethernet interface
@ -177,7 +175,9 @@ extern "C" {
#define ESP_NETIF_NETSTACK_DEFAULT_ETH _g_esp_netif_netstack_default_eth
#define ESP_NETIF_NETSTACK_DEFAULT_WIFI_STA _g_esp_netif_netstack_default_wifi_sta
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
#define ESP_NETIF_NETSTACK_DEFAULT_WIFI_AP _g_esp_netif_netstack_default_wifi_ap
#endif
#define ESP_NETIF_NETSTACK_DEFAULT_PPP _g_esp_netif_netstack_default_ppp
#define ESP_NETIF_NETSTACK_DEFAULT_SLIP _g_esp_netif_netstack_default_slip
#define ESP_NETIF_NETSTACK_DEFAULT_OPENTHREAD _g_esp_netif_netstack_default_openthread
@ -190,7 +190,9 @@ extern "C" {
//
extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_eth;
extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_wifi_sta;
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_wifi_ap;
#endif
extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_ppp;
extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_slip;
@ -200,12 +202,16 @@ extern const esp_netif_netstack_config_t *_g_esp_netif_netstack_default_slip;
// common behavioural patterns for common interfaces such as STA, AP, ETH, PPP
//
extern const esp_netif_inherent_config_t _g_esp_netif_inherent_sta_config;
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
extern const esp_netif_inherent_config_t _g_esp_netif_inherent_ap_config;
#endif
extern const esp_netif_inherent_config_t _g_esp_netif_inherent_eth_config;
extern const esp_netif_inherent_config_t _g_esp_netif_inherent_ppp_config;
extern const esp_netif_inherent_config_t _g_esp_netif_inherent_slip_config;
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
extern const esp_netif_ip_info_t _g_esp_netif_soft_ap_ip;
#endif
#if CONFIG_OPENTHREAD_ENABLED
/**

View File

@ -325,4 +325,10 @@ menu "Wi-Fi"
help
Select this option to enable GMAC support. GMAC support is compulsory for WiFi 192 bit certification.
config ESP_WIFI_SOFTAP_SUPPORT
bool "WiFi SoftAP Support"
default y
help
WiFi module can be compiled without SoftAP to save code size.
endmenu # Wi-Fi

View File

@ -1,16 +1,8 @@
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed 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.
/*
* SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ESP_WIFI_OS_ADAPTER_H_
#define ESP_WIFI_OS_ADAPTER_H_

View File

@ -1,16 +1,8 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed 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.
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* Notes about WiFi Programming
@ -275,7 +267,7 @@ esp_err_t esp_wifi_deinit(void);
* @brief Set the WiFi operating mode
*
* Set the WiFi operating mode as station, soft-AP or station+soft-AP,
* The default mode is soft-AP mode.
* The default mode is station mode.
*
* @param mode WiFi operating mode
*

@ -1 +1 @@
Subproject commit 681c8bfeb739c2fcd579e404b1df8b19acc07497
Subproject commit 657dd399cff195341fd536d503ce99f0d46876a6

View File

@ -1,16 +1,9 @@
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed 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.
/*
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include "esp_wifi.h"
#include "esp_netif.h"
#include "esp_log.h"
@ -110,6 +103,7 @@ static void wifi_default_action_sta_disconnected(void *arg, esp_event_base_t bas
}
}
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
static void wifi_default_action_ap_start(void *arg, esp_event_base_t base, int32_t event_id, void *data)
{
if (s_wifi_netifs[WIFI_IF_AP] != NULL) {
@ -123,6 +117,7 @@ static void wifi_default_action_ap_stop(void *arg, esp_event_base_t base, int32_
esp_netif_action_stop(s_wifi_netifs[WIFI_IF_AP], base, event_id, data);
}
}
#endif
static void wifi_default_action_sta_got_ip(void *arg, esp_event_base_t base, int32_t event_id, void *data)
{
@ -145,8 +140,10 @@ esp_err_t _esp_wifi_clear_default_wifi_handlers(void)
esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_STA_STOP, wifi_default_action_sta_stop);
esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_STA_CONNECTED, wifi_default_action_sta_connected);
esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, wifi_default_action_sta_disconnected);
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_AP_START, wifi_default_action_ap_start);
esp_event_handler_unregister(WIFI_EVENT, WIFI_EVENT_AP_STOP, wifi_default_action_ap_stop);
#endif
esp_event_handler_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, wifi_default_action_sta_got_ip);
esp_unregister_shutdown_handler((shutdown_handler_t)esp_wifi_stop);
wifi_default_handlers_set = false;
@ -162,6 +159,7 @@ esp_err_t _esp_wifi_set_default_wifi_handlers(void)
return ESP_OK;
}
esp_err_t err;
err = esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_START, wifi_default_action_sta_start, NULL);
if (err != ESP_OK) {
goto fail;
@ -182,6 +180,7 @@ esp_err_t _esp_wifi_set_default_wifi_handlers(void)
goto fail;
}
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
err = esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_AP_START, wifi_default_action_ap_start, NULL);
if (err != ESP_OK) {
goto fail;
@ -191,6 +190,7 @@ esp_err_t _esp_wifi_set_default_wifi_handlers(void)
if (err != ESP_OK) {
goto fail;
}
#endif
err = esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, wifi_default_action_sta_got_ip, NULL);
if (err != ESP_OK) {
@ -278,7 +278,11 @@ static esp_err_t create_and_attach(wifi_interface_t wifi_if, esp_netif_t* esp_ne
static inline esp_err_t esp_netif_attach_wifi(esp_netif_t *esp_netif, wifi_interface_t wifi_if)
{
if (esp_netif == NULL || (wifi_if != WIFI_IF_STA && wifi_if != WIFI_IF_AP)) {
if (esp_netif == NULL || (wifi_if != WIFI_IF_STA
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
&& wifi_if != WIFI_IF_AP
#endif
)) {
return ESP_ERR_INVALID_ARG;
}
s_wifi_netifs[wifi_if] = esp_netif;
@ -290,16 +294,19 @@ esp_err_t esp_netif_attach_wifi_station(esp_netif_t *esp_netif)
return esp_netif_attach_wifi(esp_netif, WIFI_IF_STA);
}
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
esp_err_t esp_netif_attach_wifi_ap(esp_netif_t *esp_netif)
{
return esp_netif_attach_wifi(esp_netif, WIFI_IF_AP);
}
#endif
//
// Default WiFi creation from user code
//
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
/**
* @brief User init default AP (official API)
*/
@ -312,6 +319,7 @@ esp_netif_t* esp_netif_create_default_wifi_ap(void)
esp_wifi_set_default_wifi_ap_handlers();
return netif;
}
#endif
/**
* @brief User init default station (official API)
@ -347,9 +355,13 @@ esp_netif_t* esp_netif_create_wifi(wifi_interface_t wifi_if, esp_netif_inherent_
};
if (wifi_if == WIFI_IF_STA) {
cfg.stack = ESP_NETIF_NETSTACK_DEFAULT_WIFI_STA;
} else if (wifi_if == WIFI_IF_AP) {
} else
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
if (wifi_if == WIFI_IF_AP) {
cfg.stack = ESP_NETIF_NETSTACK_DEFAULT_WIFI_AP;
} else {
} else
#endif
{
return NULL;
}
@ -359,6 +371,7 @@ esp_netif_t* esp_netif_create_wifi(wifi_interface_t wifi_if, esp_netif_inherent_
return netif;
}
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
/**
* @brief Creates mesh network interfaces based on default STA and AP,
* but without DHCP, this is to be enabled separately only on root node
@ -404,3 +417,4 @@ esp_err_t esp_netif_create_default_wifi_mesh_netifs(esp_netif_t **p_netif_sta, e
}
return ESP_OK;
}
#endif // CONFIG_ESP_WIFI_SOFTAP_SUPPORT

View File

@ -312,3 +312,9 @@ void ieee80211_ftm_attach(void)
/* Do not remove, stub to overwrite weak link in Wi-Fi Lib */
}
#endif
#ifndef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
void net80211_softap_funcs_init(void)
{
}
#endif

View File

@ -1,16 +1,8 @@
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed 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.
/*
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "esp_wifi.h"
#include "esp_netif.h"
#include "esp_log.h"
@ -47,10 +39,12 @@ static esp_err_t wifi_sta_receive(void *buffer, uint16_t len, void *eb)
return s_wifi_rxcbs[WIFI_IF_STA](s_wifi_netifs[WIFI_IF_STA], buffer, len, eb);
}
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
static esp_err_t wifi_ap_receive(void *buffer, uint16_t len, void *eb)
{
return s_wifi_rxcbs[WIFI_IF_AP](s_wifi_netifs[WIFI_IF_AP], buffer, len, eb);
}
#endif
static void wifi_free(void *h, void* buffer)
{
@ -118,8 +112,12 @@ esp_err_t esp_wifi_get_if_mac(wifi_netif_driver_t ifx, uint8_t mac[6])
bool esp_wifi_is_if_ready_when_started(wifi_netif_driver_t ifx)
{
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
// WiFi rxcb to be register wifi rxcb on start for AP only, station gets it registered on connect event
return (ifx->wifi_if == WIFI_IF_AP);
#else
return false;
#endif
}
esp_err_t esp_wifi_register_if_rxcb(wifi_netif_driver_t ifx, esp_netif_receive_t fn, void * arg)
@ -135,13 +133,16 @@ esp_err_t esp_wifi_register_if_rxcb(wifi_netif_driver_t ifx, esp_netif_receive_t
switch (wifi_interface)
{
case WIFI_IF_STA:
rxcb = wifi_sta_receive;
break;
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
case WIFI_IF_AP:
rxcb = wifi_ap_receive;
break;
#endif
default:
break;

View File

@ -1,16 +1,8 @@
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed 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.
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "esp_netif.h"
#include "esp_private/wifi.h"
@ -51,6 +43,7 @@ static const char* s_netif_keyif[TCPIP_ADAPTER_IF_MAX] = {
static bool s_tcpip_adapter_compat = false;
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
static void wifi_create_and_start_ap(void *esp_netif, esp_event_base_t base, int32_t event_id, void *data)
{
if (s_esp_netifs[TCPIP_ADAPTER_IF_AP] == NULL) {
@ -62,6 +55,7 @@ static void wifi_create_and_start_ap(void *esp_netif, esp_event_base_t base, int
s_esp_netifs[TCPIP_ADAPTER_IF_AP] = ap_netif;
}
}
#endif
static void wifi_create_and_start_sta(void *esp_netif, esp_event_base_t base, int32_t event_id, void *data)
{
@ -85,10 +79,13 @@ static inline esp_netif_t * netif_from_if(tcpip_adapter_if_t interface)
if (interface == TCPIP_ADAPTER_IF_STA) {
wifi_create_and_start_sta(NULL, 0, 0, NULL);
s_esp_netifs[interface] = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
} else if (interface == TCPIP_ADAPTER_IF_AP) {
}
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
else if (interface == TCPIP_ADAPTER_IF_AP) {
wifi_create_and_start_ap(NULL, 0, 0, NULL);
s_esp_netifs[interface] = esp_netif_get_handle_from_ifkey("WIFI_AP_DEF");
}
#endif
}
}
return s_esp_netifs[interface];
@ -147,10 +144,12 @@ esp_err_t tcpip_adapter_sta_input(void *buffer, uint16_t len, void *eb)
return esp_netif_receive(netif_from_if(TCPIP_ADAPTER_IF_STA), buffer, len, eb);
}
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
esp_err_t tcpip_adapter_ap_input(void *buffer, uint16_t len, void *eb)
{
return esp_netif_receive(netif_from_if(TCPIP_ADAPTER_IF_AP), buffer, len, eb);
}
#endif
esp_err_t tcpip_adapter_set_default_wifi_handlers(void)
{
@ -161,10 +160,12 @@ esp_err_t tcpip_adapter_set_default_wifi_handlers(void)
if (err != ESP_OK) {
return err;
}
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
err = esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_AP_START, wifi_create_and_start_ap, NULL);
if (err != ESP_OK) {
return err;
}
#endif
_esp_wifi_set_default_wifi_handlers();
}
return ESP_OK;
@ -319,11 +320,13 @@ esp_err_t tcpip_adapter_sta_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info
mac, ip_info);
}
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
esp_err_t tcpip_adapter_ap_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info)
{
return tcpip_adapter_compat_start_netif(netif_from_if(TCPIP_ADAPTER_IF_AP),
mac, ip_info);
}
#endif
esp_err_t tcpip_adapter_stop(tcpip_adapter_if_t tcpip_if)
{

View File

@ -2,12 +2,15 @@ set(srcs "src/wifi_config.c"
"src/wifi_scan.c"
"src/manager.c"
"src/handlers.c"
"src/scheme_softap.c"
"src/scheme_console.c"
"proto-c/wifi_config.pb-c.c"
"proto-c/wifi_scan.pb-c.c"
"proto-c/wifi_constants.pb-c.c")
if(CONFIG_ESP_WIFI_SOFTAP_SUPPORT)
list(APPEND srcs "src/scheme_softap.c")
endif()
if(CONFIG_BT_ENABLED)
if(CONFIG_BT_BLUEDROID_ENABLED OR CONFIG_BT_NIMBLE_ENABLED)
list(APPEND srcs

View File

@ -7,3 +7,7 @@ ifndef CONFIG_BT_BLUEDROID_ENABLED
COMPONENT_OBJEXCLUDE := src/scheme_ble.o
endif
endif
ifeq ($(CONFIG_ESP_WIFI_SOFTAP_SUPPORT), y)
COMPONENT_OBJEXCLUDE += src/scheme_softap.o
endif

View File

@ -1,16 +1,9 @@
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed 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.
/*
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include <string.h>
#include <esp_log.h>

View File

@ -52,13 +52,15 @@ set(srcs "port/os_xtensa.c"
"src/wps/wps_registrar.c"
"src/wps/wps_validate.c")
set(esp_srcs "esp_supplicant/src/esp_hostap.c"
"esp_supplicant/src/esp_wpa2.c"
set(esp_srcs "esp_supplicant/src/esp_wpa2.c"
"esp_supplicant/src/esp_wpa_main.c"
"esp_supplicant/src/esp_wpas_glue.c"
"esp_supplicant/src/esp_wps.c"
"esp_supplicant/src/esp_wpa3.c"
"esp_supplicant/src/esp_dpp.c")
if(CONFIG_ESP_WIFI_SOFTAP_SUPPORT)
set(esp_srcs ${esp_srcs} "esp_supplicant/src/esp_hostap.c")
endif()
if(CONFIG_WPA_MBEDTLS_CRYPTO)
set(tls_src "src/crypto/tls_mbedtls.c")

View File

@ -4,6 +4,10 @@ COMPONENT_PRIV_INCLUDEDIRS := src src/utils esp_supplicant/src
COMPONENT_SRCDIRS := port src/ap src/common src/crypto src/eap_peer src/rsn_supp src/tls src/utils src/wps esp_supplicant/src
COMPONENT_ADD_INCLUDEDIRS := include port/include esp_supplicant/include src/utils
ifeq ($(CONFIG_ESP_WIFI_SOFTAP_SUPPORT), y)
COMPONENT_OBJEXCLUDE += src/esp_hostap.o
endif
ifeq ($(CONFIG_WPA_MBEDTLS_CRYPTO), y)
COMPONENT_OBJEXCLUDE += src/tls/asn1.o \
src/tls/bignum.o \

View File

@ -1,17 +1,10 @@
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed 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.
/*
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include "utils/includes.h"
#include "utils/common.h"

View File

@ -1,21 +1,24 @@
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed 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.
/*
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ESP_HOSTAP_H
#define ESP_HOSTAP_H
#ifdef __cplusplus
extern "C" {
#endif
#include "sdkconfig.h"
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
void *hostap_init(void);
bool hostap_deinit(void *data);
#endif
#ifdef __cplusplus
}
#endif
#endif /* ESP_HOSTAP_H */

View File

@ -241,7 +241,7 @@ int esp_supplicant_init(void)
int ret = ESP_OK;
struct wpa_funcs *wpa_cb;
wpa_cb = (struct wpa_funcs *)os_malloc(sizeof(struct wpa_funcs));
wpa_cb = (struct wpa_funcs *)os_zalloc(sizeof(struct wpa_funcs));
if (!wpa_cb) {
return ESP_ERR_NO_MEM;
}
@ -253,6 +253,7 @@ int esp_supplicant_init(void)
wpa_cb->wpa_sta_disconnected_cb = wpa_sta_disconnected_cb;
wpa_cb->wpa_sta_in_4way_handshake = wpa_sta_in_4way_handshake;
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
wpa_cb->wpa_ap_join = wpa_ap_join;
wpa_cb->wpa_ap_remove = wpa_ap_remove;
wpa_cb->wpa_ap_get_wpa_ie = wpa_ap_get_wpa_ie;
@ -260,6 +261,7 @@ int esp_supplicant_init(void)
wpa_cb->wpa_ap_get_peer_spp_msg = wpa_ap_get_peer_spp_msg;
wpa_cb->wpa_ap_init = hostap_init;
wpa_cb->wpa_ap_deinit = hostap_deinit;
#endif
wpa_cb->wpa_config_parse_string = wpa_config_parse_string;
wpa_cb->wpa_parse_wpa_ie = wpa_parse_wpa_ie_wrapper;

View File

@ -1,16 +1,8 @@
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed 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.
/*
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <string.h>
@ -572,7 +564,11 @@ wps_parse_scan_result(struct wps_scan_ie *scan)
}
esp_wifi_get_mode(&op_mode);
if ((op_mode == WIFI_MODE_STA || op_mode == WIFI_MODE_APSTA) && scan->wps) {
if ((op_mode == WIFI_MODE_STA
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
|| op_mode == WIFI_MODE_APSTA
#endif
) && scan->wps) {
struct wpabuf *buf = wpabuf_alloc_copy(scan->wps + 6, scan->wps[1] - 4);
if (wps_is_selected_pbc_registrar(buf, scan->bssid)
@ -2003,7 +1999,11 @@ int wps_check_wifi_mode(void)
return ESP_FAIL;
}
if (mode == WIFI_MODE_AP || mode == WIFI_MODE_NULL || sniffer == true) {
if (
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
mode == WIFI_MODE_AP ||
#endif
mode == WIFI_MODE_NULL || sniffer == true) {
wpa_printf(MSG_ERROR, "wps check wifi mode: wrong wifi mode=%d sniffer=%d", mode, sniffer);
return ESP_ERR_WIFI_MODE;
}
@ -2180,7 +2180,11 @@ wifi_set_wps_cb(wps_st_cb_t cb)
wifi_mode_t mode;
esp_wifi_get_mode(&mode);
if (mode == WIFI_MODE_AP || mode == WIFI_MODE_NULL) {
if (
#ifdef CONFIG_ESP_WIFI_SOFTAP_SUPPORT
mode == WIFI_MODE_AP ||
#endif
mode == WIFI_MODE_NULL) {
return false;
}

View File

@ -315,6 +315,7 @@ Wi-Fi
@@@@@
- Disabling :ref:`CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE` will save some Wi-Fi binary size if WPA3 support is not needed. (Note that WPA3 is mandatory for new Wi-Fi device certifications.)
- Disabling :ref:`CONFIG_ESP_WIFI_SOFTAP_SUPPORT` will save some Wi-Fi binary size if soft-AP support is not needed.
.. only:: esp32

View File

@ -317,7 +317,7 @@ static bool wifi_cmd_ap_set(const char* ssid, const char* pass)
if (pass) {
if (strlen(pass) != 0 && strlen(pass) < 8) {
s_reconnect = true;
ESP_LOGE(TAG_AP, "password less than 8");
ESP_LOGE(TAG_AP, "password cannot be less than 8 characters long");
return false;
}
strlcpy((char*) g_ap_config.ap.password, pass, MAX_PASSPHRASE_LEN);
@ -341,8 +341,11 @@ static int wifi_cmd_ap(int argc, char** argv)
return 1;
}
wifi_cmd_ap_set(ap_args.ssid->sval[0], ap_args.password->sval[0]);
ESP_LOGI(TAG_AP, "Starting SoftAP with FTM Responder support, SSID - %s, Password - %s", ap_args.ssid->sval[0], ap_args.password->sval[0]);
if (true == wifi_cmd_ap_set(ap_args.ssid->sval[0], ap_args.password->sval[0]))
ESP_LOGI(TAG_AP, "Starting SoftAP with FTM Responder support, SSID - %s, Password - %s", ap_args.ssid->sval[0], ap_args.password->sval[0]);
else
ESP_LOGE(TAG_AP, "Failed to start SoftAP!");
return 0;
}
@ -476,7 +479,7 @@ static int wifi_cmd_ftm(int argc, char **argv)
}
bits = xEventGroupWaitBits(ftm_event_group, FTM_REPORT_BIT | FTM_FAILURE_BIT,
pdFALSE, pdFALSE, portMAX_DELAY);
pdTRUE, pdFALSE, portMAX_DELAY);
/* Processing data from FTM session */
if (bits & FTM_REPORT_BIT) {
ftm_process_report();
@ -485,7 +488,6 @@ static int wifi_cmd_ftm(int argc, char **argv)
g_ftm_report_num_entries = 0;
ESP_LOGI(TAG_STA, "Estimated RTT - %d nSec, Estimated Distance - %d.%02d meters",
g_rtt_est, g_dist_est / 100, g_dist_est % 100);
xEventGroupClearBits(ftm_event_group, FTM_REPORT_BIT);
} else {
/* Failure case */
}