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

Ethernet - allow return to DHCP after begin with static IP #823

Merged
merged 2 commits into from
Jan 24, 2024
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
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
Loading