NetBurner 3.5.6
PDF Version
Flash Form

FlashForm Example Application

Overview

The FlashForm example is a NetBurner embedded web application that demonstrates three key capabilities:

  1. Dynamic HTML - Server-side function calls embedded in HTML
  2. HTML Form Processing - Handling POST requests from web forms
  3. User Flash Parameter Storage - Persistent data storage in flash memory

Application Structure

Core Files

  • main.cpp - Main application entry point and network initialization
  • formcode.cpp - Web server functionality and form processing logic
  • index.html - Web interface with dynamic content and form
  • ReadMe.txt - Original project documentation

Main Application (main.cpp)

The main application initializes the NetBurner network stack and starts the web server:

  • Initializes the network stack
  • Enables system diagnostics
  • Starts HTTP server on default port 80
  • Waits for DHCP network configuration
  • Displays application information and NNDK revision
  • Enters main loop with 1-second delays

Features

Dynamic HTML Content

The application uses special HTML comments to embed server-side function calls:

<!--FUNCTIONCALL DoMessageName -->
<!--FUNCTIONCALL DoMessageBody -->

These tags are replaced with dynamic content when the page is served:

  • DoMessageName() - Displays the stored user name
  • DoMessageBody() - Displays the stored message

Form Processing

The web interface includes a form that allows users to:

  • Enter their name (up to 40 characters)
  • Enter a message (up to 128 characters)
  • Submit the form to store the data in flash memory

Form data is processed by the PostCallBack() function which handles:

  • eStartingPost - Initialize temporary storage
  • eVariable - Process each form field (name and comment)
  • eEndOfPost - Save data to flash and redirect to index page

Flash Storage

User data is stored persistently in flash memory using a structured approach:

struct MyOwnDataStore
{
uint32_t verify_key; // Verification key (0x48666050)
char name[40]; // User name
char msg[128]; // User message
};

The application uses NetBurner's user parameter storage functions:

Security Features

  • Data Validation - Uses a verification key to ensure data integrity
  • HTML Escaping - Uses writesafestring() to prevent HTML injection
  • Buffer Protection - Uses strncpy() with size limits to prevent buffer overflows

Usage

  1. Setup: Deploy the application to a NetBurner device
  2. Access: Open a web browser and navigate to the device's IP address
  3. View: See any previously stored name and message
  4. Update: Use the form to enter a new name and message
  5. Save: Click "Save New Message" to store the data in flash

Technical Details

Network Configuration

  • Uses DHCP for automatic IP configuration
  • HTTP server runs on port 80
  • Waits up to 5 seconds for network activation

Memory Management

  • Static storage for form processing to maintain state across callbacks
  • Flash storage persists data across power cycles
  • Verification key ensures data integrity

Error Handling

  • Displays "?" for invalid/missing name data
  • Displays "No Message Stored" for invalid/missing message data
  • Reports success/failure of flash programming operations

Development Notes

  • Functions exposed to HTML must be declared as extern "C" to prevent C++ name mangling
  • The PostCallBack function uses static variables to maintain state across multiple calls
  • As of NetBurner 3.x release, the configuration server/storage system is recommended for new applications

Dependencies