I have an ESP8266 device and want to use this to save crash reports to EEPROM. This is important as my device is remote, and not easily accessible. The remote example sketch involves using client.print() however I am using server.on() for all my purposes.
How the library example does things:
client.print("HTTP/1.1 200 OK\r\n");
client.print("Content-Type: text/plain\r\n");
client.print("Connection: close\r\n");
client.print("\r\n");
// send crash information to the web browser
SaveCrash.print(client);
Where SaveCrash gets info from the EEPROM and prints it via printf and such:
void EspSaveCrash::print(Print& outputDev)
{
// Note that 'EEPROM.begin' method is reserving a RAM buffer
// The buffer size is SAVE_CRASH_EEPROM_OFFSET + SAVE_CRASH_SPACE_SIZE
EEPROM.begin(_offset + _size);
byte crashCounter = EEPROM.read(_offset + SAVE_CRASH_COUNTER);
if (crashCounter == 0)
{
outputDev.println("No crashes saved");
return;
}
I'd like to avoid modifying the library, and was wondering if there was a way to print to a string?
So I can utilize it in the following manner (I know this won't work, just pseudo-code):
server.on("/get_crash_report", HTTP_GET, []() {
String outputDev = "";
SaveCrash.print(outputDev)
server.send(200, "text/html", outputDev);
});