Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable Ethernet library if CONFIG_ETH_ENABLED not defined in sdkconfig.h #8595

Merged
merged 2 commits into from
Sep 13, 2023
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
5 changes: 5 additions & 0 deletions libraries/Ethernet/src/ETH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "sdkconfig.h"
#ifdef CONFIG_ETH_ENABLED
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are checking too early if CONFIG_ETH_ENABLED is defined. At this point in the header, nothing is yet included. You need to at least #include "sdkconfig.h" for this to work


#include "ETH.h"
#include "esp_system.h"
#if ESP_IDF_VERSION_MAJOR > 3
Expand Down Expand Up @@ -601,3 +604,5 @@ String ETHClass::macAddress(void)
}

ETHClass ETH;

#endif // CONFIG_ETH_ENABLED
5 changes: 5 additions & 0 deletions libraries/Ethernet/src/ETH.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#ifndef _ETH_H_
#define _ETH_H_

#include "sdkconfig.h"
#ifdef CONFIG_ETH_ENABLED
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above


#include "WiFi.h"
#include "esp_system.h"
#include "esp_eth.h"
Expand Down Expand Up @@ -106,4 +109,6 @@ class ETHClass {

extern ETHClass ETH;

#endif // CONFIG_ETH_ENABLED

#endif /* _ETH_H_ */
4 changes: 4 additions & 0 deletions libraries/WiFi/src/WiFiGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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!");
Expand Down
2 changes: 2 additions & 0 deletions libraries/WiFi/src/WiFiGeneric.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down