Connectino Library
Public Member Functions | Protected Attributes | List of all members
ConnectinoAjax Class Reference

AJAX module. More...

#include <ConnectinoAjax.h>

Inheritance diagram for ConnectinoAjax:
ConnectinoModule

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...
 

Detailed Description

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"]]}

Constructor & Destructor Documentation

◆ ConnectinoAjax()

ConnectinoAjax::ConnectinoAjax ( StxHwSerial &  refSerial)

AJAX module constructor.

Instantiates the AJAX module and connects it to the hardware serial.

Parameters
refSerialA reference to the hardware serial.

Member Function Documentation

◆ moduleCallback()

bool ConnectinoAjax::moduleCallback ( uint8_t  subId,
uint8_t  reqId,
uint16_t  dataSize,
uint8_t *  data 
)
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.

Parameters
subIdSub ID of the message.
reqIdRequest ID of the message.
dataSizeSize of the received data.
dataReference to the received data.
Return values
Returnswhether or not to block the current frame.

Implements ConnectinoModule.

◆ getModId()

uint8_t ConnectinoAjax::getModId ( )
virtual

Get the ID of the AJAX module.

This function will return the module ID of the AJAX module defined in MODULE.h.

Return values
Themodule ID.

Implements ConnectinoModule.

◆ dataAvailable()

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.

Return values
Numberof received parameters.

◆ isQuery()

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.

Return values
Trueif a query was received, false otherwise.

◆ getData()

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.

Parameters
payloadBufferReference to a buffer where the parameter is written to.
payloadBufferSizeSize of the written parameter.
Return values
Trueif parameter was successfully written, false otherwise.

Member Data Documentation

◆ StxSerial

StxHwSerial& ConnectinoAjax::StxSerial
protected

Reference to the hardware serial.

◆ newData

volatile uint8_t ConnectinoAjax::newData = 0
protected

Number of parameters in the last received message.

◆ dataOffset

volatile uint16_t ConnectinoAjax::dataOffset = 0
protected

Current read index in the payload of last received message.


The documentation for this class was generated from the following files: