diff --git a/lib/ocpp/v201/charge_point.cpp b/lib/ocpp/v201/charge_point.cpp index 62f9d8bf6..6c1402787 100644 --- a/lib/ocpp/v201/charge_point.cpp +++ b/lib/ocpp/v201/charge_point.cpp @@ -180,8 +180,9 @@ void ChargePoint::start(BootReasonEnum bootreason) { // Should be done before sending the BootNotification.req so that the correct states can be reported this->component_state_manager->trigger_all_effective_availability_changed_callbacks(); this->boot_notification_req(bootreason); + // get transaction messages from db (if there are any) so they can be sent again. + this->message_queue->get_transaction_messages_from_db(); this->start_websocket(); - // FIXME(piet): Run state machine with correct initial state if (this->bootreason == BootReasonEnum::RemoteReset) { this->security_event_notification_req( @@ -191,12 +192,18 @@ void ChargePoint::start(BootReasonEnum bootreason) { this->security_event_notification_req( CiString<50>(ocpp::security_events::RESET_OR_REBOOT), std::optional>("Charging Station rebooted due to a scheduled reset!"), true, true); - } else { + } else if (this->bootreason == BootReasonEnum::PowerUp) { std::string startup_message = "Charging Station powered up! Firmware version: "; startup_message.append( this->device_model->get_value(ControllerComponentVariables::FirmwareVersion)); this->security_event_notification_req(CiString<50>(ocpp::security_events::STARTUP_OF_THE_DEVICE), std::optional>(startup_message), true, true); + } else { + std::string startup_message = "Charging station reset or reboot. Firmware version: "; + startup_message.append( + this->device_model->get_value(ControllerComponentVariables::FirmwareVersion)); + this->security_event_notification_req(CiString<50>(ocpp::security_events::RESET_OR_REBOOT), + std::optional>(startup_message), true, true); } } @@ -2141,9 +2148,6 @@ void ChargePoint::handle_boot_notification_response(CallResultremove_network_connection_profiles_below_actual_security_profile(); - // get transaction messages from db (if there are any) so they can be sent again. - message_queue->get_transaction_messages_from_db(); - // set timers if (msg.interval > 0) { this->heartbeat_timer.interval([this]() { this->heartbeat_req(); }, std::chrono::seconds(msg.interval)); @@ -2152,28 +2156,6 @@ void ChargePoint::handle_boot_notification_response(CallResultupdate_aligned_data_interval(); this->component_state_manager->send_status_notification_all_connectors(); this->ocsp_updater.start(); - - if (this->bootreason == BootReasonEnum::RemoteReset) { - this->security_event_notification_req( - CiString<50>(ocpp::security_events::RESET_OR_REBOOT), - std::optional>("Charging Station rebooted due to requested remote reset!"), true, true); - } else if (this->bootreason == BootReasonEnum::ScheduledReset) { - this->security_event_notification_req( - CiString<50>(ocpp::security_events::RESET_OR_REBOOT), - std::optional>("Charging Station rebooted due to a scheduled reset!"), true, true); - } else if (this->bootreason == BootReasonEnum::PowerUp) { - std::string startup_message = "Charging Station powered up! Firmware version: "; - startup_message.append( - this->device_model->get_value(ControllerComponentVariables::FirmwareVersion)); - this->security_event_notification_req(CiString<50>(ocpp::security_events::STARTUP_OF_THE_DEVICE), - std::optional>(startup_message), true, true); - } else { - std::string startup_message = "Charging station reset or reboot. Firmware version: "; - startup_message.append( - this->device_model->get_value(ControllerComponentVariables::FirmwareVersion)); - this->security_event_notification_req(CiString<50>(ocpp::security_events::RESET_OR_REBOOT), - std::optional>(startup_message), true, true); - } } else { auto retry_interval = DEFAULT_BOOT_NOTIFICATION_RETRY_INTERVAL; if (msg.interval > 0) {