forked from matth-x/MicroOcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOcppMessage.h
More file actions
76 lines (56 loc) · 2.35 KB
/
Copy pathOcppMessage.h
File metadata and controls
76 lines (56 loc) · 2.35 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
70
71
72
73
74
75
76
// matth-x/ESP8266-OCPP
// Copyright Matthias Akstaller 2019 - 2021
// MIT License
/**
* This framework considers OCPP operations to be a combination of two things: first, ensure that the message reaches its
* destination properly (the "Remote procedure call" header, e.g. message Id). Second, transmit the application data
* as specified in the OCPP 1.6 document.
*
* The remote procedure call (RPC) part is implemented by the class OcppOperation. The application data part is implemented by
* the respective OcppMessage subclasses, e.g. BootNotification, StartTransaction, ect.
*
* The resulting structure is that the RPC header (=instance of OcppOperation) holds a reference to the payload
* message creator (=instance of BootNotification, StartTransaction, ...). Both objects working together give the complete
* OCPP operation.
*/
#ifndef OCPPMESSAGE_H
#define OCPPMESSAGE_H
#include <ArduinoJson.h>
#include <WebSocketsClient.h>
namespace ArduinoOcpp {
DynamicJsonDocument *createEmptyDocument();
class OcppMessage {
private:
public:
OcppMessage();
virtual ~OcppMessage();
virtual const char* getOcppOperationType();
/**
* Create the payload for the respective OCPP message
*
* For instance operation Authorize: creates Authorize.req(idTag)
*
* This function is usually called multiple times by the Arduino loop(). On first call, the request is initially sent. In the
* succeeding calls, the implementers decide to either recreate the request, or do nothing as the operation is still pending.
*/
virtual DynamicJsonDocument* createReq();
virtual void processConf(JsonObject payload);
/*
* returns if the operation must be aborted
*/
virtual bool processErr(const char *code, const char *description, JsonObject details) { return true;}
/**
* Processes the request in the JSON document.
*/
virtual void processReq(JsonObject payload);
/**
* After successfully processing a request sent by the communication counterpart, this function creates the payload for a confirmation
* message.
*/
virtual DynamicJsonDocument* createConf();
virtual const char *getErrorCode() {return NULL;} //NULL means no error
virtual const char *getErrorDescription() {return "";}
virtual DynamicJsonDocument *getErrorDetails() {return createEmptyDocument();}
};
} //end namespace ArduinoOcpp
#endif