Skip to content

Commit 35eb442

Browse files
committed
add FreeVend mode
1 parent cb438fe commit 35eb442

2 files changed

Lines changed: 42 additions & 10 deletions

File tree

src/ArduinoOcpp/Tasks/ChargePointStatus/ConnectorStatus.cpp

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,18 @@ ConnectorStatus::ConnectorStatus(OcppModel& context, int connectorId)
3030

3131
connectionTimeOut = declareConfiguration<int>("ConnectionTimeOut", 30, CONFIGURATION_FN, true, true, true, false);
3232
minimumStatusDuration = declareConfiguration<int>("MinimumStatusDuration", 0, CONFIGURATION_FN, true, true, true, false);
33-
stopTransactionOnInvalidId = declareConfiguration<const char*>("StopTransactionOnInvalidId", "true", CONFIGURATION_FN, true, true, false, false);
34-
stopTransactionOnEVSideDisconnect = declareConfiguration<const char*>("StopTransactionOnEVSideDisconnect", "true", CONFIGURATION_FN, true, true, false, false);
35-
unlockConnectorOnEVSideDisconnect = declareConfiguration<const char*>("UnlockConnectorOnEVSideDisconnect", "true", CONFIGURATION_FN, true, true, false, false);
36-
localAuthorizeOffline = declareConfiguration<const char*>("LocalAuthorizeOffline", "false", CONFIGURATION_FN, true, true, false, false);
37-
localPreAuthorize = declareConfiguration<const char*>("LocalPreAuthorize", "false", CONFIGURATION_FN, true, true, false, false);
33+
stopTransactionOnInvalidId = declareConfiguration<const char*>("StopTransactionOnInvalidId", "true", CONFIGURATION_FN, true, true, true, false);
34+
stopTransactionOnEVSideDisconnect = declareConfiguration<const char*>("StopTransactionOnEVSideDisconnect", "true", CONFIGURATION_FN, true, true, true, false);
35+
unlockConnectorOnEVSideDisconnect = declareConfiguration<const char*>("UnlockConnectorOnEVSideDisconnect", "true", CONFIGURATION_FN, true, true, true, false);
36+
localAuthorizeOffline = declareConfiguration<const char*>("LocalAuthorizeOffline", "false", CONFIGURATION_FN, true, true, true, false);
37+
localPreAuthorize = declareConfiguration<const char*>("LocalPreAuthorize", "false", CONFIGURATION_FN, true, true, true, false);
3838

3939
//if the EVSE goes offline, can it continue to charge without sending StartTx / StopTx to the server when going online again?
40-
silentOfflineTransactions = declareConfiguration<const char*>("AO_SilentOfflineTransactions", "false", CONFIGURATION_FN, true, true, false, false);
40+
silentOfflineTransactions = declareConfiguration<const char*>("AO_SilentOfflineTransactions", "false", CONFIGURATION_FN, true, true, true, false);
41+
42+
//FreeVend mode
43+
freeVendActive = declareConfiguration<const char*>("AO_FreeVendActive", "true", CONFIGURATION_FN, true, true, true, false);
44+
freeVendIdTag = declareConfiguration<const char*>("AO_FreeVendIdTag", "testtesttest", CONFIGURATION_FN, true, true, true, false);
4145

4246
if (!availability) {
4347
AO_DBG_ERR("Cannot declare availability");
@@ -98,9 +102,8 @@ OcppEvseState ConnectorStatus::inferenceStatus() {
98102
return OcppEvseState::Unavailable;
99103
} else if (transaction && transaction->isRunning()) {
100104
//Transaction is currently running
101-
if ((connectorEnergizedSampler && !connectorEnergizedSampler()) ||
102-
!transaction->isActive() || //will forbid charging
103-
transaction->isIdTagDeauthorized()) {
105+
if (!ocppPermitsCharge() ||
106+
(connectorEnergizedSampler && !connectorEnergizedSampler())) {
104107
return OcppEvseState::SuspendedEVSE;
105108
}
106109
if (evRequestsEnergySampler && !evRequestsEnergySampler()) {
@@ -134,11 +137,18 @@ bool ConnectorStatus::ocppPermitsCharge() {
134137
return false;
135138
}
136139

140+
bool suspendDeAuthorizedIdTag = transaction && transaction->isIdTagDeauthorized(); //if idTag status is "DeAuthorized" and if charging should stop
141+
142+
//check special case for DeAuthorized idTags: FreeVend mode
143+
if (suspendDeAuthorizedIdTag && freeVendActive && !strcmp(*freeVendActive, "true")) {
144+
suspendDeAuthorizedIdTag = false;
145+
}
146+
137147
return transaction &&
138148
transaction->isRunning() &&
139149
transaction->isActive() &&
140150
!getErrorCode() &&
141-
!transaction->isIdTagDeauthorized();
151+
!suspendDeAuthorizedIdTag;
142152
}
143153

144154
OcppMessage *ConnectorStatus::loop() {
@@ -313,6 +323,25 @@ OcppMessage *ConnectorStatus::loop() {
313323
}
314324
} //end transaction-related operations
315325

326+
//handle FreeVend mode
327+
if (freeVendActive && *freeVendActive && !strcmp(*freeVendActive, "true") && connectorPluggedSampler) {
328+
if (!freeVendTrackPlugged && connectorPluggedSampler() && !transaction) {
329+
const char *idTag = freeVendIdTag && *freeVendIdTag ? *freeVendIdTag : "";
330+
if (!idTag || *idTag == '\0') {
331+
idTag = "A0000000";
332+
}
333+
AO_DBG_INFO("begin FreeVend Tx using idTag %s", idTag);
334+
beginSession(idTag);
335+
336+
if (!transaction) {
337+
AO_DBG_ERR("could not begin FreeVend Tx");
338+
(void)0;
339+
}
340+
}
341+
342+
freeVendTrackPlugged = connectorPluggedSampler();
343+
}
344+
316345
auto inferedStatus = inferenceStatus();
317346

318347
if (inferedStatus != currentStatus) {

src/ArduinoOcpp/Tasks/ChargePointStatus/ConnectorStatus.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ class ConnectorStatus {
6363
std::shared_ptr<Configuration<const char*>> localPreAuthorize;
6464

6565
std::shared_ptr<Configuration<const char*>> silentOfflineTransactions;
66+
std::shared_ptr<Configuration<const char*>> freeVendActive;
67+
std::shared_ptr<Configuration<const char*>> freeVendIdTag;
68+
bool freeVendTrackPlugged = false;
6669
public:
6770
ConnectorStatus(OcppModel& context, int connectorId);
6871

0 commit comments

Comments
 (0)