Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added bounds checking for ConnectorEvseIds and ISO15118EvseId #903

Merged
merged 1 commit into from
Dec 10, 2024
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: 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shoudn't this also be 37 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its can be a comma seperated list, so Hubject specified this maxLength with 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