Example Path: examples/Configuration/Application/AppData/BasicConfigVariable
BasicConfigVariable - Config Tree Demo
A NetBurner embedded systems application demonstrating the use of persistent configuration variables through an interactive serial interface.
Overview
This application showcases the NetBurner config system, which provides persistent storage for both system-defined boot parameters and user-defined variables. The config system maintains values across power cycles, making it ideal for storing device settings, calibration data, and application parameters.
Features
- Persistent Configuration Storage: Variables maintain their values after power cycling
- Interactive Serial Interface: Menu-driven system for viewing and modifying config values
- Dynamic Variable Management: Create and delete config variables at runtime
- Config Tree Visualization: View the complete configuration hierarchy
- Multiple Data Types: Support for strings, integers, and unsigned integers
Configuration Variable Types
The application demonstrates usage of several config object types:
Application Structure
Global Configuration Variables
The application defines three global configuration variables:
static config_string gSingleString{appdata,
"MyString",
"SName"};
Signed 32-bit Integer Configuration Variable.
Definition config_obj.h:703
String Configuration Variable.
Definition config_obj.h:1130
Unsigned 32-bit Integer Configuration Variable.
Definition config_obj.h:555
Each variable is initialized with:
- Parent container (appdata)
- Default value
- Unique identifier name
Serial Commands
The application provides an interactive menu system accessible via serial interface:
| Command | Description |
| C | Show Config Tree - Display complete configuration hierarchy |
| S | Show and Set gSingleString - View/modify string variable |
| V | Show and Set gMyOwnVal - View/modify signed integer variable |
| U | Show and Set gMyOwnuVal - View/modify unsigned integer variable |
| N | New/Create dynamic variable - Create new config variable at runtime |
| D | Delete dynamic variable - Remove dynamically created variable |
| Q | Query dynamic variable - Check if dynamic variable exists and show value |
| ? | Show Command List - Display available commands |
Build Requirements
Dependencies
- NetBurner SDK
- Standard C++ compiler with C++11 support
- NetBurner libraries:
Compilation
Compile using the NetBurner development environment with standard build tools. Ensure all NetBurner libraries are properly linked.
Usage
Initial Setup
- Flash the application to your NetBurner device
- Connect via serial interface (typically 115200 baud)
- Wait for network initialization (up to 5 seconds)
Startup Information
Upon boot, the application displays:
- Build timestamp
- Current IP address
- Auto-IP address
- Gateway address
- Config storage usage statistics
Interactive Operation
- View Configuration Tree: Use command C to see the complete hierarchy
- Modify Variables: Use commands S, V, or U to change values
- Dynamic Variables: Use N to create, D to delete, and Q to query runtime variables
- Help: Use ? to display the command menu
Example Session
Config Tree Demo built at 12:34:56 on Jan 15 2025
'?' for commands
IP: 192.168.1.100
AutoIP : 169.254.1.100
Gateway: 192.168.1.1
Config space used: 1024 of 8192 bytes (max)
Command List
------------
C) Show Config Tree
S) Show and Set gSingleString
V) Show and Set gMyOwnVal
U) Show and Set gMyOwnuVal
N) New/Create dynamic variable
D) Delete dynamic variable
Q) Query dynamic variable
?) Show Command List
Read char S
SName old value: MyString
Enter new value: Hello World
SName new value: Hello World
Key Features
Persistent Storage
All configuration changes are automatically saved to non-volatile storage using SaveConfigToStorage(). Values persist across power cycles and system resets.
Dynamic Variable Management
The application demonstrates creating config variables at runtime using the new operator and properly registering them with FixNonStaticObject().
Network Integration
The application initializes network interfaces and displays connection information, showing integration with NetBurner's networking stack.
System Diagnostics
Built-in system diagnostics are enabled for development and debugging purposes.
Important Notes
Variable Naming
- Each config variable must have a unique identifier name
- Duplicate names can cause issues within the config tree
- Use descriptive names for better organization
Memory Management
- Static config variables are automatically managed
- Dynamic variables require explicit cleanup using delete
- Call FixNonStaticObject() for dynamically created variables
Thread Safety
The application runs in a single-threaded context with periodic delays using OSTimeDly().
Troubleshooting
Common Issues
- Network Connection: Ensure proper network configuration if IP addresses show as 0.0.0.0
- Serial Interface: Verify baud rate and connection settings
- Config Storage: Monitor storage usage to avoid exceeding maximum capacity
- Variable Names: Ensure unique naming to prevent config tree conflicts
Development Tips