diff --git a/lib/ocpp/v201/charge_point.cpp b/lib/ocpp/v201/charge_point.cpp index 8fc4f5387..ec6afde3d 100644 --- a/lib/ocpp/v201/charge_point.cpp +++ b/lib/ocpp/v201/charge_point.cpp @@ -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(ControllerComponentVariables::SecurityProfile); + const auto network_connection_profiles = json::parse( + this->device_model->get_value(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; @@ -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(); } } }