battery check before ota
This commit is contained in:
parent
25d307e820
commit
d4d6a7ea07
11
src/ota.cpp
11
src/ota.cpp
@ -42,6 +42,14 @@ inline String getHeaderValue(String header, String headerName) {
|
|||||||
|
|
||||||
void start_ota_update() {
|
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
|
// turn on LED
|
||||||
#if (HAS_LED != NOT_A_PIN)
|
#if (HAS_LED != NOT_A_PIN)
|
||||||
#ifdef LED_ACTIVE_LOW
|
#ifdef LED_ACTIVE_LOW
|
||||||
@ -107,7 +115,6 @@ void start_ota_update() {
|
|||||||
|
|
||||||
} // start_ota_update
|
} // start_ota_update
|
||||||
|
|
||||||
|
|
||||||
void do_ota_update() {
|
void do_ota_update() {
|
||||||
char buf[17];
|
char buf[17];
|
||||||
|
|
||||||
@ -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
|
// callback function to show download progress while streaming data
|
||||||
void show_progress(size_t current, size_t size) {
|
void show_progress(size_t current, size_t size) {
|
||||||
char buf[17];
|
char buf[17];
|
||||||
snprintf(buf, 17, "%-9lu (%3lu%%)", current, current*100 / size);
|
snprintf(buf, 17, "%-9lu (%3lu%%)", current, current * 100 / size);
|
||||||
display(4, "**", buf);
|
display(4, "**", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +68,7 @@
|
|||||||
// OTA settings
|
// OTA settings
|
||||||
#define WIFI_MAX_TRY 20 // maximum number of wifi connect attempts for OTA update [default = 20]
|
#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 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
|
// LMIC settings
|
||||||
// define hardware independent LMIC settings here, settings of standard library in /lmic/config.h will be ignored
|
// define hardware independent LMIC settings here, settings of standard library in /lmic/config.h will be ignored
|
||||||
|
Loading…
Reference in New Issue
Block a user