@@ -28,6 +28,7 @@ ChargePointImpl::ChargePointImpl(const std::string& config, const fs::path& shar
28
28
ocpp::ChargingStationBase(evse_security, security_configuration),
29
29
boot_notification_callerror(false ),
30
30
initialized(false ),
31
+ bootreason(BootReasonEnum::PowerUp),
31
32
connection_state(ChargePointConnectionState::Disconnected),
32
33
registration_status(RegistrationStatus::Pending),
33
34
diagnostics_status(DiagnosticsStatus::Idle),
@@ -790,7 +791,8 @@ void ChargePointImpl::send_meter_value(int32_t connector, MeterValue meter_value
790
791
this ->send <MeterValuesRequest>(call, initiated_by_trigger_message);
791
792
}
792
793
793
- bool ChargePointImpl::start (const std::map<int , ChargePointStatus>& connector_status_map) {
794
+ bool ChargePointImpl::start (const std::map<int , ChargePointStatus>& connector_status_map, BootReasonEnum bootreason) {
795
+ this ->bootreason = bootreason;
794
796
this ->init_state_machine (connector_status_map);
795
797
this ->init_websocket ();
796
798
this ->websocket ->connect ();
@@ -801,15 +803,15 @@ bool ChargePointImpl::start(const std::map<int, ChargePointStatus>& connector_st
801
803
return true ;
802
804
}
803
805
804
- bool ChargePointImpl::restart (const std::map<int , ChargePointStatus>& connector_status_map) {
806
+ bool ChargePointImpl::restart (const std::map<int , ChargePointStatus>& connector_status_map, BootReasonEnum bootreason ) {
805
807
if (this ->stopped ) {
806
808
EVLOG_info << " Restarting OCPP Chargepoint" ;
807
809
this ->database_handler ->open_db_connection (this ->configuration ->getNumberOfConnectors ());
808
810
// instantiating new message queue on restart
809
811
this ->message_queue = this ->create_message_queue ();
810
812
this ->initialized = true ;
811
813
812
- return this ->start (connector_status_map);
814
+ return this ->start (connector_status_map, bootreason );
813
815
} else {
814
816
EVLOG_warning << " Attempting to restart Chargepoint while it has not been stopped before" ;
815
817
return false ;
@@ -1014,6 +1016,7 @@ void ChargePointImpl::message_callback(const std::string& message) {
1014
1016
auto call_error = CallError (MessageId (json_message.at (MESSAGE_ID).get <std::string>()), " FormationViolation" ,
1015
1017
e.what (), json ({}, true ));
1016
1018
this ->send (call_error);
1019
+ this ->securityEventNotification (ocpp::security_events::INVALIDMESSAGES, message, true );
1017
1020
}
1018
1021
}
1019
1022
}
@@ -1183,7 +1186,9 @@ void ChargePointImpl::handleBootNotificationResponse(ocpp::CallResult<BootNotifi
1183
1186
ocpp::DateTime ());
1184
1187
}
1185
1188
1186
- this ->message_queue ->get_transaction_messages_from_db ();
1189
+ // push transaction messages including SecurityEventNotification.req onto the message queue
1190
+ this ->message_queue ->get_transaction_messages_from_db (
1191
+ this ->configuration ->getDisableSecurityEventNotifications ());
1187
1192
1188
1193
if (this ->is_pnc_enabled ()) {
1189
1194
this ->ocsp_request_timer ->timeout (INITIAL_CERTIFICATE_REQUESTS_DELAY);
@@ -1199,6 +1204,17 @@ void ChargePointImpl::handleBootNotificationResponse(ocpp::CallResult<BootNotifi
1199
1204
this ->ocsp_request_timer ->timeout (INITIAL_CERTIFICATE_REQUESTS_DELAY);
1200
1205
}
1201
1206
1207
+ if (this ->bootreason == BootReasonEnum::RemoteReset) {
1208
+ this ->securityEventNotification (CiString<50 >(ocpp::security_events::RESET_OR_REBOOT),
1209
+ " Charging Station rebooted due to requested remote reset!" , true );
1210
+ } else if (this ->bootreason == BootReasonEnum::ScheduledReset) {
1211
+ this ->securityEventNotification (CiString<50 >(ocpp::security_events::RESET_OR_REBOOT),
1212
+ " Charging Station rebooted due to a scheduled reset!" , true );
1213
+ } else if (this ->bootreason == BootReasonEnum::PowerUp) {
1214
+ this ->securityEventNotification (CiString<50 >(ocpp::security_events::STARTUP_OF_THE_DEVICE),
1215
+ " The Charge Point has booted" , true );
1216
+ }
1217
+
1202
1218
this ->stop_pending_transactions ();
1203
1219
1204
1220
break ;
@@ -2230,7 +2246,7 @@ void ChargePointImpl::handleCertificateSignedRequest(ocpp::Call<CertificateSigne
2230
2246
this ->send <CertificateSignedResponse>(call_result);
2231
2247
2232
2248
if (response.status == CertificateSignedStatusEnumType::Rejected) {
2233
- this ->securityEventNotification (" InvalidChargePointCertificate " ,
2249
+ this ->securityEventNotification (ocpp::security_events::INVALIDCHARGEPOINTCERTIFICATE ,
2234
2250
ocpp::conversions::install_certificate_result_to_string (result), true );
2235
2251
}
2236
2252
@@ -2313,7 +2329,7 @@ void ChargePointImpl::handleInstallCertificateRequest(ocpp::Call<InstallCertific
2313
2329
this ->send <InstallCertificateResponse>(call_result);
2314
2330
2315
2331
if (response.status == InstallCertificateStatusEnumType::Rejected) {
2316
- this ->securityEventNotification (" InvalidCentralSystemCertificate " ,
2332
+ this ->securityEventNotification (ocpp::security_events::INVALIDCSMSCERTIFICATE ,
2317
2333
ocpp::conversions::install_certificate_result_to_string (result), true );
2318
2334
}
2319
2335
}
@@ -2349,7 +2365,8 @@ void ChargePointImpl::handleSignedUpdateFirmware(ocpp::Call<SignedUpdateFirmware
2349
2365
}
2350
2366
2351
2367
if (response.status == UpdateFirmwareStatusEnumType::InvalidCertificate) {
2352
- this ->securityEventNotification (" InvalidFirmwareSigningCertificate" , " Certificate is invalid." , true );
2368
+ this ->securityEventNotification (ocpp::security_events::INVALIDFIRMWARESIGNINGCERTIFICATE,
2369
+ " Certificate is invalid." , true );
2353
2370
}
2354
2371
}
2355
2372
@@ -2363,8 +2380,10 @@ void ChargePointImpl::securityEventNotification(const std::string& type, const s
2363
2380
2364
2381
this ->logging ->security (json (req).dump ());
2365
2382
2366
- ocpp::Call<SecurityEventNotificationRequest> call (req, this ->message_queue ->createMessageId ());
2367
- this ->send <SecurityEventNotificationRequest>(call);
2383
+ if (!this ->configuration ->getDisableSecurityEventNotifications ()) {
2384
+ ocpp::Call<SecurityEventNotificationRequest> call (req, this ->message_queue ->createMessageId ());
2385
+ this ->send <SecurityEventNotificationRequest>(call);
2386
+ }
2368
2387
2369
2388
if (triggered_internally and this ->security_event_callback != nullptr ) {
2370
2389
this ->security_event_callback (type, tech_info);
@@ -2414,7 +2433,7 @@ void ChargePointImpl::signed_firmware_update_status_notification(FirmwareStatusE
2414
2433
this ->send <SignedFirmwareStatusNotificationRequest>(call, initiated_by_trigger_message);
2415
2434
2416
2435
if (status == FirmwareStatusEnumType::InvalidSignature) {
2417
- this ->securityEventNotification (" InvalidFirmwareSignature " , " " , true );
2436
+ this ->securityEventNotification (ocpp::security_events::INVALIDFIRMWARESIGNATURE , " " , true );
2418
2437
}
2419
2438
2420
2439
if (this ->firmware_update_is_pending ) {
@@ -2958,7 +2977,7 @@ void ChargePointImpl::handle_data_transfer_pnc_certificate_signed(Call<DataTrans
2958
2977
this ->send <DataTransferResponse>(call_result);
2959
2978
2960
2979
if (certificate_response.status == CertificateSignedStatusEnumType::Rejected) {
2961
- this ->securityEventNotification (" InvalidChargePointCertificate " , tech_info, true );
2980
+ this ->securityEventNotification (ocpp::security_events::INVALIDCHARGEPOINTCERTIFICATE , tech_info, true );
2962
2981
}
2963
2982
} catch (const json::exception & e) {
2964
2983
EVLOG_warning << " Could not parse data of DataTransfer message CertificateSigned.req: " << e.what ();
@@ -3425,6 +3444,10 @@ void ChargePointImpl::on_firmware_update_status_notification(int32_t request_id,
3425
3444
} catch (const std::out_of_range& e) {
3426
3445
EVLOG_debug << " Could not convert incoming FirmwareStatusNotification to OCPP type" ;
3427
3446
}
3447
+
3448
+ if (firmware_update_status == FirmwareStatusNotification::Installed) {
3449
+ this ->securityEventNotification (ocpp::security_events::FIRMWARE_UPDATED, " Firmware update was installed" , true );
3450
+ }
3428
3451
}
3429
3452
3430
3453
void ChargePointImpl::diagnostic_status_notification (DiagnosticsStatus status) {
0 commit comments