4#if defined(USE_NETWORK) && defined(USE_ESP32)
11#ifdef USE_NETWORK_DEFAULT_ROUTE
14#include "esp_netif_net_stack.h"
15#include "lwip/netif.h"
26static const char *
const TAG =
"network";
31 err = esp_netif_init();
33 ESP_LOGE(TAG,
"esp_netif_init failed: (%d) %s", err, esp_err_to_name(err));
37 err = esp_event_loop_create_default();
40 if (err != ESP_OK && err != ESP_ERR_INVALID_STATE) {
41 ESP_LOGE(TAG,
"esp_event_loop_create_default failed: (%d) %s", err, esp_err_to_name(err));
52 " TCP send buffer: %d bytes",
56#ifdef USE_NETWORK_DEFAULT_ROUTE
60 if (wifi !=
nullptr && wifi->is_connected())
69 if (eth !=
nullptr && eth->is_connected())
82#ifdef USE_NETWORK_PRIMARY_INTERFACE_WIFI
83 best = connected_wifi_netif();
85 best = connected_ethernet_netif();
87 best = connected_ethernet_netif();
89 best = connected_wifi_netif();
91 if (best ==
nullptr) {
112 route_is_ours =
static_cast<void *
>(netif_default) == esp_netif_get_netif_impl(best);
117 esp_err_t err = esp_netif_set_default_netif(best);
119 ESP_LOGW(TAG,
"Failed to set default interface: (%d) %s", err, esp_err_to_name(err));
128 ESP_LOGI(TAG,
"Default interface: %s", esp_netif_get_desc(best));
uint32_t IRAM_ATTR HOT get_loop_component_start_time() const
Get the cached time in milliseconds from when the current component started its loop execution.
void mark_failed()
Mark this component as failed.
Helper class to lock the lwIP TCPIP core when making lwIP API calls from non-TCPIP threads.
esp_netif_t * get_esp_netif()
esp_netif handle, used by network for default-route arbitration.
esp_netif_t * default_netif_
uint32_t last_route_check_
void dump_config() override
static constexpr uint32_t ROUTE_CHECK_INTERVAL_MS
esp_netif_t * get_esp_netif_sta()
esp_netif handle of the station interface, used by network for default-route arbitration.
EthernetComponent * global_eth_component
WiFiComponent * global_wifi_component
Application App
Global storage of Application pointer - only one Application can exist.
struct esp_netif_obj esp_netif_t