NetBurner 3.5.6
PDF Version
Detached Config Object

This example demonstrates how to create JSON configuration objects (data or structures) in a "detached" mode, meaning they do not appear in the web page configuration screen, nor are they saved, but are exposed via individual web pages. In Detached mode they are created at boot time and can be modified and used by the application.

The example will:

  • Create a number of configuration object classes
  • Use the classes to create Detached configuration objects
  • For reference, shows how they would be exposed in the normal configuration tree
  • Expose those objects as web pages containing the JSON information

For example, if your device IP address is 10.1.1.10, opening a web browser and typing "10.1.1.10/set.json" will display that object and it's data:

ctrl_set
Hset
D 0
I 0.0001
P 1
Vset
D 0
I 0.0001
P 1
rev 0

Detached Config Example

Overview

This NetBurner application demonstrates how to create JSON configuration objects in "detached" mode. In detached mode, configuration objects are created at boot time and can be modified and used by the application, but they do not appear in the Configuration Server web interface and may or may not be saved to persistent storage depending on the application requirements. However, they can, and usually are, used by individual web pages.

Features

  • Creates multiple configuration object classes with different data types
  • Demonstrates both detached and normal configuration modes
  • Exposes configuration objects as individual JSON web pages
  • Includes examples of inheritance between configuration classes

Configuration Classes

TempRange

Base class for temperature-related configuration:

  • MaxTemp: Maximum temperature (integer, default: 100)
  • SetTemp: Set temperature (integer, default: 30)
  • MinTemp: Minimum temperature (integer, default: 10)

Thermostat

Extends TempRange with additional thermostat-specific settings:

  • Active: Enable/disable thermostat (boolean, default: true)
  • Location: Physical location (string, default: "Warehouse 1")
  • TempScale: Temperature scale chooser (Fahrenheit/Celsius/Kelvin, default: Fahrenheit)

PIDSet

PID controller configuration:

  • P: Proportional term (double, default: 1.0)
  • I: Integral term (double, default: 0.0001)
  • D: Differential term (double, default: 0.0)

ControlSet

Container for PID control settings:

  • Hset: Horizontal PID settings
  • Vset: Vertical PID settings
  • rev: Settings revision number (integer, default: 0)

Configuration Modes

The application supports two modes controlled by the DETACHED_MODE preprocessor definition:

Detached Mode (Default)

  • Configuration objects are created with the detached parameter
  • Objects are not exposed in the configuration tree
  • Objects are not saved to persistent storage
  • Objects are accessible via individual web pages

Normal Mode

  • Configuration objects are created under the appdata parent
  • Objects appear in the standard configuration tree
  • Objects are saved to persistent storage

Web Interface

The application exposes three JSON endpoints:

  • <device_ip>/set.json - Displays the ControlSet object
  • <device_ip>/thermo.json - Displays the Thermostat object
  • <device_ip>/anint.json - Displays a simple integer configuration

Example JSON Output

Accessing <device_ip>/set.json displays:

ctrl_set
Hset
D 0
I 0.0001
P 1
Vset
D 0
I 0.0001
P 1
rev 0

Usage

  1. Build and deploy the application to your NetBurner device
  2. Wait for network initialization (up to 5 seconds)
  3. Open a web browser and navigate to:

Application Structure

main.cpp - Main application code with configuration classes
ReadMe.txt - Original documentation
index.html - Basic web page with NetBurner branding

Build Requirements

Key Concepts Demonstrated

  1. Configuration Object Classes: How to create custom configuration classes that inherit from config_obj
  2. Detached Configuration: Creating configuration objects that exist only in memory
  3. Web Exposure: Using HtmlConfigExposer to make configuration objects accessible via HTTP
  4. Inheritance: How configuration classes can extend other configuration classes
  5. Multiple Data Types: Support for integers, doubles, booleans, strings, and choosers

Notes

  • The ConfigEndMarker must be placed after all configuration members in each class
  • Configuration objects can be nested within other configuration objects
  • The application name is set to "Detached Config Example"
  • Network initialization waits up to 5 seconds before starting the HTTP server