Skip to content

Commit 35998e9

Browse files
committed
ethernet: refactor begin()
1 parent cd9baae commit 35998e9

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

libraries/Ethernet/src/Ethernet.cpp

Lines changed: 11 additions & 6 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) {
@@ -31,16 +36,16 @@ int EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress ga
3136

3237
int EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway,
3338
IPAddress subnet, unsigned long timeout, unsigned long responseTimeout) {
34-
setMACAddress(mac);
35-
36-
if (!NetworkInterface::config(ip, subnet, gateway)) {
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)