Skip to content

Commit 6bc8e21

Browse files
committed
Merge branch 'main' of https://github.com/matth-x/MicroOcppSimulator into feature/v201-update
2 parents bb8b664 + 3a58611 commit 6bc8e21

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/api.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ int mocpp_api_call(const char *endpoint, MicroOcpp::Method method, const char *b
8383
if (request.containsKey("evPlugged")) {
8484
evse->setEvPlugged(request["evPlugged"]);
8585
}
86+
if (request.containsKey("evsePlugged")) {
87+
evse->setEvsePlugged(request["evsePlugged"]);
88+
}
8689
if (request.containsKey("evReady")) {
8790
evse->setEvReady(request["evReady"]);
8891
}
@@ -92,6 +95,7 @@ int mocpp_api_call(const char *endpoint, MicroOcpp::Method method, const char *b
9295
}
9396

9497
response["evPlugged"] = evse->getEvPlugged();
98+
response["evsePlugged"] = evse->getEvsePlugged();
9599
response["evReady"] = evse->getEvReady();
96100
response["evseReady"] = evse->getEvseReady();
97101
response["chargePointStatus"] = evse->getOcppStatus();

src/evse.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ void Evse::setup() {
4040
snprintf(key, 30, "evPlugged_cId_%u", connectorId);
4141
trackEvPluggedKey = key;
4242
trackEvPluggedBool = MicroOcpp::declareConfiguration(trackEvPluggedKey.c_str(), false, SIMULATOR_FN, false, false, false);
43+
snprintf(key, 30, "evsePlugged_cId_%u", connectorId);
44+
trackEvsePluggedKey = key;
45+
trackEvsePluggedBool = MicroOcpp::declareConfiguration(trackEvsePluggedKey.c_str(), false, SIMULATOR_FN, false, false, false);
4346
snprintf(key, 30, "evReady_cId_%u", connectorId);
4447
trackEvReadyKey = key;
4548
trackEvReadyBool = MicroOcpp::declareConfiguration(trackEvReadyKey.c_str(), false, SIMULATOR_FN, false, false, false);
@@ -124,7 +127,7 @@ void Evse::loop() {
124127
status = MicroOcpp::cstrFromOcppEveState(curStatus);
125128
}
126129

127-
bool simulate_isCharging = ocppPermitsCharge(connectorId) && trackEvPluggedBool->getBool() && trackEvReadyBool->getBool() && trackEvseReadyBool->getBool();
130+
bool simulate_isCharging = ocppPermitsCharge(connectorId) && trackEvPluggedBool->getBool() && trackEvsePluggedBool->getBool() && trackEvReadyBool->getBool() && trackEvseReadyBool->getBool();
128131

129132
simulate_isCharging &= limit_power >= 720.f; //minimum charging current is 6A (720W for 120V grids) according to J1772
130133

@@ -189,6 +192,17 @@ bool Evse::getEvPlugged() {
189192
return trackEvPluggedBool->getBool();
190193
}
191194

195+
void Evse::setEvsePlugged(bool plugged) {
196+
if (!trackEvsePluggedBool) return;
197+
trackEvsePluggedBool->setBool(plugged);
198+
MicroOcpp::configuration_save();
199+
}
200+
201+
bool Evse::getEvsePlugged() {
202+
if (!trackEvsePluggedBool) return false;
203+
return trackEvsePluggedBool->getBool();
204+
}
205+
192206
void Evse::setEvReady(bool ready) {
193207
if (!trackEvReadyBool) return;
194208
trackEvReadyBool->setBool(ready);

src/evse.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class Evse {
1717

1818
std::shared_ptr<MicroOcpp::Configuration> trackEvPluggedBool;
1919
std::string trackEvPluggedKey;
20+
std::shared_ptr<MicroOcpp::Configuration> trackEvsePluggedBool;
21+
std::string trackEvsePluggedKey;
2022
std::shared_ptr<MicroOcpp::Configuration> trackEvReadyBool;
2123
std::string trackEvReadyKey;
2224
std::shared_ptr<MicroOcpp::Configuration> trackEvseReadyBool;
@@ -43,6 +45,10 @@ class Evse {
4345

4446
bool getEvPlugged();
4547

48+
void setEvsePlugged(bool plugged);
49+
50+
bool getEvsePlugged();
51+
4652
void setEvReady(bool ready);
4753

4854
bool getEvReady();

0 commit comments

Comments
 (0)