forked from matth-x/MicroOcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataTransfer.cpp
More file actions
34 lines (27 loc) · 941 Bytes
/
Copy pathDataTransfer.cpp
File metadata and controls
34 lines (27 loc) · 941 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
// matth-x/ArduinoOcpp
// Copyright Matthias Akstaller 2019 - 2023
// MIT License
#include <ArduinoOcpp/Operations/DataTransfer.h>
#include <ArduinoOcpp/Debug.h>
using ArduinoOcpp::Ocpp16::DataTransfer;
DataTransfer::DataTransfer(const std::string &msg) {
this->msg = msg;
}
const char* DataTransfer::getOperationType(){
return "DataTransfer";
}
std::unique_ptr<DynamicJsonDocument> DataTransfer::createReq() {
auto doc = std::unique_ptr<DynamicJsonDocument>(new DynamicJsonDocument(JSON_OBJECT_SIZE(2) + (msg.length() + 1)));
JsonObject payload = doc->to<JsonObject>();
payload["vendorId"] = "CustomVendor";
payload["data"] = msg;
return doc;
}
void DataTransfer::processConf(JsonObject payload){
std::string status = payload["status"] | "Invalid";
if (status == "Accepted") {
AO_DBG_DEBUG("Request has been accepted");
} else {
AO_DBG_INFO("Request has been denied");
}
}