Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- StatusNotification compatibility ([#247](https://github.com/matth-x/MicroOcpp/pull/247))
- ChangeAvailability compatibility ([#285](https://github.com/matth-x/MicroOcpp/pull/285))
- Reset compatibility, UCs B11 - B12 ([#286](https://github.com/matth-x/MicroOcpp/pull/286))
- RequestStart-/StopTransaction, UCs F01 - F02 ([#289](https://github.com/matth-x/MicroOcpp/pull/289))

### Fixed

Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ set(MO_SRC
src/MicroOcpp/Operations/NotifyReport.cpp
src/MicroOcpp/Operations/RemoteStartTransaction.cpp
src/MicroOcpp/Operations/RemoteStopTransaction.cpp
src/MicroOcpp/Operations/RequestStartTransaction.cpp
src/MicroOcpp/Operations/RequestStopTransaction.cpp
src/MicroOcpp/Operations/ReserveNow.cpp
src/MicroOcpp/Operations/Reset.cpp
src/MicroOcpp/Operations/SendLocalList.cpp
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@ The following OCPP 2.0.1 use cases are implemented:
| UC | Description | Note |
| :--- | :--- | :--- |
| M03 - M05 | Certificate management | Enable Mbed-TLS to use the built-in certificate store |
| B05 - B07 | Variables | No persistency yet |
| B05 - B07 | Variables | |
| B01 - B04<br>B11 - B12 | Provisioning | Ported from OCPP 1.6 |
| E01 - E12 | Transactions | |
| F01 - F02 | Remote Start/Stop Tx | |
| - | Protocol negotiation | The charger can select the OCPP version at runtime |

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).
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).

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.

Expand Down
36 changes: 36 additions & 0 deletions src/MicroOcpp/Model/Authorization/IdToken.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,42 @@ IdToken::IdToken(const char *token, Type type) : type(type) {
}
}

bool IdToken::parseCstr(const char *token, const char *typeCstr) {
if (!token || !typeCstr) {
MO_DBG_DEBUG("TRACE");
return false;
}

if (!strcmp(typeCstr, "Central")) {
type = Type::Central;
} else if (!strcmp(typeCstr, "eMAID")) {
type = Type::eMAID;
} else if (!strcmp(typeCstr, "ISO14443")) {
type = Type::ISO14443;
} else if (!strcmp(typeCstr, "ISO15693")) {
type = Type::ISO15693;
} else if (!strcmp(typeCstr, "KeyCode")) {
MO_DBG_DEBUG("TRACE");
type = Type::KeyCode;
} else if (!strcmp(typeCstr, "Local")) {
type = Type::Local;
} else if (!strcmp(typeCstr, "MacAddress")) {
type = Type::MacAddress;
} else if (!strcmp(typeCstr, "NoAuthorization")) {
type = Type::NoAuthorization;
} else {
MO_DBG_DEBUG("TRACE");
return false;
}

auto ret = snprintf(idToken, sizeof(idToken), "%s", token);
if (ret < 0 || (size_t)ret >= sizeof(idToken)) {
return false;
}

return true;
}

const char *IdToken::get() const {
return *idToken ? idToken : nullptr;;
}
Expand Down
2 changes: 2 additions & 0 deletions src/MicroOcpp/Model/Authorization/IdToken.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class IdToken {
IdToken();
IdToken(const char *token, Type type = Type::ISO14443);

bool parseCstr(const char *token, const char *typeCstr);

const char *get() const;
const char *getTypeCstr() const;

Expand Down
13 changes: 9 additions & 4 deletions src/MicroOcpp/Model/Transactions/Transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,10 @@ class Transaction {

#include <memory>

#include <MicroOcpp/Model/Transactions/TransactionDefs.h>
#include <MicroOcpp/Model/Authorization/IdToken.h>
#include <MicroOcpp/Model/ConnectorBase/EvseId.h>

#define MO_TXID_LEN_MAX 36

namespace MicroOcpp {
namespace Ocpp201 {

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

bool idTokenTransmitted = true;
//if to fill next TxEvent with optional fields
bool notifyEvseId = false;
bool notifyIdToken = false;
bool notifyStopIdToken = false;
bool notifyReservationId = false;
bool notifyChargingState = false;
bool notifyRemoteStartId = false;

bool evConnectionTimeoutListen = true;

StopReason stopReason = StopReason::UNDEFINED;
TransactionEventTriggerReason stopTrigger = TransactionEventTriggerReason::UNDEFINED;
std::unique_ptr<IdToken> stopIdToken; // if null, then stopIdToken equals idToken
bool stopIdTokenTransmitted = true;
};

// TransactionEventRequest (1.60.1)
Expand Down Expand Up @@ -305,6 +309,7 @@ class TransactionEventData {
int numberOfPhasesUsed = -1;
int cableMaxCurrent = -1;
int reservationId = -1;
int remoteStartId = -1;

// TransactionType (2.48)
ChargingState chargingState = ChargingState::UNDEFINED;
Expand Down
20 changes: 20 additions & 0 deletions src/MicroOcpp/Model/Transactions/TransactionDefs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// matth-x/MicroOcpp
// Copyright Matthias Akstaller 2019 - 2024
// MIT License

#ifndef MO_TRANSACTIONDEFS_H
#define MO_TRANSACTIONDEFS_H

#include <MicroOcpp/Version.h>

#if MO_ENABLE_V201

#define MO_TXID_LEN_MAX 36

typedef enum RequestStartStopStatus {
RequestStartStopStatus_Accepted,
RequestStartStopStatus_Rejected
} RequestStartStopStatus;

#endif //MO_ENABLE_V201
#endif
Loading