Skip to content

Commit 3e6aa5e

Browse files
committed
Ethernet: align ctor to WiFi
1 parent 39853dd commit 3e6aa5e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

libraries/Ethernet/src/Ethernet.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#define SSID_MAX_LENGTH 32
44

55
int arduino::EthernetClass::begin(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout) {
6+
if (eth_if == nullptr) {
7+
return 0;
8+
}
69
eth_if->set_dhcp(true);
710
return _begin(mac, timeout, responseTimeout);
811
}
@@ -94,4 +97,4 @@ void arduino::EthernetClass::MACAddress(uint8_t *mac_address)
9497
macAddress(mac_address);
9598
}
9699

97-
arduino::EthernetClass Ethernet;
100+
arduino::EthernetClass Ethernet(static_cast<EthernetInterface*>(EthInterface::get_default_instance()));

libraries/Ethernet/src/Ethernet.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ class EthernetClass : public MbedSocketClass {
6060
// Returns 0 if the DHCP configuration failed, and 1 if it succeeded
6161
EthernetClass(EthernetInterface *_if)
6262
: eth_if(_if){};
63-
EthernetClass(){};
6463

6564
int begin(uint8_t *mac = nullptr, unsigned long timeout = 60000, unsigned long responseTimeout = 4000);
6665
EthernetLinkStatus linkStatus();
@@ -116,8 +115,7 @@ class EthernetClass : public MbedSocketClass {
116115
int _begin(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout);
117116

118117
volatile EthernetLinkStatus _currentNetworkStatus = Unknown;
119-
EthernetInterface net;
120-
EthernetInterface *eth_if = &net;
118+
EthernetInterface *eth_if = nullptr;
121119
arduino::IPAddress ipAddressFromSocketAddress(SocketAddress socketAddress);
122120
};
123121

0 commit comments

Comments
 (0)