Gbox 4.20
Grow box automation and monitoring - <a href='https://sites.google.com/site/growboxguy/'>https://sites.google.com/site/growboxguy/</a>
 
Loading...
Searching...
No Matches
URL_HANDLER Struct Reference

#include <ELClientWebServer.h>

Collaboration diagram for URL_HANDLER:

Data Fields

String URL
 the URL to handle
 
FP< void, char * > loadCb
 Callback for HTML page loading.
 
FP< void, char * > refreshCb
 Callback for HTML page refresh.
 
FP< void, char * > setFieldCb
 callback for setting a field from a HTML form
 
FP< void, char * > buttonCb
 callback for a HTML button press
 
struct URL_HANDLERnext
 next handler
 

Detailed Description

Web Server URL handler structure.

Definition at line 17 of file ELClientWebServer.h.

Field Documentation

◆ buttonCb

FP<void, char*> URL_HANDLER::buttonCb

callback for a HTML button press

buttonCb()

This callback is called when user presses a HTML button. After processing this callback, a page refresh will also be called to reflect the changes.

Parameters
button_idThe ID of the button
Example
void buttonCb(char * button_id)
{
String id = button_id;
if( id == F("my_button") )
{
Serial.println("My button was pressed");
}
}
ESP esp & Serial
Definition demo.ino:9
FP< void, char * > buttonCb
callback for a HTML button press

Definition at line 113 of file ELClientWebServer.h.

◆ loadCb

FP<void, char*> URL_HANDLER::loadCb

Callback for HTML page loading.

loadCb()

This callback is called when browser loads a custom page for the first time. The callback should populate all the fields that are required for displaying the page.

Parameters
urlThe URL of the page to load.
Example
void loadCb(char * url)
{
webServer.setArgString(F("field1"), F("value"));
webServer.setArgInt(F("field2"), 123);
webServer.setArgFloat(F("field3"), 12.3);
}
FP< void, char * > loadCb
Callback for HTML page loading.

Definition at line 38 of file ELClientWebServer.h.

◆ next

struct URL_HANDLER* URL_HANDLER::next

next handler

Definition at line 114 of file ELClientWebServer.h.

◆ refreshCb

FP<void, char*> URL_HANDLER::refreshCb

Callback for HTML page refresh.

refreshCb()

This callback is called when browser refreshes a page. The callback should populate all the fields that are required for displaying changes on the page.

Parameters
urlThe URL of the page to load.
Example
void refreshCb(char * url)
{
webServer.setArgString(F("field1"), F("changed_value"));
webServer.setArgInt(F("field2"), 543);
webServer.setArgFloat(F("field3"), 54.3);
}
FP< void, char * > refreshCb
Callback for HTML page refresh.

Definition at line 56 of file ELClientWebServer.h.

◆ setFieldCb

FP<void, char*> URL_HANDLER::setFieldCb

callback for setting a field from a HTML form

buttonCb()

This callback is called when a HTML form is submitted. The callback should save field changes. After processing the callback, a page refresh will also be initiated to reflect the changes.

The size of the receive buffer on ELClient is 128 bytes which can be small for receiving a large form. When the data exceeds 128 bytes, Esp-Link segments the query into smaller parts. If the callback is slow, it's possible that the UART buffer overruns while receiving the next packet causing data loss. The callback has 5ms to process the request if data comes at 115200 baud.

If debugging is enabled, data loss is very likely to happen because of packet logging.

Warning
Write this routine to be as fast as possible and turn off debugging for receiving large forms.
Parameters
field_idThe ID of the field
Example
int32_t value;
// this code should be fast
void setFieldCb(char * field_id)
{
String id = field_id;
if( id == F("my_field") )
{
value = webServer.getArgInt();
}
}
FP< void, char * > setFieldCb
callback for setting a field from a HTML form

Definition at line 92 of file ELClientWebServer.h.

◆ URL

String URL_HANDLER::URL

the URL to handle

Definition at line 20 of file ELClientWebServer.h.


The documentation for this struct was generated from the following file: