Skip to content

Commit 72462ca

Browse files
authored
Fixes static IPs for Arduino Nano Every
The example program WebClient does not work on the Arduino Nano Every when DHCP is not available or commented out - the versions of Ethernet::begin() using a static IP address fail. I tested the example on Uno, Mega2560 and Micro, it works on all of them using either DHCP or static IP. This modifies the begin() method so that it uses IPAddress::raw_address() instead of platform conditional code in the same way the DHCP version of begin() does. With this change static addresses work on the Nano Every too.
1 parent 9e8a98c commit 72462ca

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/Ethernet.cpp

+3-13
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,9 @@ void EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress g
8383
if (W5100.init() == 0) return;
8484
SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
8585
W5100.setMACAddress(mac);
86-
#ifdef ESP8266
87-
W5100.setIPAddress(&ip[0]);
88-
W5100.setGatewayIp(&gateway[0]);
89-
W5100.setSubnetMask(&subnet[0]);
90-
#elif ARDUINO > 106 || TEENSYDUINO > 121
91-
W5100.setIPAddress(ip._address.bytes);
92-
W5100.setGatewayIp(gateway._address.bytes);
93-
W5100.setSubnetMask(subnet._address.bytes);
94-
#else
95-
W5100.setIPAddress(ip._address);
96-
W5100.setGatewayIp(gateway._address);
97-
W5100.setSubnetMask(subnet._address);
98-
#endif
86+
W5100.setIPAddress(ip.raw_address());
87+
W5100.setGatewayIp(gateway.raw_address());
88+
W5100.setSubnetMask(subnet.raw_address());
9989
SPI.endTransaction();
10090
_dnsServerAddress = dns;
10191
}

0 commit comments

Comments
 (0)