ESPHome  2024.12.2
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes
esphome::ethernet::EthernetComponent Class Reference

#include <ethernet_component.h>

Inheritance diagram for esphome::ethernet::EthernetComponent:
esphome::Component

Public Member Functions

 EthernetComponent ()
 
void setup () override
 
void loop () override
 
void dump_config () override
 
float get_setup_priority () const override
 
bool can_proceed () override
 
void on_shutdown () override
 
bool is_connected ()
 
void set_clk_pin (uint8_t clk_pin)
 
void set_miso_pin (uint8_t miso_pin)
 
void set_mosi_pin (uint8_t mosi_pin)
 
void set_cs_pin (uint8_t cs_pin)
 
void set_interrupt_pin (uint8_t interrupt_pin)
 
void set_reset_pin (uint8_t reset_pin)
 
void set_clock_speed (int clock_speed)
 
void set_polling_interval (uint32_t polling_interval)
 
void set_phy_addr (uint8_t phy_addr)
 
void set_power_pin (int power_pin)
 
void set_mdc_pin (uint8_t mdc_pin)
 
void set_mdio_pin (uint8_t mdio_pin)
 
void set_clk_mode (emac_rmii_clock_mode_t clk_mode, emac_rmii_clock_gpio_t clk_gpio)
 
void add_phy_register (PHYRegister register_value)
 
void set_type (EthernetType type)
 
void set_manual_ip (const ManualIP &manual_ip)
 
network::IPAddresses get_ip_addresses ()
 
network::IPAddress get_dns_address (uint8_t num)
 
std::string get_use_address () const
 
void set_use_address (const std::string &use_address)
 
void get_eth_mac_address_raw (uint8_t *mac)
 
std::string get_eth_mac_address_pretty ()
 
eth_duplex_t get_duplex_mode ()
 
eth_speed_t get_link_speed ()
 
bool powerdown ()
 
- Public Member Functions inherited from esphome::Component
float get_actual_setup_priority () const
 
void set_setup_priority (float priority)
 
virtual float get_loop_priority () const
 priority of loop(). More...
 
void call ()
 
virtual void on_safe_shutdown ()
 
uint32_t get_component_state () const
 
virtual void mark_failed ()
 Mark this component as failed. More...
 
bool is_failed () const
 
bool is_ready () const
 
bool status_has_warning () const
 
bool status_has_error () const
 
void status_set_warning (const char *message="unspecified")
 
void status_set_error (const char *message="unspecified")
 
void status_clear_warning ()
 
void status_clear_error ()
 
void status_momentary_warning (const std::string &name, uint32_t length=5000)
 
void status_momentary_error (const std::string &name, uint32_t length=5000)
 
bool has_overridden_loop () const
 
void set_component_source (const char *source)
 Set where this component was loaded from for some debug messages. More...
 
const char * get_component_source () const
 Get the integration where this component was declared as a string. More...
 

Protected Member Functions

void start_connect_ ()
 
void dump_connect_params_ ()
 
void ksz8081_set_clock_reference_ (esp_eth_mac_t *mac)
 Set RMII Reference Clock Select bit for KSZ8081. More...
 
void write_phy_register_ (esp_eth_mac_t *mac, PHYRegister register_data)
 Set arbitratry PHY registers from config. More...
 
- Protected Member Functions inherited from esphome::Component
virtual void call_loop ()
 
virtual void call_setup ()
 
virtual void call_dump_config ()
 
void set_interval (const std::string &name, uint32_t interval, std::function< void()> &&f)
 Set an interval function with a unique name. More...
 
void set_interval (uint32_t interval, std::function< void()> &&f)
 
bool cancel_interval (const std::string &name)
 Cancel an interval function. More...
 
void set_retry (const std::string &name, uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> &&f, float backoff_increase_factor=1.0f)
 Set an retry function with a unique name. More...
 
void set_retry (uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> &&f, float backoff_increase_factor=1.0f)
 
bool cancel_retry (const std::string &name)
 Cancel a retry function. More...
 
void set_timeout (const std::string &name, uint32_t timeout, std::function< void()> &&f)
 Set a timeout function with a unique name. More...
 
void set_timeout (uint32_t timeout, std::function< void()> &&f)
 
bool cancel_timeout (const std::string &name)
 Cancel a timeout function. More...
 
void defer (const std::string &name, std::function< void()> &&f)
 Defer a callback to the next loop() call. More...
 
void defer (std::function< void()> &&f)
 Defer a callback to the next loop() call. More...
 
bool cancel_defer (const std::string &name)
 Cancel a defer callback using the specified name, name must not be empty. More...
 

Static Protected Member Functions

static void eth_event_handler (void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
 
static void got_ip_event_handler (void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
 
static void got_ip6_event_handler (void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
 

Protected Attributes

std::string use_address_
 
uint8_t clk_pin_
 
uint8_t miso_pin_
 
uint8_t mosi_pin_
 
uint8_t cs_pin_
 
int interrupt_pin_ {-1}
 
int reset_pin_ {-1}
 
int phy_addr_spi_ {-1}
 
int clock_speed_
 
uint32_t polling_interval_ {0}
 
uint8_t phy_addr_ {0}
 
int power_pin_ {-1}
 
uint8_t mdc_pin_ {23}
 
uint8_t mdio_pin_ {18}
 
emac_rmii_clock_mode_t clk_mode_ {EMAC_CLK_EXT_IN}
 
emac_rmii_clock_gpio_t clk_gpio_ {EMAC_CLK_IN_GPIO}
 
std::vector< PHYRegisterphy_registers_ {}
 
EthernetType type_ {ETHERNET_TYPE_UNKNOWN}
 
optional< ManualIPmanual_ip_ {}
 
bool started_ {false}
 
bool connected_ {false}
 
bool got_ipv4_address_ {false}
 
uint8_t ipv6_count_ {0}
 
EthernetComponentState state_ {EthernetComponentState::STOPPED}
 
uint32_t connect_begin_
 
esp_netif_t * eth_netif_ {nullptr}
 
esp_eth_handle_t eth_handle_
 
esp_eth_phy_t * phy_ {nullptr}
 
- Protected Attributes inherited from esphome::Component
uint32_t component_state_ {0x0000}
 State of this component. More...
 
float setup_priority_override_ {NAN}
 
const char * component_source_ {nullptr}
 

Detailed Description

Definition at line 51 of file ethernet_component.h.

Constructor & Destructor Documentation

◆ EthernetComponent()

esphome::ethernet::EthernetComponent::EthernetComponent ( )

Definition at line 38 of file ethernet_component.cpp.

Member Function Documentation

◆ add_phy_register()

void esphome::ethernet::EthernetComponent::add_phy_register ( PHYRegister  register_value)

Definition at line 561 of file ethernet_component.cpp.

◆ can_proceed()

bool esphome::ethernet::EthernetComponent::can_proceed ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 356 of file ethernet_component.cpp.

◆ dump_config()

void esphome::ethernet::EthernetComponent::dump_config ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 282 of file ethernet_component.cpp.

◆ dump_connect_params_()

void esphome::ethernet::EthernetComponent::dump_connect_params_ ( )
protected

Definition at line 512 of file ethernet_component.cpp.

◆ eth_event_handler()

void esphome::ethernet::EthernetComponent::eth_event_handler ( void *  arg,
esp_event_base_t  event_base,
int32_t  event_id,
void *  event_data 
)
staticprotected

Definition at line 387 of file ethernet_component.cpp.

◆ get_dns_address()

network::IPAddress esphome::ethernet::EthernetComponent::get_dns_address ( uint8_t  num)

Definition at line 382 of file ethernet_component.cpp.

◆ get_duplex_mode()

eth_duplex_t esphome::ethernet::EthernetComponent::get_duplex_mode ( )

Definition at line 587 of file ethernet_component.cpp.

◆ get_eth_mac_address_pretty()

std::string esphome::ethernet::EthernetComponent::get_eth_mac_address_pretty ( )

Definition at line 581 of file ethernet_component.cpp.

◆ get_eth_mac_address_raw()

void esphome::ethernet::EthernetComponent::get_eth_mac_address_raw ( uint8_t *  mac)

Definition at line 575 of file ethernet_component.cpp.

◆ get_ip_addresses()

network::IPAddresses esphome::ethernet::EthernetComponent::get_ip_addresses ( )

Definition at line 358 of file ethernet_component.cpp.

◆ get_link_speed()

eth_speed_t esphome::ethernet::EthernetComponent::get_link_speed ( )

Definition at line 595 of file ethernet_component.cpp.

◆ get_setup_priority()

float esphome::ethernet::EthernetComponent::get_setup_priority ( ) const
overridevirtual

Reimplemented from esphome::Component.

Definition at line 354 of file ethernet_component.cpp.

◆ get_use_address()

std::string esphome::ethernet::EthernetComponent::get_use_address ( ) const

Definition at line 566 of file ethernet_component.cpp.

◆ got_ip6_event_handler()

void esphome::ethernet::EthernetComponent::got_ip6_event_handler ( void *  arg,
esp_event_base_t  event_base,
int32_t  event_id,
void *  event_data 
)
staticprotected

Definition at line 428 of file ethernet_component.cpp.

◆ got_ip_event_handler()

void esphome::ethernet::EthernetComponent::got_ip_event_handler ( void *  arg,
esp_event_base_t  event_base,
int32_t  event_id,
void *  event_data 
)
staticprotected

Definition at line 414 of file ethernet_component.cpp.

◆ is_connected()

bool esphome::ethernet::EthernetComponent::is_connected ( )

Definition at line 510 of file ethernet_component.cpp.

◆ ksz8081_set_clock_reference_()

void esphome::ethernet::EthernetComponent::ksz8081_set_clock_reference_ ( esp_eth_mac_t *  mac)
protected

Set RMII Reference Clock Select bit for KSZ8081.

Definition at line 622 of file ethernet_component.cpp.

◆ loop()

void esphome::ethernet::EthernetComponent::loop ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 242 of file ethernet_component.cpp.

◆ on_shutdown()

void esphome::ethernet::EthernetComponent::on_shutdown ( )
inlineoverridevirtual

Reimplemented from esphome::Component.

Definition at line 59 of file ethernet_component.h.

◆ powerdown()

bool esphome::ethernet::EthernetComponent::powerdown ( )

Definition at line 603 of file ethernet_component.cpp.

◆ set_clk_mode()

void esphome::ethernet::EthernetComponent::set_clk_mode ( emac_rmii_clock_mode_t  clk_mode,
emac_rmii_clock_gpio_t  clk_gpio 
)

Definition at line 557 of file ethernet_component.cpp.

◆ set_clk_pin()

void esphome::ethernet::EthernetComponent::set_clk_pin ( uint8_t  clk_pin)

Definition at line 542 of file ethernet_component.cpp.

◆ set_clock_speed()

void esphome::ethernet::EthernetComponent::set_clock_speed ( int  clock_speed)

Definition at line 548 of file ethernet_component.cpp.

◆ set_cs_pin()

void esphome::ethernet::EthernetComponent::set_cs_pin ( uint8_t  cs_pin)

Definition at line 545 of file ethernet_component.cpp.

◆ set_interrupt_pin()

void esphome::ethernet::EthernetComponent::set_interrupt_pin ( uint8_t  interrupt_pin)

Definition at line 546 of file ethernet_component.cpp.

◆ set_manual_ip()

void esphome::ethernet::EthernetComponent::set_manual_ip ( const ManualIP manual_ip)

Definition at line 564 of file ethernet_component.cpp.

◆ set_mdc_pin()

void esphome::ethernet::EthernetComponent::set_mdc_pin ( uint8_t  mdc_pin)

Definition at line 555 of file ethernet_component.cpp.

◆ set_mdio_pin()

void esphome::ethernet::EthernetComponent::set_mdio_pin ( uint8_t  mdio_pin)

Definition at line 556 of file ethernet_component.cpp.

◆ set_miso_pin()

void esphome::ethernet::EthernetComponent::set_miso_pin ( uint8_t  miso_pin)

Definition at line 543 of file ethernet_component.cpp.

◆ set_mosi_pin()

void esphome::ethernet::EthernetComponent::set_mosi_pin ( uint8_t  mosi_pin)

Definition at line 544 of file ethernet_component.cpp.

◆ set_phy_addr()

void esphome::ethernet::EthernetComponent::set_phy_addr ( uint8_t  phy_addr)

Definition at line 553 of file ethernet_component.cpp.

◆ set_polling_interval()

void esphome::ethernet::EthernetComponent::set_polling_interval ( uint32_t  polling_interval)

Definition at line 550 of file ethernet_component.cpp.

◆ set_power_pin()

void esphome::ethernet::EthernetComponent::set_power_pin ( int  power_pin)

Definition at line 554 of file ethernet_component.cpp.

◆ set_reset_pin()

void esphome::ethernet::EthernetComponent::set_reset_pin ( uint8_t  reset_pin)

Definition at line 547 of file ethernet_component.cpp.

◆ set_type()

void esphome::ethernet::EthernetComponent::set_type ( EthernetType  type)

Definition at line 563 of file ethernet_component.cpp.

◆ set_use_address()

void esphome::ethernet::EthernetComponent::set_use_address ( const std::string &  use_address)

Definition at line 573 of file ethernet_component.cpp.

◆ setup()

void esphome::ethernet::EthernetComponent::setup ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 40 of file ethernet_component.cpp.

◆ start_connect_()

void esphome::ethernet::EthernetComponent::start_connect_ ( )
protected

Definition at line 442 of file ethernet_component.cpp.

◆ write_phy_register_()

void esphome::ethernet::EthernetComponent::write_phy_register_ ( esp_eth_mac_t *  mac,
PHYRegister  register_data 
)
protected

Set arbitratry PHY registers from config.

Definition at line 649 of file ethernet_component.cpp.

Field Documentation

◆ clk_gpio_

emac_rmii_clock_gpio_t esphome::ethernet::EthernetComponent::clk_gpio_ {EMAC_CLK_IN_GPIO}
protected

Definition at line 127 of file ethernet_component.h.

◆ clk_mode_

emac_rmii_clock_mode_t esphome::ethernet::EthernetComponent::clk_mode_ {EMAC_CLK_EXT_IN}
protected

Definition at line 126 of file ethernet_component.h.

◆ clk_pin_

uint8_t esphome::ethernet::EthernetComponent::clk_pin_
protected

Definition at line 110 of file ethernet_component.h.

◆ clock_speed_

int esphome::ethernet::EthernetComponent::clock_speed_
protected

Definition at line 117 of file ethernet_component.h.

◆ connect_begin_

uint32_t esphome::ethernet::EthernetComponent::connect_begin_
protected

Definition at line 140 of file ethernet_component.h.

◆ connected_

bool esphome::ethernet::EthernetComponent::connected_ {false}
protected

Definition at line 134 of file ethernet_component.h.

◆ cs_pin_

uint8_t esphome::ethernet::EthernetComponent::cs_pin_
protected

Definition at line 113 of file ethernet_component.h.

◆ eth_handle_

esp_eth_handle_t esphome::ethernet::EthernetComponent::eth_handle_
protected

Definition at line 142 of file ethernet_component.h.

◆ eth_netif_

esp_netif_t* esphome::ethernet::EthernetComponent::eth_netif_ {nullptr}
protected

Definition at line 141 of file ethernet_component.h.

◆ got_ipv4_address_

bool esphome::ethernet::EthernetComponent::got_ipv4_address_ {false}
protected

Definition at line 135 of file ethernet_component.h.

◆ interrupt_pin_

int esphome::ethernet::EthernetComponent::interrupt_pin_ {-1}
protected

Definition at line 114 of file ethernet_component.h.

◆ ipv6_count_

uint8_t esphome::ethernet::EthernetComponent::ipv6_count_ {0}
protected

Definition at line 137 of file ethernet_component.h.

◆ manual_ip_

optional<ManualIP> esphome::ethernet::EthernetComponent::manual_ip_ {}
protected

Definition at line 131 of file ethernet_component.h.

◆ mdc_pin_

uint8_t esphome::ethernet::EthernetComponent::mdc_pin_ {23}
protected

Definition at line 124 of file ethernet_component.h.

◆ mdio_pin_

uint8_t esphome::ethernet::EthernetComponent::mdio_pin_ {18}
protected

Definition at line 125 of file ethernet_component.h.

◆ miso_pin_

uint8_t esphome::ethernet::EthernetComponent::miso_pin_
protected

Definition at line 111 of file ethernet_component.h.

◆ mosi_pin_

uint8_t esphome::ethernet::EthernetComponent::mosi_pin_
protected

Definition at line 112 of file ethernet_component.h.

◆ phy_

esp_eth_phy_t* esphome::ethernet::EthernetComponent::phy_ {nullptr}
protected

Definition at line 143 of file ethernet_component.h.

◆ phy_addr_

uint8_t esphome::ethernet::EthernetComponent::phy_addr_ {0}
protected

Definition at line 122 of file ethernet_component.h.

◆ phy_addr_spi_

int esphome::ethernet::EthernetComponent::phy_addr_spi_ {-1}
protected

Definition at line 116 of file ethernet_component.h.

◆ phy_registers_

std::vector<PHYRegister> esphome::ethernet::EthernetComponent::phy_registers_ {}
protected

Definition at line 128 of file ethernet_component.h.

◆ polling_interval_

uint32_t esphome::ethernet::EthernetComponent::polling_interval_ {0}
protected

Definition at line 119 of file ethernet_component.h.

◆ power_pin_

int esphome::ethernet::EthernetComponent::power_pin_ {-1}
protected

Definition at line 123 of file ethernet_component.h.

◆ reset_pin_

int esphome::ethernet::EthernetComponent::reset_pin_ {-1}
protected

Definition at line 115 of file ethernet_component.h.

◆ started_

bool esphome::ethernet::EthernetComponent::started_ {false}
protected

Definition at line 133 of file ethernet_component.h.

◆ state_

EthernetComponentState esphome::ethernet::EthernetComponent::state_ {EthernetComponentState::STOPPED}
protected

Definition at line 139 of file ethernet_component.h.

◆ type_

EthernetType esphome::ethernet::EthernetComponent::type_ {ETHERNET_TYPE_UNKNOWN}
protected

Definition at line 130 of file ethernet_component.h.

◆ use_address_

std::string esphome::ethernet::EthernetComponent::use_address_
protected

Definition at line 108 of file ethernet_component.h.


The documentation for this class was generated from the following files: