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 @@ -7,6 +7,7 @@
- Allow `nullptr` as parameter for `mocpp_set_console_out` ([#224](https://github.com/matth-x/MicroOcpp/issues/224))
- Fix `mocpp_tick_ms()` on esp-idf roll-over after 12 hours
- Pin ArduinoJson to v6.21 ([#245](https://github.com/matth-x/MicroOcpp/issues/245))
- Fix bounds checking in SmartCharging module ([#260](https://github.com/matth-x/MicroOcpp/pull/260))

## [1.0.0] - 2023-10-22

Expand Down
5 changes: 5 additions & 0 deletions src/MicroOcpp/Model/SmartCharging/SmartChargingModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,11 @@ bool MicroOcpp::loadChargingSchedule(JsonObject& json, ChargingSchedule& out) {
return false;
}

if (periodJsonArray.size() > CHARGINGSCHEDULEMAXPERIODS) {
MO_DBG_WARN("exceed ChargingScheduleMaxPeriods");
return false;
}

for (JsonObject periodJson : periodJsonArray) {
out.chargingSchedulePeriod.push_back(ChargingSchedulePeriod());
if (!loadChargingSchedulePeriod(periodJson, out.chargingSchedulePeriod.back())) {
Expand Down
4 changes: 2 additions & 2 deletions src/MicroOcpp/Model/SmartCharging/SmartChargingService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,10 @@ std::unique_ptr<ChargingSchedule> SmartChargingConnector::getCompositeSchedule(i
size_t SmartChargingConnector::getChargingProfilesCount() {
size_t chargingProfilesCount = 0;
for (size_t i = 0; i < CHARGEPROFILEMAXSTACKLEVEL + 1; i++) {
if (ChargePointTxDefaultProfile[i]) {
if (TxDefaultProfile[i]) {
chargingProfilesCount++;
}
if (ChargePointMaxProfile[i]) {
if (TxProfile[i]) {
chargingProfilesCount++;
}
}
Expand Down
11 changes: 10 additions & 1 deletion src/MicroOcpp/Operations/SetChargingProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,21 @@ void SetChargingProfile::processReq(JsonObject payload) {
errorCode = "PropertyConstraintViolation";
return;
}
if (!connector->getTransaction() || !connector->getTransaction()->isRunning()) {

auto& transaction = connector->getTransaction();
if (!transaction || !connector->getTransaction()->isRunning()) {
//no transaction running, reject profile
accepted = false;
return;
}

if (chargingProfile->getTransactionId() < 0 ||
chargingProfile->getTransactionId() != transaction->getTransactionId()) {
//transactionId undefined / mismatch
accepted = false;
return;
}

//seems good
} else if (chargingProfile->getChargingProfilePurpose() == ChargingProfilePurposeType::ChargePointMaxProfile) {
if (connectorId > 0) {
Expand Down