localization

This commit is contained in:
2026-08-16 14:33:27 +02:00
parent 9c634b819e
commit fb09b2b7a1
65 changed files with 1621 additions and 1679 deletions

View File

@@ -14,9 +14,9 @@ namespace OtaUpdate {
namespace {
constexpr const char* RELEASES_API_URL =
"https://api.github.com/repos/Eiswolf-BG/eiswolfs-flightradar-CYD/releases/latest";
// GitHub verlangt bei API-Anfragen einen aussagekraeftigen User-Agent
// (sonst HTTP 403) - gleiches Prinzip wie Config::NOMINATIM_USER_AGENT
// fuer die Adresssuche.
// GitHub requires a meaningful User-Agent for API requests
// (otherwise HTTP 403) - same principle as Config::NOMINATIM_USER_AGENT
// for address search.
constexpr const char* USER_AGENT =
"EiswolfsFlightradarCYD-OTA/1.0 (+https://github.com/Eiswolf-BG/eiswolfs-flightradar-CYD)";
@@ -27,10 +27,10 @@ namespace {
return sscanf(s, "%d.%d.%d", &major, &minor, &patch) == 3;
}
// > 0 wenn a neuer als b, 0 wenn gleich, < 0 wenn a aelter als b.
// Bewusst eine echte numerische Versionsvergleich statt eines simplen
// String-Vergleichs (der wuerde z.B. "3.10.0" faelschlich als "kleiner"
// als "3.9.0" einordnen).
// > 0 if a is newer than b, 0 if equal, < 0 if a is older than b.
// Deliberately a real numeric version comparison instead of a simple
// string comparison (which would e.g. wrongly rank "3.10.0" as "less"
// than "3.9.0").
int compareVersions(const char* a, const char* b) {
int aMaj, aMin, aPat, bMaj, bMin, bPat;
if (!parseVersion(a, aMaj, aMin, aPat) || !parseVersion(b, bMaj, bMin, bPat)) return 0;
@@ -43,7 +43,7 @@ namespace {
CheckInfo checkForUpdate() {
CheckInfo info;
Serial.printf("[OTA] Pruefe auf Update: url=%s freeHeap=%u RSSI=%ddBm\n", RELEASES_API_URL,
Serial.printf("[OTA] Checking for update: url=%s freeHeap=%u RSSI=%ddBm\n", RELEASES_API_URL,
(unsigned)ESP.getFreeHeap(), WiFi.RSSI());
WiFiClientSecure client;
@@ -53,7 +53,7 @@ CheckInfo checkForUpdate() {
HTTPClient http;
http.setTimeout(8000);
if (!http.begin(client, RELEASES_API_URL)) {
Serial.println("[OTA] Pruefung fehlgeschlagen: http.begin() lieferte false.");
Serial.println("[OTA] Check failed: http.begin() returned false.");
return info;
}
http.addHeader("User-Agent", USER_AGENT);
@@ -61,10 +61,10 @@ CheckInfo checkForUpdate() {
int code = http.GET();
if (code != HTTP_CODE_OK) {
if (code < 0) {
Serial.printf("[OTA] Pruefung fehlgeschlagen: HTTP-Fehler=%d (%s)\n", code,
Serial.printf("[OTA] Check failed: HTTP error=%d (%s)\n", code,
HTTPClient::errorToString(code).c_str());
} else {
Serial.printf("[OTA] Pruefung fehlgeschlagen: HTTP-Status=%d\n", code);
Serial.printf("[OTA] Check failed: HTTP status=%d\n", code);
}
http.end();
return info;
@@ -75,13 +75,13 @@ CheckInfo checkForUpdate() {
JsonDocument doc;
DeserializationError jsonErr = deserializeJson(doc, body);
if (jsonErr) {
Serial.printf("[OTA] Pruefung fehlgeschlagen: JSON-Fehler (%s)\n", jsonErr.c_str());
Serial.printf("[OTA] Check failed: JSON error (%s)\n", jsonErr.c_str());
return info;
}
const char* tag = doc["tag_name"] | "";
if (!tag[0]) {
Serial.println("[OTA] Pruefung fehlgeschlagen: kein tag_name im Release-JSON.");
Serial.println("[OTA] Check failed: no tag_name in release JSON.");
return info;
}
@@ -99,59 +99,58 @@ CheckInfo checkForUpdate() {
}
if (!info.downloadUrl[0]) {
Serial.printf("[OTA] Pruefung fehlgeschlagen: Release v%s hat keinen firmware.bin-Anhang.\n",
Serial.printf("[OTA] Check failed: Release v%s has no firmware.bin attachment.\n",
info.latestVersion);
return info; // Release ohne firmware.bin-Anhang
return info; // Release without firmware.bin attachment
}
int cmp = compareVersions(info.latestVersion, Config::APP_VERSION);
info.result = (cmp > 0) ? CheckResult::UpdateAvailable : CheckResult::UpToDate;
Serial.printf("[OTA] Pruefung erfolgreich: installiert=v%s neuestes=v%s -> %s\n", Config::APP_VERSION,
Serial.printf("[OTA] Check successful: installed=v%s latest=v%s -> %s\n", Config::APP_VERSION,
info.latestVersion,
info.result == CheckResult::UpdateAvailable ? "Update verfuegbar" : "bereits aktuell");
info.result == CheckResult::UpdateAvailable ? "Update available" : "already up-to-date");
return info;
}
bool performUpdate(const char* url, void (*onProgress)(uint8_t percent)) {
// Diagnose-Logging (nur ueber USB-Seriell sichtbar, kein Einfluss auf
// die UI) - vorher wurde bei einem Fehlschlag nur ein simples "true/
// false" nach aussen gegeben, ohne den eigentlichen Grund (Timeout,
// TLS-Fehler, HTTP-Statuscode...) festzuhalten. Damit laesst sich ein
// fehlgeschlagener OTA-Versuch am Seriell-Monitor nachvollziehen, statt
// erneut raten zu muessen.
Serial.printf("[OTA] Start: url=%s freeHeap=%u RSSI=%ddBm\n", url,
// Diagnostic logging (only visible over USB serial, no impact on
// the UI) - previously a failed update only returned a simple "true/
// false" externally, without recording the actual reason (timeout,
// TLS error, HTTP status code...). This allows tracing a failed
// OTA attempt on the serial monitor instead of having to guess again.
Serial.printf("[OTA] Starting: url=%s freeHeap=%u RSSI=%ddBm\n", url,
(unsigned)ESP.getFreeHeap(), WiFi.RSSI());
WiFiClientSecure client;
client.setInsecure();
client.setTimeout(15000);
// WICHTIG: GitHubs "browser_download_url" fuer Release-Assets ist KEIN
// direkter Download-Link, sondern liefert erst ein HTTP 301/302-Redirect
// auf eine signierte objects.githubusercontent.com-URL. HTTPUpdate folgt
// Redirects standardmaessig NICHT (HTTPC_DISABLE_FOLLOW_REDIRECTS ist der
// Default) - ohne diese Zeile bricht der Download mit HTTP_UPDATE_FAILED
// ab, weil statt der .bin-Datei nur die Redirect-Antwort ankommt. Siehe
// z.B. espressif/arduino-esp32#3020. HTTPC_STRICT_FOLLOW_REDIRECTS
// reicht, da wir nur GET verwenden.
// IMPORTANT: GitHub's "browser_download_url" for release assets is NOT
// a direct download link, but first returns an HTTP 301/302 redirect
// to a signed objects.githubusercontent.com URL. HTTPUpdate does NOT
// follow redirects by default (HTTPC_DISABLE_FOLLOW_REDIRECTS is the
// default) - without this line the download aborts with HTTP_UPDATE_FAILED
// because only the redirect response arrives instead of the .bin file. See
// e.g. espressif/arduino-esp32#3020. HTTPC_STRICT_FOLLOW_REDIRECTS
// suffices since we only use GET.
httpUpdate.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
// Wir zeigen nach erfolgreicher Installation selbst noch eine kurze
// Erfolgsmeldung an, bevor das Geraet neu startet - siehe
// We show a brief success message ourselves after successful installation,
// before the device reboots - see
// menu_screen.cpp::runOtaUpdateScreen().
httpUpdate.rebootOnUpdate(false);
httpUpdate.onProgress([onProgress](int cur, int total) {
if (onProgress && total > 0) {
onProgress((uint8_t)((cur * 100) / total));
}
// Nur gelegentlich loggen (alle ~10%), sonst quillt der Seriell-
// Monitor bei grossen Dateien mit hunderten Zeilen ueber.
// Only log occasionally (every ~10%), otherwise the serial
// monitor overflows with hundreds of lines for large files.
static int8_t lastLoggedPercent = -1;
if (total > 0) {
int8_t pct = (int8_t)((cur * 100) / total);
if (pct != lastLoggedPercent && pct % 10 == 0) {
lastLoggedPercent = pct;
Serial.printf("[OTA] Fortschritt: %d%% (%d/%d Bytes) freeHeap=%u\n", pct, cur, total,
Serial.printf("[OTA] Progress: %d%% (%d/%d bytes) freeHeap=%u\n", pct, cur, total,
(unsigned)ESP.getFreeHeap());
}
}
@@ -160,11 +159,11 @@ bool performUpdate(const char* url, void (*onProgress)(uint8_t percent)) {
t_httpUpdate_return result = httpUpdate.update(client, url);
if (result != HTTP_UPDATE_OK) {
Serial.printf("[OTA] Fehlgeschlagen: result=%d error=%d (%s) freeHeap=%u\n", (int)result,
Serial.printf("[OTA] Failed: result=%d error=%d (%s) freeHeap=%u\n", (int)result,
httpUpdate.getLastError(), httpUpdate.getLastErrorString().c_str(),
(unsigned)ESP.getFreeHeap());
} else {
Serial.println("[OTA] Erfolgreich heruntergeladen und geflasht.");
Serial.println("[OTA] Successfully downloaded and flashed.");
}
return result == HTTP_UPDATE_OK;