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:
43
src/activities/settings/OtaUpdateActivity.h
Normal file
43
src/activities/settings/OtaUpdateActivity.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/semphr.h>
|
||||
#include <freertos/task.h>
|
||||
|
||||
#include "activities/ActivityWithSubactivity.h"
|
||||
#include "network/OtaUpdater.h"
|
||||
|
||||
class OtaUpdateActivity : public ActivityWithSubactivity {
|
||||
enum State {
|
||||
WIFI_SELECTION,
|
||||
CHECKING_FOR_UPDATE,
|
||||
WAITING_CONFIRMATION,
|
||||
UPDATE_IN_PROGRESS,
|
||||
NO_UPDATE,
|
||||
FAILED,
|
||||
FINISHED,
|
||||
SHUTTING_DOWN
|
||||
};
|
||||
|
||||
// Can't initialize this to 0 or the first render doesn't happen
|
||||
static constexpr unsigned int UNINITIALIZED_PERCENTAGE = 111;
|
||||
|
||||
TaskHandle_t displayTaskHandle = nullptr;
|
||||
SemaphoreHandle_t renderingMutex = nullptr;
|
||||
bool updateRequired = false;
|
||||
const std::function<void()> goBack;
|
||||
State state = WIFI_SELECTION;
|
||||
unsigned int lastUpdaterPercentage = UNINITIALIZED_PERCENTAGE;
|
||||
OtaUpdater updater;
|
||||
|
||||
void onWifiSelectionComplete(bool success);
|
||||
static void taskTrampoline(void* param);
|
||||
[[noreturn]] void displayTaskLoop();
|
||||
void render();
|
||||
|
||||
public:
|
||||
explicit OtaUpdateActivity(GfxRenderer& renderer, InputManager& inputManager, const std::function<void()>& goBack)
|
||||
: ActivityWithSubactivity("OtaUpdate", renderer, inputManager), goBack(goBack), updater() {}
|
||||
void onEnter() override;
|
||||
void onExit() override;
|
||||
void loop() override;
|
||||
};
|
||||
Reference in New Issue
Block a user