The HTTP2 web server module and its associated MPFS2 file system module allow the board to act as a web server. This facilitates an easy method to view status information and control applications using any standard web browser.
Three main components are necessary to understand how the HTTP2 web server works: the web pages, the MPFS2 Utility, and the source files CustomHTTPApp.c and HTTPPrint.h. An overview of the entire process is shown below.
Web Pages
This includes all the HTML and associated images, CSS stylesheets, and JavaScript files necessary to display the website. A sample application including all these components is located in the WebPages2 folder.
MPFS2 Utility
This program, supplied by Microchip, packages the web pages into a format that can be efficiently stored in either external non-volatile storage, or internal flash program memory. This program also indexes dynamic variables found in the web pages and updates HTTPPrint.h with these indices.
If external storage is being used, the MPFS2 Utility outputs a BIN file and can upload that file directly to the board. If the data is being stored in Flash program memory, the MPFS2 Utility will generate a C source file image to be included in the project.
When dynamic variables are added or removed from your application, the MPFS2 Utility will update HTTPPrint.h. When this happens, the project must be recompiled in the MPLAB IDE to ensure that all the new variable indices get added into the application.
CustomHTTPApp.c
This file implements the web application. It describes the output for dynamic variables (via HTTPPrint_varname callbacks), parses data submitted through forms (in HTTPExecuteGet and HTTPExecutePost) and validates authorization credentials (in HTTPAuthenticate). The exact functionality of these callbacks is described within the demo application's web pages, and is also documented within the CustomHTTPApp.c example that is distributed with the stack.
HTTPPrint.h
This file is generated automatically by the MPFS2 Utility. It indexes all the dynamic variables and provides the "glue" between the variables located in the web pages and their associated HTTPPrint_varname callback functions defined in CustomHTTPApp.c. This file does not require modification by the programmer.
Name |
Description |
Features available in the HTTP2 module | |
Functions and variables accessible or implemented by the stack application | |
Functions and variables intended to be accessed only by the stack | |
Functions and variables used internally by the HTTP2 module |