Connectino Library
|
AJAX module. More...
#include <ConnectinoAjax.h>
Public Member Functions | |
ConnectinoAjax (StxHwSerial &refSerial) | |
AJAX module constructor. More... | |
bool | moduleCallback (uint8_t subId, uint8_t reqId, uint16_t dataSize, uint8_t *data) |
Callback function for serial frames of the AJAX module. More... | |
uint8_t | getModId () |
Get the ID of the AJAX module. More... | |
uint8_t | dataAvailable () |
Check for available data for the AJAX module. More... | |
bool | isQuery () |
Check if the received message is a query. More... | |
bool | getData (char *payloadBuffer, uint16_t &payloadBufferSize) |
Receive the parameters sent by the WiFi module. More... | |
Public Member Functions inherited from ConnectinoModule | |
void | begin () |
Starts the module. | |
Protected Attributes | |
StxHwSerial & | StxSerial |
volatile uint8_t | newData = 0 |
volatile uint16_t | dataOffset = 0 |
Additional Inherited Members | |
Protected Member Functions inherited from ConnectinoModule | |
bool | append (uint8_t **buffer, uint16_t *bufferSize, const char data[], const uint8_t numOfSizeBytes=1) |
Append a string to the frames payload. More... | |
bool | append (uint8_t **buffer, uint16_t *bufferSize, const uint8_t data[], const uint16_t dataSize, const uint8_t numOfSizeBytes=1) |
Append binary data to the frames payload. More... | |
bool | append (uint8_t **buffer, uint16_t *bufferSize, const bool data) |
Append a boolean to the frames payload. More... | |
bool | append (uint8_t **buffer, uint16_t *bufferSize, const uint8_t data) |
Append a uint8_t variable to the frames payload. More... | |
bool | append (uint8_t **buffer, uint16_t *bufferSize, const uint16_t data) |
Append a uint16_t variable to the frames payload. More... | |
bool | append (uint8_t **buffer, uint16_t *bufferSize, const uint32_t data) |
Append a uint32_t variable to the frames payload. More... | |
AJAX module.
The AJAX module will receive string parameters sent in a JSON structure to the WiFi module on the URI "http://connectino.local/ajax/cfgpars.json" as HTML POST data in the form: {"FileName":"cfgpars.json","CmdArr":[["send","binuart","param1","param2"]]}
ConnectinoAjax::ConnectinoAjax | ( | StxHwSerial & | refSerial | ) |
AJAX module constructor.
Instantiates the AJAX module and connects it to the hardware serial.
refSerial | A reference to the hardware serial. |
|
virtual |
Callback function for serial frames of the AJAX module.
This function will be called for messages sent by the WiFi module which are targeted at the AJAX module.
subId | Sub ID of the message. |
reqId | Request ID of the message. |
dataSize | Size of the received data. |
data | Reference to the received data. |
Returns | whether or not to block the current frame. |
Implements ConnectinoModule.
|
virtual |
Get the ID of the AJAX module.
This function will return the module ID of the AJAX module defined in MODULE.h.
The | module ID. |
Implements ConnectinoModule.
uint8_t ConnectinoAjax::dataAvailable | ( | ) |
Check for available data for the AJAX module.
When a valid message with one or more parameters was received, this function will return the number of received parameters.
Number | of received parameters. |
bool ConnectinoAjax::isQuery | ( | ) |
Check if the received message is a query.
When the module has received a query from the WiFi module the user should send a response back to the WiFi module.
True | if a query was received, false otherwise. |
bool ConnectinoAjax::getData | ( | char * | payloadBuffer, |
uint16_t & | payloadBufferSize | ||
) |
Receive the parameters sent by the WiFi module.
Writes the received parameter to a given buffer and also writes the string length of the parameter to the given size parameter. This function needs to be called multiple times when there was more than one parameter received.
payloadBuffer | Reference to a buffer where the parameter is written to. |
payloadBufferSize | Size of the written parameter. |
True | if parameter was successfully written, false otherwise. |
|
protected |
Reference to the hardware serial.
|
protected |
Number of parameters in the last received message.
|
protected |
Current read index in the payload of last received message.