Skip to content

Commit b645b15

Browse files
committed
ethernet: refactor begin()
1 parent 247c263 commit b645b15

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

libraries/Ethernet/src/Ethernet.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
#if DT_HAS_COMPAT_STATUS_OKAY(ethernet_phy)
44

55
int EthernetClass::begin(uint8_t *mac, unsigned long timeout, unsigned long responseTimeout) {
6+
(void)timeout;
7+
(void)responseTimeout;
8+
if (hardwareStatus() != EthernetOk) {
9+
return 0;
10+
}
611
setMACAddress(mac);
7-
return NetworkInterface::begin(true, 0);
12+
return NetworkInterface::begin();
813
}
914

1015
int EthernetClass::begin(uint8_t *mac, IPAddress ip) {
@@ -30,17 +35,17 @@ int EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress ga
3035
}
3136

3237
int EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway,
33-
IPAddress subnet, unsigned long timeout, unsigned long responseTimeout) {
34-
setMACAddress(mac);
35-
36-
if (!NetworkInterface::config(ip, subnet, gateway)) {
38+
IPAddress subnet, unsigned long timeout, unsigned long responseTimeout) {
39+
(void)timeout;
40+
(void)responseTimeout;
41+
if (hardwareStatus() != EthernetOk) {
3742
return 0;
3843
}
39-
44+
setMACAddress(mac);
45+
config(ip, dns, gateway, subnet);
4046
if (!net_if_is_up(netif)) {
4147
net_if_up(netif);
4248
}
43-
4449
return 1;
4550
}
4651

0 commit comments

Comments
 (0)