Dynamic Variables
One of the most basic needs is to provide status information back to the user of your web application. The HTTP server provides for this using dynamic variable substitution callbacks. These commands in your HTML code will alert the server to execute a callback function at that point.
To insert a dynamic variable, place the name of the variable inside of the tilde
(~~
) character, like this: ~~myVariable~~
. When that
sequence is found, the server will call the function TCPIP_HTTP_Print_myVariable()
.
For example, here's the build date of the HEX file programmed in your part:
You can also pass parameters to dynamic variables by placing numeric values inside
of parenthesis after the variable name. ~~led(2)~~
will print the value
of the second LED. The numeric values are passed as uint16_t values to your callback function.
You can pass as many parameters as you wish to these functions, and if your C code has
constants defined, those will be parsed as well.
Exercise: Try to add the last (LSB) LED to the output above.
For short outputs (less than 16 bytes) you need only to call the appropriate
TCPIP_TCP_Put
function and return. For longer outputs the output state must be
managed through successive calls, which prevents the limited buffer space from being
overrun.