diff --git a/src/battery.cpp b/src/battery.cpp index 11371748..0e894965 100644 --- a/src/battery.cpp +++ b/src/battery.cpp @@ -49,4 +49,9 @@ uint16_t read_voltage() { return voltage; } +bool batt_sufficient() { + uint16_t volts = read_voltage(); + return (( volts < 1000 ) || (volts > OTA_MIN_BATT)); // no battery or battery sufficient +} + #endif // HAS_BATTERY_PROBE \ No newline at end of file diff --git a/src/battery.h b/src/battery.h index 93696fb5..b4a83676 100644 --- a/src/battery.h +++ b/src/battery.h @@ -9,5 +9,6 @@ uint16_t read_voltage(void); void calibrate_voltage(void); +bool batt_sufficient(void); #endif diff --git a/src/ota.cpp b/src/ota.cpp index 15ef87b5..ece73e28 100644 --- a/src/ota.cpp +++ b/src/ota.cpp @@ -45,7 +45,7 @@ void start_ota_update() { // check battery status if we can before doing ota #ifdef HAS_BATTERY_PROBE - if (batt_voltage < OTA_MIN_BATT) { + if (!batt_sufficient()) { ESP_LOGW(TAG, "Battery voltage %dmV too low for OTA", batt_voltage); return; } diff --git a/src/ota.h b/src/ota.h index 59c1e464..135591ea 100644 --- a/src/ota.h +++ b/src/ota.h @@ -5,6 +5,7 @@ #include "globals.h" #include "update.h" +#include "battery.h" #include #include #include