Using ESP-IDF to recieve UDP packets via ethernet

Viewed 20

I want to use the ESP-IDF framework to make a program that will recieve UDP packets via ethernet. I am not using an ESP32-Ethernet-Kit, but an ESP32 alongside a PHY (DP83848) in order to gain access to ethernet.

Pretty much every example I can find about UDP and ESP32 is using Wifi instead of ethernet.

What I want to do is use the basic ethernet example available in the espressif esp-idf git repository as a starting point and then add the functionality to recieve the datagrams. If I'm not wrong, what I should do is create a new event handler and use the esp_eth_update_input_path API present in the esp_eth_driver.h, but I am not sure about how to use it. Can anyone help me with this?

esp_err_t esp_eth_update_input_path(
    esp_eth_handle_t hdl,
    esp_err_t (*stack_input)(esp_eth_handle_t hdl, uint8_t *buffer, uint32_t length, void *priv),
    void *priv);
1 Answers

I posted almost the same question in the espressif ESP-IDF forum before posting this one here and got an following answer by user ESP_ondrej. I'm posting it here in case this can help someone.

All protocols examples located in the ESP-IDF supports both Wifi and Ethernet. You just need to configure it via idf.py menuconfig. Please check the README at https://github.com/espressif/esp-idf/bl ... /README.md

If you want to start from scratch with your Ethernet UDP application, you can do so. You don't need to call esp_eth_update_input_path. This function is used to direct L2 Ethernet frames to specific callback function which you don't want since you want to communicate via IP protocol. Therefore keep it as is, i.e. Ethernet frames are to be processed by lwIP stack and just use socket API as you might be used to from other platforms.

Related