From a64708fe17ae5bfc8122ce0f0b6a3b9c5fbce9f1 Mon Sep 17 00:00:00 2001 From: Anatoli Arkhipenko Date: Fri, 1 Sep 2023 11:51:11 -0400 Subject: [PATCH 1/2] disable ETH if CONFIG_ETH_ENABLED not defeined in sdkconfig.h --- libraries/Ethernet/src/ETH.cpp | 4 ++++ libraries/Ethernet/src/ETH.h | 4 ++++ libraries/WiFi/src/WiFiGeneric.cpp | 4 ++++ libraries/WiFi/src/WiFiGeneric.h | 2 ++ 4 files changed, 14 insertions(+) diff --git a/libraries/Ethernet/src/ETH.cpp b/libraries/Ethernet/src/ETH.cpp index 166f212f3a7..3af230e9ab0 100644 --- a/libraries/Ethernet/src/ETH.cpp +++ b/libraries/Ethernet/src/ETH.cpp @@ -18,6 +18,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifdef CONFIG_ETH_ENABLED + #include "ETH.h" #include "esp_system.h" #if ESP_IDF_VERSION_MAJOR > 3 @@ -601,3 +603,5 @@ String ETHClass::macAddress(void) } ETHClass ETH; + +#endif // CONFIG_ETH_ENABLED \ No newline at end of file diff --git a/libraries/Ethernet/src/ETH.h b/libraries/Ethernet/src/ETH.h index 7fc14f59cb3..a21fda6de5a 100644 --- a/libraries/Ethernet/src/ETH.h +++ b/libraries/Ethernet/src/ETH.h @@ -21,6 +21,8 @@ #ifndef _ETH_H_ #define _ETH_H_ +#ifdef CONFIG_ETH_ENABLED + #include "WiFi.h" #include "esp_system.h" #include "esp_eth.h" @@ -106,4 +108,6 @@ class ETHClass { extern ETHClass ETH; +#endif // CONFIG_ETH_ENABLED + #endif /* _ETH_H_ */ diff --git a/libraries/WiFi/src/WiFiGeneric.cpp b/libraries/WiFi/src/WiFiGeneric.cpp index 1b74d322739..49081742b53 100644 --- a/libraries/WiFi/src/WiFiGeneric.cpp +++ b/libraries/WiFi/src/WiFiGeneric.cpp @@ -426,6 +426,7 @@ static void _arduino_event_cb(void* arg, esp_event_base_t event_base, int32_t ev /* * ETH * */ +#ifdef CONFIG_ETH_ENABLED } else if (event_base == ETH_EVENT && event_id == ETHERNET_EVENT_CONNECTED) { log_v("Ethernet Link Up"); 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 #endif arduino_event.event_id = ARDUINO_EVENT_ETH_GOT_IP; memcpy(&arduino_event.event_info.got_ip, event_data, sizeof(ip_event_got_ip_t)); +#endif // CONFIG_ETH_ENABLED /* * IPv6 @@ -594,10 +596,12 @@ static bool _start_network_event_task(){ return false; } +#ifdef CONFIG_ETH_ENABLED if(esp_event_handler_instance_register(ETH_EVENT, ESP_EVENT_ANY_ID, &_arduino_event_cb, NULL, NULL)){ log_e("event_handler_instance_register for ETH_EVENT Failed!"); return false; } +#endif // CONFIG_ETH_ENABLED if(esp_event_handler_instance_register(WIFI_PROV_EVENT, ESP_EVENT_ANY_ID, &_arduino_event_cb, NULL, NULL)){ log_e("event_handler_instance_register for WIFI_PROV_EVENT Failed!"); diff --git a/libraries/WiFi/src/WiFiGeneric.h b/libraries/WiFi/src/WiFiGeneric.h index 2f670a34d05..89b9765f489 100644 --- a/libraries/WiFi/src/WiFiGeneric.h +++ b/libraries/WiFi/src/WiFiGeneric.h @@ -92,7 +92,9 @@ typedef union { ip_event_got_ip_t got_ip; ip_event_got_ip6_t got_ip6; smartconfig_event_got_ssid_pswd_t sc_got_ssid_pswd; +#ifdef CONFIG_ETH_ENABLED esp_eth_handle_t eth_connected; +#endif wifi_sta_config_t prov_cred_recv; wifi_prov_sta_fail_reason_t prov_fail_reason; } arduino_event_info_t; From af6c3a23ef2fe30d5e94cd540a81a25b9383bd8e Mon Sep 17 00:00:00 2001 From: Me No Dev Date: Wed, 13 Sep 2023 11:11:35 +0300 Subject: [PATCH 2/2] Include sdkconfig before checking config values --- libraries/Ethernet/src/ETH.cpp | 1 + libraries/Ethernet/src/ETH.h | 1 + 2 files changed, 2 insertions(+) diff --git a/libraries/Ethernet/src/ETH.cpp b/libraries/Ethernet/src/ETH.cpp index 3af230e9ab0..418135d12b5 100644 --- a/libraries/Ethernet/src/ETH.cpp +++ b/libraries/Ethernet/src/ETH.cpp @@ -18,6 +18,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "sdkconfig.h" #ifdef CONFIG_ETH_ENABLED #include "ETH.h" diff --git a/libraries/Ethernet/src/ETH.h b/libraries/Ethernet/src/ETH.h index a21fda6de5a..420b427707e 100644 --- a/libraries/Ethernet/src/ETH.h +++ b/libraries/Ethernet/src/ETH.h @@ -21,6 +21,7 @@ #ifndef _ETH_H_ #define _ETH_H_ +#include "sdkconfig.h" #ifdef CONFIG_ETH_ENABLED #include "WiFi.h"