forked from matth-x/MicroOcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReset.cpp
More file actions
43 lines (35 loc) · 1.36 KB
/
Copy pathReset.cpp
File metadata and controls
43 lines (35 loc) · 1.36 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
// matth-x/ArduinoOcpp
// Copyright Matthias Akstaller 2019 - 2022
// MIT License
#include <ArduinoOcpp/MessagesV16/Reset.h>
#include <ArduinoOcpp/Core/OcppModel.h>
#include <ArduinoOcpp/Tasks/ChargePointStatus/ChargePointStatusService.h>
using ArduinoOcpp::Ocpp16::Reset;
Reset::Reset() {
}
const char* Reset::getOcppOperationType(){
return "Reset";
}
void Reset::processReq(JsonObject payload) {
/*
* Process the application data here. Note: you have to implement the device reset procedure in your client code. You have to set
* a onSendConfListener in which you initiate a reset (e.g. calling ESP.reset() )
*/
bool isHard = !strcmp(payload["type"] | "undefined", "Hard");
if (ocppModel && ocppModel->getChargePointStatusService()) {
auto cpsService = ocppModel->getChargePointStatusService();
int connId = 0;
for (int i = 0; i < cpsService->getNumConnectors(); i++) {
auto connector = cpsService->getConnector(connId);
if (connector) {
connector->endSession(isHard ? "HardReset" : "SoftReset");
}
}
}
}
std::unique_ptr<DynamicJsonDocument> Reset::createConf(){
auto doc = std::unique_ptr<DynamicJsonDocument>(new DynamicJsonDocument(JSON_OBJECT_SIZE(1)));
JsonObject payload = doc->to<JsonObject>();
payload["status"] = "Accepted";
return doc;
}