|
NetBurner 3.5.8
PDF Version |
Example Path: examples/Web/FlashForm
The FlashForm example is a NetBurner embedded web application that demonstrates three key capabilities:
main.cpp - Main application entry point and network initializationformcode.cpp - Web server functionality and form processing logicindex.html - Web interface with dynamic content and formReadMe.txt - Original project documentationmain.cpp)The main application initializes the NetBurner network stack and starts the web server:
The application uses special HTML comments to embed server-side function calls:
These tags are replaced with dynamic content when the page is served:
DoMessageName() - Displays the stored user nameDoMessageBody() - Displays the stored messageThe web interface includes a form that allows users to:
Form data is processed by the PostCallBack() function which handles:
eStartingPost - Initialize temporary storageeVariable - Process each form field (name and comment)eEndOfPost - Save data to flash and redirect to index pageUser data is stored persistently in flash memory using a structured approach:
The application uses NetBurner's user parameter storage functions:
GetUserParameters() - Read stored data (read-only)SaveUserParameters() - Write data to flash memoryThis example stores its data in the user-parameter flash area. NetBurner also provides a higher-level configuration system (demonstrated by the HTML Post Date/Time example). Both persist to flash, but they solve different problems:
| Aspect | User-Parameter Flash | Configuration System |
|---|---|---|
| Layout | Raw binary blob - your own C struct | Structured key/value tree (Config/...) |
| API | SaveUserParameters() / GetUserParameters() | Config objects (config_int, NV<>, ...) plus CONFIGTABLE / CONFIGVALUE HTML tags |
| Schema | None - you own the layout and versioning | Typed, named, and self-describing |
| Web editing | Not exposed (app-private bytes) | Browsable / editable on the configuration server (port 20034) |
| Serialization | Fixed bytes you read and write yourself | Automatic JSON serialization |
| Best for | A small, fixed set of private app data | Structured, discoverable, user-editable settings |
When to use which:**
CONFIGTABLE / CONFIGVALUE tags in your own pages). As of the NetBurner 3.x release, it is the recommended choice for new applications.writesafestring() to prevent HTML injectionstrncpy() with size limits to prevent buffer overflowsextern "C" to prevent C++ name manglingPostCallBack function uses static variables to maintain state across multiple callshttp.h, iosys.h, system.h, httppost.h