Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit 537e3d0

Browse files
authored
v2.3.0 to add new features, send big data
### Releases v2.3.0 1. Add new features, such as `CORS`, etc. 2. Add example [EthernetWebServer_BigData](https://github.com/khoih-prog/EthernetWebServer/tree/master/examples/EthernetWebServer_BigData) to demo how to send larger data than `2/4/8/16K` buffer 3. Modify example [AdvancedWebServer](https://github.com/khoih-prog/EthernetWebServer/tree/master/examples/AdvancedWebServer) to demo how to send larger data than `2/4/8/16K` buffer 4. Update code 5. Update `Packages' Patches`
1 parent 0508dee commit 537e3d0

File tree

4 files changed

+1014
-9
lines changed

4 files changed

+1014
-9
lines changed

examples/AdvancedWebServer/AdvancedWebServer.ino

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void handleNotFound()
100100
server.send(404, F("text/plain"), message);
101101
}
102102

103-
#define ORIGINAL_STR_LEN 2048
103+
#define ORIGINAL_STR_LEN (2048 * MULTIPLY_FACTOR)
104104

105105
void drawGraph()
106106
{
@@ -113,15 +113,39 @@ void drawGraph()
113113
out.reserve(ORIGINAL_STR_LEN);
114114
}
115115

116+
117+
#if (MULTIPLY_FACTOR == 2)
118+
119+
out = F( "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"610\" height=\"150\">\n" \
120+
"<rect width=\"610\" height=\"150\" fill=\"rgb(250, 230, 210)\" stroke-width=\"3\" stroke=\"rgb(0, 0, 0)\" />\n" \
121+
"<g stroke=\"blue\">\n");
122+
123+
#elif (MULTIPLY_FACTOR == 4)
124+
125+
out = F( "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"1210\" height=\"150\">\n" \
126+
"<rect width=\"1210\" height=\"150\" fill=\"rgb(250, 230, 210)\" stroke-width=\"3\" stroke=\"rgb(0, 0, 0)\" />\n" \
127+
"<g stroke=\"blue\">\n");
128+
129+
#elif (MULTIPLY_FACTOR == 6)
130+
131+
out = F( "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"1810\" height=\"150\">\n" \
132+
"<rect width=\"1810\" height=\"150\" fill=\"rgb(250, 230, 210)\" stroke-width=\"3\" stroke=\"rgb(0, 0, 0)\" />\n" \
133+
"<g stroke=\"blue\">\n");
134+
135+
#else // (MULTIPLY_FACTOR == 1)
136+
116137
out = F( "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"310\" height=\"150\">\n" \
117138
"<rect width=\"310\" height=\"150\" fill=\"rgb(250, 230, 210)\" stroke-width=\"3\" stroke=\"rgb(0, 0, 0)\" />\n" \
118-
"<g stroke=\"blue\">\n");
139+
"<g stroke=\"blue\">\n");
140+
141+
#endif
119142

120143
char temp[70];
121144

122145
int y = rand() % 130;
123146

124-
for (int x = 10; x < 300; x += 10)
147+
//for (int x = 10; x < 300; x += 10)
148+
for (int x = 10; x < (300 * MULTIPLY_FACTOR); x += 10)
125149
{
126150
int y2 = rand() % 130;
127151
sprintf(temp, "<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" stroke-width=\"2\" />\n", x, 140 - y, x + 10, 140 - y2);
@@ -131,7 +155,7 @@ void drawGraph()
131155

132156
out += F("</g>\n</svg>\n");
133157

134-
ET_LOGDEBUG1(F("String Len = "), out.length());
158+
ET_LOGERROR1(F("String Len = "), out.length());
135159

136160
if (out.length() > previousStrLen)
137161
{

examples/AdvancedWebServer/defines.h

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@
2323
#define DEBUG_ETHERNET_WEBSERVER_PORT SerialDebug
2424

2525
// Debug Level from 0 to 4
26-
#define _ETG_LOGLEVEL_ 2
26+
#define _ETG_LOGLEVEL_ 3
2727
#define _ETHERNET_WEBSERVER_LOGLEVEL_ 1
2828

2929
#define USING_SPI2 false //true
3030

3131
#if ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) )
3232

33+
#define MULTIPLY_FACTOR 4
34+
3335
#if defined(BOARD_NAME)
3436
#undef BOARD_NAME
3537
#endif
@@ -57,10 +59,13 @@
5759
|| defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \
5860
|| defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \
5961
|| defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) )
60-
#if defined(ETHERNET_USE_SAMD)
61-
#undef ETHERNET_USE_SAMD
62-
#endif
63-
#define ETHERNET_USE_SAMD true
62+
63+
#define MULTIPLY_FACTOR 2
64+
65+
#if defined(ETHERNET_USE_SAMD)
66+
#undef ETHERNET_USE_SAMD
67+
#endif
68+
#define ETHERNET_USE_SAMD true
6469
#endif
6570

6671
#if (defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \
@@ -69,6 +74,9 @@
6974
defined(NRF52840_LED_GLASSES) || defined(MDBT50Q_RX) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) || \
7075
defined(ARDUINO_Seeed_XIAO_nRF52840) || defined(ARDUINO_Seeed_XIAO_nRF52840_Sense) || \
7176
defined(ARDUINO_SEEED_XIAO_NRF52840) || defined(ARDUINO_SEEED_XIAO_NRF52840_SENSE) )
77+
78+
#define MULTIPLY_FACTOR 2
79+
7280
#if defined(ETHERNET_USE_NRF528XX)
7381
#undef ETHERNET_USE_NRF528XX
7482
#endif
@@ -83,6 +91,9 @@
8391
#endif
8492

8593
#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) )
94+
95+
#define MULTIPLY_FACTOR 4
96+
8697
#if defined(ETHERNET_USE_RPIPICO)
8798
#undef ETHERNET_USE_RPIPICO
8899
#endif
@@ -276,6 +287,9 @@
276287
#endif
277288

278289
#elif ( defined(CORE_TEENSY) )
290+
291+
#define MULTIPLY_FACTOR 4
292+
279293
// Default pin 10 to SS/CS
280294
#define USE_THIS_SS_PIN SS //10
281295

@@ -310,6 +324,9 @@
310324
#endif
311325

312326
#elif ( defined(ESP8266) )
327+
328+
#define MULTIPLY_FACTOR 6 //4
329+
313330
// For ESP8266
314331
#if (_ETHERNET_WEBSERVER_LOGLEVEL_ > 3)
315332
#warning Use ESP8266 architecture
@@ -319,6 +336,9 @@
319336
#define BOARD_TYPE ARDUINO_BOARD
320337

321338
#elif ( defined(ESP32) )
339+
340+
#define MULTIPLY_FACTOR 4
341+
322342
// For ESP32
323343
#if (_ETHERNET_WEBSERVER_LOGLEVEL_ > 3)
324344
#warning Use ESP32 architecture
@@ -330,6 +350,8 @@
330350

331351
#elif ETHERNET_USE_RPIPICO
332352

353+
#define MULTIPLY_FACTOR 4
354+
333355
// Default pin 17 to SS/CS
334356
#if defined(ARDUINO_ARCH_MBED)
335357
// For RPI Pico using newer Arduino Mbed RP2040 core
@@ -372,6 +394,8 @@
372394

373395
#elif defined(DXCORE)
374396

397+
#define MULTIPLY_FACTOR 1
398+
375399
// Default pin 10 to SS/CS
376400
#define USE_THIS_SS_PIN SS
377401

@@ -384,6 +408,9 @@
384408
#endif
385409

386410
#else
411+
412+
#define MULTIPLY_FACTOR 1
413+
387414
// For Mega, etc.
388415
// Default pin SS/CS,if no SS pin, use pin 10
389416
#define USE_THIS_SS_PIN 10
@@ -538,6 +565,18 @@
538565
#define SHIELD_TYPE "ENC28J60 using UIPEthernet Library"
539566
#endif // #if !USE_UIP_ETHERNET
540567

568+
////////////////////////////
569+
570+
#if !defined(MULTIPLY_FACTOR)
571+
#define MULTIPLY_FACTOR 1
572+
#elif (MULTIPLY_FACTOR > 6)
573+
// Limit to max 4, for Ethernet W5500 buffer of 8K
574+
#undef MULTIPLY_FACTOR
575+
#define MULTIPLY_FACTOR 6
576+
#endif
577+
578+
////////////////////////////
579+
541580
#include <EthernetWebServer.h>
542581

543582
#ifndef SHIELD_TYPE

0 commit comments

Comments
 (0)