I am currently using a Nodemcu ESP8266-12E with the Arduino IDE in order to control my boiler. Everything is working fine, however I haven't figured out yet how to serve binary files, eg. images. (I am hosting them on a server at the moment).
ESP8266WebServer server(80);
void setup()
{
[...]
server.on("/", handleResponse);
server.onNotFound(handleResponse);
server.begin();
}
void handleResponse() {
if (server.uri() == "/style.css") {
server.send(200, "text/css", "[css]");
return;
}
if (server.uri() == "/favicon.ico") {
server.send(404, "text/html", "Not set");
return;
}
[...]
}
unsigned char favicon_ico[] = {
0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x10, 0x10, 0x00, 0x00, 0x01, 0x00,
0x18, 0x00, 0x68, 0x03, 0x00,......... 0x00
};
unsigned int favicon_ico_len = 894;
Converting the arary to a string and serving it with server.send
does not work and server.stream
expects a file.