LOGGER  Logger
Data Logging using ESP8266
Functions | Variables
webservices.h File Reference
#include "basetype.h"

Go to the source code of this file.

Functions

void webServicesInit ()
 Initialize the web services.
 
void webServicesLoop ()
 Perform periodic tasks managing web services.
 
void webXMLstartFile ()
 Start a XML file output.
 
void webXMLendFile ()
 End an XML file output.
 
void webStartPage (const char *pName="")
 
void webEndPage ()
 
void servicePageArguments ()
 
EXTERNDEF void emitButton (Print *pPrint, const char *pTitle, const char *pValue, bool highlight=false, bool enabled=true)
 
void emitButtonTD (Print *pPrint, const char *pTitle, const char *pValue, bool highlight=false, bool enabled=true)
 
void emitNumberInput (Print *pPrint, String prefix, String name, int32_t defaultValue, int digits, int minAllowed, int maxAllowed)
 
void emitGenericSelector (Print *pPrint, String prefix, const char *pName, String selectedName, const char *const pNames[], bool isEnabled=true)
 
void emitMonthSelector (Print *pPrint, String prefix, const char *pName, uint8_t month)
 
String getDefaultedArgument (String name, String defaultValue="")
 
bool webservicesDoesArgumentExist (const char *pName)
 
void webservicesSetPermanentVariableFromArguments ()
 
void versionPage ()
 Report version information.
 

Variables

Print * pWebPrint
 < version of this include file More...
 

Detailed Description

Web page Service Routines

Function Documentation

EXTERNDEF void emitButton ( Print *  pPrint,
const char *  pTitle,
const char *  pValue,
bool  highlight = false,
bool  enabled = true 
)

Emit the control for a button. When pressed a post is done with the name 'ButtonPress' and value of pName to indicate which button was pressed. The button is placed in its own table to help with formatting on the page.

Parameters
pPrintwhere to send the output
pTitlepresented to the user in the button image
pValuevalue of the buttonPress argument showing what was pressed
highlighttrue to highlight the value
enabledtrue if button can be clicked
void emitButtonTD ( Print *  pPrint,
const char *  pTitle,
const char *  pValue,
bool  highlight = false,
bool  enabled = true 
)

Emit a button in a TD element

Parameters
pPrintwhere to send the output
pTitlepresented to the user in the button image
pValuevalue of the buttonPress argument showing what was pressed
highlighttrue to highlight the value
enabledtrue if button can be clicked
void emitGenericSelector ( Print *  pPrint,
String  prefix,
const char *  pName,
String  selectedName,
const char *const  pNames[],
bool  isEnabled = true 
)

Make a Generic chooser

Forms a select list with one line per option:

/// <select name=selectName>
/// <option VALUE="opt1">opt1
///     ...
/// </select>
/// 
@param      pPrint          where to send the output
@param      prefix          string to prefix the object name with
@param      pName           name of the object
@param      selectedName    which option is currently selected
@param      pNames          list of names with a NULL at the end
@param      isEnabled       true to allow selection  
void emitMonthSelector ( Print *  pPrint,
String  prefix,
const char *  pName,
uint8_t  month 
)

Make a Month chooser

Forms a select list with one line per month:

/// <select name=selectName>
/// <option VALUE="1">January
///     ...
/// </select>
/// 
@param      pPrint          where to send the output
@param      prefix          string to prefix the object name with
@param      pName           name of the object
@param      month           current selected month as an integer 1-12  
void emitNumberInput ( Print *  pPrint,
String  prefix,
String  name,
int32_t  defaultValue,
int  digits,
int  minAllowed,
int  maxAllowed 
)

Emit a field of a form that inputs a number. When the minimum and maximum allowed values are both 0 then any positive value is allowed. When both are -1 than any value is allowed. When the maximum is less than the minimum no maximum constraint is used.

Parameters
pPrintwhere to send the output
prefixprefix string for the field name
nameremainder of the field name
defaultValuevalue for the field
digitsnumber of digits expected
minAllowedminimum allowed value
maxAllowedmaximum allowed value
String getDefaultedArgument ( String  name,
String  defaultValue = "" 
)

Get a server argument with a default value if the argument is not passed.

Parameters
namename of the argument to read
defaultValuevalue to use if the argument is missing
Returns
value of the argument (defaultValue if not there)
void servicePageArguments ( )

Service arguments to the page. This will call application specific code with argument values read from the page arguments. It is expected that pages which handle arguments (i.e. button presses) will call this routine at the correct time in their display output to process the arguments and display the results of that processing.

void webEndPage ( )

End a web page. This emits the matching framework to a webStartPage().

bool webservicesDoesArgumentExist ( const char *  pName)

Test to see if an argument exists

Returns
true if the argument is present
void webservicesSetPermanentVariableFromArguments ( )

Check the arguments to the web page. If the permanentname and the permanentvalue argument are both present set the permanent variable to the new value. Security checking is the responsibility of the caller.

void webStartPage ( const char *  pName = "")

Start a web page. This emits a framework for the page and initiates a table that has a menu in the left column a header across the top and a footer at the bottom. This call ends by emitting a

for a cell for the page unique content is the content. The for this cell will be emitted in the webEndPage() call.

Parameters
pNamename of the page

Variable Documentation

Print* pWebPrint

< version of this include file

Global pointer to where to send output for the current web page