## 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
44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
#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;
|
|
};
|