OTA updates (#96)
## Summary * Adds support for OTA * Gets latest firmware bin from latest GitHub release * I have noticed it be a little flaky unpacking the JSON and occasionally failing to start
This commit is contained in:
30
src/network/OtaUpdater.h
Normal file
30
src/network/OtaUpdater.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
class OtaUpdater {
|
||||
bool updateAvailable = false;
|
||||
std::string latestVersion;
|
||||
std::string otaUrl;
|
||||
size_t otaSize = 0;
|
||||
|
||||
public:
|
||||
enum OtaUpdaterError {
|
||||
OK = 0,
|
||||
NO_UPDATE,
|
||||
HTTP_ERROR,
|
||||
JSON_PARSE_ERROR,
|
||||
UPDATE_OLDER_ERROR,
|
||||
INTERNAL_UPDATE_ERROR,
|
||||
OOM_ERROR,
|
||||
};
|
||||
size_t processedSize = 0;
|
||||
size_t totalSize = 0;
|
||||
|
||||
OtaUpdater() = default;
|
||||
bool isUpdateNewer();
|
||||
const std::string& getLatestVersion();
|
||||
OtaUpdaterError checkForUpdate();
|
||||
OtaUpdaterError installUpdate(const std::function<void(size_t, size_t)>& onProgress);
|
||||
};
|
||||
Reference in New Issue
Block a user