Config Notify Application
Overview
This application demonstrates how to use configuration objects with change notification callbacks in an embedded system. The program creates basic configuration variables and registers callbacks to be notified when these variables change.
Features
- Configuration Management: Creates and manages different types of configuration variables (string, integer, unsigned integer)
- Change Notifications: Implements callback notifications when configuration values are modified
- Interactive Menu System: Provides a command-line interface for viewing and modifying configuration values
- Dynamic Configuration: Supports creating and deleting configuration variables at runtime
- Network Integration: Displays network interface information on startup
Configuration Variables
The application creates three main configuration objects:
- gSingleString - A string configuration variable with default value "SName"
- gMyOwnVal - An integer configuration variable with default value 199
- gMyOwnuVal - An unsigned integer configuration variable with default value 299
Command Interface
The application provides an interactive menu system with the following commands:
- C - Show Config Tree: Displays the complete configuration tree
- S - Show and Set gSingleString: View and modify the string configuration
- V - Show and Set gMyOwnVal: View and modify the integer configuration
- U - Show and Set gMyOwnuVal: View and modify the unsigned integer configuration
- N - New/Create dynamic variable: Creates a new dynamic configuration variable
- D - Delete dynamic variable: Removes the dynamic configuration variable
- Q - Query dynamic variable: Displays the value of the dynamic variable
- ? - Show Command List: Displays all available commands
Notification System
The application implements a notification callback system that:
- Uses a semaphore-based notification mechanism
- Registers callbacks for all configuration variables
- Provides real-time notification when any monitored configuration value changes
- Displays a message when a configuration change is detected
Technical Implementation
Key Components
- Configuration Objects: Uses
config_string, config_int, and config_uint types
- Callback System: Implements
ConfigNotificationCallBack for change notifications
- Semaphore Synchronization: Uses
OS_SEM for thread-safe notification handling
- Storage Management: Automatically saves configuration changes to persistent storage
Memory Management
- Static configuration objects are created at global scope
- Dynamic configuration objects can be created and destroyed at runtime
- Non-static objects require calling
FixNonStaticObject() method
Network Information
On startup, the application displays:
- IP address of the first network interface
- AutoIP address
- Gateway address
- Configuration space usage statistics
Usage
- Startup: The application initializes network interfaces and displays system information
- Command Entry: Enter single character commands to interact with the configuration system
- Value Modification: Follow prompts to enter new values for configuration variables
- Notification Monitoring: The system automatically notifies when values change
Build Information
The application displays build timestamp information on startup, showing when the code was compiled.
Example Workflow
- Start application and view initial configuration
- Use 'C' command to see the complete config tree
- Use 'S', 'V', or 'U' commands to modify configuration values
- Observe notification messages when values change
- Use 'N' to create dynamic variables and 'D' to delete them
- Use 'Q' to query dynamic variable values