Skip to content

Commit

Permalink
Fixed an issue when setting the NetworkConfigurationPriority. During …
Browse files Browse the repository at this point in the history
…the validation, every entry of the new priority list was checked using the connectivity_managers cached slots. The slots of the connectivity manager are only initialized at startup. A new profile could have been send using a SetNetworkProfile.req by the CSMS at runtime, so when validating the NetworkConfigurationPriority we shall not use the cached connectivity_manager slots but the NetworkConnectionProfiles stored in the device model

Signed-off-by: Piet Gömpel <[email protected]>
  • Loading branch information
Pietfried committed Nov 13, 2024
1 parent af3d08e commit 6b7df42
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/ocpp/v201/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1855,16 +1855,22 @@ bool ChargePoint::validate_set_variable(const SetVariableData& set_variable_data
const auto network_configuration_priorities = ocpp::split_string(set_variable_data.attributeValue.get(), ',');
const auto active_security_profile =
this->device_model->get_value<int>(ControllerComponentVariables::SecurityProfile);
const auto network_connection_profiles = json::parse(
this->device_model->get_value<std::string>(ControllerComponentVariables::NetworkConnectionProfiles));
for (const auto configuration_slot : network_configuration_priorities) {
try {
auto network_profile_opt =
this->connectivity_manager->get_network_connection_profile(std::stoi(configuration_slot));
if (!network_profile_opt.has_value()) {
auto network_profile_it =
std::find_if(network_connection_profiles.begin(), network_connection_profiles.end(),
[configuration_slot](const SetNetworkProfileRequest& network_profile) {
return network_profile.configurationSlot == std::stoi(configuration_slot);
});

if (network_profile_it == network_connection_profiles.end()) {
EVLOG_warning << "Could not find network profile for configurationSlot: " << configuration_slot;
return false;
}

auto network_profile = network_profile_opt.value();
auto network_profile = SetNetworkProfileRequest(*network_profile_it).connectionData;

if (network_profile.securityProfile <= active_security_profile) {
continue;
Expand All @@ -1887,6 +1893,8 @@ bool ChargePoint::validate_set_variable(const SetVariableData& set_variable_data
} catch (const std::invalid_argument& e) {
EVLOG_warning << "NetworkConfigurationPriority is not an integer: " << configuration_slot;
return false;
} catch (const json::exception& e) {
EVLOG_warning << "Could not parse data of SetNetworkProfileRequest: " << e.what();
}
}
}
Expand Down

0 comments on commit 6b7df42

Please sign in to comment.