Skip to content

Commit

Permalink
Ethernet - allow return to DHCP after begin with static IP
Browse files Browse the repository at this point in the history
  • Loading branch information
JAndrassy committed Dec 5, 2023
1 parent fcc63d9 commit 402e8ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libraries/Ethernet/src/Ethernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ int arduino::EthernetClass::begin(uint8_t *mac, unsigned long timeout, unsigned
_initializerCallback();
if (eth_if == nullptr) return 0;
}
eth_if->set_dhcp(true);
_begin(mac, timeout, responseTimeout);
}

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

auto ret = begin(mac, timeout, responseTimeout);
auto ret = _begin(mac, timeout, responseTimeout);
return ret;
}

Expand Down
2 changes: 2 additions & 0 deletions libraries/Ethernet/src/Ethernet.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ class EthernetClass : public MbedSocketClass {
constexpr static int maintain () { return DHCP_CHECK_NONE; }

private:
int _begin(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout);

volatile EthernetLinkStatus _currentNetworkStatus = Unknown;
EthernetInterface net;
EthernetInterface *eth_if = &net;
Expand Down

0 comments on commit 402e8ea

Please sign in to comment.