2025-12-22 17:16:46 +11:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
class OtaUpdater {
|
|
|
|
|
bool updateAvailable = false;
|
|
|
|
|
std::string latestVersion;
|
|
|
|
|
std::string otaUrl;
|
|
|
|
|
size_t otaSize = 0;
|
2026-01-27 14:30:27 +00:00
|
|
|
size_t processedSize = 0;
|
|
|
|
|
size_t totalSize = 0;
|
|
|
|
|
bool render = false;
|
2025-12-22 17:16:46 +11:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
enum OtaUpdaterError {
|
|
|
|
|
OK = 0,
|
|
|
|
|
NO_UPDATE,
|
|
|
|
|
HTTP_ERROR,
|
|
|
|
|
JSON_PARSE_ERROR,
|
|
|
|
|
UPDATE_OLDER_ERROR,
|
|
|
|
|
INTERNAL_UPDATE_ERROR,
|
|
|
|
|
OOM_ERROR,
|
|
|
|
|
};
|
2026-01-27 14:30:27 +00:00
|
|
|
|
|
|
|
|
size_t getOtaSize() const { return otaSize; }
|
|
|
|
|
|
|
|
|
|
size_t getProcessedSize() const { return processedSize; }
|
|
|
|
|
|
|
|
|
|
size_t getTotalSize() const { return totalSize; }
|
|
|
|
|
|
|
|
|
|
bool getRender() const { return render; }
|
2025-12-22 17:16:46 +11:00
|
|
|
|
|
|
|
|
OtaUpdater() = default;
|
2026-01-03 08:19:53 +00:00
|
|
|
bool isUpdateNewer() const;
|
|
|
|
|
const std::string& getLatestVersion() const;
|
2025-12-22 17:16:46 +11:00
|
|
|
OtaUpdaterError checkForUpdate();
|
2026-01-27 14:30:27 +00:00
|
|
|
OtaUpdaterError installUpdate();
|
2025-12-22 17:16:46 +11:00
|
|
|
};
|