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()
that was registered dynamically
with the HTTP server.
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 either numeric values
or string of characters inside of parenthesis after the variable name.
~led(2)~
will print the value
of the second LED. The numeric values are passed as int32_t values to your callback function.
The string values are passed as pointers to string of characters.
As an example, here is a binary representation which LEDs are on and off on the board (in the current Harmony release, this part is only working on Explorer 16 board):
Exercise: Try to add the last (LSB) LED to the output above.
For data output you need only to call the
TCPIP_HTTP_NET_DynamicWrite
function and return.
Longer outputs may be done using successive calls, which prevents the limited buffer space from being
overrun.