This commit is contained in:
@@ -3,8 +3,10 @@
|
||||
#include <ArduinoLog.h>
|
||||
#include "../global_data/defines.h"
|
||||
#include <Preferences.h>
|
||||
#include <fetchOTA.h>
|
||||
|
||||
extern Preferences prefs;
|
||||
extern OTAStatus ota_status;
|
||||
|
||||
void printSuffix(Print* _logOutput, int logLevel)
|
||||
{
|
||||
@@ -37,4 +39,44 @@ String processor(const String& var)
|
||||
}
|
||||
|
||||
return String("Test");
|
||||
}
|
||||
|
||||
// OTA Callbacks
|
||||
void update_started() {
|
||||
Log.verbose("OTA Update started");
|
||||
ota_status.update_progress = 0;
|
||||
}
|
||||
|
||||
void update_finished() {
|
||||
Log.verbose("OTA Update finished");
|
||||
ota_status.update_progress = -1;
|
||||
}
|
||||
|
||||
void update_progress(int cur, int total) {
|
||||
ota_status.update_progress = total/cur;
|
||||
Log.verbose("OTA Update progress: %d/%d", cur, total);
|
||||
}
|
||||
|
||||
void update_error(int err) {
|
||||
Log.error("OTA Update error: %d", err);
|
||||
ota_status.update_progress = -2;
|
||||
}
|
||||
|
||||
void check_update_task(void* parameter) {
|
||||
#ifdef USE_INA226
|
||||
OTA ota("https://iot.tobiasmaier.me/firmware/waterlevel", current_software_version, "INA226");
|
||||
#else
|
||||
OTA ota("https://iot.tobiasmaier.me/firmware/waterlevel", current_software_version, "INA233");
|
||||
#endif
|
||||
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);
|
||||
ota_status.update_available = true;
|
||||
ota_status.latest_version = fw.version;
|
||||
} else {
|
||||
Log.verbose("No new firmware available");
|
||||
}
|
||||
delay(1000 * 60 * 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user