Skip to content

Commit

Permalink
v1.0.9
Browse files Browse the repository at this point in the history
#### New in v1.0.9

1. Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future.
2. Add default SS/CS pin for ESP8266 and ESP32
  • Loading branch information
khoih-prog authored May 16, 2020
1 parent e6bbcb4 commit c0694b5
Show file tree
Hide file tree
Showing 31 changed files with 1,607 additions and 586 deletions.
13 changes: 7 additions & 6 deletions LibraryPatches/Ethernet/src/Ethernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases
Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer
Licensed under MIT license
Version: 1.0.8
Version: 1.0.9
Copyright 2018 Paul Stoffregen
Expand Down Expand Up @@ -39,7 +39,8 @@
More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge
1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards
1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. Sync with ESP8266 core 2.7.1.
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards.
1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future.
*****************************************************************************************************************************/

#include <Arduino.h>
Expand All @@ -63,6 +64,7 @@ void EthernetClass::setRstPin(uint8_t pinRST)
void EthernetClass::setCsPin(uint8_t pinCS)
{
_pinCS = pinCS;
W5100.setSS(pinCS);

#if ( ETHERNET_DEBUG > 0 )
Serial.print("Input pinCS = ");
Expand Down Expand Up @@ -104,11 +106,9 @@ int EthernetClass::begin(uint8_t *mac, unsigned long timeout, unsigned long resp
#endif

// Initialise the basic info
// KH
if (W5100.init(MAX_SOCK_NUM, _pinCS) == 0)
if (W5100.init() == 0)
return 0;


SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
W5100.setMACAddress(mac);
W5100.setIPAddress(IPAddress(0,0,0,0).raw_address());
Expand Down Expand Up @@ -157,7 +157,8 @@ void EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress g

void EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet)
{
if (W5100.init(MAX_SOCK_NUM, _pinCS) == 0)
// Initialise the basic info
if (W5100.init() == 0)
return;

SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
Expand Down
5 changes: 3 additions & 2 deletions LibraryPatches/Ethernet/src/Ethernet.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases
Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer
Licensed under MIT license
Version: 1.0.8
Version: 1.0.9
Copyright 2018 Paul Stoffregen
Expand Down Expand Up @@ -39,7 +39,8 @@
More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge
1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards
1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. Sync with ESP8266 core 2.7.1.
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards.
1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future.
*****************************************************************************************************************************/

#ifndef ethernet_h_
Expand Down
7 changes: 4 additions & 3 deletions LibraryPatches/Ethernet/src/EthernetServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases
Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer
Licensed under MIT license
Version: 1.0.8
Version: 1.0.9
Copyright 2018 Paul Stoffregen
Expand Down Expand Up @@ -37,9 +37,10 @@
1.0.5 K Hoang 24/04/2020 Add support to nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense,
Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B30_ublox, etc.
More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge
1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards
1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards
1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. Sync with ESP8266 core 2.7.1.
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards.
1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future.
*****************************************************************************************************************************/

#include <Arduino.h>
Expand Down
46 changes: 29 additions & 17 deletions LibraryPatches/Ethernet/src/utility/w5100.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,26 @@
Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases
Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer
Licensed under MIT license
Version: 1.0.8
Version: 1.0.9
Copyright 2018 Paul Stoffregen
Copyright (c) 2010 by Cristian Maglie <c.maglie@bug.st>
This file is free software; you can redistribute it and/or modify
it under the terms of either the GNU General Public License version 2
or the GNU Lesser General Public License version 2.1, both as
published by the Free Software Foundation.
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -26,9 +37,10 @@
1.0.5 K Hoang 24/04/2020 Add support to nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense,
Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B30_ublox, etc.
More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge
1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards
1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards
1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. Sync with ESP8266 core 2.7.1.
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards.
1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future.
*****************************************************************************************************************************/

#include <Arduino.h>
Expand Down Expand Up @@ -91,16 +103,16 @@
//KH for ESP32
#elif defined(ESP32)
//pin SS already defined in ESP32 as pin 5, don't use this as conflict with SPIFFS, EEPROM, etc.
// Use in GPIO13
#warning w5100.cpp Use ESP32, change SS_PIN_DEFAULT to GPIO13, MOSI(23), MISO(19), SCK(18)
#define SS_PIN_DEFAULT 13 //SS
// Use in GPIO22
#warning w5100.cpp Use ESP32, change SS_PIN_DEFAULT to GPIO22, MOSI(23), MISO(19), SCK(18)
#define SS_PIN_DEFAULT 22 //SS
///////

//KH for ESP8266
#elif defined(ESP8266)
//pin SS already defined in ESP8266 as pin 15. Conflict => Move to pin 5 (D1)
#warning w5100.cpp Use ESP8266, change SS_PIN_DEFAULT to SS(5), MOSI(13), MISO(12), SCK(14)
#define SS_PIN_DEFAULT D1 // 5, SS
//pin SS already defined in ESP8266 as pin 15. Conflict => Move to pin GPIO4 (D2)
#warning w5100.cpp Use ESP8266, change SS_PIN_DEFAULT to SS(4), MOSI(13), MISO(12), SCK(14)
#define SS_PIN_DEFAULT D2 // GPIO4, SS

///////

Expand Down Expand Up @@ -167,7 +179,7 @@ uint8_t W5100Class::init(uint8_t socketNumbers, uint8_t new_ss_pin)
// reset time, this can be edited or removed.
delay(560);

W5100Class::ss_pin = new_ss_pin;
//W5100Class::ss_pin = new_ss_pin;

#if ( W5100_DEBUG > 0 )
//KH
Expand All @@ -178,7 +190,7 @@ uint8_t W5100Class::init(uint8_t socketNumbers, uint8_t new_ss_pin)
Serial.print(", W5100Class::ss_pin = ");
Serial.println(W5100Class::ss_pin);
#endif

SPI.begin();

initSS();
Expand Down Expand Up @@ -314,7 +326,7 @@ uint8_t W5100Class::softReset(void)
{
uint16_t count=0;

#if ( W5100_DEBUG > 0 )
#if ( W5100_DEBUG > 1 )
Serial.println("Wiznet soft reset");
#endif

Expand Down
28 changes: 20 additions & 8 deletions LibraryPatches/Ethernet/src/utility/w5100.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,26 @@
Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases
Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer
Licensed under MIT license
Version: 1.0.8
Version: 1.0.9
Copyright 2018 Paul Stoffregen
Copyright (c) 2010 by Cristian Maglie <c.maglie@bug.st>
This file is free software; you can redistribute it and/or modify
it under the terms of either the GNU General Public License version 2
or the GNU Lesser General Public License version 2.1, both as
published by the Free Software Foundation.
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -26,9 +37,10 @@
1.0.5 K Hoang 24/04/2020 Add support to nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense,
Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B30_ublox, etc.
More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge
1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards
1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards
1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. Sync with ESP8266 core 2.7.1.
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards.
1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future.
*****************************************************************************************************************************/

// w5100.h contains private W5x00 hardware "driver" level definitions
Expand Down
31 changes: 21 additions & 10 deletions LibraryPatches/EthernetLarge/src/EthernetLarge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases
Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer
Licensed under MIT license
Version: 1.0.8
Version: 1.0.9
Copyright 2018 Paul Stoffregen
Expand Down Expand Up @@ -39,14 +39,17 @@
More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge
1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards
1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. Sync with ESP8266 core 2.7.1.
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards.
1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future.
*****************************************************************************************************************************/

#include <Arduino.h>
#include "EthernetLarge.h"
#include "utility/w5100.h"
#include "Dhcp.h"

#define ETHERNET_DEBUG 1

IPAddress EthernetClass::_dnsServerAddress;
DhcpClass* EthernetClass::_dhcp = NULL;

Expand All @@ -60,10 +63,14 @@ void EthernetClass::setRstPin(uint8_t pinRST)
void EthernetClass::setCsPin(uint8_t pinCS)
{
_pinCS = pinCS;
W5100.setSS(pinCS);

#if ( ETHERNET_DEBUG > 0 )
Serial.print("Input pinCS = ");
Serial.println(pinCS);
Serial.print("_pinCS = ");
Serial.println(_pinCS);
#endif
}

void EthernetClass::initMaxSockNum(uint8_t maxSockNum)
Expand Down Expand Up @@ -92,10 +99,13 @@ int EthernetClass::begin(uint8_t *mac, unsigned long timeout, unsigned long resp
static DhcpClass s_dhcp;
_dhcp = &s_dhcp;

#if ( ETHERNET_DEBUG > 0 )
Serial.print("_pinCS = ");
Serial.print(_pinCS);
#endif

// Initialise the basic info
//if (W5100.init() == 0) return 0;
// KH
if (W5100.init(MAX_SOCK_NUM, _pinCS) == 0)
if (W5100.init() == 0)
return 0;


Expand Down Expand Up @@ -146,13 +156,13 @@ void EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress g

void EthernetClass::begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet)
{
//if (W5100.init() == 0) return;
// KH
if (W5100.init(MAX_SOCK_NUM, _pinCS) == 0)
// Initialise the basic info
if (W5100.init() == 0)
return;

SPI.beginTransaction(SPI_ETHERNET_SETTINGS);
W5100.setMACAddress(mac);
#ifdef ESP8266
#if ( defined(ESP8266) || defined(ESP32) )
W5100.setIPAddress(&ip[0]);
W5100.setGatewayIp(&gateway[0]);
W5100.setSubnetMask(&subnet[0]);
Expand Down Expand Up @@ -200,7 +210,8 @@ int EthernetClass::maintain()
if (_dhcp != NULL) {
// we have a pointer to dhcp, use it
rc = _dhcp->checkLease();
switch (rc) {
switch (rc)
{
case DHCP_CHECK_NONE:
//nothing done
break;
Expand Down
7 changes: 4 additions & 3 deletions LibraryPatches/EthernetLarge/src/EthernetLarge.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases
Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer
Licensed under MIT license
Version: 1.0.8
Version: 1.0.9
Copyright 2018 Paul Stoffregen
Expand Down Expand Up @@ -39,7 +39,8 @@
More Custom Ethernet libraries supported such as Ethernet2, Ethernet3, EthernetLarge
1.0.6 K Hoang 27/04/2020 Add support to ESP32/ESP8266 boards
1.0.7 K Hoang 30/04/2020 Add ENC28J60 support to ESP32/ESP8266 boards
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards. Sync with ESP8266 core 2.7.1.
1.0.8 K Hoang 12/05/2020 Fix W5x00 support for ESP8266 boards.
1.0.9 K Hoang 15/05/2020 Add EthernetWrapper.h for easier W5x00 support as well as more Ethernet libs in the future.
*****************************************************************************************************************************/

#ifndef ethernet_h_
Expand Down Expand Up @@ -123,7 +124,7 @@ class EthernetClass {
EthernetLinkStatus linkStatus();
EthernetHardwareStatus hardwareStatus();

// Manaul configuration
// Manual configuration
void begin(uint8_t *mac, IPAddress ip);
void begin(uint8_t *mac, IPAddress ip, IPAddress dns);
void begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway);
Expand Down
Loading

0 comments on commit c0694b5

Please sign in to comment.