Skip to content

Commit 9f6d312

Browse files
committed
Fix bug with creating a ComponentVariable with variable as std::nullopt instead of customData.
Signed-off-by: Maaike Zijderveld, iolar <git.mail@iolar.nl>
1 parent 31c84cf commit 9f6d312

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

include/ocpp/v201/ctrlr_component_variables.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#ifndef OCPP_V201_CTRLR_COMPONENT_VARIABLES
55
#define OCPP_V201_CTRLR_COMPONENT_VARIABLES
66

7+
#include <set>
8+
79
#include <ocpp/v201/ocpp_types.hpp>
810

911
namespace ocpp {

include/ocpp/v201/ocpp_types.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#ifndef OCPP_V201_OCPP_TYPES_HPP
66
#define OCPP_V201_OCPP_TYPES_HPP
77

8-
#include <set>
98
#include <string>
109

1110
#include <nlohmann/json_fwd.hpp>

lib/ocpp/v201/functional_blocks/provisioning.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ void Provisioning::handle_set_network_profile_req(Call<SetNetworkProfileRequest>
389389

390390
int index_to_override = -1;
391391
int index = 0;
392-
for (const SetNetworkProfileRequest network_profile : network_connection_profiles) {
392+
for (const SetNetworkProfileRequest& network_profile : network_connection_profiles) {
393393
if (network_profile.configurationSlot == msg.configurationSlot) {
394394
index_to_override = index;
395395
}
@@ -515,7 +515,7 @@ void Provisioning::handle_reset_req(Call<ResetRequest> call) {
515515
}
516516

517517
void Provisioning::handle_variable_changed(const SetVariableData& set_variable_data) {
518-
ComponentVariable component_variable = {set_variable_data.component, std::nullopt, set_variable_data.variable};
518+
ComponentVariable component_variable = {set_variable_data.component, set_variable_data.variable, std::nullopt};
519519

520520
if (set_variable_data.attributeType.has_value() and
521521
set_variable_data.attributeType.value() != AttributeEnum::Actual) {
@@ -602,7 +602,7 @@ void Provisioning::handle_variables_changed(const std::map<SetVariableData, SetV
602602
}
603603

604604
bool Provisioning::validate_set_variable(const SetVariableData& set_variable_data) {
605-
ComponentVariable cv = {set_variable_data.component, std::nullopt, set_variable_data.variable};
605+
ComponentVariable cv = {set_variable_data.component, set_variable_data.variable, std::nullopt};
606606
if (cv == ControllerComponentVariables::NetworkConfigurationPriority) {
607607
const auto network_configuration_priorities = ocpp::split_string(set_variable_data.attributeValue.get(), ',');
608608
const auto active_security_profile =
@@ -611,7 +611,7 @@ bool Provisioning::validate_set_variable(const SetVariableData& set_variable_dat
611611
try {
612612
const auto network_connection_profiles = json::parse(
613613
this->device_model.get_value<std::string>(ControllerComponentVariables::NetworkConnectionProfiles));
614-
for (const auto configuration_slot : network_configuration_priorities) {
614+
for (const auto& configuration_slot : network_configuration_priorities) {
615615
auto network_profile_it =
616616
std::find_if(network_connection_profiles.begin(), network_connection_profiles.end(),
617617
[configuration_slot](const SetNetworkProfileRequest& network_profile) {

src/code_generator/common/templates/ocpp_types.hpp.jinja

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct {{type.name}} {
4343
/// \brief Conversion from a given json object \p j to a given {{ type.name }} \p k
4444
void from_json(const json& j, {{ type.name }}& k);
4545

46-
// \brief Writes the string representation of the given {{ type.name }} \p k to the given output stream \p os
46+
/// \brief Writes the string representation of the given {{ type.name }} \p k to the given output stream \p os
4747
/// \returns an output stream with the {{ type.name }} written to
4848
std::ostream& operator<<(std::ostream& os, const {{ type.name }}& k);
4949

0 commit comments

Comments
 (0)