NetBurner 3.5.6
PDF Version
Config Server Programming Guide

Configuration Server Programming Guide

Introduction

The NetBurner Configuration System provides a comprehensive solution for managing system and application settings stored in flash memory. This system enables configuration through multiple interfaces while maintaining data persistence across power cycles.

Configuration System Overview

Configuration System
v
┌─────────────────┼─────────────────┐
│ │ │
v v v
Web Interface Application Code Serial Interface
(Port 20034) (Direct Access) (UART Console)
│ │ │
└─────────────────┴─────────────────┘
v
JSON Storage
(Flash Memory)

Access Methods

The configuration data can be accessed and modified through multiple interfaces:

  1. System Configuration Web Server - Port 20034
  2. Application Code - Direct programmatic access
  3. Custom Web Interface - Your own web pages
  4. Serial Config Server - Command-line interface via UART

Key Features

  • Persistent Storage - All settings saved to flash memory
  • JSON Format - Configuration stored as JSON blobs
  • Hierarchical Structure - Tree-based organization with leaves
  • Flexible Access - Modify entire JSON or individual components
  • Version Control - Automatic version tracking on updates
  • Application Upload - Built-in firmware update capability

Configuration Structure

The configuration system uses a hierarchical tree structure with distinct branches for system and application data.

Configuration Tree Hierarchy

Config (Root)
┌────────────┼────────────┐
│ │ │
v v v
Version Reboot [Branches]
┌───────────────────┴───────────────────┐
│ │
v v
AppData Sys
(Application Data) (System Settings)
│ │
┌─────────┴─────────┐ ┌─────────────┴─────────────┐
│ │ │ │
v v v v
User-Defined Custom Data Boot NetIf
Variables Objects Settings (Network Interfaces)

Root Level: Config

The top-level Config object contains:

Field Type Description
Version Integer Automatically updated when settings saved
Reboot Boolean Forces module reboot when configuration updated
AppData Object User application data container
Sys Object System settings container

Example Structure:**

{
"Config": {
"Version": 15,
"Reboot": false,
"AppData": { ... },
"Sys": { ... }
}
}

Config.AppData

The AppData leaf is dedicated to user application data, providing a designated space for custom settings and parameters.

Purpose and Usage

Application Configuration
v
AppData
┌────────────┼────────────┬────────────┐
│ │ │ │
v v v v
Strings Integers Lists Custom
Objects

Available Configuration Objects

The system provides various typed configuration objects:

Example: Application Settings

// Define application configuration
namespace AppConfig
{
config_string deviceName("DeviceName", "Device-001",
"Display name for this device");
config_int sampleRate("SampleRate", 1000,
"Sensor sampling rate (Hz)");
config_bool enableLogging("EnableLogging", true,
"Enable data logging");
config_chooser mode("Mode",
{"Normal", "Debug", "Production"},
0, "Operating mode");
}
Boolean Configuration Variable.
Definition config_obj.h:997
Chooser Configuration Variable - Select From a List of Items.
Definition config_obj.h:2027
Signed 32-bit Integer Configuration Variable.
Definition config_obj.h:700
String Configuration Variable.
Definition config_obj.h:1127

Configuration Object Hierarchy

Config.AppData
┌────────────┼────────────┬────────────┐
│ │ │ │
v v v v
DeviceName SampleRate EnableLogging Mode
(string) (integer) (boolean) (chooser)

For detailed examples**, see:

  • BasicConfigVariable example
  • \examples\Configuration\BasicConfigVariable

Config.Sys - System Settings

The Sys leaf contains all device system settings including boot parameters and network configuration.

System Configuration Tree

Config.Sys
┌───────────┴───────────┐
│ │
v v
Boot NetIf
(Boot Settings) (Network Interfaces)
│ │
v v
[Boot Options] [Interface Settings]

Config.Sys.Boot - Boot Settings

Boot settings control system startup behavior, security, and serial configuration access.

Boot Configuration Parameters

Parameter Type Description
Abort String Key sequence to interrupt boot (default: "A")
BootBaud Integer Baud rate for boot UART
BootDelay Integer Wait time for abort sequence (seconds)
BootQuiet Boolean Suppress boot output messages
BootUart Integer UART number for boot output
Password String Configuration/upload password
User String Configuration/upload username
SerialConfig Enum Serial config server mode

Boot Process Flow

Power On / Reset
v
Initialize Hardware
v
Display Boot Banner
v
┌──────────┴──────────┐
│ │
BootQuiet=false BootQuiet=true
│ │
v │
Show Boot Messages │
│ │
└──────────┬──────────┘
v
Wait for Abort Key
(BootDelay seconds)
┌───────────┴───────────┐
│ │
Abort Pressed Timeout
│ │
v v
Enter Serial Config Continue Boot
Server │
│ v
v Call UserMain()
Config Shell
Available

Serial Config Server Modes

The SerialConfig parameter offers four operational modes:

SerialConfig Options
┌───────────────┼───────────────┬───────────────┐
│ │ │ │
v v v v
DuringBoot AlwaysEnabled PauseAfterBoot Disabled
│ │ │ │
v v v v
Available Always Pause Before Never
During Boot Active UserMain Available

Mode Descriptions

DuringBoot (Recommended)**

  • Serial config available only during boot
  • Use abort character sequence to enter
  • Safe for production use

    AlwaysEnabled (Use with Caution)**

  • Serial config always accessible via BootUart
  • May interfere with application serial I/O
  • Risk of accidental config corruption

    PauseAfterBoot**

  • Boot pauses after init() called
  • Serial config enabled automatically
  • Type boot to resume application

    Disabled**

  • Serial config completely disabled
  • No boot interruption possible
  • Maximum security, no serial access

Security Configuration

Authentication Required?
┌──────┴──────┐
│ │
v v
User + Password No Auth
Required Required
│ │
v v
Protected Open Access
(Recommended)

When both User and Password are set:

  • Required for configuration changes
  • Required for application uploads
  • Protects against unauthorized access

Config.Sys.NetIf - Network Interfaces

The NetIf section contains settings for all network interfaces including Ethernet and WiFi.

Network Interface Tree

Config.Sys.NetIf
┌────────────────┼────────────────┐
│ │ │
v v v
Ethernet0 Ethernet1 WiFi0
│ │ │
v v v
[Interface Settings] [Settings] [Settings]

Common Interface Parameters

Parameter Description
DeviceName Interface name for DDNS/NetBIOS registration
DhcpDiscoverSec Delay before DHCP Discover (seconds)
DiscoveryReportInterval Device discovery report frequency
DiscoveryReportUrl Discovery server URL
MAC Interface MAC address

Discovery Configuration

Device Discovery
v
DiscoveryReportInterval
(Report Frequency Timer)
v
DiscoveryReportUrl
┌────────────┴────────────┐
│ │
v v
NetBurner Server Custom Server
(discover.netburner.com) (Your URL)
│ │
v v
Report Device Report Device
Information Information

Discovery Options:**

  • Default: Reports to NetBurner's discovery server
  • Custom: Set your own discovery server URL
  • Disabled: Leave URL blank to disable reporting

Config.Sys.NetIf.Ethernet0.IPv4

IPv4 configuration settings for Ethernet interfaces.

IPv4 Settings Overview

IPv4 Configuration
┌───────────┴───────────┐
│ │
v v
Active Values Static Values
(Currently In Use) (Manual Config)
│ │
v v
┌───────┴───────┐ ┌───────┴───────┐
│ │ │ │ │ │
v v v v v v
Addr DNS Gate Addr DNS Gate
Mask Mask

IPv4 Parameters

Active Settings (Read-Only)

Parameter Description
ActiveAddr Current IPv4 address in use
ActiveDNS1 Current primary DNS server
ActiveDNS2 Current secondary DNS server
ActiveGate Current gateway address
ActiveMask Current subnet mask
AutoIPAddr Auto-assigned IP (if applicable)
AutoIPEn Auto-IP enabled status

Static Settings (User Configurable)

Parameter Description
StaticAddr Manually configured IP address
StaticDNS1 Manually configured primary DNS
StaticDNS2 Manually configured secondary DNS
StaticGate Manually configured gateway
StaticMask Manually configured subnet mask

IPv4 Mode Selection

The Mode parameter determines how IPv4 settings are obtained:

IPv4 Mode
┌───────────────┼───────────────┬─────────────┐
│ │ │ │
v v v v
DHCP DHCP w/Fallback Static Disabled
│ │ │ │
v v v v
Use DHCP Try DHCP Use Static Interface
Server First Values Disabled
│ │ │
│ v │
│ ┌───────┴───────┐ │
│ │ │ │
│ v v │
│ Success Failure │
│ │ │ │
│ v v │
│ Use DHCP Use Static │
│ │
└────────────────┬───────────────┘
v
Active Values Set
DHCP Namespace.
Definition dhcpd.h:39

Mode Descriptions

DHCP**

  • Obtain all settings from DHCP server
  • If DHCP fails, no network connectivity

    DHCP with Fallback**

  • Try DHCP first
  • Fall back to static values if DHCP unavailable
  • Recommended for most applications

    Static**

  • Use manually configured static values
  • No DHCP attempts

    Disabled**

  • Interface completely disabled
  • No network activity

Config.Sys.NetIf.Ethernet0.IPv6

IPv6 configuration settings for Ethernet interfaces.

IPv6 Settings Overview

IPv6 Configuration
┌───────────┴───────────┐
│ │
v v
Active Values Static Values
│ │
v v
┌─────┴─────┐ ┌─────┴─────┐
│ │ │ │ │ │
v v v v v v
Addr DNS Routes Addr DNS1 DNS2

IPv6 Parameters

Active Settings (Read-Only)

Parameter Description
ActiveAddr Array of active IPv6 addresses
ActiveDNS Array of active IPv6 DNS servers
ActiveRoutes Array of active IPv6 routes

Static Settings (User Configurable)

Parameter Description
StaticAddr Manually configured IPv6 address
StaticDNS1 Manually configured primary IPv6 DNS
StaticDNS2 Manually configured secondary IPv6 DNS

IPv6 Mode Selection

Similar to IPv4, the Mode parameter offers:

  • DHCP - DHCPv6/SLAAC automatic configuration
  • DHCP w/Fallback - Try auto-config, fall back to static
  • Static - Use manually configured values
  • Disabled - Disable IPv6 on interface

Configuration Web Interface

The configuration web server runs on port 20034 and provides a full-featured interface for viewing and modifying settings.

Accessing the Web Interface

Browser Request
v
http://[device-ip]:20034
v
Configuration Web Interface
v
┌──────────────────────────────┐
│ │
│ ┌────────────────────────┐ │
│ │ Navigation Tree │ │
│ │ │ │
│ │ > Config │ │
│ │ > AppData │ │
│ │ > Sys │ │
│ │ > Boot │ │
│ │ > NetIf │ │
│ └────────────────────────┘ │
│ │
│ ┌────────────────────────┐ │
│ │ Value Editor │ │
│ │ │ │
│ │ [Input Fields] │ │
│ │ [Checkboxes] │ │
│ │ [Dropdowns] │ │
│ └────────────────────────┘ │
│ │
│ [Control Buttons] │
│ │
└──────────────────────────────┘

Example URL**: http://10.1.1.100:20034

Web Interface Features

Navigation Controls

Configuration Tree Controls
┌───────────┴───────────┐
│ │
v v
Expand All Collapse All
│ │
v v
Show All Branches Hide All Branches

Action Buttons

Button Function Action
Expand All Expand entire tree Shows all configuration branches
Collapse All Collapse entire tree Hides all sub-branches
Update Record Save changes Writes current values to flash
Download Config Export configuration Downloads JSON file
Restore Config Import configuration Uploads JSON file
Raw Config Page View raw interface Shows unformatted JSON editor
NB Discover NetBurner discovery Opens discover.netburner.com
Discover Local Local network scan Finds devices without internet

Application Update Feature

Application Update Process
v
┌────────┴────────┐
│ Choose File │
│ (.bin) │
└────────┬────────┘
v
┌────────┴────────┐
│ Send File │
│ (Upload) │
└────────┬────────┘
v
┌────────┴────────┐
│ Verify Image │
└────────┬────────┘
v
┌────────┴────────┐
│ Flash to │
│ Memory │
└────────┬────────┘
v
┌────────┴────────┐
│ Reboot with │
│ New App │
└─────────────────┘

Update Steps:**

  1. Click "Choose File" button
  2. Select compiled .bin file
  3. Click "Send File" to upload
  4. Wait for verification and programming
  5. Device automatically reboots with new application

Serial Configuration Interface

The serial configuration interface provides command-line access to the configuration system via UART.

Accessing Serial Config

Boot Process Start
v
Display Boot Message:
"Type <Abort> to Abort boot..."
┌───────┴───────┐
│ │
Abort Pressed Timeout Expires
│ │
v v
Serial Config Continue to
Server UserMain()
v
┌─────────────┐
│ Prompt │
│ > │
└─────────────┘

Serial Config Prompt

When successfully entered, you'll see:

>

As you navigate, the prompt shows your location:

> # Root level
Config.Sys> # In Sys branch
Config.Sys.Boot> # In Boot settings

Navigation Model

The serial config operates like a file system:

Configuration Tree Navigation
v
Root Directory (>)
┌─────────┴─────────┐
│ │
v v
Type Branch Name Use Commands
│ │
v v
Enter Branch Navigate/Modify
v
New Prompt Level
(e.g., Config.Sys>)

Serial Config Commands

Command Syntax Description
help help Display all available commands
boot boot Exit config server and boot application
reboot reboot Restart the module
flash flash Upload new application via serial
ls ls List current level contents
.. .. Move up one level in tree
<var>? Config? Display variable contents
<var>=<val> Boot.Abort="B" Set variable value
save save Save changes to flash

Command Examples

Viewing Configuration

> Config?
{
"Version": 15,
"Reboot": false,
"AppData": {...},
"Sys": {...}
}
> Config.Sys.Boot?
{
"Abort": "A",
"BootBaud": 115200,
"BootDelay": 3,
...
}

Modifying Settings

> Config.Sys.Boot
Config.Sys.Boot> Abort="B"
Config.Sys.Boot> BootDelay=5
Config.Sys.Boot> save
Configuration saved.
Config.Sys.Boot> ..
Config.Sys> boot
Continuing boot...

Navigation Example

> Config
Config> Sys
Config.Sys> NetIf
Config.Sys.NetIf> Ethernet0
Config.Sys.NetIf.Ethernet0> IPv4
Config.Sys.NetIf.Ethernet0.IPv4> ls
ActiveAddr
ActiveDNS1
ActiveDNS2
Mode
StaticAddr
...
Config.Sys.NetIf.Ethernet0.IPv4> ..
Config.Sys.NetIf.Ethernet0> ..
Config.Sys.NetIf> ..
Config.Sys> ..
Config> ..
>

Uploading Application via Serial

Serial Flash Process
v
┌────────┴────────┐
│ Type: flash │
└────────┬────────┘
v
┌────────┴────────┐
│ Press F5 │
│ (in MTTTY) │
└────────┬────────┘
v
┌────────┴────────┐
│ Select .bin │
│ File │
└────────┬────────┘
v
┌────────┴────────┐
│ Transfer │
│ via YMODEM │
└────────┬────────┘
v
┌────────┴────────┐
│ Verify & │
│ Program │
└────────┬────────┘
v
┌────────┴────────┐
│ Reboot │
└─────────────────┘

Steps:**

  1. Enter serial config mode
  2. Type flash and press Enter
  3. In MTTTY: Press F5 to open file dialog
  4. Select your .bin file
  5. Wait for transfer and programming
  6. Device reboots automatically

Creating a Custom Web Interface

The configuration web interface can be completely customized with your own design, branding, and functionality.

Customization Workflow

Custom Interface Creation
┌───────────┴───────────┐
│ │
v v
Replace ROOT.html Rebuild System
│ Libraries
v │
Your Custom HTML v
CSS, JavaScript Updated Config
Your Logo Server
│ │
└───────────┬───────────┘
v
Custom Web Interface
Deployed

Steps to Customize

Option 1: Replace System Interface

  1. Locate system file:
    <NNDK Install Directory>\nbrtos\source\ROOT.html
  2. Create your custom ROOT.html
  3. Rebuild system libraries:
    • Follow NBEclipse Getting Started Guide
    • Rebuild system libraries section

Option 2: Replace Logo Only

  1. Locate logo file:
    <NNDK Install Directory>\nbrtos\source\LOGO.gif
  2. Replace with your logo image
  3. Rebuild system libraries

Custom Interface Example

A complete example demonstrating the current config web interface structure is available:

Location:**

<NNDK Install Directory>\examples\Configuration\BasicWebConfig

This example shows:

  • HTML structure
  • JavaScript interaction
  • CSS styling
  • Configuration API usage

Configuration API Examples

NetBurner provides comprehensive examples demonstrating various aspects of the configuration system.

Example Projects Overview

Configuration Examples
┌───────────────┼───────────────┬───────────────┐
│ │ │ │
v v v v
BasicConfigVar BasicWebConfig CustomWebConfig CustomRangeLimit
│ │ │ │
v v v v
Basic Config Web-Based Advanced Web Validation &
Variables Interface (Bootstrap) Range Limits

Available Examples

1. BasicConfigVariable

Location:** <NNDK>\examples\Configuration\BasicConfigVariable

Demonstrates:**

  • Basic config object usage
  • Creating config variables
  • Reading and writing values
  • Saving to flash

    Key Concepts:**

    // String configuration
    config_string deviceName("Name", "Device-001", "Device identifier");
    // Integer configuration
    config_int sampleRate("Rate", 1000, "Sample rate in Hz");
    // Boolean configuration
    config_bool enabled("Enabled", true, "Feature enabled");
    // Reading values
    const char* name = deviceName.c_str();
    int rate = sampleRate;
    bool isEnabled = enabled;
    // Writing values
    deviceName = "Device-002";
    sampleRate = 2000;
    enabled = false;
    // Save to flash
    void SaveConfigToStorage()
    Save configuration to flash storage.

2. BasicWebConfig

Location:** <NNDK>\examples\Configuration\BasicWebConfig

Demonstrates:**

  • Config system web interface basics
  • Dynamic web page generation
  • Real-time value updates
  • Form handling

    Architecture:**

    Browser NetBurner Device
    │ │
    v v
    Web Page <─────────────> HTTP Server
    │ │
    v v
    User Input ────────────> Config Objects
    v
    Flash Storage

3. CustomWebConfig

Location:** <NNDK>\examples\Configuration\CustomWebConfig

Demonstrates:**

  • Advanced web interface design
  • Bootstrap framework integration
  • jQuery for dynamic updates
  • Professional UI/UX

    Features:**

  • Responsive design
  • Interactive controls
  • Real-time validation
  • Modern web technologies

4. CustomRangeLimit

Location:** <NNDK>\examples\Configuration\CustomRangeLimit

Demonstrates:**

  • Extending config objects
  • Custom validation logic
  • Min/max range checking
  • Input constraints

    Example:**

    // Custom range-limited integer
    {
    public:
    config_int_limit(const char* name, int defaultVal,
    int minVal, int maxVal, const char* desc)
    : config_int(name, defaultVal, desc),
    min(minVal), max(maxVal) {}
    bool SetValue(int val) override
    {
    if (val < min || val > max)
    return false; // Reject out-of-range
    return config_int::SetValue(val);
    }
    private:
    int min, max;
    };
    // Usage
    config_int_limit temperature("Temp", 25, 0, 100,
    "Temperature (0-100C)");
    A config_int with minimum and/or maximum values Attempting to set a value lower than the minimum or g...
    Definition config_obj.h:2274
    config_int_limit(config_obj &owner, int def_val, int minv=INT_MIN, int maxv=INT_MAX, const char *name=NULL, const char *desc=NULL)
    Object constructor with the parent/owner leaf parameter and limits.
    Definition config_obj.h:2290

Example Selection Guide

Choose Example Based On Need
┌───────────┼───────────┬───────────┐
│ │ │ │
v v v v
Just Starting? Need Web? Want Advanced? Need Validation?
│ │ │ │
v v v v
BasicConfigVar BasicWebConfig CustomWebConfig CustomRangeLimit

Best Practices

Configuration Design Principles

1. Organization Strategy

Configuration Organization
┌───────────┴───────────┐
│ │
v v
System Settings Application Data
(Config.Sys) (Config.AppData)
│ │
v v
Don't Modify Organize Logically
(Read-only) │
┌──────────┴──────────┐
│ │
v v
By Feature By Function

Guidelines:**

  • Keep application data in Config.AppData
  • Don't modify Config.Sys unless necessary
  • Group related settings together
  • Use descriptive names
  • Add helpful descriptions

2. Variable Naming

Good Variable Names:
deviceName Clear purpose
sampleRateHz Includes units
enableDataLogging Boolean prefix
motorSpeedRPM Descriptive + units
Poor Variable Names:
var1 Meaningless
x Too short
temp Ambiguous
d No context

3. Security Considerations

Security Best Practices
┌───────────┼───────────┬───────────┐
│ │ │ │
v v v v
Set User Set Strong Disable Limit
Name Password Serial Access
When Prod

Recommendations:**

  • Always set User and Password for production
  • Use strong passwords (8+ characters, mixed case, numbers)
  • Disable serial config in deployed systems
  • Limit web interface access by network
  • Consider custom web interface with authentication

4. Performance Optimization

Configuration Access Patterns
┌───────────┴───────────┐
│ │
v v
Frequent Access Rare Access
│ │
v v
Cache Values Read Direct
in Variables from Config
│ │
v v
Update Cache on Access Only
Config Change When Needed

Tips:**

  • Cache frequently accessed values
  • Update cache when config changes
  • Minimize flash writes
  • Batch configuration updates

5. Validation and Error Handling

Input Validation Flow
v
Receive New Value
v
┌────────┴────────┐
│ Validate │
│ - Type check │
│ - Range check │
│ - Format check│
└────────┬────────┘
┌───────┴───────┐
│ │
v v
Valid Invalid
│ │
v v
Apply Value Reject + Error
│ Message
v
Save to Flash

Implementation:**

  • Always validate user input
  • Use custom config classes for complex validation
  • Provide clear error messages
  • Log configuration changes

Troubleshooting

Common Issues and Solutions

Issue: Cannot Access Web Interface

Symptom: Browser cannot connect to port 20034
v
Troubleshooting Steps:
┌────┴────┬────────┬────────┐
│ │ │ │
v v v v
Check IP Check Firewall Web Server
Address Port Rules Started?
int connect(const IPADDR &ipAddress, uint16_t remotePort, uint32_t timeout)
Establish a TCP connection to a remote host.
Definition tcp.h:1547

Solutions:**

  1. Verify device IP address is correct
  2. Ensure using port 20034: http://ip:20034
  3. Check firewall allows port 20034
  4. Verify config web server is enabled in code

Issue: Serial Config Not Accessible

Symptom: Abort sequence doesn't work
v
Check Configuration:
┌────┴────┬─────────┬──────────┐
│ │ │ │
v v v v
Abort BootDelay BootUart SerialConfig
Key? Timeout? Correct? Enabled?

Solutions:**

  1. Verify Abort key is correct (default: "A")
  2. Send abort key during BootDelay window
  3. Ensure using correct UART port
  4. Check SerialConfig not set to "Disabled"

Issue: Configuration Changes Not Saved

Symptom: Settings revert after reboot
v
Verify Save Process:
┌────┴────┬─────────────┐
│ │ │
v v v
Clicked Called Save Flash
Update? Function? Write OK?

Solutions:**

  1. Web Interface: Click "Update Record" button
  2. Serial: Execute save command
  3. Code: Call SaveConfigToStorage()
  4. Check flash memory not full/corrupted

Issue: Custom Config Variables Not Appearing

Symptom: Variables not visible in interface
v
Check Registration:
┌────┴────┬──────────┬───────────┐
│ │ │ │
v v v v
Created Registered Correct Rebuild
Object? to Tree? Namespace? Done?

Solutions:**

  1. Ensure config object created globally
  2. Check object registered to Config.AppData
  3. Verify namespace/path is correct
  4. Rebuild project completely

Debug Checklist

Configuration Debug Process
v
Enable Debug Output
v
Check Serial Console
v
Verify Network Settings
v
Test with Examples
v
Review System Logs
v
Check Flash Memory

Debug Steps:**

  1. Enable serial debug output with printf()
  2. Monitor boot messages on UART
  3. Verify network connectivity
  4. Test with provided examples first
  5. Check system logs for errors
  6. Verify flash memory health

Advanced Topics

Custom Configuration Objects

You can create custom configuration types by extending base classes:

// Custom enum configuration
class config_enum : public config_chooser
{
public:
enum MyEnum { OPTION_A, OPTION_B, OPTION_C };
config_enum(const char* name, MyEnum defaultVal, const char* desc)
: config_chooser(name, {"A", "B", "C"},
(int)defaultVal, desc) {}
MyEnum GetValue() const {
return (MyEnum)GetSelection();
}
};

Configuration Callbacks

Implement change notifications:

class config_int_notify : public config_int
{
public:
using NotifyCallback = void (*)(int oldVal, int newVal);
config_int_notify(const char* name, int defaultVal,
const char* desc, NotifyCallback cb)
: config_int(name, defaultVal, desc), callback(cb) {}
bool SetValue(int val) override {
int oldVal = GetValue();
if (config_int::SetValue(val)) {
if (callback) callback(oldVal, val);
return true;
}
return false;
}
private:
NotifyCallback callback;
};
// Usage
void onSpeedChanged(int oldVal, int newVal) {
printf("Speed changed from %d to %d\n", oldVal, newVal);
UpdateMotorSpeed(newVal);
}
config_int_notify motorSpeed("Speed", 1000, "Motor speed",
onSpeedChanged);

Configuration Persistence

Configuration Save Process
v
Collect All Config Data
v
Convert to JSON
v
Calculate Checksum
v
Write to Flash
v
Verify Write
┌────────┴────────┐
│ │
v v
Success Failure
│ │
v v
Return true Return false
v
Retry Logic

API Quick Reference

Core Configuration Functions

// Initialize configuration system
void InitConfigSystem();
// Save configuration to flash
// Load configuration from flash
bool LoadConfigFromStorage();
// Reset to factory defaults
void ResetConfigToDefaults();
// Get configuration as JSON
std::string GetConfigJSON();
// Set configuration from JSON
bool SetConfigJSON(const char* json);

Configuration Object Types

// String configuration
config_string myString("name", "default", "description");
// Integer configuration
config_int myInt("name", 0, "description");
// Boolean configuration
config_bool myBool("name", false, "description");
// Chooser/dropdown configuration
config_chooser myChoice("name", {"opt1", "opt2"}, 0, "description");

Accessing Values

// Reading
const char* str = myString.c_str();
int value = myInt;
bool flag = myBool;
int selection = myChoice.GetSelection();
// Writing
myString = "new value";
myInt = 42;
myBool = true;
myChoice.SetSelection(1);
// Save to flash

Summary

The NetBurner Configuration System provides a powerful, flexible solution for managing device settings:

Key Features Recap

Configuration System Capabilities
┌───────────────────┼───────────────────┐
│ │ │
v v v
Multi-Interface Hierarchical Persistent
Access Structure Storage
│ │ │
v v v
Web, Serial, Tree-Based Flash
Application JSON Memory

Access Methods Summary

Interface Port/Method Use Case
Web UI Port 20034 User-friendly configuration
Serial Config Boot UART Command-line access
Application API Direct code Programmatic control
Custom Web Your design Branded interface

Configuration Hierarchy

Config (Root)
├── Version (auto-updated)
├── Reboot (force reboot flag)
├── AppData (your application data)
│ ├── Custom variables
│ ├── Settings
│ └── Parameters
└── Sys (system settings)
├── Boot (boot configuration)
│ ├── Abort key
│ ├── Serial config
│ └── Security
└── NetIf (network interfaces)
├── Ethernet0
│ ├── IPv4
│ └── IPv6
└── [Other interfaces]

Best Practices Checklist

  • Organize application data in Config.AppData
  • Use descriptive variable names with units
  • Set User and Password for production
  • Validate all user input
  • Cache frequently accessed values
  • Provide helpful descriptions
  • Test with provided examples
  • Implement error handling
  • Document custom configurations
  • Use version control for config schemas

Getting Started

  1. Learn the Basics
    • Review BasicConfigVariable example
    • Understand config object types
    • Practice reading/writing values
  2. Web Integration
    • Study BasicWebConfig example
    • Create simple web interface
    • Test configuration updates
  3. Advanced Features
    • Explore CustomWebConfig for UI
    • Implement validation with CustomRangeLimit
    • Create custom config objects
  4. Production Deployment
    • Set security credentials
    • Disable unnecessary interfaces
    • Implement change logging
    • Test recovery procedures

The NetBurner Configuration System simplifies device management while providing the flexibility needed for complex embedded applications.