Difficulty using sendContent_P
Posted: Sat Nov 12, 2016 6:30 pm
Hi,
I've got a feeling I'm overlooking something very simple, but can't put my finger on it. Specifically, I am trying to take the HelloServer example and modify it to use the sendContent_P function. The error I am getting during compilation is
The actual routine I'm trying to get to work is this one:
I understand that this is an overly simple example, but I am trying to build up to send an image that is stored in base64. So I read the forum about someone trying to send 4K worth of data and thought this would be straightforward.
Can someone point me to what I am doing wrong? The headers included
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
In other words, the only change I am making to the example is the routine shown above.
Thanks in advance for any help - and for your patience.
mconsidine
I've got a feeling I'm overlooking something very simple, but can't put my finger on it. Specifically, I am trying to take the HelloServer example and modify it to use the sendContent_P function. The error I am getting during compilation is
Code: Select all
no matching function for call to 'ESP8266WebServer::sendContent_P(String&, unsigned int)'
The actual routine I'm trying to get to work is this one:
Code: Select all
void handleRoot() {
digitalWrite(led, 1);
//server.send(200, "text/plain", "hello from esp8266!");
String webtext = "<h1>";
webtext += "This would be the main homepage";
webtext += "</h1>";
server.setContentLength(strlen_P(webtext) );
server.send(200, "text/html", "" );
server.sendContent_P( webtext, sizeof(webtext));
digitalWrite(led, 0);
}
I understand that this is an overly simple example, but I am trying to build up to send an image that is stored in base64. So I read the forum about someone trying to send 4K worth of data and thought this would be straightforward.
Can someone point me to what I am doing wrong? The headers included
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
In other words, the only change I am making to the example is the routine shown above.
Thanks in advance for any help - and for your patience.
mconsidine