batteryCheck: fix enabling circuit breaker still causing battery failsafes

Failing checks caused failsafe flags to stay true when enabling the circuit breaker but not rebooting.
Resetting the failsafe flags state when the circuit breaker is set resolves this issue.
This commit is contained in:
Matthias Grob 2024-11-19 18:13:28 +01:00
parent 3943025f32
commit 53d920ea33

View File

@ -75,6 +75,10 @@ static constexpr const char *battery_fault_reason_str(battery_fault_reason_t bat
void BatteryChecks::checkAndReport(const Context &context, Report &reporter)
{
if (circuit_breaker_enabled_by_val(_param_cbrk_supply_chk.get(), CBRK_SUPPLY_CHK_KEY)) {
// Reset related failsafe flags otherwise failures from before disabling the check cause failsafes without reported reason
reporter.failsafeFlags().battery_unhealthy = false;
reporter.failsafeFlags().battery_low_remaining_time = false;
reporter.failsafeFlags().battery_warning = battery_status_s::BATTERY_WARNING_NONE;
return;
}