Windows Virtual Shields for Arduino
Public Member Functions | Public Attributes | List of all members
Web Class Reference

#include <Web.h>

Inherits Sensor.

Public Member Functions

 Web (const VirtualShield &shield)
 Initializes a new instance of the Web class. More...
 
int get (String url, String parsingInstructions=(const char *) 0, int maxLength=0)
 Performs a web Get, optionally returning a result. More...
 
int post (String url, String data, String parsingInstructions=(const char *) 0, int maxLength=0)
 Performs a web Post, optionally returning a result. More...
 
int get (EPtr url, EPtr parsingInstructions, int maxLength=0)
 Performs a web Get, optionally returning a result. More...
 
int post (EPtr url, EPtr data, EPtr parsingInstructions, int maxLength=0)
 Performs a web Post, optionally returning a result. More...
 
void getResponse (char *responseBuffer, int length, char **parts=0, int partCount=0)
 Copies the current web response (only valid before another web event) into a supplied buffer. More...
 
void onJsonReceived (ArduinoJson::JsonObject &root, ShieldEvent *shieldEvent) override
 Event called when a valid json message was received. Consumes the proper values for this sensor. More...
 
- Public Member Functions inherited from Sensor
 Sensor (const VirtualShield &shield, const char sensorType)
 Initializes a new instance of the Sensor class. More...
 
int start (double delta=0, long interval=0)
 Starts the sensor, triggered when longer than the interval and larger than the delta. More...
 
virtual int stop ()
 Stops this sensor. More...
 
int get ()
 Gets a single, current sensor reading. More...
 
int getOnChange (double delta=0)
 Requests a single reading when more than the delta beyond the current reading. More...
 
bool isUpdated ()
 Determines whether this sensor has an updated value. Resets to false after this call. More...
 
int writeAll (const char *serviceName, EPtr values[], int count, Attr extraAttributes[]=0, int extraAttributeCount=0)
 Writes all EPtr values to the communication channel. More...
 
int sensorAction (SensorAction sensorAction, double delta=0, long interval=0) const
 Sends the specific action to start/stop/get/onChange the sensor using a delta and interval. More...
 
virtual bool isEvent (const char *tag, const char *action, ShieldEvent *shieldEvent)
 Determines whether the specified shieldEvent matches the tag and action. More...
 
virtual bool isEvent (int id, const char *action, ShieldEvent *shieldEvent)
 Determines whether the specified shieldEvent matches the id and action. More...
 
void setOnEvent (void(*onEvent)(ShieldEvent *shieldEvent))
 
int sendStop (const char *serviceName)
 
virtual void onJsonReceived (JsonObject &root, ShieldEvent *shieldEvent)
 Event called when a valid json message was received. Consumes the proper values for this sensor. More...
 

Public Attributes

int resultId
 
- Public Attributes inherited from Sensor
void(* onEvent )(ShieldEvent *shieldEvent)
 
VirtualShieldshield
 
ShieldEvent recentEvent
 
const char sensorType
 
bool isRunning = false
 

Additional Inherited Members

- Protected Attributes inherited from Sensor
bool _isUpdated = false
 

Constructor & Destructor Documentation

Web::Web ( const VirtualShield shield)

Initializes a new instance of the Web class.

Parameters
shieldThe shield.

Member Function Documentation

int Web::get ( String  url,
String  parsingInstructions = (const char*) 0,
int  maxLength = 0 
)

Performs a web Get, optionally returning a result.

Parameters
urlThe url.
parsingInstructionsThe parsing instructions.
maxLengthThe maximum length of the result.
Returns
The id of the message. Negative if an error.
int Web::get ( EPtr  url,
EPtr  parsingInstructions,
int  maxLength = 0 
)

Performs a web Get, optionally returning a result.

Parameters
urlThe url.
parsingInstructionsThe parsing instructions.
maxLengthThe maximum length of the result.
Returns
The id of the message. Negative if an error.
void Web::getResponse ( char *  responseBuffer,
int  length,
char **  parts = 0,
int  partCount = 0 
)

Copies the current web response (only valid before another web event) into a supplied buffer.

Parameters
responseBufferThe buffer to place the response.
lengthThe maximum length of the buffer.
partsArray of character pointers to populate after parsing.
partCountThe part count.
void Web::onJsonReceived ( ArduinoJson::JsonObject &  root,
ShieldEvent shieldEvent 
)
override

Event called when a valid json message was received. Consumes the proper values for this sensor.

Parameters
rootThe root json object.
shieldEventThe shield event.
int Web::post ( String  url,
String  data,
String  parsingInstructions = (const char*) 0,
int  maxLength = 0 
)

Performs a web Post, optionally returning a result.

Parameters
urlThe url.
dataThe data.
parsingInstructionsThe parsing instructions.
maxLengthThe maximum length of the result.
Returns
The id of the message. Negative if an error.
int Web::post ( EPtr  url,
EPtr  data,
EPtr  parsingInstructions,
int  maxLength = 0 
)

Performs a web Post, optionally returning a result.

Parameters
urlThe url.
dataThe data.
parsingInstructionsThe parsing instructions.
maxLengthThe maximum length of the result.
Returns
The id of the message. Negative if an error.

Member Data Documentation

int Web::resultId

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