forked from matth-x/MicroOcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOcppSocket.h
More file actions
69 lines (48 loc) · 1.45 KB
/
Copy pathOcppSocket.h
File metadata and controls
69 lines (48 loc) · 1.45 KB
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
// matth-x/ArduinoOcpp
// Copyright Matthias Akstaller 2019 - 2022
// MIT License
#ifndef OCPPSOCKET_H
#define OCPPSOCKET_H
#include <Arduino.h>
#include <functional>
namespace ArduinoOcpp {
using ReceiveTXTcallback = std::function<bool(const char*, size_t)>;
class OcppSocket {
public:
OcppSocket() = default;
virtual ~OcppSocket() = default;
virtual void loop() = 0;
virtual bool sendTXT(String &out) = 0;
virtual void setReceiveTXTcallback(ReceiveTXTcallback &receiveTXT) = 0; //ReceiveTXTcallback is defined in OcppServer.h
};
} //end namespace ArduinoOcpp
#ifndef AO_CUSTOM_WS
#include <WebSocketsClient.h>
#include <WebSocketsServer.h>
namespace ArduinoOcpp {
namespace EspWiFi {
class OcppClientSocket : public OcppSocket {
private:
//std::shared_ptr<WebSocketsClient> wsock;
WebSocketsClient *wsock;
public:
//OcppClientSocket(ReceiveTXTcallback &receiveTXT, std::shared_ptr<WebSocketsClient> wsock);
OcppClientSocket(WebSocketsClient *wsock);
void loop();
bool sendTXT(String &out);
void setReceiveTXTcallback(ReceiveTXTcallback &receiveTXT);
};
class OcppServerSocket : public OcppSocket {
private:
IPAddress ip_addr;
public:
OcppServerSocket(IPAddress &ip_addr);
~OcppServerSocket();
void loop();
bool sendTXT(String &out);
void setReceiveTXTcallback(ReceiveTXTcallback &receiveTXT);
};
} //end namespace EspWiFi
} //end namespace ArduinoOcpp
#endif //ndef AO_CUSTOM_WS
#endif