Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ jobs:
target: esp32p4
- path: 'components/esp-box/example'
target: esp32s3
- path: 'components/ethernet/example'
target: esp32
- path: 'components/event_manager/example'
target: esp32
- path: 'components/expressive_eyes/example'
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/upload_components.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ jobs:
components/drv2605
components/encoder
components/esp-box
# ethernet is intentionally listed ahead of the esp32-p4-* board BSPs
# (esp32-p4-eth / esp32-p4-function-ev-board / esp32-p4-nano), which
# depend on espp/ethernet, so it is uploaded to the registry first.
components/ethernet
components/esp32-p4-function-ev-board
components/esp32-timer-cam
components/event_manager
Expand Down
3 changes: 1 addition & 2 deletions components/esp32-ethernet-kit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ idf_component_register(
SRC_DIRS "src"
REQUIRES
"base_component"
"esp_eth"
"ethernet"
"esp_netif"
"esp_event"
REQUIRED_IDF_TARGETS "esp32"
)
1 change: 1 addition & 0 deletions components/esp32-ethernet-kit/idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ tags:
dependencies:
idf: ">=5.0"
espp/base_component: ">=1.0"
espp/ethernet: ">=1.0"
targets:
- esp32
34 changes: 7 additions & 27 deletions components/esp32-ethernet-kit/include/esp32-ethernet-kit.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#pragma once

#include <array>
#include <atomic>
#include <functional>
#include <memory>

#include <sdkconfig.h>

#include <esp_eth.h>
#include <esp_netif.h>

#include "base_component.hpp"
#include "ethernet.hpp"

namespace espp {
/// @brief Board Support Package (BSP) for the Espressif ESP32-Ethernet-Kit A V1.2.
Expand Down Expand Up @@ -127,11 +127,11 @@ class Esp32EthernetKit : public BaseComponent {
/// Check whether the interface has a usable IP address
/// (DHCP lease granted in CLIENT mode, or link is up in SERVER mode).
/// \return True if the interface is connected with a valid IP.
bool is_ethernet_connected() const { return ethernet_connected_; }
bool is_ethernet_connected() const { return ethernet_ && ethernet_->is_connected(); }

/// Get the most recently acquired IPv4 address (0 if none).
/// \return The IPv4 address.
esp_ip4_addr_t ethernet_ip() const { return ethernet_ip_; }
esp_ip4_addr_t ethernet_ip() const { return ethernet_ ? ethernet_->ip() : esp_ip4_addr_t{}; }

protected:
Esp32EthernetKit();
Expand Down Expand Up @@ -159,28 +159,8 @@ class Esp32EthernetKit : public BaseComponent {
// Member variables
/////////////////////////////////////////////////////////////////////////////

// Ethernet
DhcpMode dhcp_mode_{DhcpMode::CLIENT};
esp_netif_ip_info_t server_ip_info_{}; ///< Resolved static IP (server mode only)
client_ip_callback_t client_ip_callback_{nullptr};
EthernetLinkCallback on_link_up_{};
EthernetLinkCallback on_link_down_{};
EthernetIpCallback on_got_ip_{};
EthernetLinkCallback on_lost_ip_{};
std::atomic<bool> ethernet_initialized_{false};
std::atomic<bool> ethernet_connected_{false};
esp_ip4_addr_t ethernet_ip_{};
esp_eth_handle_t eth_handle_{nullptr};
esp_eth_netif_glue_handle_t eth_glue_{nullptr}; // esp_eth_netif_glue_handle_t
esp_netif_t *eth_netif_{nullptr};

static void ethernet_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id,
void *event_data);
static void ethernet_got_ip_handler(void *arg, esp_event_base_t event_base, int32_t event_id,
void *event_data);
static void ethernet_lost_ip_handler(void *arg, esp_event_base_t event_base, int32_t event_id,
void *event_data);
static void ethernet_client_ip_handler(void *arg, esp_event_base_t event_base, int32_t event_id,
void *event_data);
// The board's RMII Ethernet is driven by the reusable espp::Ethernet component
// (this BSP just supplies the board-specific pins / PHY).
std::unique_ptr<espp::Ethernet> ethernet_;
}; // class Esp32EthernetKit
} // namespace espp
Loading