From aaebd56db08abf2ae9bb26d0a9ed16c8780ae28f Mon Sep 17 00:00:00 2001 From: Rye Date: Sat, 4 Jan 2014 14:33:34 +0800 Subject: [PATCH 1/2] Added support for ENC28J60 chips via ntruchsess' arduino_uip library --- WebServer.h | 18 +++++++++++++++--- examples/Web_HelloWorld/Web_HelloWorld.ino | 8 ++++++++ readme.md | 6 ++++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/WebServer.h b/WebServer.h index df3905c..7320385 100644 --- a/WebServer.h +++ b/WebServer.h @@ -28,15 +28,22 @@ #include #include -#include -#include + +#ifdef UIPETHERNET_H +# include +# include +# define MAX_SOCK_NUM 255 +#else +# include +# include +#endif /******************************************************************** * CONFIGURATION ********************************************************************/ #define WEBDUINO_VERSION 1007 -#define WEBDUINO_VERSION_STRING "1.7" +#define WEBDUINO_VERSION_STRING "1.7.1" #if WEBDUINO_SUPRESS_SERVER_HEADER #define WEBDUINO_SERVER_HEADER "" @@ -397,7 +404,12 @@ size_t WebServer::write(uint8_t ch) size_t WebServer::write(const char *str) { +#ifdef UIPETHERNET_H + return m_client.write((const uint8_t *)str, sizeof(str)); +#else return m_client.write(str); +#endif + } size_t WebServer::write(const uint8_t *buffer, size_t size) diff --git a/examples/Web_HelloWorld/Web_HelloWorld.ino b/examples/Web_HelloWorld/Web_HelloWorld.ino index aebf90a..be4d436 100644 --- a/examples/Web_HelloWorld/Web_HelloWorld.ino +++ b/examples/Web_HelloWorld/Web_HelloWorld.ino @@ -1,7 +1,15 @@ /* Web_HelloWorld.pde - very simple Webduino example */ #include "SPI.h" +/* If you have a Microchip ENC28J60-based Ethernet shield, + * you can use arduino_uip library at https://github.com/ntruchsess/arduino_uip + * and replace the line below with: + * + * #include "UIPEthernet.h" + * + */ #include "Ethernet.h" + #include "WebServer.h" /* CHANGE THIS TO YOUR OWN UNIQUE VALUE. The MAC number should be diff --git a/readme.md b/readme.md index e312bc1..9ecfd39 100644 --- a/readme.md +++ b/readme.md @@ -36,11 +36,13 @@ These have all been tested with the library successfully: - [Adafruit Ethernet Shield w/ Wiznet 811MJ module](http://www.ladyada.net/make/eshield/) - [NKC Electronics Ethernet Shield DIY Kit](http://store.nkcelectronics.com/nkc-ethernet-shield-diy-kit-without-wiz812mj-mod812.html) -Shields using the Microchip ENC28J60 chip won't work with the library as that requires more software support for implementating -the TCP/IP stack. +Shields using the Microchip ENC28J60 chip can use ntruchsess' arduino_uip library (https://github.com/ntruchsess/arduino_uip) as a drop-in replacement for the stock Arduino Ethernet library. Take note that since the TCP/IP stack is implemented in software, the compiled sketch size will significantly increase. As a result, if you use an ENC28J60-based shield, your Arduino should have, at the very least, an ATMega328 chip. ## Version history +### 1.7.1 released Jan 2013 +- added support for ENC28J60 chips via ntruchsess' arduino_uip library. + ### 1.7 released in Jan 2012 - fixed Google Code issue [4](http://code.google.com/p/webduino/issues/detail?id=4) where expect fails with high-ASCII characters due to sign issues From d67e428bc52fc98eff530128a00cf0882d6bf536 Mon Sep 17 00:00:00 2001 From: rye Date: Sat, 23 Aug 2014 14:28:59 +0800 Subject: [PATCH 2/2] updated code to reflect latest arduino_uip --- WebServer.h | 3 +-- readme.md | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/WebServer.h b/WebServer.h index 7320385..5af904b 100644 --- a/WebServer.h +++ b/WebServer.h @@ -32,7 +32,6 @@ #ifdef UIPETHERNET_H # include # include -# define MAX_SOCK_NUM 255 #else # include # include @@ -357,7 +356,7 @@ class WebServer: public Print WebServer::WebServer(const char *urlPrefix, int port) : m_server(port), - m_client(MAX_SOCK_NUM), + m_client(), m_urlPrefix(urlPrefix), m_pushbackDepth(0), m_contentLength(0), diff --git a/readme.md b/readme.md index 9ecfd39..7639efa 100644 --- a/readme.md +++ b/readme.md @@ -36,7 +36,7 @@ These have all been tested with the library successfully: - [Adafruit Ethernet Shield w/ Wiznet 811MJ module](http://www.ladyada.net/make/eshield/) - [NKC Electronics Ethernet Shield DIY Kit](http://store.nkcelectronics.com/nkc-ethernet-shield-diy-kit-without-wiz812mj-mod812.html) -Shields using the Microchip ENC28J60 chip can use ntruchsess' arduino_uip library (https://github.com/ntruchsess/arduino_uip) as a drop-in replacement for the stock Arduino Ethernet library. Take note that since the TCP/IP stack is implemented in software, the compiled sketch size will significantly increase. As a result, if you use an ENC28J60-based shield, your Arduino should have, at the very least, an ATMega328 chip. +Shields using the Microchip ENC28J60 chip can use [ntruchsess' arduino_uip library](https://github.com/ntruchsess/arduino_uip) as a drop-in replacement for the stock Arduino Ethernet library. Take note that since the TCP/IP stack is implemented in software, the compiled sketch size will significantly increase. As a result, if you use an ENC28J60-based shield, your Arduino should have, at the very least, an ATMega328 chip. ## Version history