Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added transmission of boot reason to OCPP module on start of OCPP service #517

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion modules/OCPP/OCPP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,31 @@ ocpp::SessionStartedReason get_session_started_reason(const types::evse_manager:
}
}

ocpp::v16::BootReasonEnum get_boot_reason(types::system::BootReason reason) {
switch (reason) {
case types::system::BootReason::ApplicationReset:
return ocpp::v16::BootReasonEnum::ApplicationReset;
case types::system::BootReason::FirmwareUpdate:
return ocpp::v16::BootReasonEnum::FirmwareUpdate;
case types::system::BootReason::LocalReset:
return ocpp::v16::BootReasonEnum::LocalReset;
case types::system::BootReason::PowerUp:
return ocpp::v16::BootReasonEnum::PowerUp;
case types::system::BootReason::RemoteReset:
return ocpp::v16::BootReasonEnum::RemoteReset;
case types::system::BootReason::ScheduledReset:
return ocpp::v16::BootReasonEnum::ScheduledReset;
case types::system::BootReason::Triggered:
return ocpp::v16::BootReasonEnum::Triggered;
case types::system::BootReason::Unknown:
return ocpp::v16::BootReasonEnum::Unknown;
case types::system::BootReason::Watchdog:
return ocpp::v16::BootReasonEnum::Watchdog;
default:
throw std::runtime_error("Could not convert BootReasonEnum");
}
}

void create_empty_user_config(const fs::path& user_config_path) {
if (fs::exists(user_config_path.parent_path())) {
std::ofstream fs(user_config_path.c_str());
Expand Down Expand Up @@ -778,7 +803,8 @@ void OCPP::ready() {
this->evse_ready_cv.wait(lk);
}

if (this->charge_point->start()) {
const auto boot_reason = get_boot_reason(this->r_system->call_get_boot_reason());
if (this->charge_point->start({}, boot_reason)) {
// signal that we're started
this->started = true;
EVLOG_info << "OCPP initialized";
Expand Down
Loading