Public Access
Updates from Gitea, step 2: the connection (check and list work on the device)
The roots (ISRG X1 and X2), an HTTPS client that reads the answer as a stream, GiteaReleases (the latest and a list of ten), the Update Service's requests, install from Gitea through the existing install path, the daily check's schedule, the Check for updates setting, and console commands: update check | list | status | install <tag>. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
#include "services/clock_service.h"
|
||||
#include "services/debug_console.h"
|
||||
#include "services/file_ops.h"
|
||||
#include "update_check.h"
|
||||
#include "services/gemini_service.h"
|
||||
#include "services/gnss_service.h"
|
||||
#include "services/power_service.h"
|
||||
@@ -182,6 +183,7 @@ void setup() {
|
||||
wifi = new WifiService(settings, *savedNetworks, *clockService);
|
||||
update = new UpdateService(nvs, *wifi, *savedNetworks, *storageService, bus, settings);
|
||||
fileOps = new FileOps(*storageService, filesInUse);
|
||||
update->enableDailyCheck();
|
||||
irc = new IrcService(nvs, "roro_" + identity::defaultShortName(), *wifi, *storageService, *clockService, bus);
|
||||
notifier = new Notifier(bus, settings);
|
||||
notifier->onShow = [](uint32_t now, uint32_t until) { power->onNotification(now, until); };
|
||||
@@ -441,6 +443,64 @@ static void fileOpsStep() {
|
||||
else console.printf("%s: ok\n", name);
|
||||
}
|
||||
|
||||
// `update ...`: the project's releases on Gitea (R1, #6). The answers come from the Update Service's
|
||||
// task a moment later; updateStep() prints them.
|
||||
static int updateWatch = 0; // 1: a check, 2: a list
|
||||
|
||||
static void printReleases(bool list) {
|
||||
GiteaReleases& g = update->gitea();
|
||||
if (g.status() == GiteaReleases::Status::Failed) return (void)console.printf("update: %s\n", g.error().c_str());
|
||||
std::string running = update->runningVersion();
|
||||
if (!list) {
|
||||
release::Release r;
|
||||
if (!g.latest(r)) return (void)console.println("update: nothing known yet");
|
||||
console.printf("update: latest %s of %s, %u bytes: %s (running %s)\n", r.tag.c_str(), r.date().c_str(), (unsigned)r.otaSize,
|
||||
release::isNewer(r, running) ? "newer" : "not newer", running.c_str());
|
||||
console.printf("update: %s\n", r.notes.c_str());
|
||||
return;
|
||||
}
|
||||
for (auto& r : g.list())
|
||||
console.printf("update: %-8s %s %8u B %s\n", r.tag.c_str(), r.date().c_str(), (unsigned)r.otaSize, r.notes.substr(0, 60).c_str());
|
||||
console.println("update: end of list");
|
||||
}
|
||||
|
||||
static void updateStep() {
|
||||
if (!updateWatch || update->giteaBusy()) return;
|
||||
printReleases(updateWatch == 2);
|
||||
updateWatch = 0;
|
||||
}
|
||||
|
||||
static void updateCommand(const String& args) {
|
||||
if (args == "check" || args == "list") {
|
||||
if (update->giteaBusy()) return (void)console.println("update: busy");
|
||||
args == "check" ? update->requestCheck() : update->requestList();
|
||||
updateWatch = args == "check" ? 1 : 2;
|
||||
} else if (args == "status") {
|
||||
GiteaReleases& g = update->gitea();
|
||||
console.printf("update: running %s, failed here before: %s, daily check %s, heap %u\n", update->runningVersion().c_str(),
|
||||
update->failedVersion().empty() ? "none" : update->failedVersion().c_str(),
|
||||
settings.getBool(Setting::CheckUpdates) ? "on" : "off", (unsigned)ESP.getFreeHeap());
|
||||
console.printf("update: gitea %s %s\n", g.status() == GiteaReleases::Status::Done ? "done" : g.status() == GiteaReleases::Status::Failed ? "failed" : g.status() == GiteaReleases::Status::Busy ? "busy" : "never asked", g.error().c_str());
|
||||
printReleases(false);
|
||||
} else if (args.startsWith("install ")) {
|
||||
String rest = args.substring(8);
|
||||
bool force = rest.endsWith(" force");
|
||||
if (force) rest.remove(rest.length() - 6);
|
||||
#ifndef RORO_DEBUG
|
||||
force = false; // only the Debug Console may install on a Debug Build, which a release isn't
|
||||
#endif
|
||||
std::string why = update->requestInstall(rest.c_str(), force);
|
||||
console.printf("update: %s\n", why.empty() ? "installing" : why.c_str());
|
||||
#ifdef RORO_DEBUG
|
||||
} else if (args.startsWith("pretend ")) { // update pretend v0.9.0 | off: what the comparisons take as running
|
||||
update->pretendVersion(args.substring(8) == "off" ? "" : args.substring(8).c_str());
|
||||
console.printf("update: running %s\n", update->runningVersion().c_str());
|
||||
#endif
|
||||
} else {
|
||||
console.println("update: check | list | status | install <tag>");
|
||||
}
|
||||
}
|
||||
|
||||
static void fileCommand(const String& line) {
|
||||
int space = line.indexOf(' ');
|
||||
std::string command = line.substring(0, space).c_str(), rest = line.substring(space + 1).c_str();
|
||||
@@ -507,6 +567,7 @@ static const char* const kHelp =
|
||||
"gemini get <url> fetch a Gemini page and report header, size, certificate, heap\n"
|
||||
"irc start | irc stop | irc dump | irc say <buffer> <text>\n"
|
||||
"install <path.ota> Update from SD\n"
|
||||
"update check | list | status | install <tag> the project's releases on Gitea\n"
|
||||
"sd card | sd list | cat <path> | log <text> | burst | sound on|off | short | normal\n"
|
||||
#ifdef RORO_DEBUG
|
||||
"crash abort|wdt crash on purpose (to test crash reports and Safe Mode)\n"
|
||||
@@ -571,6 +632,7 @@ static void runCommand(String line) {
|
||||
esp_log_level_set("*", static_cast<esp_log_level_t>(constrain(level, 0, 5)));
|
||||
console.printf("log level: %d\n", constrain(level, 0, 5));
|
||||
}
|
||||
if (line.startsWith("update ")) updateCommand(line.substring(7));
|
||||
if (line.startsWith("cp ") || line.startsWith("mv ") || line.startsWith("rm ") || line.startsWith("mkdir ") ||
|
||||
line.startsWith("du ") || line == "cancel")
|
||||
fileCommand(line);
|
||||
@@ -1010,6 +1072,7 @@ static void loopPass() {
|
||||
if (noiseTest) noiseTest->step(now);
|
||||
#endif
|
||||
noteStableOnce(now);
|
||||
updateStep();
|
||||
fileOpsStep();
|
||||
uploadStep();
|
||||
printListingWhenReady();
|
||||
|
||||
Reference in New Issue
Block a user