I am quite new to programming the ESP8266. before anypone points it out, I do plan to port my code to the newer ESP32 when I get one to develop with, but for now the ESP8266 is the only development hardware I have to work with.
I have designed a configuration page on my PC which I would now like to get programmed onto the ESP8266, but I have run into an interesting problem. A typical config web page body might broadly consist of:
- a header section and a div containing some kind of navigation which is consistently shown on each page
- a body div which will display different configuration options depending on the navigation option chosen
- a footer section which may contain the authors name, version number, date etc. which again is displayed consistently on every page
Currently I have plans to provide 4 separate configuration pages by function group:
- Page 1: general options such as AP or station mode and enabling/disabling options
- Page 2: WiFi configuration including IP address, gateway and mask, as well as wifi security
- Page 3: configuration parameters for the hardware interface that I am building
- Page 4: admin functions such as resetting the password, re-instating default settings and reboot
Given the small amount of memory on a microcontroller, I would like to define the header and footer sections only once and build a page that automatically adds them to the top and bottom of the selected configuration options section. The problem I have encountered is, that one can only use one server.send() in response to a request, and only one snprintf statement to compose the page. So how do I pull the 3 sections of the page together into one response without otherwise duplicating the header and footer section in each of the 4 functions that will return a configuration page?