40void ELClientRest::restCallback(
void *res)
46 resp->
popArg(&_status,
sizeof(_status));
48 _elc->
_debug->print(
"REST code ");
49 _elc->
_debug->println(_status);
80 uint8_t sec = !!security;
81 restCb.
attach(
this, &ELClientRest::restCallback);
84 _elc->
Request(host, strlen(host));
90 if (pkt && (int32_t)pkt->
value >= 0) {
91 remote_instance = pkt->
value;
94 return (
int)pkt->
value;
115 if (remote_instance < 0)
return;
118 _elc->
Request(method, strlen(method));
119 _elc->
Request(path, strlen(path));
120 if (data != NULL && len > 0) {
143 request(path, method, data, strlen(data));
233 _elc->
Request(&header_index, 1);
234 _elc->
Request(value, strlen(value));
252 _elc->
Request(&header_index, 1);
253 _elc->
Request(value, strlen(value));
271 _elc->
Request(&header_index, 1);
272 _elc->
Request(value, strlen(value));
323 if (_status == 0)
return 0;
324 memcpy(data, _data, _len>maxLen?maxLen:_len);
376 uint32_t
wait = millis();
377 while (_status == 0 && (millis() -
wait < timeout)) {
Definitions for ELClientRes.
int16_t popArg(void *data, uint16_t maxLen)
Extract an argument from the response packet.
int16_t popArgPtr(void **data)
Extract pointer to an argument from the response packet.
void setUserAgent(const char *value)
Set user agent of header.
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.
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 get(const char *path, const char *data=NULL)
Send GET request to REST server.
void request(const char *path, const char *method, const char *data=NULL)
Send request to REST server.
void setHeader(const char *value)
Set generic header content.
uint16_t waitResponse(char *data, uint16_t maxLen, uint32_t timeout=DEFAULT_REST_TIMEOUT)
Wait for the response.
void post(const char *path, const char *data)
Send POST request to REST server.
void setContentType(const char *value)
Set content type of header.
uint16_t getResponse(char *data, uint16_t maxLen)
Retrieve response.
ELClientPacket * Process(void)
Handle serial input.
void Request(uint16_t cmd, uint32_t value, uint16_t argc)
Start a request.
ELClientPacket * WaitReturn(uint32_t timeout=ESP_TIMEOUT)
Wait for a response from ESP for a given timeout.
void attach(T *item, retT(T::*method)(argT))