From d69c726c2207f3e8ca88451a05194f532d284068 Mon Sep 17 00:00:00 2001 From: Cornelius Claussen Date: Wed, 26 Jun 2024 08:44:33 +0200 Subject: [PATCH] YetiDriver: Fix events on start up Signed-off-by: Cornelius Claussen --- modules/EvseManager/EvseManager.cpp | 2 +- .../board_support/evse_board_supportImpl.cpp | 12 +++++++++--- .../board_support/evse_board_supportImpl.hpp | 3 ++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/modules/EvseManager/EvseManager.cpp b/modules/EvseManager/EvseManager.cpp index e9917ddc15..822c3c55e4 100644 --- a/modules/EvseManager/EvseManager.cpp +++ b/modules/EvseManager/EvseManager.cpp @@ -884,7 +884,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 diff --git a/modules/YetiDriver/board_support/evse_board_supportImpl.cpp b/modules/YetiDriver/board_support/evse_board_supportImpl.cpp index 143c6e9621..039c7a8f38 100644 --- a/modules/YetiDriver/board_support/evse_board_supportImpl.cpp +++ b/modules/YetiDriver/board_support/evse_board_supportImpl.cpp @@ -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(); @@ -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) { diff --git a/modules/YetiDriver/board_support/evse_board_supportImpl.hpp b/modules/YetiDriver/board_support/evse_board_supportImpl.hpp index 259cbdca12..ce1742f396 100644 --- a/modules/YetiDriver/board_support/evse_board_supportImpl.hpp +++ b/modules/YetiDriver/board_support/evse_board_supportImpl.hpp @@ -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 };