Skip to content

Commit fff900d

Browse files
Disable Ethernet library if CONFIG_ETH_ENABLED not defined in sdkconfig.h (espressif#8595)
* disable ETH if CONFIG_ETH_ENABLED not defeined in sdkconfig.h * Include sdkconfig before checking config values --------- Co-authored-by: Me No Dev <[email protected]>
1 parent d048e21 commit fff900d

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

Diff for: libraries/Ethernet/src/ETH.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1919
*/
2020

21+
#include "sdkconfig.h"
22+
#ifdef CONFIG_ETH_ENABLED
23+
2124
#include "ETH.h"
2225
#include "esp_system.h"
2326
#if ESP_IDF_VERSION_MAJOR > 3
@@ -601,3 +604,5 @@ String ETHClass::macAddress(void)
601604
}
602605

603606
ETHClass ETH;
607+
608+
#endif // CONFIG_ETH_ENABLED

Diff for: libraries/Ethernet/src/ETH.h

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
#ifndef _ETH_H_
2222
#define _ETH_H_
2323

24+
#include "sdkconfig.h"
25+
#ifdef CONFIG_ETH_ENABLED
26+
2427
#include "WiFi.h"
2528
#include "esp_system.h"
2629
#include "esp_eth.h"
@@ -106,4 +109,6 @@ class ETHClass {
106109

107110
extern ETHClass ETH;
108111

112+
#endif // CONFIG_ETH_ENABLED
113+
109114
#endif /* _ETH_H_ */

Diff for: libraries/WiFi/src/WiFiGeneric.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ static void _arduino_event_cb(void* arg, esp_event_base_t event_base, int32_t ev
426426
/*
427427
* ETH
428428
* */
429+
#ifdef CONFIG_ETH_ENABLED
429430
} else if (event_base == ETH_EVENT && event_id == ETHERNET_EVENT_CONNECTED) {
430431
log_v("Ethernet Link Up");
431432
arduino_event.event_id = ARDUINO_EVENT_ETH_CONNECTED;
@@ -446,6 +447,7 @@ static void _arduino_event_cb(void* arg, esp_event_base_t event_base, int32_t ev
446447
#endif
447448
arduino_event.event_id = ARDUINO_EVENT_ETH_GOT_IP;
448449
memcpy(&arduino_event.event_info.got_ip, event_data, sizeof(ip_event_got_ip_t));
450+
#endif // CONFIG_ETH_ENABLED
449451

450452
/*
451453
* IPv6
@@ -594,10 +596,12 @@ static bool _start_network_event_task(){
594596
return false;
595597
}
596598

599+
#ifdef CONFIG_ETH_ENABLED
597600
if(esp_event_handler_instance_register(ETH_EVENT, ESP_EVENT_ANY_ID, &_arduino_event_cb, NULL, NULL)){
598601
log_e("event_handler_instance_register for ETH_EVENT Failed!");
599602
return false;
600603
}
604+
#endif // CONFIG_ETH_ENABLED
601605

602606
if(esp_event_handler_instance_register(WIFI_PROV_EVENT, ESP_EVENT_ANY_ID, &_arduino_event_cb, NULL, NULL)){
603607
log_e("event_handler_instance_register for WIFI_PROV_EVENT Failed!");

Diff for: libraries/WiFi/src/WiFiGeneric.h

+2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ typedef union {
9292
ip_event_got_ip_t got_ip;
9393
ip_event_got_ip6_t got_ip6;
9494
smartconfig_event_got_ssid_pswd_t sc_got_ssid_pswd;
95+
#ifdef CONFIG_ETH_ENABLED
9596
esp_eth_handle_t eth_connected;
97+
#endif
9698
wifi_sta_config_t prov_cred_recv;
9799
wifi_prov_sta_fail_reason_t prov_fail_reason;
98100
} arduino_event_info_t;

0 commit comments

Comments
 (0)