DEV Community

zhuyue
zhuyue

Posted on

Download the web pages to ESP8266 for simple programmable controller

In order to save the web pages in FLASH of ESP8266, I specially wrote a software tool by delphi.
This software tool reads all the web page files (including html, css, js, images, etc.) from one folder, and packages them to a binary file.

Ground the GPIO0 of the ESP8266 to start, the ESP8266 enters the serial port download mode.
Then use the download software to select the packaged web page file and command the save location, and then download it to the ESP8266 through the serial port together with the firmware file.

At the same time, the software also calculates the storage location of each file in flash according to the size of each file and automatically generates an .h file, which is used to load the corresponding web page from flash when downloading the web page.

For the newly designed simple programmable controller, the modification of the web page is also a very important, the use of serial tools to download the steps are cumbersome and slow, which affects the development speed, so I firstly designed such tool to download the web page remotely by TCP commands.

Modify the code of ESP8266 to add the function of erasing and reading flash content through TCP command.
And reserve a space of 4KByte for the flash storage location and size of each web page.

When receiving HTTP request from the browser, if the HTTP request file is a web page, it will first find out the storage location and size of the file from the flash according to the file name, if not found, it will still response the default web pages.

In the PC tool side, the codes are also added to send TCP commands to erase, write, read contents from ESP8266, and the web pages are divided to packages with 512 bytes size.

In the future, such a function can also be open to customers, so that customers can customize their own web pages.

Image description

Image description

Image description

Top comments (0)