ESP32 Ethernet: How to get current link duplex status

This is how you can get the current link speed of an Ethernet connection on the ESP32 using the ESP-IDF framework.

#include <esp_eth.h>

// Get duplex mode
eth_duplex_t duplex_mode;
if (esp_eth_ioctl(eth_handle, ETH_CMD_G_DUPLEX_MODE, &duplex_mode) == ESP_OK) {
    const char* duplex_str = (duplex_mode == ETH_DUPLEX_HALF) ? "Half Duplex" : "Full Duplex";
    ESP_LOGI(TAG, "Ethernet Duplex: %s", duplex_str);
}