Skip to content

Commit 5416829

Browse files
authored
Fixed bug setting NetworkConfigurationPriority (#866)
* Fixed an issue when setting the NetworkConfigurationPriority. During 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 <pietgoempel@gmail.com>
1 parent d042629 commit 5416829

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

lib/ocpp/v201/charge_point.cpp

+20-9
Original file line numberDiff line numberDiff line change
@@ -1855,16 +1855,23 @@ bool ChargePoint::validate_set_variable(const SetVariableData& set_variable_data
18551855
const auto network_configuration_priorities = ocpp::split_string(set_variable_data.attributeValue.get(), ',');
18561856
const auto active_security_profile =
18571857
this->device_model->get_value<int>(ControllerComponentVariables::SecurityProfile);
1858-
for (const auto configuration_slot : network_configuration_priorities) {
1859-
try {
1860-
auto network_profile_opt =
1861-
this->connectivity_manager->get_network_connection_profile(std::stoi(configuration_slot));
1862-
if (!network_profile_opt.has_value()) {
1858+
1859+
try {
1860+
const auto network_connection_profiles = json::parse(
1861+
this->device_model->get_value<std::string>(ControllerComponentVariables::NetworkConnectionProfiles));
1862+
for (const auto configuration_slot : network_configuration_priorities) {
1863+
auto network_profile_it =
1864+
std::find_if(network_connection_profiles.begin(), network_connection_profiles.end(),
1865+
[configuration_slot](const SetNetworkProfileRequest& network_profile) {
1866+
return network_profile.configurationSlot == std::stoi(configuration_slot);
1867+
});
1868+
1869+
if (network_profile_it == network_connection_profiles.end()) {
18631870
EVLOG_warning << "Could not find network profile for configurationSlot: " << configuration_slot;
18641871
return false;
18651872
}
18661873

1867-
auto network_profile = network_profile_opt.value();
1874+
auto network_profile = SetNetworkProfileRequest(*network_profile_it).connectionData;
18681875

18691876
if (network_profile.securityProfile <= active_security_profile) {
18701877
continue;
@@ -1884,10 +1891,14 @@ bool ChargePoint::validate_set_variable(const SetVariableData& set_variable_data
18841891
<< " is >= 2 but no CSMS Root Certifciate is installed";
18851892
return false;
18861893
}
1887-
} catch (const std::invalid_argument& e) {
1888-
EVLOG_warning << "NetworkConfigurationPriority is not an integer: " << configuration_slot;
1889-
return false;
18901894
}
1895+
} catch (const std::invalid_argument& e) {
1896+
EVLOG_warning << "NetworkConfigurationPriority contains at least one value which is not an integer: "
1897+
<< set_variable_data.attributeValue.get();
1898+
return false;
1899+
} catch (const json::exception& e) {
1900+
EVLOG_warning << "Could not parse NetworkConnectionProfiles or SetNetworkProfileRequest: " << e.what();
1901+
return false;
18911902
}
18921903
}
18931904
return true;

0 commit comments

Comments
 (0)