@@ -648,9 +648,6 @@ bool ChargePoint::send(CallError call_error) {
648
648
}
649
649
650
650
void ChargePoint::init_websocket () {
651
-
652
- std::promise<int > network_promise;
653
-
654
651
if (this ->device_model ->get_value <std::string>(ControllerComponentVariables::ChargePointId).find (' :' ) !=
655
652
std::string::npos) {
656
653
EVLOG_AND_THROW (std::runtime_error (" ChargePointId must not contain \' :\' " ));
@@ -663,10 +660,28 @@ void ChargePoint::init_websocket() {
663
660
const auto connection_options = this ->get_ws_connection_options (std::stoi (configuration_slot));
664
661
const auto network_connection_profile = this ->get_network_connection_profile (std::stoi (configuration_slot));
665
662
666
- if (!network_connection_profile.has_value () or
667
- (this ->callbacks .configure_network_connection_profile_callback .has_value () and
668
- !this ->callbacks .configure_network_connection_profile_callback .value ()(network_connection_profile.value (),
669
- network_promise))) {
663
+ if (this ->callbacks .configure_network_connection_profile_callback .has_value () and network_connection_profile) {
664
+ auto config_status = this ->callbacks .configure_network_connection_profile_callback .value ()(
665
+ network_connection_profile.value ()); /* */
666
+
667
+ if (config_status.wait_for (5s) == std::future_status::timeout) {
668
+ EVLOG_info << " timeout!!!" ;
669
+ EVLOG_warning
670
+ << " NetworkConnectionProfile could not be retrieved or configuration of network with the given "
671
+ " profile failed" ;
672
+ this ->websocket_timer .timeout (
673
+ [this ]() {
674
+ this ->next_network_configuration_priority ();
675
+ this ->start_websocket ();
676
+ },
677
+ WEBSOCKET_INIT_DELAY);
678
+ return ;
679
+ } else if (config_status.wait_for (5s) == std::future_status::timeout) {
680
+ ; // do nothing?
681
+ } else {
682
+ EVLOG_info << " config status -------> : " << config_status.get ().success ;
683
+ }
684
+ } else {
670
685
EVLOG_warning << " NetworkConnectionProfile could not be retrieved or configuration of network with the given "
671
686
" profile failed" ;
672
687
this ->websocket_timer .timeout (
@@ -677,9 +692,6 @@ void ChargePoint::init_websocket() {
677
692
WEBSOCKET_INIT_DELAY);
678
693
return ;
679
694
}
680
-
681
- EVLOG_info << " connection profile value: -> " << network_promise.get_future ().get ();
682
-
683
695
const auto & security_profile_cv = ControllerComponentVariables::SecurityProfile;
684
696
if (security_profile_cv.variable .has_value ()) {
685
697
this ->device_model ->set_read_only_value (security_profile_cv.component , security_profile_cv.variable .value (),
@@ -698,8 +710,7 @@ void ChargePoint::init_websocket() {
698
710
}
699
711
700
712
// call the registered websocket connected callback if it exists
701
- if (this ->callbacks .websocket_connected_callback .has_value ())
702
- {
713
+ if (this ->callbacks .websocket_connected_callback .has_value ()) {
703
714
this ->callbacks .websocket_connected_callback .value ()(network_connection_profile);
704
715
}
705
716
@@ -735,9 +746,8 @@ void ChargePoint::init_websocket() {
735
746
// Get the current time point using steady_clock
736
747
this ->time_disconnected = std::chrono::steady_clock::now ();
737
748
}
738
- // call the disconnected callback if it exists
739
- if (this ->callbacks .websocket_disconnected_callback .has_value ())
740
- {
749
+ // call the disconnected callback if it exists
750
+ if (this ->callbacks .websocket_disconnected_callback .has_value ()) {
741
751
this ->callbacks .websocket_disconnected_callback .value ();
742
752
}
743
753
this ->client_certificate_expiration_check_timer .stop ();
0 commit comments