status_led(green_only);
while (1) {
- /* Feed the dog */
- if ((solar_prod_value != 0) && (home_conso_value != 0) && (water_centi_degrees < ABSOLUTE_MAX_WATER_TEMP)) {
+ /* Feed the dog if sensor values are relevant */
+ int allow_wd_feed = 1;
+ if ((solar_prod_value == 0) || (home_conso_value == 0)) {
+ allow_wd_feed = 0;
+ }
+ if ((water_centi_degrees < 0) || (water_centi_degrees > (ABSOLUTE_MAX_WATER_TEMP + 200))) {
+ allow_wd_feed = 0;
+ }
+ /* Blocked in overvoltage mode */
+ if ((mode == mode_overvoltage) && (overvoltage == 0)) {
+ allow_wd_feed = 0;
+ }
+ /* Blocked in overtemperature mode */
+ if (mode == mode_overtemp) {
+ if ((mosfet_temp_shutdown == 0) && (internal_temp_error_shutdown >= 0)) {
+ allow_wd_feed = 0;
+ }
+ }
+ /* Blocked in water critical temperature mode */
+ if (mode == mode_water_critical) {
+ if (water_centi_degrees < ABSOLUTE_MAX_WATER_TEMP) {
+ allow_wd_feed = 0;
+ }
+ }
+ /* Otherwise, feed the dog */
+ if (allow_wd_feed == 1) {
watchdog_feed();
}