forked from matth-x/MicroOcppSimulator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
64 lines (52 loc) · 1.7 KB
/
main.cpp
File metadata and controls
64 lines (52 loc) · 1.7 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
#include "mongoose.h"
#include "webserver.h"
#include <ArduinoOcppMongooseClient.h>
#include "evse.h"
#include <iostream>
#include <ArduinoOcpp.h>
#include <ArduinoOcpp/Core/Configuration.h>
#include <ArduinoOcpp/Core/FilesystemAdapter.h>
#include <ArduinoOcpp/Platform.h>
#include <ArduinoOcpp/Context.h>
#include <ArduinoOcpp/Model/Model.h>
#include <ArduinoOcpp/Core/Time.h>
struct mg_mgr mgr;
ArduinoOcpp::AOcppMongooseClient *osock;
#if AO_NUMCONNECTORS == 3
std::array<Evse, AO_NUMCONNECTORS - 1> connectors {{1,2}};
#else
std::array<Evse, AO_NUMCONNECTORS - 1> connectors {{1}};
#endif
int main() {
mg_log_set(MG_LL_INFO);
mg_mgr_init(&mgr);
mg_http_listen(&mgr, "0.0.0.0:8000", http_serve, NULL); // Create listening connection
std::shared_ptr<ArduinoOcpp::FilesystemAdapter> filesystem;
#ifndef AO_DEACTIVATE_FLASH
filesystem =
ArduinoOcpp::makeDefaultFilesystemAdapter(ArduinoOcpp::FilesystemOpt::Use_Mount_FormatOnFail);
#endif
osock = new ArduinoOcpp::AOcppMongooseClient(&mgr,
"ws://echo.websocket.events",
"charger-01",
"",
"",
filesystem);
server_initialize(osock);
OCPP_initialize(*osock,
ChargerCredentials("Demo Charger", "My Company Ltd."),
ArduinoOcpp::FilesystemOpt::Use_Mount_FormatOnFail);
for (unsigned int i = 0; i < connectors.size(); i++) {
connectors[i].setup();
}
for (;;) { // Block forever
mg_mgr_poll(&mgr, 100);
OCPP_loop();
for (unsigned int i = 0; i < connectors.size(); i++) {
connectors[i].loop();
}
}
delete osock;
mg_mgr_free(&mgr);
return 0;
}