mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
Merge branch 'feature/bridge_hosted' into 'master'
feat(bridge_hosted): Make Network Bridge work with ESP-Hosted See merge request espressif/esp-idf!40361
This commit is contained in:
@@ -97,13 +97,13 @@ static void port_action_start(void *handler_args, esp_event_base_t base, int32_t
|
||||
{
|
||||
esp_netif_br_glue_t *netif_glue = handler_args;
|
||||
|
||||
#if CONFIG_ESP_WIFI_ENABLED
|
||||
#if CONFIG_ESP_WIFI_ENABLED || CONFIG_SLAVE_SOC_WIFI_SUPPORTED
|
||||
if (base == WIFI_EVENT) {
|
||||
ESP_LOGD(TAG, "wifi_action_start: %p, %p, %" PRId32 ", %p", netif_glue, base, event_id, event_data);
|
||||
start_br_if_stopped(netif_glue);
|
||||
esp_netif_bridge_add_port(netif_glue->base.netif, netif_glue->wifi_esp_netif);
|
||||
} else
|
||||
#endif /* CONFIG_ESP_WIFI_ENABLED */
|
||||
#endif /* CONFIG_ESP_WIFI_ENABLED || CONFIG_SLAVE_SOC_WIFI_SUPPORTED */
|
||||
if (base == ETH_EVENT) {
|
||||
esp_eth_handle_t eth_handle = *(esp_eth_handle_t *)event_data;
|
||||
ESP_LOGD(TAG, "eth_action_start: %p, %p, %" PRId32 ", %p, %p", netif_glue, base, event_id, event_data, *(esp_eth_handle_t *)event_data);
|
||||
@@ -122,12 +122,12 @@ static void port_action_stop(void *handler_args, esp_event_base_t base, int32_t
|
||||
|
||||
// if one of the bridge's ports is stopped, we need to stop the bridge too, since port's lwip_netif is removed and so it would become
|
||||
// an invalid reference in the bridge's internal structure (there is no way how to remove single port from bridge in current LwIP)
|
||||
#if CONFIG_ESP_WIFI_ENABLED
|
||||
#if CONFIG_ESP_WIFI_ENABLED || CONFIG_SLAVE_SOC_WIFI_SUPPORTED
|
||||
if (base == WIFI_EVENT) {
|
||||
ESP_LOGD(TAG, "wifi_action_stop: %p, %p, %" PRId32 ", %p", netif_glue, base, event_id, event_data);
|
||||
stop_br_if_started(netif_glue);
|
||||
} else
|
||||
#endif /* CONFIG_ESP_WIFI_ENABLED */
|
||||
#endif /* CONFIG_ESP_WIFI_ENABLED || CONFIG_SLAVE_SOC_WIFI_SUPPORTED */
|
||||
if (base == ETH_EVENT) {
|
||||
esp_eth_handle_t eth_handle = *(esp_eth_handle_t *)event_data;
|
||||
ESP_LOGD(TAG, "eth_action_stop: %p, %p, %" PRId32 ", %p, %p", netif_glue, base, event_id, event_data, *(esp_eth_handle_t *)event_data);
|
||||
@@ -148,12 +148,12 @@ static void port_action_connected(void *handler_args, esp_event_base_t base, int
|
||||
ESP_LOGD(TAG, "action_connected, no action bridge is up");
|
||||
return;
|
||||
}
|
||||
#if CONFIG_ESP_WIFI_ENABLED
|
||||
#if CONFIG_ESP_WIFI_ENABLED || CONFIG_SLAVE_SOC_WIFI_SUPPORTED
|
||||
if (base == WIFI_EVENT) {
|
||||
ESP_LOGD(TAG, "wifi_action_connected: %p, %p, %" PRId32 ", %p", netif_glue, base, event_id, event_data);
|
||||
esp_netif_action_connected(netif_glue->base.netif, 0, 0, NULL);
|
||||
} else
|
||||
#endif /* CONFIG_ESP_WIFI_ENABLED */
|
||||
#endif /* CONFIG_ESP_WIFI_ENABLED || CONFIG_SLAVE_SOC_WIFI_SUPPORTED */
|
||||
if (base == ETH_EVENT) {
|
||||
esp_eth_handle_t eth_handle = *(esp_eth_handle_t *)event_data;
|
||||
ESP_LOGD(TAG, "eth_action_connected: %p, %p, %" PRId32 ", %p, %p", netif_glue, base, event_id, event_data, *(esp_eth_handle_t *)event_data);
|
||||
@@ -261,7 +261,7 @@ fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if CONFIG_ESP_WIFI_ENABLED
|
||||
#if CONFIG_ESP_WIFI_ENABLED || CONFIG_SLAVE_SOC_WIFI_SUPPORTED
|
||||
static esp_err_t esp_netif_br_glue_clear_instance_handlers_wifi(esp_netif_br_glue_handle_t esp_netif_br_glue)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(esp_netif_br_glue, ESP_ERR_INVALID_ARG, TAG, "esp_netif_br_glue handle can't be null");
|
||||
@@ -322,7 +322,7 @@ fail:
|
||||
esp_netif_br_glue_clear_instance_handlers_wifi(esp_netif_br_glue);
|
||||
return ret;
|
||||
}
|
||||
#endif /* CONFIG_ESP_WIFI_ENABLED */
|
||||
#endif /* CONFIG_ESP_WIFI_ENABLED || CONFIG_SLAVE_SOC_WIFI_SUPPORTED */
|
||||
|
||||
esp_err_t esp_netif_br_glue_add_port(esp_netif_br_glue_handle_t netif_br_glue, esp_netif_t *esp_netif_port)
|
||||
{
|
||||
@@ -348,7 +348,7 @@ esp_err_t esp_netif_br_glue_add_port(esp_netif_br_glue_handle_t netif_br_glue, e
|
||||
|
||||
esp_err_t esp_netif_br_glue_add_wifi_port(esp_netif_br_glue_handle_t netif_br_glue, esp_netif_t *esp_netif_port)
|
||||
{
|
||||
#if CONFIG_ESP_WIFI_ENABLED
|
||||
#if CONFIG_ESP_WIFI_ENABLED || CONFIG_SLAVE_SOC_WIFI_SUPPORTED
|
||||
esp_err_t ret = ESP_OK;
|
||||
ESP_GOTO_ON_FALSE(netif_br_glue->wifi_esp_netif == NULL, ESP_ERR_INVALID_STATE, fail_ret, TAG, "WiFi interface already registered");
|
||||
const char *if_desc = esp_netif_get_desc(esp_netif_port);
|
||||
@@ -365,7 +365,7 @@ fail_ret:
|
||||
return ret;
|
||||
#else
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
#endif /* CONFIG_ESP_WIFI_ENABLED */
|
||||
#endif /* CONFIG_ESP_WIFI_ENABLED || CONFIG_SLAVE_SOC_WIFI_SUPPORTED */
|
||||
}
|
||||
|
||||
esp_netif_br_glue_handle_t esp_netif_br_glue_new(void)
|
||||
@@ -390,11 +390,11 @@ esp_err_t esp_netif_br_glue_del(esp_netif_br_glue_handle_t netif_br_glue)
|
||||
{
|
||||
stop_br_if_started(netif_br_glue);
|
||||
esp_netif_br_glue_clear_instance_handlers(netif_br_glue);
|
||||
#if CONFIG_ESP_WIFI_ENABLED
|
||||
#if CONFIG_ESP_WIFI_ENABLED || CONFIG_SLAVE_SOC_WIFI_SUPPORTED
|
||||
if (netif_br_glue->wifi_esp_netif != NULL) {
|
||||
esp_netif_br_glue_clear_instance_handlers_wifi(netif_br_glue);
|
||||
}
|
||||
#endif /* CONFIG_ESP_WIFI_ENABLED */
|
||||
#endif /* CONFIG_ESP_WIFI_ENABLED || CONFIG_SLAVE_SOC_WIFI_SUPPORTED */
|
||||
free(netif_br_glue->ports_esp_netifs);
|
||||
free(netif_br_glue);
|
||||
netif_br_glue = NULL;
|
||||
|
||||
@@ -46,6 +46,8 @@ The work flow of the example is then as follows:
|
||||
|
||||
To run this example, it's recommended that you have either an official ESP32 Ethernet development board - [ESP32-Ethernet-Kit](https://docs.espressif.com/projects/esp-idf/en/latest/hw-reference/get-started-ethernet-kit.html), or 3rd party ESP32 board as long as it's integrated with a supported Ethernet PHY chips and connected with supported SPI Ethernet modules (for example `DM9051`, `W5500` or `KSZ8851SNL`). Or ESP32(S/C series) board without internal Ethernet interface but connected to multiple SPI Ethernet modules. Note that it is recommended to use multiple SPI Ethernet modules of the same type rather than combination of internal EMAC and SPI module since you don't need to take care of load balancing (internal EMAC has much higher bandwidth than SPI Ethernet modules).
|
||||
|
||||
The example will also work on the [ESP32-P4-Function-EV-Board](https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32p4/esp32-p4-function-ev-board/index.html). It has an internal Ethernet interface, with WiFi provided by the onboard ESP32-C6 using the [ESP-Hosted](https://components.espressif.com/components/espressif/esp_hosted/) component.
|
||||
|
||||
### Pin Assignment
|
||||
|
||||
See common pin assignments for [Ethernet examples](../../ethernet/README.md#common-pin-assignments).
|
||||
|
||||
@@ -8,7 +8,7 @@ endmenu
|
||||
|
||||
menu "Example AP Wifi Configuration"
|
||||
config EXAMPLE_BR_WIFI
|
||||
depends on SOC_WIFI_SUPPORTED
|
||||
depends on SOC_WIFI_SUPPORTED || SLAVE_SOC_WIFI_SUPPORTED
|
||||
default n
|
||||
bool "Bridge WiFi interface"
|
||||
help
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
dependencies:
|
||||
espressif/ethernet_init:
|
||||
version: "~1.2.0"
|
||||
espressif/esp_wifi_remote:
|
||||
version: ">=1.3.1,<2.0"
|
||||
rules:
|
||||
- if: "target in [esp32p4, esp32h2]"
|
||||
espressif/esp_hosted:
|
||||
version: ">=2.11.0"
|
||||
rules:
|
||||
- if: "target in [esp32p4, esp32h2]"
|
||||
|
||||
Reference in New Issue
Block a user