@@ -136,7 +136,7 @@ ETHClass::ETHClass(uint8_t eth_index)
136
136
_pin_mcd (-1 ), _pin_mdio(-1 ), _pin_power(-1 ), _pin_rmii_clock(-1 )
137
137
#endif /* CONFIG_ETH_USE_ESP32_EMAC */
138
138
,
139
- _task_stack_size (4096 ) {
139
+ _task_stack_size (4096 ), _eth_connected_event_handle( 0 ) {
140
140
}
141
141
142
142
ETHClass::~ETHClass () {}
@@ -359,7 +359,7 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i
359
359
/* attach to receive events */
360
360
initNetif ((Network_Interface_ID)(ESP_NETIF_ID_ETH + _eth_index));
361
361
362
- Network.onSysEvent (onEthConnected, ARDUINO_EVENT_ETH_CONNECTED);
362
+ _eth_connected_event_handle = Network.onSysEvent (onEthConnected, ARDUINO_EVENT_ETH_CONNECTED);
363
363
364
364
ret = esp_eth_start (_eth_handle);
365
365
if (ret != ESP_OK) {
@@ -849,7 +849,7 @@ bool ETHClass::beginSPI(
849
849
perimanSetPinBusExtraType (_pin_rst, " ETH_RST" );
850
850
}
851
851
852
- Network.onSysEvent (onEthConnected, ARDUINO_EVENT_ETH_CONNECTED);
852
+ _eth_connected_event_handle = Network.onSysEvent (onEthConnected, ARDUINO_EVENT_ETH_CONNECTED);
853
853
854
854
return true ;
855
855
@@ -885,7 +885,8 @@ static bool empty_ethDetachBus(void *bus_pointer) {
885
885
886
886
void ETHClass::end (void ) {
887
887
888
- Network.removeEvent (onEthConnected, ARDUINO_EVENT_ETH_CONNECTED);
888
+ Network.removeEvent (_eth_connected_event_handle);
889
+ _eth_connected_event_handle = 0 ;
889
890
890
891
if (_eth_handle != NULL ) {
891
892
if (esp_eth_stop (_eth_handle) != ESP_OK) {
0 commit comments