Skip to content

Ethernet, initCallback, ctor and eth_if #901

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

Merged
merged 6 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Ethernet: align ctor to WiFi
  • Loading branch information
pennam committed Jun 18, 2024
commit 3e6aa5e378226fd079ec08dd17aa503ff89ea85e
5 changes: 4 additions & 1 deletion libraries/Ethernet/src/Ethernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#define SSID_MAX_LENGTH 32

int arduino::EthernetClass::begin(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout) {
if (eth_if == nullptr) {
return 0;
}
eth_if->set_dhcp(true);
return _begin(mac, timeout, responseTimeout);
}
Expand Down Expand Up @@ -94,4 +97,4 @@ void arduino::EthernetClass::MACAddress(uint8_t *mac_address)
macAddress(mac_address);
}

arduino::EthernetClass Ethernet;
arduino::EthernetClass Ethernet(static_cast<EthernetInterface*>(EthInterface::get_default_instance()));
4 changes: 1 addition & 3 deletions libraries/Ethernet/src/Ethernet.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class EthernetClass : public MbedSocketClass {
// Returns 0 if the DHCP configuration failed, and 1 if it succeeded
EthernetClass(EthernetInterface *_if)
: eth_if(_if){};
EthernetClass(){};

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

volatile EthernetLinkStatus _currentNetworkStatus = Unknown;
EthernetInterface net;
EthernetInterface *eth_if = &net;
EthernetInterface *eth_if = nullptr;
arduino::IPAddress ipAddressFromSocketAddress(SocketAddress socketAddress);
};

Expand Down