Merge branch 'feature/remove_wifi_config_option' into 'master'

Remove wifi config option

Remove Wi-Fi enable/disable option from Kconfig. This can be detected by the presence of esp_wifi_init() function in the application. Minimum footprint impact after the change.

See merge request !1098
This commit is contained in:
Ivan Grokhotkov
2017-08-16 18:43:56 +08:00
18 changed files with 145 additions and 99 deletions

View File

@@ -560,15 +560,19 @@ config ESP32_XTAL_FREQ
endmenu endmenu
menuconfig WIFI_ENABLED config NO_BLOBS
bool "WiFi" bool "No Binary Blobs"
default y depends on !BT_ENABLED
default n
help help
Select this option to enable WiFi stack and show the submenu with WiFi configuration choices. If enabled, this disables the linking of binary libraries in the application build. Note
that after enabling this Wi-Fi/Bluetooth will not work.
menu Wi-Fi
config SW_COEXIST_ENABLE config SW_COEXIST_ENABLE
bool "Software controls WiFi/Bluetooth coexistence" bool "Software controls WiFi/Bluetooth coexistence"
depends on WIFI_ENABLED && BT_ENABLED depends on BT_ENABLED
default n default n
help help
If enabled, WiFi & Bluetooth coexistence is controlled by software rather than hardware. If enabled, WiFi & Bluetooth coexistence is controlled by software rather than hardware.
@@ -578,7 +582,6 @@ config SW_COEXIST_ENABLE
config ESP32_WIFI_STATIC_RX_BUFFER_NUM config ESP32_WIFI_STATIC_RX_BUFFER_NUM
int "Max number of WiFi static RX buffers" int "Max number of WiFi static RX buffers"
depends on WIFI_ENABLED
range 2 25 range 2 25
default 10 default 10
help help
@@ -590,7 +593,6 @@ config ESP32_WIFI_STATIC_RX_BUFFER_NUM
config ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM config ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM
int "Max number of WiFi dynamic RX buffers" int "Max number of WiFi dynamic RX buffers"
depends on WIFI_ENABLED
range 0 128 range 0 128
default 32 default 32
help help
@@ -606,7 +608,6 @@ config ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM
choice ESP32_WIFI_TX_BUFFER choice ESP32_WIFI_TX_BUFFER
prompt "Type of WiFi TX buffers" prompt "Type of WiFi TX buffers"
depends on WIFI_ENABLED
default ESP32_WIFI_DYNAMIC_TX_BUFFER default ESP32_WIFI_DYNAMIC_TX_BUFFER
help help
Select type of WiFi tx buffers and show the submenu with the number of WiFi tx buffers choice. Select type of WiFi tx buffers and show the submenu with the number of WiFi tx buffers choice.
@@ -626,13 +627,11 @@ endchoice
config ESP32_WIFI_TX_BUFFER_TYPE config ESP32_WIFI_TX_BUFFER_TYPE
int int
depends on WIFI_ENABLED
default 0 if ESP32_WIFI_STATIC_TX_BUFFER default 0 if ESP32_WIFI_STATIC_TX_BUFFER
default 1 if ESP32_WIFI_DYNAMIC_TX_BUFFER default 1 if ESP32_WIFI_DYNAMIC_TX_BUFFER
config ESP32_WIFI_STATIC_TX_BUFFER_NUM config ESP32_WIFI_STATIC_TX_BUFFER_NUM
int "Max number of WiFi static TX buffers" int "Max number of WiFi static TX buffers"
depends on WIFI_ENABLED
depends on ESP32_WIFI_STATIC_TX_BUFFER depends on ESP32_WIFI_STATIC_TX_BUFFER
range 16 64 range 16 64
default 32 default 32
@@ -646,7 +645,6 @@ config ESP32_WIFI_STATIC_TX_BUFFER_NUM
config ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM config ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM
int "Max number of WiFi dynamic TX buffers" int "Max number of WiFi dynamic TX buffers"
depends on WIFI_ENABLED
depends on ESP32_WIFI_DYNAMIC_TX_BUFFER depends on ESP32_WIFI_DYNAMIC_TX_BUFFER
range 16 64 range 16 64
default 32 default 32
@@ -659,7 +657,6 @@ config ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM
config ESP32_WIFI_AMPDU_ENABLED config ESP32_WIFI_AMPDU_ENABLED
bool "WiFi AMPDU" bool "WiFi AMPDU"
depends on WIFI_ENABLED
default y default y
help help
Select this option to enable AMPDU feature Select this option to enable AMPDU feature
@@ -689,21 +686,14 @@ config ESP32_WIFI_RX_BA_WIN
config ESP32_WIFI_NVS_ENABLED config ESP32_WIFI_NVS_ENABLED
bool "WiFi NVS flash" bool "WiFi NVS flash"
depends on WIFI_ENABLED
default y default y
help help
Select this option to enable WiFi NVS flash Select this option to enable WiFi NVS flash
config PHY_ENABLED
bool
default y if WIFI_ENABLED || BT_ENABLED
menu PHY menu PHY
visible if PHY_ENABLED
config ESP32_PHY_CALIBRATION_AND_DATA_STORAGE config ESP32_PHY_CALIBRATION_AND_DATA_STORAGE
bool "Do phy calibration and store calibration data in NVS" bool "Do phy calibration and store calibration data in NVS"
depends on PHY_ENABLED
default y default y
help help
If this option is enabled, NVS will be initialized and calibration data will be loaded from there. If this option is enabled, NVS will be initialized and calibration data will be loaded from there.
@@ -714,7 +704,6 @@ config ESP32_PHY_CALIBRATION_AND_DATA_STORAGE
config ESP32_PHY_INIT_DATA_IN_PARTITION config ESP32_PHY_INIT_DATA_IN_PARTITION
bool "Use a partition to store PHY init data" bool "Use a partition to store PHY init data"
depends on PHY_ENABLED
default n default n
help help
If enabled, PHY init data will be loaded from a partition. If enabled, PHY init data will be loaded from a partition.
@@ -733,15 +722,13 @@ config ESP32_PHY_MAX_WIFI_TX_POWER
int "Max WiFi TX power (dBm)" int "Max WiFi TX power (dBm)"
range 0 20 range 0 20
default 20 default 20
depends on PHY_ENABLED && WIFI_ENABLED
help help
Set maximum transmit power for WiFi radio. Actual transmit power for high Set maximum transmit power for WiFi radio. Actual transmit power for high
data rates may be lower than this setting. data rates may be lower than this setting.
config ESP32_PHY_MAX_TX_POWER config ESP32_PHY_MAX_TX_POWER
int int
depends on PHY_ENABLED default ESP32_PHY_MAX_WIFI_TX_POWER
default 20 if !WIFI_ENABLED
default ESP32_PHY_MAX_WIFI_TX_POWER if WIFI_ENABLED
endmenu endmenu
endmenu

View File

@@ -7,12 +7,8 @@ CFLAGS += -DBOOTLOADER_BUILD
#endif #endif
COMPONENT_SRCDIRS := . hwcrypto COMPONENT_SRCDIRS := . hwcrypto
LIBS := core rtc ifndef CONFIG_NO_BLOBS
ifdef CONFIG_PHY_ENABLED # BT || WIFI LIBS := core rtc net80211 pp wpa smartconfig coexist wps wpa2 phy
LIBS += phy coexist
endif
ifdef CONFIG_WIFI_ENABLED
LIBS += net80211 pp wpa smartconfig coexist wps wpa2
endif endif
LINKER_SCRIPTS += esp32.common.ld esp32.rom.ld esp32.peripherals.ld LINKER_SCRIPTS += esp32.common.ld esp32.rom.ld esp32.peripherals.ld

View File

@@ -23,6 +23,7 @@
#include "esp_event_loop.h" #include "esp_event_loop.h"
#include "esp_task.h" #include "esp_task.h"
#include "esp_eth.h" #include "esp_eth.h"
#include "esp_system.h"
#include "rom/ets_sys.h" #include "rom/ets_sys.h"
@@ -47,7 +48,6 @@ do{\
typedef esp_err_t (*system_event_handler_t)(system_event_t *e); typedef esp_err_t (*system_event_handler_t)(system_event_t *e);
#ifdef CONFIG_WIFI_ENABLED
static esp_err_t system_event_ap_start_handle_default(system_event_t *event); static esp_err_t system_event_ap_start_handle_default(system_event_t *event);
static esp_err_t system_event_ap_stop_handle_default(system_event_t *event); static esp_err_t system_event_ap_stop_handle_default(system_event_t *event);
static esp_err_t system_event_sta_start_handle_default(system_event_t *event); static esp_err_t system_event_sta_start_handle_default(system_event_t *event);
@@ -55,7 +55,6 @@ static esp_err_t system_event_sta_stop_handle_default(system_event_t *event);
static esp_err_t system_event_sta_connected_handle_default(system_event_t *event); static esp_err_t system_event_sta_connected_handle_default(system_event_t *event);
static esp_err_t system_event_sta_disconnected_handle_default(system_event_t *event); static esp_err_t system_event_sta_disconnected_handle_default(system_event_t *event);
static esp_err_t system_event_sta_got_ip_default(system_event_t *event); static esp_err_t system_event_sta_got_ip_default(system_event_t *event);
#endif
#ifdef CONFIG_ETHERNET #ifdef CONFIG_ETHERNET
static esp_err_t system_event_eth_start_handle_default(system_event_t *event); static esp_err_t system_event_eth_start_handle_default(system_event_t *event);
@@ -68,27 +67,25 @@ static esp_err_t system_event_eth_disconnected_handle_default(system_event_t *ev
Any entry in this table which is disabled by config will have a NULL handler. Any entry in this table which is disabled by config will have a NULL handler.
*/ */
static const system_event_handler_t default_event_handlers[SYSTEM_EVENT_MAX] = { static system_event_handler_t default_event_handlers[SYSTEM_EVENT_MAX] = {
#ifdef CONFIG_WIFI_ENABLED
[SYSTEM_EVENT_WIFI_READY] = NULL, [SYSTEM_EVENT_WIFI_READY] = NULL,
[SYSTEM_EVENT_SCAN_DONE] = NULL, [SYSTEM_EVENT_SCAN_DONE] = NULL,
[SYSTEM_EVENT_STA_START] = system_event_sta_start_handle_default, [SYSTEM_EVENT_STA_START] = NULL,
[SYSTEM_EVENT_STA_STOP] = system_event_sta_stop_handle_default, [SYSTEM_EVENT_STA_STOP] = NULL,
[SYSTEM_EVENT_STA_CONNECTED] = system_event_sta_connected_handle_default, [SYSTEM_EVENT_STA_CONNECTED] = NULL,
[SYSTEM_EVENT_STA_DISCONNECTED] = system_event_sta_disconnected_handle_default, [SYSTEM_EVENT_STA_DISCONNECTED] = NULL,
[SYSTEM_EVENT_STA_AUTHMODE_CHANGE] = NULL, [SYSTEM_EVENT_STA_AUTHMODE_CHANGE] = NULL,
[SYSTEM_EVENT_STA_GOT_IP] = system_event_sta_got_ip_default, [SYSTEM_EVENT_STA_GOT_IP] = NULL,
[SYSTEM_EVENT_STA_WPS_ER_SUCCESS] = NULL, [SYSTEM_EVENT_STA_WPS_ER_SUCCESS] = NULL,
[SYSTEM_EVENT_STA_WPS_ER_FAILED] = NULL, [SYSTEM_EVENT_STA_WPS_ER_FAILED] = NULL,
[SYSTEM_EVENT_STA_WPS_ER_TIMEOUT] = NULL, [SYSTEM_EVENT_STA_WPS_ER_TIMEOUT] = NULL,
[SYSTEM_EVENT_STA_WPS_ER_PIN] = NULL, [SYSTEM_EVENT_STA_WPS_ER_PIN] = NULL,
[SYSTEM_EVENT_AP_START] = system_event_ap_start_handle_default, [SYSTEM_EVENT_AP_START] = NULL,
[SYSTEM_EVENT_AP_STOP] = system_event_ap_stop_handle_default, [SYSTEM_EVENT_AP_STOP] = NULL,
[SYSTEM_EVENT_AP_STACONNECTED] = NULL, [SYSTEM_EVENT_AP_STACONNECTED] = NULL,
[SYSTEM_EVENT_AP_STADISCONNECTED] = NULL, [SYSTEM_EVENT_AP_STADISCONNECTED] = NULL,
[SYSTEM_EVENT_AP_PROBEREQRECVED] = NULL, [SYSTEM_EVENT_AP_PROBEREQRECVED] = NULL,
[SYSTEM_EVENT_AP_STA_GOT_IP6] = NULL, [SYSTEM_EVENT_AP_STA_GOT_IP6] = NULL,
#endif
#ifdef CONFIG_ETHERNET #ifdef CONFIG_ETHERNET
[SYSTEM_EVENT_ETH_START] = system_event_eth_start_handle_default, [SYSTEM_EVENT_ETH_START] = system_event_eth_start_handle_default,
[SYSTEM_EVENT_ETH_STOP] = system_event_eth_stop_handle_default, [SYSTEM_EVENT_ETH_STOP] = system_event_eth_stop_handle_default,
@@ -106,7 +103,7 @@ esp_err_t system_event_eth_start_handle_default(system_event_t *event)
esp_eth_get_mac(eth_mac); esp_eth_get_mac(eth_mac);
tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &eth_ip); tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &eth_ip);
tcpip_adapter_start(TCPIP_ADAPTER_IF_ETH, eth_mac, &eth_ip); tcpip_adapter_eth_start(eth_mac, &eth_ip);
return ESP_OK; return ESP_OK;
} }
@@ -156,7 +153,6 @@ esp_err_t system_event_eth_disconnected_handle_default(system_event_t *event)
} }
#endif #endif
#ifdef CONFIG_WIFI_ENABLED
static esp_err_t system_event_sta_got_ip_default(system_event_t *event) static esp_err_t system_event_sta_got_ip_default(system_event_t *event)
{ {
WIFI_API_CALL_CHECK("esp_wifi_internal_set_sta_ip", esp_wifi_internal_set_sta_ip(), ESP_OK); WIFI_API_CALL_CHECK("esp_wifi_internal_set_sta_ip", esp_wifi_internal_set_sta_ip(), ESP_OK);
@@ -178,7 +174,7 @@ esp_err_t system_event_ap_start_handle_default(system_event_t *event)
WIFI_API_CALL_CHECK("esp_wifi_mac_get", esp_wifi_get_mac(ESP_IF_WIFI_AP, ap_mac), ESP_OK); WIFI_API_CALL_CHECK("esp_wifi_mac_get", esp_wifi_get_mac(ESP_IF_WIFI_AP, ap_mac), ESP_OK);
tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_AP, &ap_ip); tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_AP, &ap_ip);
tcpip_adapter_start(TCPIP_ADAPTER_IF_AP, ap_mac, &ap_ip); tcpip_adapter_ap_start(ap_mac, &ap_ip);
return ESP_OK; return ESP_OK;
} }
@@ -199,7 +195,7 @@ esp_err_t system_event_sta_start_handle_default(system_event_t *event)
WIFI_API_CALL_CHECK("esp_wifi_mac_get", esp_wifi_get_mac(ESP_IF_WIFI_STA, sta_mac), ESP_OK); WIFI_API_CALL_CHECK("esp_wifi_mac_get", esp_wifi_get_mac(ESP_IF_WIFI_STA, sta_mac), ESP_OK);
tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &sta_ip); tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &sta_ip);
tcpip_adapter_start(TCPIP_ADAPTER_IF_STA, sta_mac, &sta_ip); tcpip_adapter_sta_start(sta_mac, &sta_ip);
return ESP_OK; return ESP_OK;
} }
@@ -250,7 +246,6 @@ esp_err_t system_event_sta_disconnected_handle_default(system_event_t *event)
WIFI_API_CALL_CHECK("esp_wifi_internal_reg_rxcb", esp_wifi_internal_reg_rxcb(ESP_IF_WIFI_STA, NULL), ESP_OK); WIFI_API_CALL_CHECK("esp_wifi_internal_reg_rxcb", esp_wifi_internal_reg_rxcb(ESP_IF_WIFI_STA, NULL), ESP_OK);
return ESP_OK; return ESP_OK;
} }
#endif
static esp_err_t esp_system_event_debug(system_event_t *event) static esp_err_t esp_system_event_debug(system_event_t *event)
{ {
@@ -408,3 +403,17 @@ esp_err_t esp_event_process_default(system_event_t *event)
} }
return ESP_OK; return ESP_OK;
} }
esp_err_t esp_wifi_init(wifi_init_config_t *config)
{
default_event_handlers[SYSTEM_EVENT_STA_START] = system_event_sta_start_handle_default;
default_event_handlers[SYSTEM_EVENT_STA_STOP] = system_event_sta_stop_handle_default;
default_event_handlers[SYSTEM_EVENT_STA_CONNECTED] = system_event_sta_connected_handle_default;
default_event_handlers[SYSTEM_EVENT_STA_DISCONNECTED] = system_event_sta_disconnected_handle_default;
default_event_handlers[SYSTEM_EVENT_STA_GOT_IP] = system_event_sta_got_ip_default;
default_event_handlers[SYSTEM_EVENT_AP_START] = system_event_ap_start_handle_default;
default_event_handlers[SYSTEM_EVENT_AP_STOP] = system_event_ap_stop_handle_default;
esp_register_shutdown_handler((shutdown_handler_t)esp_wifi_stop);
return esp_wifi_init_internal(config);
}

View File

@@ -49,6 +49,15 @@ void system_init(void) __attribute__ ((deprecated));
*/ */
void system_restore(void) __attribute__ ((deprecated)); void system_restore(void) __attribute__ ((deprecated));
typedef void (*shutdown_handler_t)(void);
/**
* @brief Register shutdown handler
*
* This function allows you to register a handler that gets invoked before a
* systematic shutdown of the chip.
*/
esp_err_t esp_register_shutdown_handler(shutdown_handler_t handle);
/** /**
* @brief Restart PRO and APP CPUs. * @brief Restart PRO and APP CPUs.
* *

View File

@@ -144,7 +144,7 @@ typedef struct {
extern const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs; extern const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs;
#define WIFI_INIT_CONFIG_MAGIC 0x1F2F3F4F #define WIFI_INIT_CONFIG_MAGIC 0x1F2F3F4F
#ifdef CONFIG_WIFI_ENABLED
#define WIFI_INIT_CONFIG_DEFAULT() { \ #define WIFI_INIT_CONFIG_DEFAULT() { \
.event_handler = &esp_event_send, \ .event_handler = &esp_event_send, \
.wpa_crypto_funcs = g_wifi_default_wpa_crypto_funcs, \ .wpa_crypto_funcs = g_wifi_default_wpa_crypto_funcs, \
@@ -160,9 +160,6 @@ extern const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs;
.rx_ba_win = CONFIG_ESP32_WIFI_RX_BA_WIN,\ .rx_ba_win = CONFIG_ESP32_WIFI_RX_BA_WIN,\
.magic = WIFI_INIT_CONFIG_MAGIC\ .magic = WIFI_INIT_CONFIG_MAGIC\
}; };
#else
#define WIFI_INIT_CONFIG_DEFAULT() {0}; _Static_assert(0, "please enable wifi in menuconfig to use esp_wifi.h");
#endif
/** /**
* @brief Init WiFi * @brief Init WiFi

View File

@@ -40,6 +40,20 @@
extern "C" { extern "C" {
#endif #endif
/**
* @brief Initialize Wi-Fi Driver
* Alloc resource for WiFi driver, such as WiFi control structure, RX/TX buffer,
* WiFi NVS structure among others.
*
* @param config provide WiFi init configuration
*
* @return
* - ESP_OK: succeed
* - ESP_ERR_WIFI_NO_MEM: out of memory
* - others: refer to error code esp_err.h
*/
esp_err_t esp_wifi_init_internal(wifi_init_config_t *config);
/** /**
* @brief get whether the wifi driver is allowed to transmit data or not * @brief get whether the wifi driver is allowed to transmit data or not
* *

View File

@@ -32,7 +32,6 @@
#include "nvs_flash.h" #include "nvs_flash.h"
#include "sdkconfig.h" #include "sdkconfig.h"
#ifdef CONFIG_PHY_ENABLED
#include "phy.h" #include "phy.h"
#include "phy_init_data.h" #include "phy_init_data.h"
#include "esp_coexist.h" #include "esp_coexist.h"
@@ -298,4 +297,3 @@ void esp_phy_load_cal_and_init(void)
free(cal_data); // PHY maintains a copy of calibration data, so we can free this free(cal_data); // PHY maintains a copy of calibration data, so we can free this
} }
#endif // CONFIG_PHY_ENABLED

View File

@@ -39,6 +39,9 @@ static const char* TAG = "system_api";
static uint8_t base_mac_addr[6] = { 0 }; static uint8_t base_mac_addr[6] = { 0 };
#define SHUTDOWN_HANDLERS_NO 2
static shutdown_handler_t shutdown_handlers[SHUTDOWN_HANDLERS_NO];
void system_init() void system_init()
{ {
} }
@@ -227,23 +230,28 @@ esp_err_t esp_read_mac(uint8_t* mac, esp_mac_type_t type)
return ESP_OK; return ESP_OK;
} }
void esp_restart_noos() __attribute__ ((noreturn)); esp_err_t esp_register_shutdown_handler(shutdown_handler_t handler)
/* Dummy function to be used instead of esp_wifi_stop if WiFi stack is not
* linked in (even though CONFIG_WIFI_ENABLED is set).
*/
esp_err_t wifi_stop_noop()
{ {
int i;
for (i = 0; i < SHUTDOWN_HANDLERS_NO; i++) {
if (shutdown_handlers[i] == NULL) {
shutdown_handlers[i] = handler;
return ESP_OK; return ESP_OK;
}
}
return ESP_FAIL;
} }
esp_err_t esp_wifi_stop(void) __attribute((weak, alias("wifi_stop_noop"))); void esp_restart_noos() __attribute__ ((noreturn));
void IRAM_ATTR esp_restart(void) void IRAM_ATTR esp_restart(void)
{ {
#ifdef CONFIG_WIFI_ENABLED int i;
esp_wifi_stop(); for (i = 0; i < SHUTDOWN_HANDLERS_NO; i++) {
#endif if (shutdown_handlers[i]) {
shutdown_handlers[i]();
}
}
// Disable scheduler on this core. // Disable scheduler on this core.
vTaskSuspendAll(); vTaskSuspendAll();

View File

@@ -96,8 +96,7 @@ config FREERTOS_WATCHPOINT_END_OF_STACK
config FREERTOS_THREAD_LOCAL_STORAGE_POINTERS config FREERTOS_THREAD_LOCAL_STORAGE_POINTERS
int "Number of thread local storage pointers" int "Number of thread local storage pointers"
range 0 256 if !(WIFI_ENABLED || ETHERNET) range 1 256
range 1 256 if WIFI_ENABLED || ETHERNET
default 1 default 1
help help
FreeRTOS has the ability to store per-thread pointers in the task FreeRTOS has the ability to store per-thread pointers in the task

View File

@@ -177,13 +177,8 @@ typedef struct tcpip_adapter_api_msg_s {
void tcpip_adapter_init(void); void tcpip_adapter_init(void);
/** /**
* @brief Start an interface with specific MAC and IP * @brief Start the ethernet interface with specific MAC and IP
* *
* softAP or station interface will be initialized, connect WiFi stack with TCPIP stack.
*
* For softAP interface, DHCP server will be started automatically.
*
* @param[in] tcpip_if: the interface which we will start
* @param[in] mac: set MAC address of this interface * @param[in] mac: set MAC address of this interface
* @param[in] ip_info: set IP address of this interface * @param[in] ip_info: set IP address of this interface
* *
@@ -191,7 +186,37 @@ void tcpip_adapter_init(void);
* ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS * ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS
* ESP_ERR_NO_MEM * ESP_ERR_NO_MEM
*/ */
esp_err_t tcpip_adapter_start(tcpip_adapter_if_t tcpip_if, uint8_t *mac, tcpip_adapter_ip_info_t *ip_info); esp_err_t tcpip_adapter_eth_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info);
/**
* @brief Start the Wi-Fi station interface with specific MAC and IP
*
* Station interface will be initialized, connect WiFi stack with TCPIP stack.
*
* @param[in] mac: set MAC address of this interface
* @param[in] ip_info: set IP address of this interface
*
* @return ESP_OK
* ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS
* ESP_ERR_NO_MEM
*/
esp_err_t tcpip_adapter_sta_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info);
/**
* @brief Start the Wi-Fi AP interface with specific MAC and IP
*
* softAP interface will be initialized, connect WiFi stack with TCPIP stack.
*
* DHCP server will be started automatically.
*
* @param[in] mac: set MAC address of this interface
* @param[in] ip_info: set IP address of this interface
*
* @return ESP_OK
* ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS
* ESP_ERR_NO_MEM
*/
esp_err_t tcpip_adapter_ap_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info);
/** /**
* @brief Stop an interface * @brief Stop an interface

View File

@@ -40,6 +40,7 @@
static struct netif *esp_netif[TCPIP_ADAPTER_IF_MAX]; static struct netif *esp_netif[TCPIP_ADAPTER_IF_MAX];
static tcpip_adapter_ip_info_t esp_ip[TCPIP_ADAPTER_IF_MAX]; static tcpip_adapter_ip_info_t esp_ip[TCPIP_ADAPTER_IF_MAX];
static tcpip_adapter_ip6_info_t esp_ip6[TCPIP_ADAPTER_IF_MAX]; static tcpip_adapter_ip6_info_t esp_ip6[TCPIP_ADAPTER_IF_MAX];
static netif_init_fn esp_netif_init_fn[TCPIP_ADAPTER_IF_MAX];
static tcpip_adapter_dhcp_status_t dhcps_status = TCPIP_ADAPTER_DHCP_INIT; static tcpip_adapter_dhcp_status_t dhcps_status = TCPIP_ADAPTER_DHCP_INIT;
static tcpip_adapter_dhcp_status_t dhcpc_status[TCPIP_ADAPTER_IF_MAX] = {TCPIP_ADAPTER_DHCP_INIT}; static tcpip_adapter_dhcp_status_t dhcpc_status[TCPIP_ADAPTER_IF_MAX] = {TCPIP_ADAPTER_DHCP_INIT};
@@ -96,22 +97,12 @@ void tcpip_adapter_init(void)
} }
} }
static netif_init_fn tcpip_if_to_netif_init_fn(tcpip_adapter_if_t tcpip_if) static inline netif_init_fn tcpip_if_to_netif_init_fn(tcpip_adapter_if_t tcpip_if)
{ {
switch(tcpip_if) { if (tcpip_if < TCPIP_ADAPTER_IF_MAX)
#ifdef CONFIG_WIFI_ENABLED return esp_netif_init_fn[tcpip_if];
case TCPIP_ADAPTER_IF_AP: else
return wlanif_init_ap;
case TCPIP_ADAPTER_IF_STA:
return wlanif_init_sta;
#endif
#ifdef CONFIG_ETHERNET
case TCPIP_ADAPTER_IF_ETH:
return ethernetif_init;
#endif
default:
return NULL; return NULL;
}
} }
static int tcpip_adapter_ipc_check(tcpip_adapter_api_msg_t *msg) static int tcpip_adapter_ipc_check(tcpip_adapter_api_msg_t *msg)
@@ -181,6 +172,24 @@ esp_err_t tcpip_adapter_start(tcpip_adapter_if_t tcpip_if, uint8_t *mac, tcpip_a
return ESP_OK; return ESP_OK;
} }
esp_err_t tcpip_adapter_eth_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info)
{
esp_netif_init_fn[TCPIP_ADAPTER_IF_ETH] = ethernetif_init;
return tcpip_adapter_start(TCPIP_ADAPTER_IF_ETH, mac, ip_info);
}
esp_err_t tcpip_adapter_sta_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info)
{
esp_netif_init_fn[TCPIP_ADAPTER_IF_STA] = wlanif_init_sta;
return tcpip_adapter_start(TCPIP_ADAPTER_IF_STA, mac, ip_info);
}
esp_err_t tcpip_adapter_ap_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info)
{
esp_netif_init_fn[TCPIP_ADAPTER_IF_AP] = wlanif_init_ap;
return tcpip_adapter_start(TCPIP_ADAPTER_IF_AP, mac, ip_info);
}
static esp_err_t tcpip_adapter_start_api(tcpip_adapter_api_msg_t * msg) static esp_err_t tcpip_adapter_start_api(tcpip_adapter_api_msg_t * msg)
{ {
return tcpip_adapter_start(msg->tcpip_if, msg->mac, msg->ip_info); return tcpip_adapter_start(msg->tcpip_if, msg->mac, msg->ip_info);

View File

@@ -1,4 +1,3 @@
# Override some defaults so BT stack is enabled # Override some defaults so BT stack is enabled
# and WiFi disabled by default in this example # by default in this example
CONFIG_BT_ENABLED=y CONFIG_BT_ENABLED=y
CONFIG_WIFI_ENABLED=n

View File

@@ -1,4 +1,3 @@
# Override some defaults so BT stack is enabled # Override some defaults so BT stack is enabled
# and WiFi disabled by default in this example # by default in this example
CONFIG_BT_ENABLED=y CONFIG_BT_ENABLED=y
CONFIG_WIFI_ENABLED=n

View File

@@ -1,4 +1,3 @@
# Override some defaults so BT stack is enabled # Override some defaults so BT stack is enabled
# and WiFi disabled by default in this example # by default in this example
CONFIG_BT_ENABLED=y CONFIG_BT_ENABLED=y
CONFIG_WIFI_ENABLED=n

View File

@@ -1,2 +1 @@
# CONFIG_WIFI_ENABLED is not set
CONFIG_ETHERNET=y CONFIG_ETHERNET=y

View File

@@ -1,2 +1,2 @@
# Disable WiFi stack by default #
CONFIG_WIFI_ENABLED=n

View File

@@ -174,7 +174,6 @@ CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=0
# CONFIG_ESP32_XTAL_FREQ_26 is not set # CONFIG_ESP32_XTAL_FREQ_26 is not set
CONFIG_ESP32_XTAL_FREQ_AUTO=y CONFIG_ESP32_XTAL_FREQ_AUTO=y
CONFIG_ESP32_XTAL_FREQ=0 CONFIG_ESP32_XTAL_FREQ=0
CONFIG_WIFI_ENABLED=y
CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10
CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=0 CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=0
# CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set # CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set