First Version to be updateable over API
All checks were successful
Test compiling project / test (push) Successful in 2m34s
All checks were successful
Test compiling project / test (push) Successful in 2m34s
This commit is contained in:
@@ -53,7 +53,11 @@ void update_finished() {
|
||||
}
|
||||
|
||||
void update_progress(int cur, int total) {
|
||||
ota_status.update_progress = total/cur;
|
||||
ota_status.update_progress = 0;
|
||||
if (cur != 0 ) {
|
||||
ota_status.update_progress = total/cur;
|
||||
}
|
||||
|
||||
Log.verbose("OTA Update progress: %d/%d", cur, total);
|
||||
}
|
||||
|
||||
@@ -63,6 +67,8 @@ void update_error(int err) {
|
||||
}
|
||||
|
||||
void check_update_task(void* parameter) {
|
||||
ota_status.current_version = current_software_version;
|
||||
ota_status.update_progress = -1;
|
||||
#ifdef USE_INA226
|
||||
OTA ota("https://iot.tobiasmaier.me/firmware/waterlevel", current_software_version, "INA226");
|
||||
#else
|
||||
@@ -71,12 +77,27 @@ void check_update_task(void* parameter) {
|
||||
while (true) {
|
||||
Firmware fw = ota.getLatestVersionOnServer();
|
||||
if (fw.valid) {
|
||||
Log.verbose("New firmware available: %d.%d.%d, current versio: %d.%d.%d", fw.version.major, fw.version.minor, fw.version.patch, current_software_version.major, current_software_version.minor, current_software_version.patch);
|
||||
Log.verbose("New firmware available: %d.%d.%d, current version: %d.%d.%d", fw.version.major, fw.version.minor, fw.version.patch, current_software_version.major, current_software_version.minor, current_software_version.patch);
|
||||
ota_status.update_available = true;
|
||||
ota_status.latest_version = fw.version;
|
||||
ota_status.update_url = fw.url;
|
||||
} else {
|
||||
if (fw.version.major != 0 && fw.version.minor != 0 && fw.version.patch != 0) {
|
||||
ota_status.latest_version = fw.version;
|
||||
ota_status.update_available = false;
|
||||
}
|
||||
|
||||
Log.verbose("No new firmware available");
|
||||
}
|
||||
delay(1000 * 60 * 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void run_ota_update_task(void* parameter) {
|
||||
TaskArgs_t *args = (TaskArgs_t *) parameter;
|
||||
Log.verbose("Running OTA upgrade now with URL: %s", args->ota_status.update_url.c_str());
|
||||
run_ota_update(args->ota_status.update_url, update_started, update_finished, update_progress, update_error);
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
Reference in New Issue
Block a user