From e04a0d66b80ed20d5a62eba62569fa29f784130a Mon Sep 17 00:00:00 2001 From: Liu Zhi Fu Date: Thu, 12 Oct 2017 20:24:02 +0800 Subject: [PATCH] esp32/tcpipadapter: correct eth ip got event info 1. Raise SYSTEM_EVENT_ETH_GOT_IP when eth got ip 2. Add default handler for SYSTEM_EVENT_ETH_GOT_IP 3. Minor change about ethernet kconfig --- components/esp32/event_default_handlers.c | 14 +++++++++++++- components/ethernet/Kconfig | 2 +- components/tcpip_adapter/tcpip_adapter_lwip.c | 9 +++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/components/esp32/event_default_handlers.c b/components/esp32/event_default_handlers.c index 8f1f2e936..e4941362c 100644 --- a/components/esp32/event_default_handlers.c +++ b/components/esp32/event_default_handlers.c @@ -61,6 +61,7 @@ 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_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_got_ip_default(system_event_t *event); /* Default event handler functions @@ -124,11 +125,21 @@ esp_err_t system_event_eth_disconnected_handle_default(system_event_t *event) return ESP_OK; } +static esp_err_t system_event_eth_got_ip_default(system_event_t *event) +{ + ESP_LOGI(TAG, "eth ip: " IPSTR ", mask: " IPSTR ", gw: " IPSTR, + IP2STR(&event->event_info.got_ip.ip_info.ip), + IP2STR(&event->event_info.got_ip.ip_info.netmask), + IP2STR(&event->event_info.got_ip.ip_info.gw)); + + return ESP_OK; +} + 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); - ESP_LOGI(TAG, "ip: " IPSTR ", mask: " IPSTR ", gw: " IPSTR, + ESP_LOGI(TAG, "sta ip: " IPSTR ", mask: " IPSTR ", gw: " IPSTR, IP2STR(&event->event_info.got_ip.ip_info.ip), IP2STR(&event->event_info.got_ip.ip_info.netmask), IP2STR(&event->event_info.got_ip.ip_info.gw)); @@ -414,4 +425,5 @@ void esp_event_set_default_eth_handlers() default_event_handlers[SYSTEM_EVENT_ETH_STOP] = system_event_eth_stop_handle_default; default_event_handlers[SYSTEM_EVENT_ETH_CONNECTED] = system_event_eth_connected_handle_default; default_event_handlers[SYSTEM_EVENT_ETH_DISCONNECTED] = system_event_eth_disconnected_handle_default; + default_event_handlers[SYSTEM_EVENT_ETH_GOT_IP] = system_event_eth_got_ip_default; } diff --git a/components/ethernet/Kconfig b/components/ethernet/Kconfig index 11d6d84b2..f7281bc4c 100644 --- a/components/ethernet/Kconfig +++ b/components/ethernet/Kconfig @@ -11,7 +11,7 @@ config DMA_RX_BUF_NUM If enable flow ctrl, the num must be above 9 . config DMA_TX_BUF_NUM - int "Number of DMA RX buffers" + int "Number of DMA TX buffers" range 3 20 default 10 help diff --git a/components/tcpip_adapter/tcpip_adapter_lwip.c b/components/tcpip_adapter/tcpip_adapter_lwip.c index 86fe8dbfb..394ad69c9 100644 --- a/components/tcpip_adapter/tcpip_adapter_lwip.c +++ b/components/tcpip_adapter/tcpip_adapter_lwip.c @@ -756,8 +756,13 @@ static void tcpip_adapter_dhcpc_cb(struct netif *netif) ip4_addr_set(&ip_info->gw, ip_2_ip4(&netif->gw)); //notify event - evt.event_id = SYSTEM_EVENT_STA_GOT_IP; - evt.event_info.got_ip.ip_changed = false; + if (tcpip_if == TCPIP_ADAPTER_IF_ETH) { + evt.event_id = SYSTEM_EVENT_ETH_GOT_IP; + evt.event_info.got_ip.ip_changed = true; + } else { + evt.event_id = SYSTEM_EVENT_STA_GOT_IP; + evt.event_info.got_ip.ip_changed = false; + } if (memcmp(ip_info, ip_info_old, sizeof(tcpip_adapter_ip_info_t))) { evt.event_info.got_ip.ip_changed = true;