esp-netif: Make dependency on esp-eth optional

* esp-netif to optionally depend on esp-eth (only for l2tap config)
* esp_eth.h now includes the original ethernet header and the
ethernet-netif glue layer
* Updated examples and test to explicitely use esp-eth dependency if
needed
This commit is contained in:
David Cermak 2022-05-02 15:47:05 +02:00 committed by David Čermák
parent 680f3a50c2
commit 5e19b9c951
14 changed files with 44 additions and 16 deletions

View File

@ -0,0 +1,16 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
/**
* Purpose of this file is to create a common header for the typical ethernet usecase,
* so using the ethernet driver and the default glue layer to its network interface.
*
* If you prefer to create a custom network interface or use the Ethernet as a driver only,
* then it is recommended to include the "esp_eth_driver.h" only.
*/
#include "esp_eth_driver.h"
#include "esp_eth_netif_glue.h"

View File

@ -10,7 +10,6 @@ set(srcs
"esp_netif_handlers.c"
"esp_netif_objects.c"
"esp_netif_defaults.c"
"vfs_l2tap/esp_vfs_l2tap.c"
"lwip/esp_netif_lwip.c"
"lwip/esp_netif_lwip_defaults.c"
"lwip/esp_netif_sta_list.c")
@ -33,7 +32,17 @@ list(APPEND srcs
"loopback/esp_netif_loopback.c")
endif()
if(CONFIG_ESP_NETIF_L2_TAP)
list(APPEND srcs
"vfs_l2tap/esp_vfs_l2tap.c")
endif()
idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "${include_dirs}"
PRIV_INCLUDE_DIRS "${priv_include_dirs}"
REQUIRES lwip esp_eth)
REQUIRES lwip)
if(CONFIG_ESP_NETIF_L2_TAP)
idf_component_optional_requires(PRIVATE esp_eth)
endif()

View File

@ -6,9 +6,6 @@
#include "esp_netif.h"
#include "esp_wifi_default.h"
#if CONFIG_ETH_ENABLED
#include "esp_eth.h"
#endif
//
// Purpose of this module is to provide

View File

@ -14,10 +14,6 @@
#include "esp_netif_types.h"
#include "esp_netif_defaults.h"
#ifdef CONFIG_ETH_ENABLED
#include "esp_eth_netif_glue.h"
#endif
#ifdef __cplusplus
extern "C" {

View File

@ -1,3 +1,3 @@
idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS "../private_include" "."
PRIV_REQUIRES cmock test_utils esp_netif nvs_flash driver)
PRIV_REQUIRES cmock test_utils esp_netif nvs_flash driver esp_eth)

View File

@ -19,12 +19,12 @@
#include "esp_log.h"
#include "esp_check.h"
#include "esp_netif.h"
#include "esp_eth.h"
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include "freertos/queue.h"
#if CONFIG_ESP_NETIF_L2_TAP
#define INVALID_FD (-1)
@ -624,4 +624,3 @@ esp_err_t esp_vfs_l2tap_intf_unregister(const char *base_path)
return ESP_OK;
}
#endif // CONFIG_ESP_NETIF_L2_TAP

View File

@ -20,3 +20,7 @@ idf_component_register(
PRIV_INCLUDE_DIRS "private_include"
REQUIRES ${dependencies}
PRIV_REQUIRES ${private_dependencies})
if(CONFIG_ETH_ENABLED)
idf_component_optional_requires(PRIVATE esp_eth)
endif()

View File

@ -17,6 +17,10 @@
#include "mdns_networking.h"
#include "esp_log.h"
#include "esp_random.h"
#if CONFIG_ETH_ENABLED
#include "esp_eth.h"
#endif
#ifdef MDNS_ENABLE_DEBUG
void mdns_debug_packet(const uint8_t * data, size_t len);

View File

@ -1,2 +1,2 @@
idf_component_register(SRC_DIRS "."
PRIV_REQUIRES cmock test_utils mqtt nvs_flash app_update)
PRIV_REQUIRES cmock test_utils mqtt nvs_flash app_update esp_eth)

View File

@ -1,4 +1,4 @@
idf_component_register(SRCS "connect.c" "stdin_out.c" "addr_from_stdin.c"
INCLUDE_DIRS "include"
PRIV_REQUIRES esp_netif driver
PRIV_REQUIRES esp_netif driver esp_eth
)

View File

@ -15,6 +15,7 @@ extern "C" {
#include "esp_err.h"
#include "esp_netif.h"
#include "esp_eth.h"
#ifdef CONFIG_EXAMPLE_CONNECT_ETHERNET
#define EXAMPLE_INTERFACE get_example_netif()

View File

@ -1,4 +1,4 @@
idf_component_register(SRCS "esp_eth_mac_enc28j60.c"
"esp_eth_phy_enc28j60.c"
PRIV_REQUIRES driver
PRIV_REQUIRES driver esp_eth
INCLUDE_DIRS ".")

View File

@ -14,7 +14,7 @@
#include "freertos/queue.h"
#include "esp_event.h"
#include "esp_log.h"
#include "esp_eth.h"
#include "esp_eth_driver.h"
#include "esp_wifi.h"
#include "nvs_flash.h"
#include "esp_private/wifi.h"

View File

@ -8,6 +8,8 @@
*/
#pragma once
#include "esp_eth.h"
#ifdef __cplusplus
extern "C" {
#endif