battery check before ota

This commit is contained in:
Klaus K Wilting 2018-09-23 18:45:46 +02:00
parent 25d307e820
commit d4d6a7ea07
2 changed files with 11 additions and 3 deletions

View File

@ -42,6 +42,14 @@ 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_voltage < OTA_MIN_BATT) {
ESP_LOGW(TAG, "Battery voltage %dmV too low for OTA", batt_voltage);
return;
}
#endif
// turn on LED
#if (HAS_LED != NOT_A_PIN)
#ifdef LED_ACTIVE_LOW
@ -107,7 +115,6 @@ void start_ota_update() {
} // start_ota_update
void do_ota_update() {
char buf[17];
@ -130,7 +137,7 @@ void do_ota_update() {
ESP_LOGI(TAG, "New firmware version v%s available. Downloading...",
latest.c_str());
display(2, "OK", latest.c_str());
display(3, "**", "");
String firmwarePath = bintray.getBinaryPath(latest);
if (!firmwarePath.endsWith(".bin")) {
@ -319,7 +326,7 @@ void display(const uint8_t row, std::string status, std::string msg) {
// callback function to show download progress while streaming data
void show_progress(size_t current, size_t size) {
char buf[17];
snprintf(buf, 17, "%-9lu (%3lu%%)", current, current*100 / size);
snprintf(buf, 17, "%-9lu (%3lu%%)", current, current * 100 / size);
display(4, "**", buf);
}

View File

@ -68,6 +68,7 @@
// OTA settings
#define WIFI_MAX_TRY 20 // maximum number of wifi connect attempts for OTA update [default = 20]
#define FLASH_MAX_TRY 3 // maximum number of attempts for writing update binary to flash [default = 3]
#define OTA_MIN_BATT 3700 // minimum battery level vor OTA [millivolt]
// LMIC settings
// define hardware independent LMIC settings here, settings of standard library in /lmic/config.h will be ignored