#ifndef ETHERNET_MANAGER_H #define ETHERNET_MANAGER_H #include "esp_err.h" #include "esp_eth.h" #include "esp_netif.h" // ============================================================================ // Configuration // ============================================================================ typedef struct { bool use_dhcp; char static_ip[16]; char netmask[16]; char gateway[16]; char dns_primary[16]; char dns_secondary[16]; } bmc_eth_config_t; // ============================================================================ // Function Declarations // ============================================================================ /** * @brief Initialize the Ethernet manager * * Sets up W5500 SPI Ethernet and network stack. * * @return ESP_OK on success, error code otherwise */ esp_err_t ethernet_manager_init(void); /** * @brief Check if Ethernet is connected * * @return true if connected, false otherwise */ bool ethernet_is_connected(void); /** * @brief Get the current IP address * * @param ip_str Buffer to store IP address string (min 16 bytes) * @return ESP_OK on success, error code otherwise */ esp_err_t ethernet_get_ip(char *ip_str); /** * @brief Get network information * * @param ip IP address buffer (min 16 bytes) * @param netmask Netmask buffer (min 16 bytes) * @param gateway Gateway buffer (min 16 bytes) * @return ESP_OK on success, error code otherwise */ esp_err_t ethernet_get_network_info(char *ip, char *netmask, char *gateway); /** * @brief Get MAC address * * @param mac_str Buffer to store MAC address string (min 18 bytes) * @return ESP_OK on success, error code otherwise */ esp_err_t ethernet_get_mac(char *mac_str); /** * @brief Set static IP configuration * * @param config Network configuration * @return ESP_OK on success, error code otherwise */ esp_err_t ethernet_set_static_ip(const bmc_eth_config_t *config); /** * @brief Enable DHCP * * @return ESP_OK on success, error code otherwise */ esp_err_t ethernet_enable_dhcp(void); /** * @brief Get Ethernet link speed * * @return Speed in Mbps, or 0 if not connected */ int ethernet_get_link_speed(void); /** * @brief Get Ethernet duplex mode * * @return true for full duplex, false for half duplex */ bool ethernet_is_full_duplex(void); // ============================================================================ // Event Callbacks // ============================================================================ typedef enum { ETH_EVENT_CONNECTED, ETH_EVENT_DISCONNECTED, ETH_EVENT_GOT_IP, ETH_EVENT_LOST_IP, } eth_event_type_t; typedef void (*eth_event_callback_t)(eth_event_type_t event); /** * @brief Register callback for Ethernet events * * @param callback Function to call on events * @return ESP_OK on success, error code otherwise */ esp_err_t ethernet_register_event_callback(eth_event_callback_t callback); #endif // ETHERNET_MANAGER_H