supla-device
Toggle main menu visibility
Loading...
Searching...
No Matches
src
supla
network
client.h
1
/*
2
Copyright (C) AC SOFTWARE SP. Z O.O.
3
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License
6
as published by the Free Software Foundation; either version 2
7
of the License, or (at your option) any later version.
8
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
*/
18
19
#ifndef SRC_SUPLA_NETWORK_CLIENT_H_
20
#define SRC_SUPLA_NETWORK_CLIENT_H_
21
22
#include <stddef.h>
23
#include <stdint.h>
24
25
#include "ip_address.h"
26
27
class
SuplaDeviceClass
;
28
29
namespace
Supla {
30
31
#ifndef ARDUINO
32
#ifdef F
33
#undef F
34
#endif
35
#define F(argument_F) (argument_F)
36
#endif
37
38
class
Client {
39
public
:
40
Client();
41
virtual
~Client();
42
43
virtual
int
available() = 0;
44
virtual
void
stop() = 0;
45
virtual
uint8_t connected() = 0;
46
virtual
void
setTimeoutMs(uint16_t timeoutMs) = 0;
47
48
int
connect(
IPAddress
ip, uint16_t port);
49
int
connect(
const
char
*host, uint16_t port);
50
size_t
write(uint8_t);
51
size_t
write(
const
uint8_t *buf,
size_t
size);
52
size_t
write(
const
void
*buf,
size_t
size = 0);
53
54
size_t
print(
const
char
*);
55
size_t
println(
const
char
*);
56
#ifdef ARDUINO
57
size_t
print(const ::__FlashStringHelper *);
58
size_t
println(const ::__FlashStringHelper *);
59
#endif
60
size_t
println();
61
62
int
read();
63
int
read(uint8_t *buf,
size_t
size);
64
int
read(
char
*buf,
size_t
size);
65
66
// SSL configuration
67
virtual
void
setSSLEnabled(
bool
enabled);
68
void
setCACert(
const
char
*rootCA);
69
70
void
setDebugLogs(
bool
);
71
bool
isDebugLogs()
const
;
72
void
setSdc(
SuplaDeviceClass
*sdc);
73
74
uint32_t getSrcConnectionIPAddress()
const
;
75
76
protected
:
77
virtual
bool
isCertificateValidationEnabled()
const
;
78
virtual
int
connectImp(
const
char
*host, uint16_t port) = 0;
79
virtual
size_t
writeImp(
const
uint8_t *buf,
size_t
size) = 0;
80
virtual
int
readImp(uint8_t *buf,
size_t
size) = 0;
81
82
bool
sslEnabled =
false
;
83
bool
debugLogs =
false
;
84
const
char
*rootCACert =
nullptr
;
85
unsigned
int
rootCACertSize = 0;
86
SuplaDeviceClass
*sdc =
nullptr
;
87
uint32_t srcIp = 0;
88
};
89
90
extern
Client
*ClientBuilder();
91
};
// namespace Supla
92
93
#endif
// SRC_SUPLA_NETWORK_CLIENT_H_
IPAddress
Definition
ip_address.h:30
SuplaDeviceClass
Definition
SuplaDevice.h:163
Supla::Client
Definition
client.h:38
Generated by
1.17.0