Skip to content

Commit ffbb6e4

Browse files
authored
v2.0.1 RequestStart/-StopTx (UCs F01 - F02) (#289)
* adopt v201_ed2 PowerPathClosed * allow tx on evseId 0 * add RequestStart-/StopTransaction * update changelog
1 parent 2020ba7 commit ffbb6e4

15 files changed

+503
-71
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- StatusNotification compatibility ([#247](https://github.com/matth-x/MicroOcpp/pull/247))
2626
- ChangeAvailability compatibility ([#285](https://github.com/matth-x/MicroOcpp/pull/285))
2727
- Reset compatibility, UCs B11 - B12 ([#286](https://github.com/matth-x/MicroOcpp/pull/286))
28+
- RequestStart-/StopTransaction, UCs F01 - F02 ([#289](https://github.com/matth-x/MicroOcpp/pull/289))
2829

2930
### Fixed
3031

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ set(MO_SRC
4646
src/MicroOcpp/Operations/NotifyReport.cpp
4747
src/MicroOcpp/Operations/RemoteStartTransaction.cpp
4848
src/MicroOcpp/Operations/RemoteStopTransaction.cpp
49+
src/MicroOcpp/Operations/RequestStartTransaction.cpp
50+
src/MicroOcpp/Operations/RequestStopTransaction.cpp
4951
src/MicroOcpp/Operations/ReserveNow.cpp
5052
src/MicroOcpp/Operations/Reset.cpp
5153
src/MicroOcpp/Operations/SendLocalList.cpp

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,13 @@ The following OCPP 2.0.1 use cases are implemented:
8080
| UC | Description | Note |
8181
| :--- | :--- | :--- |
8282
| M03 - M05 | Certificate management | Enable Mbed-TLS to use the built-in certificate store |
83-
| B05 - B07 | Variables | No persistency yet |
83+
| B05 - B07 | Variables | |
8484
| B01 - B04<br>B11 - B12 | Provisioning | Ported from OCPP 1.6 |
8585
| E01 - E12 | Transactions | |
86+
| F01 - F02 | Remote Start/Stop Tx | |
8687
| - | Protocol negotiation | The charger can select the OCPP version at runtime |
8788

88-
The OCPP 2.0.1 features are in an early development stage. By default, they are disabled and excluded from the build, so they have no impact on the firmware size. To enable, set the build flag `MO_ENABLE_V201=1` and initialize the library with the ProtocolVersion parameter `2.0.1` (see [this example](https://github.com/matth-x/MicroOcppSimulator/blob/657e606c3b178d3add242935d413c72624130ff3/src/main.cpp#L43-L47) in the Simulator).
89+
The OCPP 2.0.1 features are in an alpha development stage (no persistency yet). By default, they are disabled and excluded from the build, so they have no impact on the firmware size. To enable, set the build flag `MO_ENABLE_V201=1` and initialize the library with the ProtocolVersion parameter `2.0.1` (see [this example](https://github.com/matth-x/MicroOcppSimulator/blob/657e606c3b178d3add242935d413c72624130ff3/src/main.cpp#L43-L47) in the Simulator).
8990

9091
An integration of the library for OCPP 1.6 will also be functional with the 2.0.1 upgrade. It works with the same API in MicroOcpp.h.
9192

src/MicroOcpp/Model/Authorization/IdToken.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,42 @@ IdToken::IdToken(const char *token, Type type) : type(type) {
2727
}
2828
}
2929

30+
bool IdToken::parseCstr(const char *token, const char *typeCstr) {
31+
if (!token || !typeCstr) {
32+
MO_DBG_DEBUG("TRACE");
33+
return false;
34+
}
35+
36+
if (!strcmp(typeCstr, "Central")) {
37+
type = Type::Central;
38+
} else if (!strcmp(typeCstr, "eMAID")) {
39+
type = Type::eMAID;
40+
} else if (!strcmp(typeCstr, "ISO14443")) {
41+
type = Type::ISO14443;
42+
} else if (!strcmp(typeCstr, "ISO15693")) {
43+
type = Type::ISO15693;
44+
} else if (!strcmp(typeCstr, "KeyCode")) {
45+
MO_DBG_DEBUG("TRACE");
46+
type = Type::KeyCode;
47+
} else if (!strcmp(typeCstr, "Local")) {
48+
type = Type::Local;
49+
} else if (!strcmp(typeCstr, "MacAddress")) {
50+
type = Type::MacAddress;
51+
} else if (!strcmp(typeCstr, "NoAuthorization")) {
52+
type = Type::NoAuthorization;
53+
} else {
54+
MO_DBG_DEBUG("TRACE");
55+
return false;
56+
}
57+
58+
auto ret = snprintf(idToken, sizeof(idToken), "%s", token);
59+
if (ret < 0 || (size_t)ret >= sizeof(idToken)) {
60+
return false;
61+
}
62+
63+
return true;
64+
}
65+
3066
const char *IdToken::get() const {
3167
return *idToken ? idToken : nullptr;;
3268
}

src/MicroOcpp/Model/Authorization/IdToken.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class IdToken {
3939
IdToken();
4040
IdToken(const char *token, Type type = Type::ISO14443);
4141

42+
bool parseCstr(const char *token, const char *typeCstr);
43+
4244
const char *get() const;
4345
const char *getTypeCstr() const;
4446

src/MicroOcpp/Model/Transactions/Transaction.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,10 @@ class Transaction {
173173

174174
#include <memory>
175175

176+
#include <MicroOcpp/Model/Transactions/TransactionDefs.h>
176177
#include <MicroOcpp/Model/Authorization/IdToken.h>
177178
#include <MicroOcpp/Model/ConnectorBase/EvseId.h>
178179

179-
#define MO_TXID_LEN_MAX 36
180-
181180
namespace MicroOcpp {
182181
namespace Ocpp201 {
183182

@@ -264,14 +263,19 @@ class Transaction {
264263
char transactionId [MO_TXID_LEN_MAX + 1] = {'\0'};
265264
int remoteStartId = -1;
266265

267-
bool idTokenTransmitted = true;
266+
//if to fill next TxEvent with optional fields
267+
bool notifyEvseId = false;
268+
bool notifyIdToken = false;
269+
bool notifyStopIdToken = false;
270+
bool notifyReservationId = false;
271+
bool notifyChargingState = false;
272+
bool notifyRemoteStartId = false;
268273

269274
bool evConnectionTimeoutListen = true;
270275

271276
StopReason stopReason = StopReason::UNDEFINED;
272277
TransactionEventTriggerReason stopTrigger = TransactionEventTriggerReason::UNDEFINED;
273278
std::unique_ptr<IdToken> stopIdToken; // if null, then stopIdToken equals idToken
274-
bool stopIdTokenTransmitted = true;
275279
};
276280

277281
// TransactionEventRequest (1.60.1)
@@ -305,6 +309,7 @@ class TransactionEventData {
305309
int numberOfPhasesUsed = -1;
306310
int cableMaxCurrent = -1;
307311
int reservationId = -1;
312+
int remoteStartId = -1;
308313

309314
// TransactionType (2.48)
310315
ChargingState chargingState = ChargingState::UNDEFINED;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// matth-x/MicroOcpp
2+
// Copyright Matthias Akstaller 2019 - 2024
3+
// MIT License
4+
5+
#ifndef MO_TRANSACTIONDEFS_H
6+
#define MO_TRANSACTIONDEFS_H
7+
8+
#include <MicroOcpp/Version.h>
9+
10+
#if MO_ENABLE_V201
11+
12+
#define MO_TXID_LEN_MAX 36
13+
14+
typedef enum RequestStartStopStatus {
15+
RequestStartStopStatus_Accepted,
16+
RequestStartStopStatus_Rejected
17+
} RequestStartStopStatus;
18+
19+
#endif //MO_ENABLE_V201
20+
#endif

0 commit comments

Comments
 (0)