NetBurner Remote Web Console Example
Overview
This example demonstrates the Remote Web Console feature for NetBurner devices. The Remote Web Console creates a web-based interface that redirects the device's stdout output (normally sent to the USB serial port or DB9) to a webpage accessible at http://your-device-ip/console.html. For example, a printf("Hello Wolrd"); in the application will appear in the web page console window just as it would a serial port terminal.
The Remote Console can be added to any application with:
This feature is particularly useful for:
- Remote debugging and monitoring
- Accessing device output without physical USB connection
- Web-based device interaction and command input
- Development and troubleshooting in network environments
Features
- Web-based Console: Access device output through any web browser
- Real-time Output: Stdout redirected to web interface
- Interactive Commands: Simple command processing demonstration
- Network Accessibility: Remote access via device IP address
Files Description
main.cpp
The main application file containing:
- Network stack initialization
- HTTP server startup
- Remote console enablement
- Simple command processing loop
- Periodic status output
ReadMe.txt
Documentation file explaining the Remote Web Console implementation and usage.
Implementation Details
Key Components
- Network Initialization
#define TICKS_PER_SECOND
System clock ticks per second.
Definition constants.h:49
void StartHttp(uint16_t port, bool RunConfigMirror)
Start the HTTP web server. Further documentation in the Initialization section Initialization - Syste...
void init()
System initialization. Ideally called at the beginning of all applications, since the easiest Recover...
bool WaitForActiveNetwork(uint32_t ticks_to_wait=120 *TICKS_PER_SECOND, int interface=-1)
Wait for an active network connection on at least one interface.
- Remote Console Setup
#include <remoteconsole.h>
void EnableRemoteConsole()
Enables the remote webconsole feature.
- Command Processing
- Listens for character input
- Responds to 'h' command with "Hello!"
- Provides feedback for unknown commands
- Outputs periodic status dots
Required Headers
Usage Instructions
Building and Deploying
- Compile the Application
- Use NetBurner development tools to build the project
- Ensure all required libraries are linked
- Deploy to Device
- Flash the compiled binary to your NetBurner device
- Connect the device to your network
- Network Configuration
- Ensure the device obtains an IP address
- Note the device's IP address for web access
Accessing the Web Console
- Open Web Browser
- Navigate to
http://[device-ip]/console.html
- Replace
[device-ip] with your device's actual IP address
- Interact with Console
- View real-time output from the device
- Send commands through the web interface
- Monitor periodic status updates (dots every second)
Available Commands
- **'h'**: Displays "Hello!" message
- Other characters: Shows "Unknown command" message
- Periodic Output: Status dots appear every second
Technical Notes
System Diagnostics
void EnableSystemDiagnostics()
Turn on the diagnostic reports from the config page.
- Enabled for development and debugging
- Consider disabling for production deployments
Timing and Delays
- Main loop executes every second
- Provides regular status updates
- Prevents excessive CPU usage
Network Dependencies
- Requires active network connection
- HTTP server must be running
- Device must be accessible via IP address
Customization Options
Extending Commands
Add more command processing in the main loop:
if (c == 'h')
{
printf("\r\nHello!\r\n");
}
else if (c == 's')
{
printf("\r\nStatus: Running\r\n");
}
Modifying Output Frequency
Change the delay value to adjust status update frequency:
Adding Application Logic
Insert your application-specific code within the main loop while preserving the console functionality.
Troubleshooting
Common Issues
- Cannot Access Web Console
- Verify device IP address
- Check network connectivity
- Ensure HTTP server is running
- Confirm firewall settings
- No Output Visible
- Check if RemoteConsole is enabled
- Verify printf statements are executing
- Ensure web page is properly loaded
- Commands Not Responding
- Verify character input handling
- Check if charavail() is functioning
- Ensure main loop is executing
Debug Steps
- Monitor USB serial output during development
- Use network tools to verify device connectivity
- Check HTTP server status and logs
- Verify application is running and not stuck