#include <ELClientRest.h>
Public Member Functions | |
| ELClientRest (ELClient *e) | |
| Constructor for ELClientRest. | |
| int | begin (const char *host, uint16_t port=80, boolean security=false) |
| Initialize communication to a REST server. | |
| void | request (const char *path, const char *method, const char *data=NULL) |
| Send request to REST server. | |
| void | request (const char *path, const char *method, const char *data, int len) |
| Send request to REST server. | |
| void | get (const char *path, const char *data=NULL) |
| Send GET request to REST server. | |
| void | post (const char *path, const char *data) |
| Send POST request to REST server. | |
| void | put (const char *path, const char *data) |
| Send PUT request to REST server. | |
| void | del (const char *path) |
| Send DELETE request to REST server. | |
| uint16_t | getResponse (char *data, uint16_t maxLen) |
| Retrieve response. | |
| uint16_t | waitResponse (char *data, uint16_t maxLen, uint32_t timeout=DEFAULT_REST_TIMEOUT) |
| Wait for the response. | |
| void | setUserAgent (const char *value) |
| Set user agent of header. | |
| void | setContentType (const char *value) |
| Set content type of header. | |
| void | setHeader (const char *value) |
| Set generic header content. | |
Definition at line 39 of file ELClientRest.h.
| ELClientRest::ELClientRest | ( | ELClient * | e | ) |
Constructor for ELClientRest.
| e | Pointer to ELClient structure |
Definition at line 26 of file ELClientRest.cpp.
| int ELClientRest::begin | ( | const char * | host, |
| uint16_t | port = 80, |
||
| boolean | security = false |
||
| ) |
Initialize communication to a REST server.
begin(const char* host, uint16_t port, boolean security)
Initialize communication to a remote server, this communicates with esp-link but does not open a connection to the remote server.
| host | Host to be connected. Can be a URL or an IP address in the format of xxx.xxx.xxx.xxx . |
| port | Port to be used to send/receive packets. Port MUST NOT be 80, 23 or 2323, as these ports are already used by EL-CLIENT on the ESP8266 |
| security | Flag if secure connection should be established |
Definition at line 78 of file ELClientRest.cpp.

| void ELClientRest::del | ( | const char * | path | ) |
Send DELETE request to REST server.
| path | Path that extends the URL of the REST request (command or data for the REST server) |
Definition at line 217 of file ELClientRest.cpp.

| void ELClientRest::get | ( | const char * | path, |
| const char * | data = NULL |
||
| ) |
Send GET request to REST server.
get(const char* path, const char* data)
| path | Path that extends the URL of the REST request (command or data for the REST server) |
| data | Pointer to data buffer |
Definition at line 159 of file ELClientRest.cpp.


| uint16_t ELClientRest::getResponse | ( | char * | data, |
| uint16_t | maxLen | ||
| ) |
Retrieve response.
getResponse(char* data, uint16_t maxLen)
Checks if a response from the remote server was received, returns the HTTP status code or 0 if no response (may need to wait longer)
| data | Pointer to buffer for received packet |
| maxLen | Size of buffer for received packet. If the received packet is larger than the buffer, the received packet will be truncated. |
uint16_t Size of received packet or number of sent bytes or 0 if no response Definition at line 321 of file ELClientRest.cpp.

| void ELClientRest::post | ( | const char * | path, |
| const char * | data | ||
| ) |
Send POST request to REST server.
post(const char* path, const char* data)
| path | Path that extends the URL of the REST request (command or data for the REST server) |
| data | Pointer to data buffer |
Definition at line 192 of file ELClientRest.cpp.

| void ELClientRest::put | ( | const char * | path, |
| const char * | data | ||
| ) |
Send PUT request to REST server.
put(const char* path, const char* data)
| path | Path that extends the URL of the REST request (command or data for the REST server) |
| data | Pointer to data buffer |
Definition at line 206 of file ELClientRest.cpp.

| void ELClientRest::request | ( | const char * | path, |
| const char * | method, | ||
| const char * | data, | ||
| int | len | ||
| ) |
Send request to REST server.
request(const char* path, const char* method, const char* data, int len)
| path | Path that extends the URL of the REST request (command or data for the REST server) |
| method | REST method, allowed values are "GET", "POST", "PUT" or "DELETE" |
| data | Pointer to data buffer |
| len | Size of data buffer |
Definition at line 112 of file ELClientRest.cpp.

| void ELClientRest::request | ( | const char * | path, |
| const char * | method, | ||
| const char * | data = NULL |
||
| ) |
Send request to REST server.
request(const char* path, const char* method, const char* data)
The data must be null-terminated.
| path | Path that extends the URL of the REST request (command or data for the REST server) |
| method | REST method, allowed values are "GET", "POST", "PUT" or "DELETE" |
| data | Pointer to data buffer |
Definition at line 141 of file ELClientRest.cpp.


| void ELClientRest::setContentType | ( | const char * | value | ) |
Set content type of header.
setContentType(const char* value)
If no content type is set, it defaults to "x-www-form-urlencoded"
| value | Content type |
Definition at line 248 of file ELClientRest.cpp.

| void ELClientRest::setHeader | ( | const char * | value | ) |
Set generic header content.
If no generic header is set, it defaults to an empty string
| value | Header content |
Definition at line 229 of file ELClientRest.cpp.

| void ELClientRest::setUserAgent | ( | const char * | value | ) |
Set user agent of header.
setUserAgent(const char* value)
If no user agent is set, it defaults to "esp-link"
| value | User agent |
Definition at line 267 of file ELClientRest.cpp.

| uint16_t ELClientRest::waitResponse | ( | char * | data, |
| uint16_t | maxLen, | ||
| uint32_t | timeout = DEFAULT_REST_TIMEOUT |
||
| ) |
Wait for the response.
waitResponse(char* data, uint16_t maxLen, uint32_t timeout)
Wait for the response from the remote server for time_out, returns the HTTP status code, 0 if no response (may need to wait longer)
| data | Pointer to buffer for received packet |
| maxLen | Size of buffer for received packet. If the received packet is larger than the buffer, the received packet will be truncated. |
| timeout | (optional) Timout in milli seconds to wait for a response, defaults to 5000ms |
uint16_t Size of received packet or number of sent bytes or 0 if no response Definition at line 374 of file ELClientRest.cpp.
