ThingsBoard Client SDK 0.16.0
Client SDK to connect with ThingsBoard IoT Platform from IoT devices (Arduino, Espressif, etc.)
Loading...
Searching...
No Matches
Arduino_HTTP_Client.h
Go to the documentation of this file.
1#ifndef Arduino_HTTP_Client_h
2#define Arduino_HTTP_Client_h
3
4#ifdef ARDUINO
5
6// Local includes.
7#include "IHTTP_Client.h"
8
9// Library includes.
10#include <ArduinoHttpClient.h>
11
12
15class Arduino_HTTP_Client : public IHTTP_Client {
16 public:
25 Arduino_HTTP_Client(Client& transport_client, char const * host, uint16_t port);
26
27 ~Arduino_HTTP_Client() override = default;
28
29 void set_keep_alive(bool keep_alive) override;
30
31 int connect(char const * host, uint16_t port) override;
32
33 void stop() override;
34
35 int post(char const * url_path, char const * content_type, char const * request_body) override;
36
37 int get_response_status_code() override;
38
39 int get(char const * url_path) override;
40
41#if THINGSBOARD_ENABLE_STL
42 std::string get_response_body() override;
43#else
44 String get_response_body() override;
45#endif // THINGSBOARD_ENABLE_STL
46
47 private:
48 HttpClient m_http_client; // Underlying HTTP client instance used to send data
49};
50
51#endif // ARDUINO
52
53#endif // Arduino_HTTP_Client_h
HTTP Client interface that contains the method that a class that can be used to send and receive data...
Definition: IHTTP_Client.h:22
virtual int post(char const *url_path, char const *content_type, char const *request_body)=0
Connects to the server and sends a POST request with a body and content type.
virtual void stop()=0
Disconnects the given device from the current host and clears about any remaining bytes still in the ...
virtual int get(const char *url_path)=0
Connects to the server and sends a GET request.
virtual std::string get_response_body()=0
Returns the response body of a previously sent message as a string object, skips any response headers...
virtual void set_keep_alive(bool keep_alive)=0
Sets whether to close the HTTP connection for every single request and reconnect once a new request i...
virtual int connect(char const *host, uint16_t port)=0
Connects to the given server instance over the defined port.
virtual int get_response_status_code()=0
Gets the HTTP status code contained in the server response.