NetBurner 3.5.7
PDF Version
Custom Range Limit Config Variables

Custom Range Limit Configuration Demo

A NetBurner embedded application demonstrating advanced configuration system capabilities with custom validation objects and range-limited configuration variables.

Overview

This application showcases the NetBurner Config system by implementing custom configuration object classes that extend the base config_obj functionality. The demo specifically focuses on creating configuration variables with custom validation logic, including a novel color brightness validator.

Key Features

Built-in Configuration Objects

The application demonstrates several built-in NetBurner configuration object types:

Custom Configuration Object: Color Brightness Validator

The centerpiece of this demo is the config_color_brightlimit class, which validates HTML color strings based on perceived brightness:

  • Accepts hex color strings in format #rrggbb (e.g., #00ccff)
  • Calculates perceived brightness using ITU-R Recommendation BT.601 coefficients
  • Enforces minimum and maximum brightness thresholds
  • Provides meaningful error messages for invalid inputs

Brightness Calculation

The luminance calculation uses the ITU standard coefficients:

Luminance = (0.2582 * R + 0.66 * G + 0.0818 * B) * 100 / 255

Configuration Variables

The application defines several global configuration variables:

Variable Type Default Range/Limit Description
gSingleString config_string_limit "SNameLimit" 1-10 chars String length demo
gMyOwnVal config_int_limit 199 -200 to 200 Integer range demo
gMyOwnuVal config_uint_limit 299 0 to 300 Unsigned int range demo
gMyOwndVal config_double_limit 9.0 -10.0 to 10.0 Double precision demo
gMyOwnpVal config_pass_limit "" 5-128 chars Password field demo
gMyDarkColor config_color_brightlimit "#331122" 0-50% brightness Dark color validator
gMyLightColor config_color_brightlimit "#cceeff" 50-100% brightness Light color validator

Interactive Commands

The application provides a serial console interface with the following commands:

  • C - Show Config Tree: Display the complete configuration hierarchy
  • S - Show and Set gSingleString: Modify the string limit example
  • V - Show and Set gMyOwnVal: Modify the integer limit example
  • U - Show and Set gMyOwnuVal: Modify the unsigned integer limit example
  • N - New/Create dynamic variable: Create a new config variable at runtime
  • D - Delete dynamic variable: Remove the dynamically created variable
  • Q - Query dynamic variable: Display the value of the dynamic variable
  • ? - Show Command List: Display available commands

Technical Implementation

Custom Validation Logic

The config_color_brightlimit class demonstrates several advanced concepts:

  1. Server-side Validation: The TestNewValue() method provides robust server-side validation with custom error messages
  2. Client-side Schema: The ExtendedSchema() method adds HTML pattern validation for web-based configuration
  3. Operator Overloading: Multiple assignment operators handle different input types while maintaining validation
  4. Error Reporting: Uses LogParseError() to provide user-friendly error messages

Dynamic Configuration Management

The application shows how to:

  • Create configuration objects dynamically at runtime
  • Properly manage memory for dynamic config objects
  • Use FixNonStaticObject() for runtime-created config variables

Web Interface Integration

The configuration system automatically generates a web-based configuration interface at the device's IP address. The custom validation rules are enforced both in the web UI (client-side) and on the device (server-side).

Network Information

Upon startup, the application displays:

  • Device IP address
  • AutoIP address
  • Gateway address
  • Configuration space usage statistics

Building and Running

This application is designed for NetBurner embedded systems. Ensure you have:

  • NetBurner development environment installed
  • Compatible NetBurner hardware platform
  • Network connectivity for web-based configuration access

Configuration Storage

All configuration changes are automatically persisted to non-volatile storage using the NetBurner configuration system. Changes survive device reboots and power cycles.

Use Cases

This demo is particularly useful for:

  • Learning NetBurner configuration system concepts
  • Implementing custom validation logic for configuration parameters
  • Creating domain-specific configuration objects
  • Understanding client-server validation patterns
  • Building robust embedded configuration systems

Error Handling

The application includes comprehensive error handling for:

  • Invalid color format strings
  • Out-of-range brightness values
  • Network connectivity issues
  • Memory management for dynamic objects

Extension Points

The framework demonstrated here can be extended to create custom validators for:

  • IP address ranges
  • Time/date validation
  • File path validation
  • Custom protocol parameters
  • Hardware-specific constraints