11
11
12
12
#include < stdexcept>
13
13
#include < string>
14
- #include < future>
15
14
using namespace std ::chrono_literals;
16
15
17
16
const auto DEFAULT_MAX_CUSTOMER_INFORMATION_DATA_LENGTH = 51200 ;
@@ -30,16 +29,17 @@ bool Callbacks::all_callbacks_valid() const {
30
29
// this->connector_effective_operative_status_changed_callback != nullptr and
31
30
this ->get_log_request_callback != nullptr and this ->unlock_connector_callback != nullptr and
32
31
this ->remote_start_transaction_callback != nullptr and this ->is_reservation_for_token_callback != nullptr and
33
- this ->update_firmware_request_callback != nullptr and this ->websocket_connected_callback != nullptr and
34
- this ->websocket_disconnected_callback != nullptr and
32
+ this ->update_firmware_request_callback != nullptr and
35
33
(!this ->variable_changed_callback .has_value () or this ->variable_changed_callback .value () != nullptr ) and
36
34
(!this ->validate_network_profile_callback .has_value () or
37
35
this ->validate_network_profile_callback .value () != nullptr ) and
38
36
(!this ->configure_network_connection_profile_callback .has_value () or
39
37
this ->configure_network_connection_profile_callback .value () != nullptr ) and
40
38
(!this ->time_sync_callback .has_value () or this ->time_sync_callback .value () != nullptr ) and
41
39
(!this ->boot_notification_callback .has_value () or this ->boot_notification_callback .value () != nullptr ) and
42
- (!this ->ocpp_messages_callback .has_value () or this ->ocpp_messages_callback .value () != nullptr );
40
+ (!this ->ocpp_messages_callback .has_value () or this ->ocpp_messages_callback .value () != nullptr ) and
41
+ (!this ->websocket_connected_callback .has_value () or this ->websocket_connected_callback != nullptr ) and
42
+ (!this ->websocket_disconnected_callback .has_value () or this ->websocket_disconnected_callback != nullptr );
43
43
}
44
44
45
45
ChargePoint::ChargePoint (const std::map<int32_t , int32_t >& evse_connector_structure,
@@ -697,8 +697,11 @@ void ChargePoint::init_websocket() {
697
697
AttributeEnum::Actual, std::to_string (security_profile));
698
698
}
699
699
700
- // call the registered websocket connected callback
701
- this ->callbacks .websocket_connected_callback (network_connection_profile);
700
+ // call the registered websocket connected callback if it exists
701
+ if (this ->callbacks .websocket_connected_callback .has_value ())
702
+ {
703
+ this ->callbacks .websocket_connected_callback .value ()(network_connection_profile);
704
+ }
702
705
703
706
if (this ->registration_status == RegistrationStatusEnum::Accepted and
704
707
this ->time_disconnected .time_since_epoch () != 0s) {
@@ -732,7 +735,11 @@ void ChargePoint::init_websocket() {
732
735
// Get the current time point using steady_clock
733
736
this ->time_disconnected = std::chrono::steady_clock::now ();
734
737
}
735
- this ->callbacks .websocket_disconnected_callback ();
738
+ // call the disconnected callback if it exists
739
+ if (this ->callbacks .websocket_disconnected_callback .has_value ())
740
+ {
741
+ this ->callbacks .websocket_disconnected_callback .value ();
742
+ }
736
743
this ->client_certificate_expiration_check_timer .stop ();
737
744
this ->v2g_certificate_expiration_check_timer .stop ();
738
745
});
0 commit comments