I have an Arduino sketch that serves an HTML web page using the standard Ethernet library (https://github.com/arduino-libraries/Ethernet) and the Ethernet Web Server library (https://github.com/khoih-prog/EthernetWebServer). I am serving HTML stored directly in the Arduino memory. The processor is the ARM Cortex M0+. Here is an extract from the code I am using:
#include <Ethernet.h>
#include <EthernetWebServer.h>
#define webpage "Big HTML string"
EthernetWebServer webServer;
void setup()
{
SerialUSB.begin(9600);
Ethernet.begin(settings.macAddress, settings.ipAddress, settings.ipAddressDns, settings.ipAddressGateway, settings.ipAddressSubnet); // 'settings' is a struct declared elsewhere
webServer = EthernetWebServer(settings.portHttp);
webServer.on("/login", [&webServer]{ // /login handler
webServer.send(200, "text/html", webpage);
});
}
void loop()
{
webServer.handleClient();
}
When I refresh the page (send GET request) more than 9 times or so the Arduino freezes. I have checked by placing SerialUSB.println() inside the code and it seems to stop before even entering the "/login handler" callback.
Does anyone know the cause or at least how to solve this?