@@ -198,6 +198,11 @@ void ConnectivityManager::set_websocket_connection_options(const WebsocketConnec
198
198
}
199
199
}
200
200
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
+
201
206
void ConnectivityManager::run () {
202
207
{
203
208
std::unique_lock<std::mutex> lock (reconnect_mutex);
@@ -320,7 +325,7 @@ bool ConnectivityManager::init_websocket(std::optional<int32_t> config_slot) {
320
325
}
321
326
case std::future_status::ready: {
322
327
ConfigNetworkResult result = config_status.get ();
323
- if (result.success ) {
328
+ if (result.success && result. network_profile_slot == config_slot_int ) {
324
329
EVLOG_debug << " Config slot " << config_slot_int << " is configured, try to connect" ;
325
330
connection_options.iface_or_ip = result.interface_address ;
326
331
this ->pending_network_slot = config_slot_int;
@@ -461,51 +466,6 @@ int32_t ConnectivityManager::get_next_network_configuration_priority_slot(const
461
466
return std::stoi (new_prio_string);
462
467
}
463
468
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
-
509
469
void ConnectivityManager::on_websocket_connected_callback (
510
470
const int configuration_slot, const std::optional<NetworkConnectionProfile> network_connection_profile) {
511
471
NetworkConnectionProfile profile;
@@ -589,11 +549,6 @@ void ConnectivityManager::on_websocket_failed_callback(
589
549
reconnect (configuration_slot, false );
590
550
}
591
551
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
-
597
552
std::optional<int32_t > ConnectivityManager::get_configuration_slot_priority (const int32_t configuration_slot) {
598
553
// Convert to string as a vector of strings is used.
599
554
const std::string configuration_slot_string = std::to_string (configuration_slot);
0 commit comments