Skip to content

Commit 84d3a3b

Browse files
committed
'Fix' some lint issues and clang format issues.
Signed-off-by: Maaike <maaike@iolar.nl>
1 parent 8c6089f commit 84d3a3b

File tree

6 files changed

+18
-83
lines changed

6 files changed

+18
-83
lines changed

include/ocpp/common/websocket/websocket_base.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ class WebsocketBase {
6060
websocketpp::connection_hdl handle;
6161
std::mutex reconnect_mutex;
6262
std::mutex connection_mutex;
63-
bool shutting_down;
6463

6564
/// \brief Indicates if the required callbacks are registered
6665
/// \returns true if the websocket is properly initialized

include/ocpp/v201/charge_point.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ class ChargePoint : ocpp::ChargingStationBase {
233233
UploadLogStatusEnum upload_log_status;
234234
int32_t upload_log_status_id;
235235
BootReasonEnum bootreason;
236-
uint32_t network_configuration_priority;
237236
bool skip_invalid_csms_certificate_notifications;
238237

239238
/// \brief Component responsible for maintaining and persisting the operational status of CS, EVSEs, and connectors.

include/ocpp/v201/connectivity_manager.hpp

+6-10
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@ class ConnectivityManager {
190190
///
191191
void set_websocket_connection_options(const WebsocketConnectionOptions& connection_options);
192192

193+
///
194+
/// \brief Get the active network configuration slot in use.
195+
/// \return The active slot the network is connected to or the pending slot.
196+
///
197+
int32_t get_active_network_configuration_slot() const;
198+
193199
private: // Functions
194200
// Disable copy constructor.
195201
ConnectivityManager(const ConnectivityManager&) = delete;
@@ -212,10 +218,6 @@ class ConnectivityManager {
212218
/// \brief Get next network slot for next priority.
213219
int32_t get_next_network_configuration_priority_slot(const int32_t configuration_slot);
214220

215-
/// @brief Removes all network connection profiles below the actual security profile and stores the new list in the
216-
/// device model
217-
void remove_network_connection_profiles_below_actual_security_profile();
218-
219221
///
220222
/// \brief Called when the websocket is connected.
221223
/// \param configuration_slot Configuration slot the websocket is connected to.
@@ -244,12 +246,6 @@ class ConnectivityManager {
244246
const std::optional<NetworkConnectionProfile> network_connection_profile,
245247
const WebsocketCloseReason reason);
246248

247-
///
248-
/// \brief Get the active network configuration slot in use.
249-
/// \return The active slot the network is connected to or the pending slot.
250-
///
251-
int32_t get_active_network_configuration_slot() const;
252-
253249
///
254250
/// \brief Get the priority of the given configuration slot.
255251
/// \param configuration_slot The configuration slot to get the priority from.

lib/ocpp/common/websocket/websocket_base.cpp

+1-8
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@
77
namespace ocpp {
88

99
WebsocketBase::WebsocketBase() :
10-
m_is_connected(false),
11-
connected_callback(nullptr),
12-
closed_callback(nullptr),
13-
message_callback(nullptr),
14-
shutting_down(false) {
10+
m_is_connected(false), connected_callback(nullptr), closed_callback(nullptr), message_callback(nullptr) {
1511

1612
set_connection_options_base(connection_options);
1713

@@ -72,9 +68,6 @@ void WebsocketBase::disconnect(WebsocketCloseReason code) {
7268
EVLOG_error << "Cannot disconnect a websocket that was not initialized";
7369
return;
7470
}
75-
if (code == WebsocketCloseReason::Normal) {
76-
this->shutting_down = true;
77-
}
7871
if (this->ping_timer) {
7972
this->ping_timer->stop();
8073
}

lib/ocpp/v201/charge_point.cpp

+5-12
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ ChargePoint::ChargePoint(const std::map<int32_t, int32_t>& evse_connector_struct
5959
const Callbacks& callbacks) :
6060
ocpp::ChargingStationBase(evse_security),
6161
registration_status(RegistrationStatusEnum::Rejected),
62-
network_configuration_priority(0),
6362
skip_invalid_csms_certificate_notifications(false),
6463
reset_scheduled(false),
6564
reset_scheduled_evseids{},
@@ -763,16 +762,6 @@ std::optional<NetworkConnectionProfile> ChargePoint::get_network_connection_prof
763762
return std::nullopt;
764763
}
765764

766-
void ChargePoint::next_network_configuration_priority() {
767-
const auto network_connection_priorities = ocpp::get_vector_from_csv(
768-
this->device_model->get_value<std::string>(ControllerComponentVariables::NetworkConfigurationPriority));
769-
if (network_connection_priorities.size() > 1) {
770-
EVLOG_info << "Switching to next network configuration priority";
771-
}
772-
this->network_configuration_priority =
773-
(this->network_configuration_priority + 1) % (network_connection_priorities.size());
774-
}
775-
776765
void ChargePoint::remove_network_connection_profiles_below_actual_security_profile() {
777766
// Remove all the profiles that are a lower security level than security_level
778767
const auto security_level = this->device_model->get_value<int>(ControllerComponentVariables::SecurityProfile);
@@ -1292,10 +1281,14 @@ void ChargePoint::handle_variable_changed(const SetVariableData& set_variable_da
12921281

12931282
if (component_variable_change_requires_websocket_option_update_without_reconnect(component_variable)) {
12941283
EVLOG_debug << "Reconfigure websocket due to relevant change of ControllerComponentVariable";
1284+
uint32_t active_slot = 0;
1285+
if (connectivity_manager != nullptr) {
1286+
active_slot = static_cast<uint32_t>(connectivity_manager->get_active_network_configuration_slot());
1287+
}
12951288
const auto configuration_slot =
12961289
ocpp::get_vector_from_csv(
12971290
this->device_model->get_value<std::string>(ControllerComponentVariables::NetworkConfigurationPriority))
1298-
.at(this->network_configuration_priority);
1291+
.at(active_slot);
12991292
const auto connection_options = this->get_ws_connection_options(std::stoi(configuration_slot));
13001293
if (connectivity_manager != nullptr) {
13011294
this->connectivity_manager->set_websocket_connection_options(connection_options);

lib/ocpp/v201/connectivity_manager.cpp

+6-51
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ void ConnectivityManager::set_websocket_connection_options(const WebsocketConnec
198198
}
199199
}
200200

201+
int32_t ConnectivityManager::get_active_network_configuration_slot() const {
202+
std::unique_lock<std::recursive_mutex> lock(this->config_slot_mutex);
203+
return (active_network_slot != 0 ? active_network_slot : pending_network_slot);
204+
}
205+
201206
void ConnectivityManager::run() {
202207
{
203208
std::unique_lock<std::mutex> lock(reconnect_mutex);
@@ -320,7 +325,7 @@ bool ConnectivityManager::init_websocket(std::optional<int32_t> config_slot) {
320325
}
321326
case std::future_status::ready: {
322327
ConfigNetworkResult result = config_status.get();
323-
if (result.success) {
328+
if (result.success && result.network_profile_slot == config_slot_int) {
324329
EVLOG_debug << "Config slot " << config_slot_int << " is configured, try to connect";
325330
connection_options.iface_or_ip = result.interface_address;
326331
this->pending_network_slot = config_slot_int;
@@ -461,51 +466,6 @@ int32_t ConnectivityManager::get_next_network_configuration_priority_slot(const
461466
return std::stoi(new_prio_string);
462467
}
463468

464-
void ConnectivityManager::remove_network_connection_profiles_below_actual_security_profile() {
465-
// Remove all the profiles that are a lower security level than security_level
466-
const auto security_level = this->device_model.get_value<int>(ControllerComponentVariables::SecurityProfile);
467-
468-
auto network_connection_profiles =
469-
json::parse(this->device_model.get_value<std::string>(ControllerComponentVariables::NetworkConnectionProfiles));
470-
471-
auto is_lower_security_level = [security_level](const SetNetworkProfileRequest& item) {
472-
return item.connectionData.securityProfile < security_level;
473-
};
474-
475-
network_connection_profiles.erase(
476-
std::remove_if(network_connection_profiles.begin(), network_connection_profiles.end(), is_lower_security_level),
477-
network_connection_profiles.end());
478-
479-
this->device_model.set_value(ControllerComponentVariables::NetworkConnectionProfiles.component,
480-
ControllerComponentVariables::NetworkConnectionProfiles.variable.value(),
481-
AttributeEnum::Actual, network_connection_profiles.dump());
482-
483-
// Update the NetworkConfigurationPriority so only remaining profiles are in there
484-
const auto network_priority = ocpp::get_vector_from_csv(
485-
this->device_model.get_value<std::string>(ControllerComponentVariables::NetworkConfigurationPriority));
486-
487-
auto in_network_profiles = [&network_connection_profiles](const std::string& item) {
488-
auto is_same_slot = [&item](const SetNetworkProfileRequest& profile) {
489-
return std::to_string(profile.configurationSlot) == item;
490-
};
491-
return std::any_of(network_connection_profiles.begin(), network_connection_profiles.end(), is_same_slot);
492-
};
493-
494-
std::string new_network_priority;
495-
for (const auto& item : network_priority) {
496-
if (in_network_profiles(item)) {
497-
if (!new_network_priority.empty()) {
498-
new_network_priority += ',';
499-
}
500-
new_network_priority += item;
501-
}
502-
}
503-
504-
this->device_model.set_value(ControllerComponentVariables::NetworkConfigurationPriority.component,
505-
ControllerComponentVariables::NetworkConfigurationPriority.variable.value(),
506-
AttributeEnum::Actual, new_network_priority);
507-
}
508-
509469
void ConnectivityManager::on_websocket_connected_callback(
510470
const int configuration_slot, const std::optional<NetworkConnectionProfile> network_connection_profile) {
511471
NetworkConnectionProfile profile;
@@ -589,11 +549,6 @@ void ConnectivityManager::on_websocket_failed_callback(
589549
reconnect(configuration_slot, false);
590550
}
591551

592-
int32_t ConnectivityManager::get_active_network_configuration_slot() const {
593-
std::unique_lock<std::recursive_mutex> lock(this->config_slot_mutex);
594-
return (active_network_slot != 0 ? active_network_slot : pending_network_slot);
595-
}
596-
597552
std::optional<int32_t> ConnectivityManager::get_configuration_slot_priority(const int32_t configuration_slot) {
598553
// Convert to string as a vector of strings is used.
599554
const std::string configuration_slot_string = std::to_string(configuration_slot);

0 commit comments

Comments
 (0)