Skip to content

Commit 31f8045

Browse files
authored
Merge pull request #823 from JAndrassy/ethernet_return_to_dhcp
Ethernet - allow return to DHCP after begin with static IP
2 parents fb8dc9d + 6701a63 commit 31f8045

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

libraries/Ethernet/src/Ethernet.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ int arduino::EthernetClass::begin(uint8_t *mac, unsigned long timeout, unsigned
88
_initializerCallback();
99
if (eth_if == nullptr) return 0;
1010
}
11+
eth_if->set_dhcp(true);
12+
_begin(mac, timeout, responseTimeout);
13+
}
1114

15+
int arduino::EthernetClass::_begin(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout) {
1216
if (mac != nullptr) {
1317
eth_if->get_emac().set_hwaddr(mac);
1418
}
@@ -53,7 +57,7 @@ int arduino::EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPA
5357
eth_if->set_network(_ip, _netmask, _gateway);
5458
eth_if->add_dns_server(_dnsServer1, nullptr);
5559

56-
auto ret = begin(mac, timeout, responseTimeout);
60+
auto ret = _begin(mac, timeout, responseTimeout);
5761
return ret;
5862
}
5963

libraries/Ethernet/src/Ethernet.h

+2
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ class EthernetClass : public MbedSocketClass {
116116
constexpr static int maintain () { return DHCP_CHECK_NONE; }
117117

118118
private:
119+
int _begin(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout);
120+
119121
volatile EthernetLinkStatus _currentNetworkStatus = Unknown;
120122
EthernetInterface net;
121123
EthernetInterface *eth_if = &net;

0 commit comments

Comments
 (0)