mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 12:14:32 +02:00
Merge branch 'bugfix/separate_ethernet_and_wifi' into 'master'
Allow separate ethernet & wifi configuration If only 1/2 of ethernet & WiFi are enabled in config, the other interface is no longer linked into the firmware. * Fixes bug where enabling Ethernet but not WiFi would fail to compile. * Also means that enabling WiFi but not Ethernet no longer links some unused ethernet interface functions. See merge request !525
This commit is contained in:
@@ -45,14 +45,9 @@ do{\
|
|||||||
}\
|
}\
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
typedef esp_err_t (*system_event_handle_fn_t)(system_event_t *e);
|
typedef esp_err_t (*system_event_handler_t)(system_event_t *e);
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
system_event_id_t event_id;
|
|
||||||
system_event_handle_fn_t event_handle;
|
|
||||||
} system_event_handle_t;
|
|
||||||
|
|
||||||
|
|
||||||
|
#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);
|
||||||
@@ -60,39 +55,50 @@ 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
|
||||||
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);
|
||||||
static esp_err_t system_event_eth_stop_handle_default(system_event_t *event);
|
static esp_err_t system_event_eth_stop_handle_default(system_event_t *event);
|
||||||
static esp_err_t system_event_eth_connected_handle_default(system_event_t *event);
|
static esp_err_t system_event_eth_connected_handle_default(system_event_t *event);
|
||||||
static esp_err_t system_event_eth_disconnected_handle_default(system_event_t *event);
|
static esp_err_t system_event_eth_disconnected_handle_default(system_event_t *event);
|
||||||
|
#endif
|
||||||
|
|
||||||
static system_event_handle_t g_system_event_handle_table[] = {
|
/* Default event handler functions
|
||||||
{SYSTEM_EVENT_WIFI_READY, NULL},
|
|
||||||
{SYSTEM_EVENT_SCAN_DONE, NULL},
|
Any entry in this table which is disabled by config will have a NULL handler.
|
||||||
{SYSTEM_EVENT_STA_START, system_event_sta_start_handle_default},
|
*/
|
||||||
{SYSTEM_EVENT_STA_STOP, system_event_sta_stop_handle_default},
|
static const system_event_handler_t default_event_handlers[SYSTEM_EVENT_MAX] = {
|
||||||
{SYSTEM_EVENT_STA_CONNECTED, system_event_sta_connected_handle_default},
|
#ifdef CONFIG_WIFI_ENABLED
|
||||||
{SYSTEM_EVENT_STA_DISCONNECTED, system_event_sta_disconnected_handle_default},
|
[SYSTEM_EVENT_WIFI_READY] = NULL,
|
||||||
{SYSTEM_EVENT_STA_AUTHMODE_CHANGE, NULL},
|
[SYSTEM_EVENT_SCAN_DONE] = NULL,
|
||||||
{SYSTEM_EVENT_STA_GOT_IP, system_event_sta_got_ip_default},
|
[SYSTEM_EVENT_STA_START] = system_event_sta_start_handle_default,
|
||||||
{SYSTEM_EVENT_STA_WPS_ER_SUCCESS, NULL},
|
[SYSTEM_EVENT_STA_STOP] = system_event_sta_stop_handle_default,
|
||||||
{SYSTEM_EVENT_STA_WPS_ER_FAILED, NULL},
|
[SYSTEM_EVENT_STA_CONNECTED] = system_event_sta_connected_handle_default,
|
||||||
{SYSTEM_EVENT_STA_WPS_ER_TIMEOUT, NULL},
|
[SYSTEM_EVENT_STA_DISCONNECTED] = system_event_sta_disconnected_handle_default,
|
||||||
{SYSTEM_EVENT_STA_WPS_ER_PIN, NULL},
|
[SYSTEM_EVENT_STA_AUTHMODE_CHANGE] = NULL,
|
||||||
{SYSTEM_EVENT_AP_START, system_event_ap_start_handle_default},
|
[SYSTEM_EVENT_STA_GOT_IP] = system_event_sta_got_ip_default,
|
||||||
{SYSTEM_EVENT_AP_STOP, system_event_ap_stop_handle_default},
|
[SYSTEM_EVENT_STA_WPS_ER_SUCCESS] = NULL,
|
||||||
{SYSTEM_EVENT_AP_STACONNECTED, NULL},
|
[SYSTEM_EVENT_STA_WPS_ER_FAILED] = NULL,
|
||||||
{SYSTEM_EVENT_AP_STADISCONNECTED, NULL},
|
[SYSTEM_EVENT_STA_WPS_ER_TIMEOUT] = NULL,
|
||||||
{SYSTEM_EVENT_AP_PROBEREQRECVED, NULL},
|
[SYSTEM_EVENT_STA_WPS_ER_PIN] = NULL,
|
||||||
{SYSTEM_EVENT_AP_STA_GOT_IP6, NULL},
|
[SYSTEM_EVENT_AP_START] = system_event_ap_start_handle_default,
|
||||||
{SYSTEM_EVENT_ETH_START, system_event_eth_start_handle_default},
|
[SYSTEM_EVENT_AP_STOP] = system_event_ap_stop_handle_default,
|
||||||
{SYSTEM_EVENT_ETH_STOP, system_event_eth_stop_handle_default},
|
[SYSTEM_EVENT_AP_STACONNECTED] = NULL,
|
||||||
{SYSTEM_EVENT_ETH_CONNECTED, system_event_eth_connected_handle_default},
|
[SYSTEM_EVENT_AP_STADISCONNECTED] = NULL,
|
||||||
{SYSTEM_EVENT_ETH_DISCONNECTED, system_event_eth_disconnected_handle_default},
|
[SYSTEM_EVENT_AP_PROBEREQRECVED] = NULL,
|
||||||
{SYSTEM_EVENT_ETH_GOT_IP, NULL},
|
[SYSTEM_EVENT_AP_STA_GOT_IP6] = NULL,
|
||||||
{SYSTEM_EVENT_MAX, NULL},
|
#endif
|
||||||
|
#ifdef CONFIG_ETHERNET
|
||||||
|
[SYSTEM_EVENT_ETH_START] = system_event_eth_start_handle_default,
|
||||||
|
[SYSTEM_EVENT_ETH_STOP] = system_event_eth_stop_handle_default,
|
||||||
|
[SYSTEM_EVENT_ETH_CONNECTED] = system_event_eth_connected_handle_default,
|
||||||
|
[SYSTEM_EVENT_ETH_DISCONNECTED] = system_event_eth_disconnected_handle_default,
|
||||||
|
[SYSTEM_EVENT_ETH_GOT_IP] = NULL,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef CONFIG_ETHERNET
|
||||||
esp_err_t system_event_eth_start_handle_default(system_event_t *event)
|
esp_err_t system_event_eth_start_handle_default(system_event_t *event)
|
||||||
{
|
{
|
||||||
tcpip_adapter_ip_info_t eth_ip;
|
tcpip_adapter_ip_info_t eth_ip;
|
||||||
@@ -121,7 +127,6 @@ esp_err_t system_event_eth_connected_handle_default(system_event_t *event)
|
|||||||
tcpip_adapter_dhcpc_get_status(TCPIP_ADAPTER_IF_ETH, &status);
|
tcpip_adapter_dhcpc_get_status(TCPIP_ADAPTER_IF_ETH, &status);
|
||||||
|
|
||||||
if (status == TCPIP_ADAPTER_DHCP_INIT) {
|
if (status == TCPIP_ADAPTER_DHCP_INIT) {
|
||||||
|
|
||||||
tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_ETH);
|
tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_ETH);
|
||||||
} else if (status == TCPIP_ADAPTER_DHCP_STOPPED) {
|
} else if (status == TCPIP_ADAPTER_DHCP_STOPPED) {
|
||||||
tcpip_adapter_ip_info_t eth_ip;
|
tcpip_adapter_ip_info_t eth_ip;
|
||||||
@@ -149,9 +154,9 @@ esp_err_t system_event_eth_disconnected_handle_default(system_event_t *event)
|
|||||||
tcpip_adapter_down(TCPIP_ADAPTER_IF_ETH);
|
tcpip_adapter_down(TCPIP_ADAPTER_IF_ETH);
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
#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);
|
||||||
@@ -245,6 +250,7 @@ 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)
|
||||||
{
|
{
|
||||||
@@ -377,10 +383,10 @@ esp_err_t esp_event_process_default(system_event_t *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
esp_system_event_debug(event);
|
esp_system_event_debug(event);
|
||||||
if ((event->event_id < SYSTEM_EVENT_MAX) && (event->event_id == g_system_event_handle_table[event->event_id].event_id)) {
|
if ((event->event_id < SYSTEM_EVENT_MAX)) {
|
||||||
if (g_system_event_handle_table[event->event_id].event_handle) {
|
if (default_event_handlers[event->event_id] != NULL) {
|
||||||
ESP_LOGV(TAG, "enter default callback");
|
ESP_LOGV(TAG, "enter default callback");
|
||||||
g_system_event_handle_table[event->event_id].event_handle(event);
|
default_event_handlers[event->event_id](event);
|
||||||
ESP_LOGV(TAG, "exit default callback");
|
ESP_LOGV(TAG, "exit default callback");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@@ -78,11 +78,6 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if ESP_LWIP
|
|
||||||
#include "esp_wifi_internal.h"
|
|
||||||
#include "esp_eth.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SIZEOF_STRUCT_PBUF LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf))
|
#define SIZEOF_STRUCT_PBUF LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf))
|
||||||
/* Since the pool is created in memp, PBUF_POOL_BUFSIZE will be automatically
|
/* Since the pool is created in memp, PBUF_POOL_BUFSIZE will be automatically
|
||||||
aligned there. Therefore, PBUF_POOL_BUFSIZE_ALIGNED can be used here. */
|
aligned there. Therefore, PBUF_POOL_BUFSIZE_ALIGNED can be used here. */
|
||||||
@@ -352,8 +347,8 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
|
|||||||
p->flags = 0;
|
p->flags = 0;
|
||||||
|
|
||||||
#if ESP_LWIP
|
#if ESP_LWIP
|
||||||
p->user_buf = NULL;
|
p->l2_owner = NULL;
|
||||||
p->user_flag = PBUF_USER_FLAG_OWNER_NULL;
|
p->l2_buf = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloc(length=%"U16_F") == %p\n", length, (void *)p));
|
LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloc(length=%"U16_F") == %p\n", length, (void *)p));
|
||||||
@@ -722,11 +717,10 @@ pbuf_free(struct pbuf *p)
|
|||||||
} else if (type == PBUF_ROM || type == PBUF_REF) {
|
} else if (type == PBUF_ROM || type == PBUF_REF) {
|
||||||
|
|
||||||
#if ESP_LWIP
|
#if ESP_LWIP
|
||||||
if (type == PBUF_REF && p->user_flag == PBUF_USER_FLAG_OWNER_WIFI ) {
|
if (p->l2_owner != NULL
|
||||||
esp_wifi_internal_free_rx_buffer(p->user_buf);
|
&& p->l2_buf != NULL
|
||||||
}
|
&& p->l2_owner->l2_buffer_free_notify != NULL) {
|
||||||
if (type == PBUF_REF && p->user_flag == PBUF_USER_FLAG_OWNER_ETH ) {
|
p->l2_owner->l2_buffer_free_notify(p->l2_buf);
|
||||||
esp_eth_free_rx_buf(p->user_buf);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
memp_free(MEMP_PBUF, p);
|
memp_free(MEMP_PBUF, p);
|
||||||
|
@@ -330,6 +330,10 @@ struct netif {
|
|||||||
u16_t loop_cnt_current;
|
u16_t loop_cnt_current;
|
||||||
#endif /* LWIP_LOOPBACK_MAX_PBUFS */
|
#endif /* LWIP_LOOPBACK_MAX_PBUFS */
|
||||||
#endif /* ENABLE_LOOPBACK */
|
#endif /* ENABLE_LOOPBACK */
|
||||||
|
|
||||||
|
#if ESP_LWIP
|
||||||
|
void (*l2_buffer_free_notify)(void *user_buf); /* Allows LWIP to notify driver when a L2-supplied pbuf can be freed */
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#if LWIP_CHECKSUM_CTRL_PER_NETIF
|
#if LWIP_CHECKSUM_CTRL_PER_NETIF
|
||||||
|
@@ -105,12 +105,6 @@ typedef enum {
|
|||||||
/** indicates this pbuf includes a TCP FIN flag */
|
/** indicates this pbuf includes a TCP FIN flag */
|
||||||
#define PBUF_FLAG_TCP_FIN 0x20U
|
#define PBUF_FLAG_TCP_FIN 0x20U
|
||||||
|
|
||||||
#if ESP_LWIP
|
|
||||||
#define PBUF_USER_FLAG_OWNER_NULL 0
|
|
||||||
#define PBUF_USER_FLAG_OWNER_WIFI 1
|
|
||||||
#define PBUF_USER_FLAG_OWNER_ETH 2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct pbuf {
|
struct pbuf {
|
||||||
/** next pbuf in singly linked pbuf chain */
|
/** next pbuf in singly linked pbuf chain */
|
||||||
struct pbuf *next;
|
struct pbuf *next;
|
||||||
@@ -144,8 +138,8 @@ struct pbuf {
|
|||||||
u16_t ref;
|
u16_t ref;
|
||||||
|
|
||||||
#if ESP_LWIP
|
#if ESP_LWIP
|
||||||
void *user_buf;
|
struct netif *l2_owner;
|
||||||
u8_t user_flag;
|
void *l2_buf;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -82,7 +82,10 @@ ethernet_low_level_init(struct netif *netif)
|
|||||||
netif->flags |= NETIF_FLAG_IGMP;
|
netif->flags |= NETIF_FLAG_IGMP;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
/* Do whatever else is needed to initialize interface. */
|
|
||||||
|
#ifndef CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE
|
||||||
|
netif->l2_buffer_free_notify = esp_eth_free_rx_buf;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -152,11 +155,12 @@ ethernetif_input(struct netif *netif, void *buffer, uint16_t len)
|
|||||||
|
|
||||||
if(buffer== NULL || netif == NULL)
|
if(buffer== NULL || netif == NULL)
|
||||||
goto _exit;
|
goto _exit;
|
||||||
#if CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE
|
#ifdef CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE
|
||||||
p = pbuf_alloc(PBUF_RAW, len, PBUF_RAM);
|
p = pbuf_alloc(PBUF_RAW, len, PBUF_RAM);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
p->l2_owner = NULL;
|
||||||
memcpy(p->payload, buffer, len);
|
memcpy(p->payload, buffer, len);
|
||||||
|
|
||||||
/* full packet send to tcpip_thread to process */
|
/* full packet send to tcpip_thread to process */
|
||||||
@@ -171,13 +175,13 @@ if (netif->input(p, netif) != ERR_OK) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
p->payload = buffer;
|
p->payload = buffer;
|
||||||
p->user_flag = PBUF_USER_FLAG_OWNER_ETH;
|
p->l2_owner = netif;
|
||||||
p->user_buf = buffer;
|
p->l2_buf = buffer;
|
||||||
|
|
||||||
/* full packet send to tcpip_thread to process */
|
/* full packet send to tcpip_thread to process */
|
||||||
if (netif->input(p, netif) != ERR_OK) {
|
if (netif->input(p, netif) != ERR_OK) {
|
||||||
LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
|
LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
|
||||||
p->user_flag = PBUF_USER_FLAG_OWNER_NULL;
|
p->l2_owner = NULL;
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -84,7 +84,9 @@ low_level_init(struct netif *netif)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Do whatever else is needed to initialize interface. */
|
#if !ESP_L2_TO_L3_COPY
|
||||||
|
netif->l2_buffer_free_notify = esp_wifi_internal_free_rx_buffer;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,6 +121,7 @@ low_level_output(struct netif *netif, struct pbuf *p)
|
|||||||
LWIP_DEBUGF(PBUF_DEBUG, ("low_level_output: pbuf is a list, application may has bug"));
|
LWIP_DEBUGF(PBUF_DEBUG, ("low_level_output: pbuf is a list, application may has bug"));
|
||||||
q = pbuf_alloc(PBUF_RAW_TX, p->tot_len, PBUF_RAM);
|
q = pbuf_alloc(PBUF_RAW_TX, p->tot_len, PBUF_RAM);
|
||||||
if (q != NULL) {
|
if (q != NULL) {
|
||||||
|
q->l2_owner = NULL;
|
||||||
pbuf_copy(q, p);
|
pbuf_copy(q, p);
|
||||||
} else {
|
} else {
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
@@ -154,6 +157,7 @@ wlanif_input(struct netif *netif, void *buffer, u16_t len, void* eb)
|
|||||||
esp_wifi_internal_free_rx_buffer(eb);
|
esp_wifi_internal_free_rx_buffer(eb);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
p->l2_owner = NULL;
|
||||||
memcpy(p->payload, buffer, len);
|
memcpy(p->payload, buffer, len);
|
||||||
esp_wifi_internal_free_rx_buffer(eb);
|
esp_wifi_internal_free_rx_buffer(eb);
|
||||||
#else
|
#else
|
||||||
@@ -163,8 +167,8 @@ wlanif_input(struct netif *netif, void *buffer, u16_t len, void* eb)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
p->payload = buffer;
|
p->payload = buffer;
|
||||||
p->user_buf = eb;
|
p->l2_owner = netif;
|
||||||
p->user_flag = PBUF_USER_FLAG_OWNER_WIFI;
|
p->l2_buf = eb;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* full packet send to tcpip_thread to process */
|
/* full packet send to tcpip_thread to process */
|
||||||
|
@@ -60,8 +60,27 @@ void tcpip_adapter_init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static netif_init_fn tcpip_if_to_netif_init_fn(tcpip_adapter_if_t tcpip_if)
|
||||||
|
{
|
||||||
|
switch(tcpip_if) {
|
||||||
|
#ifdef CONFIG_WIFI_ENABLED
|
||||||
|
case TCPIP_ADAPTER_IF_AP:
|
||||||
|
case TCPIP_ADAPTER_IF_STA:
|
||||||
|
return wlanif_init;
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_ETHERNET
|
||||||
|
case TCPIP_ADAPTER_IF_ETH:
|
||||||
|
return ethernetif_init;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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_start(tcpip_adapter_if_t tcpip_if, uint8_t *mac, tcpip_adapter_ip_info_t *ip_info)
|
||||||
{
|
{
|
||||||
|
netif_init_fn netif_init;
|
||||||
|
|
||||||
if (tcpip_if >= TCPIP_ADAPTER_IF_MAX || mac == NULL || ip_info == NULL) {
|
if (tcpip_if >= TCPIP_ADAPTER_IF_MAX || mac == NULL || ip_info == NULL) {
|
||||||
return ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS;
|
return ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS;
|
||||||
}
|
}
|
||||||
@@ -72,11 +91,10 @@ esp_err_t tcpip_adapter_start(tcpip_adapter_if_t tcpip_if, uint8_t *mac, tcpip_a
|
|||||||
return ESP_ERR_NO_MEM;
|
return ESP_ERR_NO_MEM;
|
||||||
}
|
}
|
||||||
memcpy(esp_netif[tcpip_if]->hwaddr, mac, NETIF_MAX_HWADDR_LEN);
|
memcpy(esp_netif[tcpip_if]->hwaddr, mac, NETIF_MAX_HWADDR_LEN);
|
||||||
if (tcpip_if == TCPIP_ADAPTER_IF_AP || tcpip_if == TCPIP_ADAPTER_IF_STA) {
|
|
||||||
netif_add(esp_netif[tcpip_if], &ip_info->ip, &ip_info->netmask, &ip_info->gw, NULL, wlanif_init, tcpip_input);
|
netif_init = tcpip_if_to_netif_init_fn(tcpip_if);
|
||||||
} else if (tcpip_if == TCPIP_ADAPTER_IF_ETH) {
|
assert(netif_init != NULL);
|
||||||
netif_add(esp_netif[tcpip_if], &ip_info->ip, &ip_info->netmask, &ip_info->gw, NULL, ethernetif_init, tcpip_input);
|
netif_add(esp_netif[tcpip_if], &ip_info->ip, &ip_info->netmask, &ip_info->gw, NULL, netif_init, tcpip_input);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tcpip_if == TCPIP_ADAPTER_IF_AP) {
|
if (tcpip_if == TCPIP_ADAPTER_IF_AP) {
|
||||||
@@ -757,4 +775,4 @@ esp_err_t tcpip_adapter_get_hostname(tcpip_adapter_if_t tcpip_if, const char **h
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /* CONFIG_TCPIP_LWIP */
|
||||||
|
2
examples/ethernet/ethernet/sdkconfig.defaults
Normal file
2
examples/ethernet/ethernet/sdkconfig.defaults
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# CONFIG_WIFI_ENABLED is not set
|
||||||
|
CONFIG_ETHERNET=y
|
Reference in New Issue
Block a user