Skip to content

Commit c64da25

Browse files
authored
feat(net): Add ETH handle to events and data to lost_ip (#11986)
1 parent 0b6e560 commit c64da25

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

libraries/Ethernet/src/ETH.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,17 @@ void ETHClass::_onEthEvent(int32_t event_id, void *event_data) {
107107
} else if (event_id == ETHERNET_EVENT_DISCONNECTED) {
108108
log_v("%s Disconnected", desc());
109109
arduino_event.event_id = ARDUINO_EVENT_ETH_DISCONNECTED;
110+
arduino_event.event_info.eth_disconnected = handle();
110111
clearStatusBits(ESP_NETIF_CONNECTED_BIT | ESP_NETIF_HAS_IP_BIT | ESP_NETIF_HAS_LOCAL_IP6_BIT | ESP_NETIF_HAS_GLOBAL_IP6_BIT);
111112
} else if (event_id == ETHERNET_EVENT_START) {
112113
log_v("%s Started", desc());
113114
arduino_event.event_id = ARDUINO_EVENT_ETH_START;
115+
arduino_event.event_info.eth_started = handle();
114116
setStatusBits(ESP_NETIF_STARTED_BIT);
115117
} else if (event_id == ETHERNET_EVENT_STOP) {
116118
log_v("%s Stopped", desc());
117119
arduino_event.event_id = ARDUINO_EVENT_ETH_STOP;
120+
arduino_event.event_info.eth_stopped = handle();
118121
clearStatusBits(
119122
ESP_NETIF_STARTED_BIT | ESP_NETIF_CONNECTED_BIT | ESP_NETIF_HAS_IP_BIT | ESP_NETIF_HAS_LOCAL_IP6_BIT | ESP_NETIF_HAS_GLOBAL_IP6_BIT
120123
| ESP_NETIF_HAS_STATIC_IP_BIT

libraries/Network/src/NetworkEvents.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,13 @@ typedef enum {
9999
typedef union {
100100
ip_event_ap_staipassigned_t wifi_ap_staipassigned;
101101
ip_event_got_ip_t got_ip;
102+
ip_event_got_ip_t lost_ip;
102103
ip_event_got_ip6_t got_ip6;
103104
#if CONFIG_ETH_ENABLED
105+
esp_eth_handle_t eth_started;
106+
esp_eth_handle_t eth_stopped;
104107
esp_eth_handle_t eth_connected;
108+
esp_eth_handle_t eth_disconnected;
105109
#endif
106110
#if SOC_WIFI_SUPPORTED || CONFIG_ESP_WIFI_REMOTE_ENABLED
107111
wifi_event_sta_scan_done_t wifi_scan_done;

libraries/Network/src/NetworkInterface.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ void NetworkInterface::_onIpEvent(int32_t event_id, void *event_data) {
9797
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_VERBOSE
9898
log_v("%s Lost IP", desc());
9999
#endif
100+
memcpy(&arduino_event.event_info.lost_ip, event_data, sizeof(ip_event_got_ip_t));
100101
#if SOC_WIFI_SUPPORTED || CONFIG_ESP_WIFI_REMOTE_ENABLED
101102
if (_interface_id == ESP_NETIF_ID_STA) {
102103
arduino_event.event_id = ARDUINO_EVENT_WIFI_STA_LOST_IP;

0 commit comments

Comments
 (0)