Skip to content

Commit

Permalink
Added bounds checking for ConnectorEvseIds and ISO15118EvseId (#903)
Browse files Browse the repository at this point in the history
Signed-off-by: Piet Gömpel <[email protected]>
  • Loading branch information
Pietfried authored Dec 10, 2024
1 parent 2f005e0 commit 21c83c9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
4 changes: 3 additions & 1 deletion config/v16/profile_schemas/Internal.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,9 @@
"ConnectorEvseIds": {
"$comment": "Comma separated EVSEIDs for OCPP connectors starting with connector 1 in one string.",
"type": "string",
"readOnly": false
"readOnly": false,
"minLength": 7,
"maxLength": 1000
},
"AllowChargingProfileWithoutStartSchedule": {
"$comment": "OCPP1.6 specifies that for certain ChargingProfiles the startSchedule field needs to be set. This flag ignores this requirement and will accept those profiles without startSchedule, assuming startSchedule is now.",
Expand Down
4 changes: 3 additions & 1 deletion config/v201/component_config/custom/EVSE_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@
"variable_name": "ISO15118EvseId",
"characteristics": {
"supportsMonitoring": true,
"dataType": "string"
"dataType": "string",
"minLimit": 7,
"maxLimit": 37
},
"attributes": [
{
Expand Down
4 changes: 3 additions & 1 deletion config/v201/component_config/custom/EVSE_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@
"variable_name": "ISO15118EvseId",
"characteristics": {
"supportsMonitoring": true,
"dataType": "string"
"dataType": "string",
"minLimit": 7,
"maxLimit": 37
},
"attributes": [
{
Expand Down
18 changes: 17 additions & 1 deletion lib/ocpp/v16/charge_point_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,18 @@ bool ChargePointConfiguration::validate_measurands(const json& config) {
return true;
}

bool validate_connector_evse_ids(const std::string& value) {
// this fullfills parts of HUB-24-003 of Requirements EVSE Check PnC with ISO15118-2 v4
const auto evse_ids = split_string(value, ',');
for (const auto& evse_id : evse_ids) {
if (evse_id.size() < 7 or evse_id.size() > 37) {
EVLOG_warning << "Attempting to set ConnectorEvseIds to invalid value: " << evse_id;
return false;
}
}
return true;
}

bool ChargePointConfiguration::measurands_supported(std::string csv) {

if (csv.empty()) {
Expand Down Expand Up @@ -3802,7 +3814,11 @@ ConfigurationStatus ChargePointConfiguration::set(CiString<50> key, CiString<500
}
if (key == "ConnectorEvseIds") {
if (this->getConnectorEvseIds().has_value()) {
this->setConnectorEvseIds(value.get());
if (validate_connector_evse_ids(value.get())) {
this->setConnectorEvseIds(value.get());
} else {
return ConfigurationStatus::Rejected;
}
} else {
return ConfigurationStatus::NotSupported;
}
Expand Down

0 comments on commit 21c83c9

Please sign in to comment.