Skip to content

Commit 0d5019a

Browse files
committed
esp8266 arduino core compatibility
1 parent 4f4ac17 commit 0d5019a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Ethernet.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ 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-
#if ARDUINO > 106 || TEENSYDUINO > 121
86+
#ifdef ESP8266
87+
W5100.setIPAddress(&ip[0]);
88+
W5100.setGatewayIp(&gateway[0]);
89+
W5100.setSubnetMask(&subnet[0]);
90+
#elif ARDUINO > 106 || TEENSYDUINO > 121
8791
W5100.setIPAddress(ip._address.bytes);
8892
W5100.setGatewayIp(gateway._address.bytes);
8993
W5100.setSubnetMask(subnet._address.bytes);

src/utility/w5100.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,8 @@ extern W5100Class W5100;
454454
#ifndef UTIL_H
455455
#define UTIL_H
456456

457+
#ifndef htons
458+
457459
#define htons(x) ( (((x)<<8)&0xFF00) | (((x)>>8)&0xFF) )
458460
#define ntohs(x) htons(x)
459461

@@ -463,4 +465,6 @@ extern W5100Class W5100;
463465
((x)>>24 & 0x000000FFUL) )
464466
#define ntohl(x) htonl(x)
465467

468+
#endif // !defined(htons)
469+
466470
#endif

0 commit comments

Comments
 (0)