@@ -1252,7 +1252,7 @@ void handleRoot()
1252
1252
{
1253
1253
digitalWrite(led, 1);
1254
1254
1255
- #define BUFFER_SIZE 400
1255
+ #define BUFFER_SIZE 512
1256
1256
1257
1257
char temp[ BUFFER_SIZE] ;
1258
1258
int sec = millis() / 1000;
@@ -1305,29 +1305,54 @@ void handleNotFound()
1305
1305
digitalWrite(led, 0);
1306
1306
}
1307
1307
1308
+ #define ORIGINAL_STR_LEN 2048
1309
+
1308
1310
void drawGraph()
1309
1311
{
1310
- String out;
1311
- out.reserve(3000);
1312
+ static String out;
1313
+ static uint16_t previousStrLen = ORIGINAL_STR_LEN;
1314
+
1315
+ if (out.length() == 0)
1316
+ {
1317
+ ET_LOGWARN1(F("String Len = 0, extend to"), ORIGINAL_STR_LEN);
1318
+ out.reserve(ORIGINAL_STR_LEN);
1319
+ }
1320
+
1321
+ out = F( "<svg xmlns=\" http://www.w3.org/2000/svg\ " version=\" 1.1\" width=\" 310\" height=\" 150\" >\n" \
1322
+ "<rect width=\" 310\" height=\" 150\" fill=\" rgb(250, 230, 210)\" stroke-width=\" 3\" stroke=\" rgb(0, 0, 0)\" />\n" \
1323
+ "<g stroke=\" blue\" >\n");
1324
+
1312
1325
char temp[ 70] ;
1313
- out += "<svg xmlns=\" http://www.w3.org/2000/svg\ " version=\" 1.1\" width=\" 310\" height=\" 150\" >\n";
1314
- out += "<rect width=\" 310\" height=\" 150\" fill=\" rgb(250, 230, 210)\" stroke-width=\" 1\" stroke=\" rgb(0, 0, 0)\" />\n";
1315
- out += "<g stroke=\" black\" >\n";
1326
+
1316
1327
int y = rand() % 130;
1317
1328
1318
1329
for (int x = 10; x < 300; x += 10)
1319
1330
{
1320
1331
int y2 = rand() % 130;
1321
- sprintf(temp, "<line x1=\" %d\" y1=\" %d\" x2=\" %d\" y2=\" %d\" stroke-width=\" 1 \" />\n", x, 140 - y, x + 10, 140 - y2);
1332
+ sprintf(temp, "<line x1=\" %d\" y1=\" %d\" x2=\" %d\" y2=\" %d\" stroke-width=\" 2 \" />\n", x, 140 - y, x + 10, 140 - y2);
1322
1333
out += temp;
1323
1334
y = y2;
1324
1335
}
1325
- out += "</g >\n</svg >\n";
1336
+
1337
+ out += F("</g >\n</svg >\n");
1338
+
1339
+ ET_LOGDEBUG1(F("String Len = "), out.length());
1340
+
1341
+ if (out.length() > previousStrLen)
1342
+ {
1343
+ ET_LOGERROR3(F("String Len > "), previousStrLen, F(", extend to"), out.length() + 48);
1326
1344
1327
- server.send(200, "image/svg+xml", out);
1345
+ previousStrLen = out.length() + 48;
1346
+
1347
+ out.reserve(previousStrLen);
1348
+ }
1349
+ else
1350
+ {
1351
+ server.send(200, "image/svg+xml", out);
1352
+ }
1328
1353
}
1329
1354
1330
- void setup(void )
1355
+ void setup()
1331
1356
{
1332
1357
pinMode(led, OUTPUT);
1333
1358
digitalWrite(led, 0);
@@ -1389,9 +1414,42 @@ void setup(void)
1389
1414
Serial.println(Ethernet.localIP());
1390
1415
}
1391
1416
1392
- void loop(void)
1417
+
1418
+ void heartBeatPrint()
1419
+ {
1420
+ static int num = 1;
1421
+
1422
+ Serial.print(F("."));
1423
+
1424
+ if (num == 80)
1425
+ {
1426
+ Serial.println();
1427
+ num = 1;
1428
+ }
1429
+ else if (num++ % 10 == 0)
1430
+ {
1431
+ Serial.print(F(" "));
1432
+ }
1433
+ }
1434
+
1435
+ void check_status()
1436
+ {
1437
+ static unsigned long checkstatus_timeout = 0;
1438
+
1439
+ #define STATUS_CHECK_INTERVAL 10000L
1440
+
1441
+ // Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change.
1442
+ if ((millis() > checkstatus_timeout) || (checkstatus_timeout == 0))
1443
+ {
1444
+ heartBeatPrint();
1445
+ checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL;
1446
+ }
1447
+ }
1448
+
1449
+ void loop()
1393
1450
{
1394
1451
server.handleClient();
1452
+ check_status();
1395
1453
}
1396
1454
```
1397
1455
@@ -1415,8 +1473,8 @@ void loop(void)
1415
1473
// If USE_BUILTIN_ETHERNET == false and USE_UIP_ETHERNET == false =>
1416
1474
// either use W5x00 with EthernetXYZ library
1417
1475
// or ENC28J60 with EthernetENC library
1418
- // #define USE_BUILTIN_ETHERNET true
1419
- #define USE_BUILTIN_ETHERNET false
1476
+ #define USE_BUILTIN_ETHERNET true
1477
+ // #define USE_BUILTIN_ETHERNET false
1420
1478
1421
1479
//#define USE_UIP_ETHERNET true
1422
1480
#define USE_UIP_ETHERNET false
@@ -1432,9 +1490,9 @@ void loop(void)
1432
1490
#define USE_ETHERNET false //true
1433
1491
#define USE_ETHERNET2 false //true
1434
1492
#define USE_ETHERNET3 false //true
1435
- #define USE_ETHERNET_LARGE false
1493
+ #define USE_ETHERNET_LARGE true
1436
1494
#define USE_ETHERNET_ESP8266 false //true
1437
- #define USE_ETHERNET_ENC true
1495
+ #define USE_ETHERNET_ENC false
1438
1496
#define USE_CUSTOM_ETHERNET false
1439
1497
#endif
1440
1498
0 commit comments