Skip to content

Commit 75a3c37

Browse files
authored
Merge pull request #96 from d-a-v/master
compatibility for esp8266 core
2 parents 4f4ac17 + 5f64311 commit 75a3c37

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

examples/BarometricPressureWebServer/BarometricPressureWebServer.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ unsigned int readRegister(byte registerName, int numBytes) {
228228
// take the chip select low to select the device:
229229
digitalWrite(chipSelectPin, LOW);
230230
// send the device the register you want to read:
231-
int command = SPI.transfer(registerName);
231+
SPI.transfer(registerName);
232232
// send a value of 0 to read the first byte returned:
233233
inByte = SPI.transfer(0x00);
234234

src/Ethernet.cpp

+5-1
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

+4
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)