From 0d5019a412857e6b221dd45c2c93633c7b62b276 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Sat, 20 Apr 2019 01:32:52 +0200 Subject: [PATCH 1/3] esp8266 arduino core compatibility --- src/Ethernet.cpp | 6 +++++- src/utility/w5100.h | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Ethernet.cpp b/src/Ethernet.cpp index 658bd642..9257090c 100644 --- a/src/Ethernet.cpp +++ b/src/Ethernet.cpp @@ -83,7 +83,11 @@ void EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress g if (W5100.init() == 0) return; SPI.beginTransaction(SPI_ETHERNET_SETTINGS); W5100.setMACAddress(mac); -#if ARDUINO > 106 || TEENSYDUINO > 121 +#ifdef ESP8266 + W5100.setIPAddress(&ip[0]); + W5100.setGatewayIp(&gateway[0]); + W5100.setSubnetMask(&subnet[0]); +#elif ARDUINO > 106 || TEENSYDUINO > 121 W5100.setIPAddress(ip._address.bytes); W5100.setGatewayIp(gateway._address.bytes); W5100.setSubnetMask(subnet._address.bytes); diff --git a/src/utility/w5100.h b/src/utility/w5100.h index e6e01e1a..099556a6 100644 --- a/src/utility/w5100.h +++ b/src/utility/w5100.h @@ -454,6 +454,8 @@ extern W5100Class W5100; #ifndef UTIL_H #define UTIL_H +#ifndef htons + #define htons(x) ( (((x)<<8)&0xFF00) | (((x)>>8)&0xFF) ) #define ntohs(x) htons(x) @@ -463,4 +465,6 @@ extern W5100Class W5100; ((x)>>24 & 0x000000FFUL) ) #define ntohl(x) htonl(x) +#endif // !defined(htons) + #endif From 0dab7b994384afedd00ba23e358ec2bed450c4c6 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Sat, 20 Apr 2019 01:54:31 +0200 Subject: [PATCH 2/3] remove unused warning --- .../BarometricPressureWebServer/BarometricPressureWebServer.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino b/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino index 56ccc66c..1b940f30 100644 --- a/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino +++ b/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino @@ -228,7 +228,7 @@ unsigned int readRegister(byte registerName, int numBytes) { // take the chip select low to select the device: digitalWrite(chipSelectPin, LOW); // send the device the register you want to read: - int command = SPI.transfer(registerName); + /*int command =*/ SPI.transfer(registerName); // send a value of 0 to read the first byte returned: inByte = SPI.transfer(0x00); From 5f64311e27d5c3ff2c38de6f590583833907083e Mon Sep 17 00:00:00 2001 From: per1234 Date: Tue, 23 Apr 2019 15:26:21 +0200 Subject: [PATCH 3/3] remove useless comment from @per1234 Co-Authored-By: d-a-v --- .../BarometricPressureWebServer/BarometricPressureWebServer.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino b/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino index 1b940f30..99840354 100644 --- a/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino +++ b/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino @@ -228,7 +228,7 @@ unsigned int readRegister(byte registerName, int numBytes) { // take the chip select low to select the device: digitalWrite(chipSelectPin, LOW); // send the device the register you want to read: - /*int command =*/ SPI.transfer(registerName); + SPI.transfer(registerName); // send a value of 0 to read the first byte returned: inByte = SPI.transfer(0x00);