-
-
Notifications
You must be signed in to change notification settings - Fork 212
/
Copy pathAClient.h
86 lines (62 loc) · 2.14 KB
/
AClient.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
AClient.h - Copyable Client implementation for Mbed Core
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef MBEDACLIENT_H
#define MBEDACLIENT_H
#include <Arduino.h>
#include "MbedClient.h"
namespace arduino {
class AClient : public Client {
public:
AClient() {}
virtual int connect(IPAddress ip, uint16_t port);
virtual int connect(const char *host, uint16_t port);
int connectSSL(IPAddress ip, uint16_t port);
int connectSSL(const char* host, uint16_t port);
virtual void stop();
virtual explicit operator bool();
virtual uint8_t connected();
uint8_t status();
IPAddress remoteIP();
uint16_t remotePort();
virtual size_t write(uint8_t);
virtual size_t write(const uint8_t *buf, size_t size);
virtual void flush();
virtual int available();
virtual int read();
virtual int read(uint8_t *buf, size_t size);
virtual int peek();
using Print::write;
void setSocketTimeout(unsigned long timeout);
protected:
friend class EthernetServer;
friend class WiFiServer;
std::shared_ptr<MbedClient> client;
virtual NetworkInterface* getNetwork() = 0;
virtual void newMbedClient();
void setSocket(Socket* sock);
};
class ASslClient : public AClient {
public:
ASslClient() {}
void disableSNI(bool statusSNI);
void appendCustomCACert(const char* ca_cert);
void setCACert(const char* rootCA);
void setCertificate(const char* clientCert);
void setPrivateKey(const char* privateKey);
protected:
virtual void newMbedClient();
};
}
#endif