forked from matth-x/MicroOcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOcppServer.h
More file actions
49 lines (33 loc) · 1021 Bytes
/
Copy pathOcppServer.h
File metadata and controls
49 lines (33 loc) · 1021 Bytes
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
// matth-x/ESP8266-OCPP
// Copyright Matthias Akstaller 2019 - 2021
// MIT License
#ifndef OCPPSERVER_H
#define OCPPSERVER_H
#include <vector>
#include <WebSocketsServer.h>
namespace ArduinoOcpp {
typedef uint8_t WsClient;
typedef std::function<bool(const char*, size_t)> ReceiveTXTcallback;
namespace EspWiFi {
struct ReceiveTXTroute {
IPAddress ip_addr;
WsClient num;
ReceiveTXTcallback processTXT;
};
class OcppServer {
private:
std::vector<ReceiveTXTroute> receiveTXTrouting;
WebSocketsServer wsockServer = WebSocketsServer(80);
OcppServer();
static OcppServer *instance;
public:
static OcppServer *getInstance();
void loop();
void wsockEvent(WsClient num, WStype_t type, uint8_t * payload, size_t length);
void setReceiveTXTcallback(IPAddress &ip_addr, ReceiveTXTcallback &callback);
void removeReceiveTXTcallback(IPAddress &ip_addr);
bool sendTXT(IPAddress &ip_addr, String &out);
};
} //end namespace EspWiFi
} //end namespace ArduinoOcpp
#endif