dhgdh

Dependencies:   MAX44000 PWM_Tone_Library nexpaq_mdk

Fork of LED_Demo by joey shelton

Committer:
nexpaq
Date:
Sat Sep 17 16:32:05 2016 +0000
Revision:
1:55a6170b404f
checking in for sharing

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nexpaq 1:55a6170b404f 1 #ifndef HTTPSCLIENT_H
nexpaq 1:55a6170b404f 2 #define HTTPSCLIENT_H
nexpaq 1:55a6170b404f 3
nexpaq 1:55a6170b404f 4 #include "Socket/Socket.h"
nexpaq 1:55a6170b404f 5 #include "Socket/Endpoint.h"
nexpaq 1:55a6170b404f 6 #include "axTLS/ssl/ssl.h"
nexpaq 1:55a6170b404f 7 #include "HTTPHeader.h"
nexpaq 1:55a6170b404f 8
nexpaq 1:55a6170b404f 9 /**
nexpaq 1:55a6170b404f 10 TCP socket connection
nexpaq 1:55a6170b404f 11 */
nexpaq 1:55a6170b404f 12 class HTTPSClient : public Socket, public Endpoint {
nexpaq 1:55a6170b404f 13
nexpaq 1:55a6170b404f 14 public:
nexpaq 1:55a6170b404f 15 /** TCP socket connection
nexpaq 1:55a6170b404f 16 */
nexpaq 1:55a6170b404f 17 HTTPSClient();
nexpaq 1:55a6170b404f 18
nexpaq 1:55a6170b404f 19
nexpaq 1:55a6170b404f 20 virtual ~HTTPSClient();
nexpaq 1:55a6170b404f 21
nexpaq 1:55a6170b404f 22 /** Connects this TCP socket to the server
nexpaq 1:55a6170b404f 23 \param host The host to connect to. It can either be an IP Address or a hostname that will be resolved with DNS.
nexpaq 1:55a6170b404f 24 \param port The host's port to connect to.
nexpaq 1:55a6170b404f 25 \return 0 on success, -1 on failure.
nexpaq 1:55a6170b404f 26 */
nexpaq 1:55a6170b404f 27 int connect(const char* host);
nexpaq 1:55a6170b404f 28
nexpaq 1:55a6170b404f 29 /** Check if the socket is connected
nexpaq 1:55a6170b404f 30 \return true if connected, false otherwise.
nexpaq 1:55a6170b404f 31 */
nexpaq 1:55a6170b404f 32 bool is_connected(void);
nexpaq 1:55a6170b404f 33
nexpaq 1:55a6170b404f 34 // Returns the size of the body
nexpaq 1:55a6170b404f 35 HTTPHeader get(char *path);
nexpaq 1:55a6170b404f 36
nexpaq 1:55a6170b404f 37 int read(char *data, int len);
nexpaq 1:55a6170b404f 38
nexpaq 1:55a6170b404f 39
nexpaq 1:55a6170b404f 40 void close();
nexpaq 1:55a6170b404f 41
nexpaq 1:55a6170b404f 42 private:
nexpaq 1:55a6170b404f 43
nexpaq 1:55a6170b404f 44
nexpaq 1:55a6170b404f 45 int send(char* data, int length);
nexpaq 1:55a6170b404f 46
nexpaq 1:55a6170b404f 47 uint8_t read_line();
nexpaq 1:55a6170b404f 48 HTTPHeader read_header();
nexpaq 1:55a6170b404f 49
nexpaq 1:55a6170b404f 50 bool _is_connected;
nexpaq 1:55a6170b404f 51 SSL_CTX _ssl_ctx;
nexpaq 1:55a6170b404f 52 SSL _ssl;
nexpaq 1:55a6170b404f 53 std::string _host;
nexpaq 1:55a6170b404f 54 };
nexpaq 1:55a6170b404f 55
nexpaq 1:55a6170b404f 56 #endif