- Wed Dec 25, 2019 6:39 am
#85047
Same problem here.
Example code below comes from the "Hello world" example, adapted for use of PROGMEM.
I need to copy PROGMEM to an intermediate String because that string must be manipulated before sending.
This code works ok with v2.5.2.
With v.2.6.3 the program crashes.
If I use a string literal in server.send(200, "text/plain", "Hello world"); it works (but that is not the intention).
If I remove all references to esp8266Webserver, there is no crash and the String s is printed nicely in the serial monitor.
My interpretation is that esp8266webserver cannot handle a string originating from PROGMEM as of v2.6.
Is this a bug?
Can I copy the string from PROGMEM in another way that does not hurt esp8266webserver?
For the moment I have to stay with esp8266 libs version 2.5.2.
Using Arduino 1.8.10, NodeMCU 1.0 .
Code: Select all...
#include <ESP8266WebServer.h> // Include the WebServer library
ESP8266WebServer server(80); // Create a webserver object that listens for HTTP request on port 80
const char HoofdPagina[] PROGMEM = R"=====(
<!DOCTYPE html>
<html>
<head>
<titel>Exper met PROGMEM</titel>
</head>
<body>
<h2>Hello world!</h2>
</body>
</html>
)=====";
void handleRoot(); // function prototypes for HTTP handlers
void handleNotFound();
void setup(void){
...
String s = HoofdPagina;
Serial.println(s);
server.on("/", handleRoot); // Call the 'handleRoot' function when a client requests URI "/"
server.onNotFound(handleNotFound);
server.begin(); // Actually start the server
Serial.println("HTTP server started");
}
void loop(void){
server.handleClient(); // Listen for HTTP requests from clients
}
void handleRoot() {
String s = HoofdPagina;
Serial.println(s);
server.send(200, "text/html", s); // Send HTTP status 200 (Ok) and send some text to the browser/client
}
void handleNotFound(){
server.send(404, "text/plain", "404: Not found");
}