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
4 changes: 4 additions & 0 deletions src/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ int mocpp_api_call(const char *endpoint, MicroOcpp::Method method, const char *b
if (request.containsKey("evPlugged")) {
evse->setEvPlugged(request["evPlugged"]);
}
if (request.containsKey("evsePlugged")) {
evse->setEvsePlugged(request["evsePlugged"]);
}
if (request.containsKey("evReady")) {
evse->setEvReady(request["evReady"]);
}
Expand All @@ -92,6 +95,7 @@ int mocpp_api_call(const char *endpoint, MicroOcpp::Method method, const char *b
}

response["evPlugged"] = evse->getEvPlugged();
response["evsePlugged"] = evse->getEvsePlugged();
response["evReady"] = evse->getEvReady();
response["evseReady"] = evse->getEvseReady();
response["chargePointStatus"] = evse->getOcppStatus();
Expand Down
16 changes: 15 additions & 1 deletion src/evse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ void Evse::setup() {
snprintf(key, 30, "evPlugged_cId_%u", connectorId);
trackEvPluggedKey = key;
trackEvPluggedBool = MicroOcpp::declareConfiguration(trackEvPluggedKey.c_str(), false, SIMULATOR_FN, false, false, false);
snprintf(key, 30, "evsePlugged_cId_%u", connectorId);
trackEvsePluggedKey = key;
trackEvsePluggedBool = MicroOcpp::declareConfiguration(trackEvsePluggedKey.c_str(), false, SIMULATOR_FN, false, false, false);
snprintf(key, 30, "evReady_cId_%u", connectorId);
trackEvReadyKey = key;
trackEvReadyBool = MicroOcpp::declareConfiguration(trackEvReadyKey.c_str(), false, SIMULATOR_FN, false, false, false);
Expand Down Expand Up @@ -139,7 +142,7 @@ void Evse::loop() {
}
}

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

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

Expand Down Expand Up @@ -209,6 +212,17 @@ bool Evse::getEvPlugged() {
return trackEvPluggedBool->getBool();
}

void Evse::setEvsePlugged(bool plugged) {
if (!trackEvsePluggedBool) return;
trackEvsePluggedBool->setBool(plugged);
MicroOcpp::configuration_save();
}

bool Evse::getEvsePlugged() {
if (!trackEvsePluggedBool) return false;
return trackEvsePluggedBool->getBool();
}

void Evse::setEvReady(bool ready) {
if (!trackEvReadyBool) return;
trackEvReadyBool->setBool(ready);
Expand Down
6 changes: 6 additions & 0 deletions src/evse.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class Evse {

std::shared_ptr<MicroOcpp::Configuration> trackEvPluggedBool;
std::string trackEvPluggedKey;
std::shared_ptr<MicroOcpp::Configuration> trackEvsePluggedBool;
std::string trackEvsePluggedKey;
std::shared_ptr<MicroOcpp::Configuration> trackEvReadyBool;
std::string trackEvReadyKey;
std::shared_ptr<MicroOcpp::Configuration> trackEvseReadyBool;
Expand All @@ -43,6 +45,10 @@ class Evse {

bool getEvPlugged();

void setEvsePlugged(bool plugged);

bool getEvsePlugged();

void setEvReady(bool ready);

bool getEvReady();
Expand Down
Loading