OTA battery check

This commit is contained in:
Klaus K Wilting 2018-11-05 21:40:07 +01:00
parent 8ae5b6e970
commit b0fa5e9021
3 changed files with 11 additions and 10 deletions

View File

@ -50,8 +50,13 @@ uint16_t read_voltage() {
}
bool batt_sufficient() {
#ifdef HAS_BATTERY_PROBE
uint16_t volts = read_voltage();
return (( volts < 1000 ) || (volts > OTA_MIN_BATT)); // no battery or battery sufficient
return ((volts < 1000) ||
(volts > OTA_MIN_BATT)); // no battery or battery sufficient
#else
return true;
#endif
}
#endif // HAS_BATTERY_PROBE

View File

@ -40,15 +40,11 @@ inline String getHeaderValue(String header, String headerName) {
void start_ota_update() {
/*
// check battery status if we can before doing ota
#ifdef HAS_BATTERY_PROBE
if (!batt_sufficient()) {
ESP_LOGW(TAG, "Battery voltage %dmV too low for OTA", batt_voltage);
ESP_LOGE(TAG, "Battery voltage %dmV too low for OTA", batt_voltage);
return;
}
#endif
*/
switch_LED(LED_ON);

View File

@ -69,7 +69,7 @@
#define USE_OTA 1 // Comment out to disable OTA update
#define WIFI_MAX_TRY 5 // maximum number of wifi connect attempts for OTA update [default = 20]
#define OTA_MAX_TRY 5 // maximum number of attempts for OTA download and write to flash [default = 3]
#define OTA_MIN_BATT 3700 // minimum battery level for OTA [millivolt]
#define OTA_MIN_BATT 3600 // minimum battery level for OTA [millivolt]
#define RESPONSE_TIMEOUT_MS 60000 // firmware binary server connection timeout [milliseconds]
// LMIC settings