EmbAJAX
Simplistic framework for creating and handling displays and controls on a web page served by an embeddable device (Arduino or other microcontroller with Arduino support).
|
The main interface class. More...
#include <EmbAJAX.h>
Public Member Functions | |
EmbAJAXPage (EmbAJAXBase *children[NUM], const char *title, const char *header_add=0, uint16_t min_interval=100) | |
void | printPage () override |
void | print () const override |
void | handleRequest (void(*change_callback)()=0) override |
bool | hasActiveClient (uint64_t latency_ms=5000) const |
Public Member Functions inherited from EmbAJAXContainer< NUM > | |
EmbAJAXContainer (EmbAJAXBase *children[NUM]) | |
bool | sendUpdates (uint16_t since, bool first) override |
EmbAJAXElement * | findChild (const char *id) const override final |
Public Member Functions inherited from EmbAJAXBase | |
virtual EmbAJAXElement * | toElement () |
void | setVisible (bool visible) |
void | setEnabled (bool enabled) |
Protected Attributes | |
const char * | _title |
const char * | _header_add |
uint16_t | _min_interval |
uint64_t | _latest_ping |
Protected Attributes inherited from EmbAJAXContainer< NUM > | |
EmbAJAXBase ** | _children |
Additional Inherited Members | |
Public Types inherited from EmbAJAXBase | |
enum | Property { Visibility , Enabledness , Value , FirstElementSpecificProperty , HTMLAllowed } |
Static Public Member Functions inherited from EmbAJAXBase | |
static void | setDriver (EmbAJAXOutputDriverBase *driver) |
Protected Member Functions inherited from EmbAJAXContainer< NUM > | |
void | setBasicProperty (uint8_t num, bool status) override |
Protected Member Functions inherited from EmbAJAXBase | |
void | printChildren (EmbAJAXBase **children, size_t num) const |
bool | sendUpdates (EmbAJAXBase **children, size_t num, uint16_t since, bool first) |
EmbAJAXElement * | findChild (EmbAJAXBase **children, size_t num, const char *id) const |
void | printPage (EmbAJAXBase **children, size_t num, const char *_title, const char *_header, uint16_t _min_interval) const |
void | handleRequest (EmbAJAXBase **children, size_t num, void(*change_callback)()) |
Static Protected Attributes inherited from EmbAJAXBase | |
static EmbAJAXOutputDriverBase * | _driver |
static char | itoa_buf [8] |
constexpr static const char | null_string [1] |
The main interface class.
This is the main interface class. Create a web-page with a list of elements on it, and arrange for print() (for page loads) adn handleRequest() (for AJAX calls) to be called on requests. By default, both page loads, and AJAX are handled on the same URL, but the first via GET, and the second via POST.
|
inline |
Create a web page.
children | list of elements on the page |
title | title (may be 0). This string is not copied, please do not use a temporary string. |
header_add | literal text (may be 0) to be added to the header, e.g. CSS (linked or in-line). This string is not copied, please do not use a temporary string). |
min_interval | minimum interval (ms) between two requests sent by a single client. A lower value may reduce latency at the cost of traffic/CPU. |
|
inlineoverridevirtual |
Handle AJAX client request. You should arrange for this function to be called, whenever there is a POST request to whichever URL you served the page itself, from.
change_callback | If some value has changed in the client, this function will be called. While it is optional to specify this, if there are any changes that may need to be sent back to the client in response to the change, you should specify this function, and handle the change inside it. This way, an update can be sent back to the client, immediately, for a smooth UI experience. (Otherwise the client will be updated on the next poll). |
Implements EmbAJAXPageBase.
|
inline |
Returns true if a client seems to be connected (connected clients should send a ping at least once per second; by default this function returns whether a ping has been seen within the last 5000 ms.
latency_ms | Number of milliseconds to consider as maximum silence period for an active connection |
|
inlineoverridevirtual |
Serve the page including headers and all child elements. You should arrange for this function to be called, whenever there is a GET request to the desired URL.
Reimplemented from EmbAJAXContainer< NUM >.
|
inlineoverridevirtual |
Duplication of print(), needed for internal reasons. Use print(), instead!
Implements EmbAJAXPageBase.