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

YetiDriver: Fix events on start up #747

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion modules/EvseManager/EvseManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ void EvseManager::ready() {

// start with a limit of 0 amps. We will get a budget from EnergyManager that is locally limited by hw
// caps.
charger->set_max_current(0.0F, date::utc_clock::now() + std::chrono::seconds(10));
charger->set_max_current(0.0F, date::utc_clock::now() + std::chrono::seconds(120));
this->p_evse->publish_waiting_for_external_ready(config.external_ready_to_start_charging);
if (not config.external_ready_to_start_charging) {
// immediately ready, otherwise delay until we get the external signal
Expand Down
12 changes: 9 additions & 3 deletions modules/YetiDriver/board_support/evse_board_supportImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ void evse_board_supportImpl::init() {
mod->serial.signalCPState.connect([this](CpState cp_state) {
if (cp_state not_eq last_cp_state) {
auto event_cp_state = cast_event_type(cp_state);
EVLOG_info << "CP state changed: " << types::board_support_common::event_to_string(event_cp_state.event);
publish_event(event_cp_state);
EVLOG_info << "CP state changed: "
<< types::board_support_common::event_to_string(cast_event_type(last_cp_state).event) << " -> "
<< types::board_support_common::event_to_string(event_cp_state.event);
if (enabled) {
publish_event(event_cp_state);
}

if (cp_state == CpState_STATE_A) {
mod->clear_errors_on_unplug();
Expand Down Expand Up @@ -192,7 +196,9 @@ void evse_board_supportImpl::handle_evse_replug(int& value) {
}

void evse_board_supportImpl::handle_enable(bool& value) {
// Query CP state once and publish
enabled = true;
// Publish CP state once on enable
publish_event(cast_event_type(last_cp_state));
}

void evse_board_supportImpl::handle_setup(bool& three_phases, bool& has_ventilation, std::string& country_code) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ class evse_board_supportImpl : public evse_board_supportImplBase {
types::evse_board_support::HardwareCapabilities caps;
std::atomic_bool caps_received{false};
std::mutex capsMutex;
CpState last_cp_state{CpState::CpState_STATE_E};
CpState last_cp_state{CpState::CpState_STATE_F};
bool last_relais_state{false};
types::board_support_common::ProximityPilot last_pp{types::board_support_common::Ampacity::None};
void wait_for_caps();
std::atomic_bool enabled{false};
// ev@3370e4dd-95f4-47a9-aaec-ea76f34a66c9:v1
};

Expand Down
Loading