Skip to content

Commit b26645b

Browse files
authored
Merge branch 'master' into master
2 parents 0142605 + fa56b12 commit b26645b

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,10 @@ You can either:
9797

9898
Connect your Arduino to ethernet and use your web browser to access the web interface on default IP: http://192.168.1.254
9999
Enjoy :-)
100+
100101
# Settings
101-
- settings marked \* are only available if ENABLE_DHCP is defined in advanced_settings.h
102-
- settings marked \*\* are only available if ENABLE_EXTENDED_WEBUI is defined in advanced_settings.h
102+
- settings marked \* are only available if ENABLE_DHCP is defined in advanced_settings.h
103+
- settings marked \*\* are only available if ENABLE_EXTENDED_WEBUI is defined in advanced_settings.h
103104

104105
## System Info
105106
<img src="pics/modbus1.png" alt="modbus1" style="zoom:100%;" />

arduino-modbus-rtu-tcp-gateway/04-webserver.ino

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ void recvWeb(EthernetClient &client) {
137137
// Get the requested page from URI
138138
byte reqPage = PAGE_ERROR; // requested page, 404 error is a default
139139
if (uri[0] == '/') {
140-
if (uri[1] == '\0') // the homepage System Info
141-
reqPage = PAGE_INFO;
142-
else if (!strcmp(uri + 2, ".htm")) {
143-
reqPage = byte(uri[1] - 48); // Convert single ASCII char to byte
144-
if (reqPage >= PAGE_WAIT) reqPage = PAGE_ERROR;
145-
} else if (!strcmp(uri, "/d.json")) {
140+
if (uri[1] == '\0') {
141+
reqPage = PAGE_INFO; // Homepage
142+
} else if (uri[1] >= '0' && uri[1] <= '9' && strcmp(uri + 2, ".htm") == 0) {
143+
reqPage = byte(uri[1] - '0'); // Convert ASCII digit to byte
144+
if (reqPage > PAGE_WAIT) reqPage = PAGE_ERROR;
145+
} else if (strcmp(uri, "/d.json") == 0) {
146146
reqPage = PAGE_DATA;
147147
}
148148
}

arduino-modbus-rtu-tcp-gateway/05-pages.ino

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ void sendPage(EthernetClient &client, byte reqPage) {
1515
char webOutBuffer[WEB_OUT_BUFFER_SIZE];
1616
ChunkedPrint chunked(client, webOutBuffer, sizeof(webOutBuffer)); // the StreamLib object to replace client print
1717
if (reqPage == PAGE_ERROR) {
18-
chunked.print(F("HTTP/1.1 404 Not Found\r\n"
19-
"\r\n"
20-
"404 Not found"));
21-
chunked.end();
18+
chunked.print(F(
19+
"HTTP/1.1 404 Not Found\r\n"
20+
"Content-Type: text/plain\r\n"
21+
"Content-Length: 13\r\n\r\n"
22+
"404 Not Found"));
23+
chunked.flush();
2224
return;
2325
} else if (reqPage == PAGE_DATA) {
2426
chunked.print(F("HTTP/1.1 200\r\n" // An advantage of HTTP 1.1 is that you can keep the connection alive

arduino-modbus-rtu-tcp-gateway/arduino-modbus-rtu-tcp-gateway.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@
2626
ENABLE_EXTENDED_WEBUI and ENABLE_DHCP is set by default for Mega
2727
v7.3 2024-01-16 Bugfix Modbus RTU Request form, code comments
2828
v7.4 2024-12-16 CSS improvement, code optimization, simplify DHCP renew, better README (solution to ethernet reset issue)
29+
v7.5 2025-XX-XX Fix 404 error page
2930
*/
3031

31-
#include "advanced_settings.h"
32+
const byte VERSION[] = { 7, 5 };
33+
3234
#include <SPI.h>
3335
#include <Ethernet.h>
3436
#include <EthernetUdp.h>
@@ -42,8 +44,6 @@
4244
#include <avr/wdt.h>
4345
#include <util/atomic.h>
4446

45-
const byte VERSION[] = { 7, 4 };
46-
4747
typedef struct {
4848
byte ip[4];
4949
byte subnet[4];

0 commit comments

Comments
 (0)