Post topics, source code that relate to the Arduino Platform

User avatar
By Pablo2048
#73207 Yes, exactly, what NickLD wrote with small correction:
replace httpServer.send(200, "text/html", MAIN_page); with httpServer.send_P(200, "text/html", MAIN_page, sizeof(MAIN_page));
there are _P methods for direct PROGMEM output (see ESP8266WebServer.h)
User avatar
By pedros89
#92857 I could not be more grateful. Thank you very much mr Pablo2048. I was having a headache because when my webpage was becoming big and with many string concatenations I had a white blank page in return on the browser. Serial printing the webpage stirng I realized that there was the
Code: Select allerror E (49837) uart: uart_write_bytes(1159): buffer null

I understood that the problem was that I needed to send smaller chunk of html to the client but I didn't know how to do it.
I came across this post and with your code now everything is sorted. I still would like to dig deeper in the matter because using the code above without the headers does not work.
I can mark my GitHub issue as solved thanks to you.
https://github.com/espressif/arduino-esp32/issues/5802

I have also made a python3 script that takes a long html string (e.g. 100000 chars) and splits it in smaller strings (every n characters) and put these smaller strings in a .txt file. Then each piece of webpage can be copy pasted in the Arduino code and be sent to the client with
Code: Select allserver.sendContent(small_string)

Script here below.
https://stackoverflow.com/a/70287092/13795525
User avatar
By Inq720
#93855 I see you solved it and congratulations. I know intimately how hard it is to do what you have achieved. I also want to plug my web server library in case someone else would rather it just work and not have to suffer like you and I have. The library shines with this particular issue. For just serving pages, all you need to code is:
Code: Select all#include <InqPortal.h>

InqPortal svr;

void setup()
{
  svr.begin("FirstPortal", NULL,
    "<your router SSID>", "<your router Password>");
}

loop() {}


Run and browse to the Admin and upload your web content to the disk and away you go.

My test website is about 44 files totaling 1.8MB. The largest image file is 457KB. I've not tested with bigger, but it should handle all the way up to the biggest thing the 3MB disk can hold.

A continuous 100 hour test serving 9 browsers continuously re-loading the same page pumped out 180GB.