|
NetBurner 3.5.8
PDF Version |
Example Path: examples/Configuration/Web/CustomWebConfig
This is an advanced embedded web configuration system built for NetBurner devices. It provides a modern, responsive web interface for managing device configuration objects, combining a C++ configuration backend with a plain-JavaScript (fetch) frontend. The system lets users configure thermostat settings, email notifications, and other application-specific parameters through a web browser.
This example is an advanced version of the BasicWebConfig example that builds the interface in JavaScript using the browser's fetch() API. It also demonstrates how to store and display custom application data in the AppData section.
Configuration objects are created when the device first boots, then stored so they persist after the device has been power cycled. The page styles the values with the self-contained, modern stylesheet (plain CSS, no framework or CDN) beyond the basic config-server presentation.
The application is built around a hierarchical configuration system using C++ classes:
config_obj - Base container object for organizing other configuration objectsconfig_bool - Boolean valuesconfig_int - Integer values config_double - Double precision floating point valuesconfig_string - String valuesconfig_chooser - Multiple choice dropdown optionsconfig_pass - Password fieldsconfig_IPADDR4 - IPv4 addressesconfig_IPADDR6 - IPv6 addressesconfig_MACADR - MAC addressesThermostat1 Class**
m_maxTemp - Maximum temperature setting (default: 100)m_setTemp - Target temperature setting (default: 30)m_minTemp - Minimum temperature setting (default: 10)m_powerMax - Maximum power setting (default: 200)m_active - Thermostat active status (default: true)
Thermostat2 Class** (extends Thermostat1)
m_tempRec1 - Temperature record 1 (default: 101)m_tempRec2 - Temperature record 2 (default: 102)
EmailNotify Class**
m_normal - Normal notification email addressm_emergency - Emergency notification email addressm_choose - Action chooser (Alert, TurnOff, Crash options)The web interface features:
The application provides a command-line interface through the serial port:
C - Show complete configuration treeE - Show email notification settingsF - Show and modify email normal contact addressN - Show IP address for first network interfaceS - Show and modify global string settingT - Show thermostat 1 settingsV - Show and modify global integer value2 - Show thermostat 2 settings6 - Show all interface IP addresses and system time? - Display command listThe system automatically configures network settings:
To extend the system:
The application displays build timestamp and provides network status information including:
Replace 10.1.1.x with your device's IP address. The config mirror serves each section as JSON.
Read the application config:
Read the network config:
Write a value back. The object must keep the same top-level section key the GET returned (AppData here), so the config server can match the leaf; the page posts the whole edited section the same way. This minimal body updates a single field:
Re-read Config/AppData (or reload the page) to confirm the new, flash-persisted value.