Files
roro9stack/src/apps/firmware_page.h
T
twislaandClaude Sonnet 5.5 4ef41347ab Updates from Gitea, step 4: the Firmware page shows the project's releases
Latest release (checked on Enter, or c), Older releases (the last ten,
newest first), a release page with the tag's message, and an install
dialog; going back to an older release asks differently. A failed check
someone asked for shows a Toast. A Debug Build shows the latest release
and says it can't install it: it would take its console away.

Tried on the device: a check, the list, the release page, the dialog
(Cancel is the default; Back cancels), and the install from the screen
with its progress screen, then the restart into the release build and its
confirmation.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
2026-10-06 16:06:49 +02:00

69 lines
2.1 KiB
C++

#pragma once
#include <memory>
#include <mutex>
#include <string>
#include <vector>
#include "dialog_model.h"
#include "key_event.h"
#include "list_model.h"
#include "release_info.h"
#include "services/storage_service.h"
#include "services/update_service.h"
#include "services/wifi_service.h"
#include "ui/canvas.h"
#include "ui/theme.h"
namespace roro {
// Settings → Firmware: the running version and its Probation, where to push Firmware Updates, the
// project's releases on Gitea (the latest, and the ten before it), and the Update Files on the SD
// card (in /updates) to install from.
class FirmwarePage {
public:
FirmwarePage(UpdateService& update, WifiService& wifi, StorageService& storage)
: update_(update), wifi_(wifi), storage_(storage) {}
void enter();
bool onKey(const KeyEvent& e); // false: leave the page
void draw(Canvas& c);
private:
enum Row { kVersion, kStatus, kAddress, kLatest, kOlder, kSdHeader, kFixed };
enum class View { Main, Release, Older };
enum class Ask { None, SdFile, Release };
std::vector<std::string> files();
std::string latestText(bool& warn) const;
void openRelease(const release::Release& r);
bool installable(std::string& why) const; // the shown release: can it be installed from here?
void drawMain(Canvas& c);
void drawRelease(Canvas& c);
void drawOlder(Canvas& c);
void say(const std::string& text);
UpdateService& update_;
WifiService& wifi_;
StorageService& storage_;
ListModel list_{theme::kContent.h / theme::kLineHeight};
ListModel older_{(theme::kContent.h - 11) / theme::kLineHeight}; // above the hint line
std::unique_ptr<DialogModel> confirm_;
Ask ask_ = Ask::None;
View view_ = View::Main;
release::Release shown_; // the release page
std::vector<release::Release> olderReleases_;
uint32_t olderSeq_ = 0;
int shownTop_ = 0;
std::string message_;
uint32_t messageMs_ = 0;
// Filled on the storage task.
std::mutex lock_;
std::vector<std::string> files_;
bool listed_ = false;
};
} // namespace roro