esp8266_web_settings beta
esp8266_web_settings Detailed Documentation

Introduction

An implementation of a Web Server supporting setting panels.

HTTPS is not supported. Minimal authentication - a single id/password - is supported for save, reboot, factory defaults, and upload.

Overview

The server supports the following pages or requests:

  • "/": The root page. This contains the setting panels, and five buttons, Save, Reset Form, Reboot, Factory Defaults, and Uplaod Firmware.
  • "/style.css": CSS styles for the root page.
  • "/script.js": JavaScript for the root page.
  • "/settings/get": This path requires at least one parameter, the setting tab name. The values for that tab are returned as JSON. Example: "/settings/get?tab=Overview"
  • "/settings/set": Handles POST of the form data from the main page. When all data has been transferred to the settings, the on_save callback is invoked.
  • "/reboot": Call the on_restart callback. Performs no other action. Unprotected.
  • "/factoryreset": Call the on_factory_reset callback. Performs no other action. Unprotected.
  • "/upload": Show the upload page; this allows firmware uploads. Unprotected.
  • "/upload": POST request; upload firmware. Unprotected.

If the on_restart or on_factory_reset callbacks are not provided (i.e. are null), the associated URLs will not be registered. The '/upload' URL will also not be registered if the on_restart callback is null.

The main page is written to storage (TinyFS) in the setup method, and served directly from storage thereafter. Sufficient storage must be available for the complete main page.

A 404 handler is also installed. When SoftAP mode is detected, this will return a 302 response redirecting the page to the root page. This makes the server function as a captive portal in this mode. When the system is not in SoftAP mode, a simple 404 page is returned.

The on_save callback should save and apply settings.

The on_reboot callback should set a flag to indicate a reboot has been requested, and perform this in the main loop after a short delay (e.g. 100ms) by calling ESP.restart().

The on_factory_reset callback should set a flag to indcate a factory reset has been requested, and perform this in the main loop after a short delay. To reset, the following operations should be performed: LittleFS.format() and/or TinyFS.format(), depending on which file systems are in use.

  • ESP.eraseConfig().
  • ESP.reset().

This uses the ESP Asynch Web Server to serve the page.