OTA: a Check button tells whether the node is up to date, without sending anything
build / ci-image (push) Successful in 10s
build / build (push) Successful in 26m44s

Login, `ver`, `fw status` (and `fw ver` for the release lookup), then the
outcome: "up to date: the node already runs <tag>, no update needed" or
"update available: <tag>, delta N B", with the node's version on top. It
stops before `fw begin` and before the side channel, so no chunks go on air.
OtaTransfer.checkOnly, OtaState.available; OtaResult carries the release
tag and the `ver` reply.

Refs #28

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 5.5 committed 2026-11-19 12:09:56 +01:00
1 parent 8939cef7c1
commit 3293254443
3 files changed
+82 -10

No files matched your search

+60 -7
View File
@@ -40,12 +40,23 @@ class OtaCancelled extends OtaError {
OtaCancelled() : super('cancelled');
}
enum OtaState { current, noPackage, staged, applied }
/// [available]: only with [OtaTransfer.checkOnly] -- a delta for the node's
/// image exists, nothing was sent.
enum OtaState { current, available, noPackage, staged, applied }
class OtaResult {
OtaResult(this.state, {this.package, this.versionAfter, this.airtime = 0});
OtaResult(
this.state, {
this.package,
this.tag,
this.versionBefore,
this.versionAfter,
this.airtime = 0,
});
final OtaState state;
final OtaPackage? package;
final String? tag; // the release, when the package came from one
final String? versionBefore; // `ver`, with checkOnly
final String? versionAfter;
final double airtime;
}
@@ -68,6 +79,7 @@ class OtaTransfer {
this.apply = true,
this.applyWait = const Duration(seconds: 60),
this.release,
this.checkOnly = false,
}) : _bucket = OtaBucket(duty);
final MeshCoreConnector connector;
@@ -87,6 +99,10 @@ class OtaTransfer {
/// latest public release).
final OtaRelease? release;
/// Only find out whether an update exists: login, `ver`, `fw status`, the
/// release lookup -- and stop before `fw begin`.
final bool checkOnly;
final OtaBucket _bucket;
late final RepeaterCommandService _cli = RepeaterCommandService(connector);
StreamSubscription<Uint8List>? _frames;
@@ -540,6 +556,7 @@ class OtaTransfer {
});
try {
await _login();
final before = checkOnly ? await _ask('ver') : null;
final status = await _ask('fw status');
var base = otaParseStatus(status)?.$2;
if (base == null && status.startsWith('>')) {
@@ -548,14 +565,23 @@ class OtaTransfer {
}
if (base == null) {
log('no base image: not an -ota build');
return OtaResult(OtaState.noPackage, airtime: airtime);
return OtaResult(
OtaState.noPackage,
versionBefore: before,
airtime: airtime,
);
}
var pkgs = packages;
String? tag;
if (pkgs.isEmpty) {
final target = otaParseTarget(await _ask('fw ver'));
if (target == null) {
log('`fw ver` names no target: not an -ota build');
return OtaResult(OtaState.noPackage, airtime: airtime);
return OtaResult(
OtaState.noPackage,
versionBefore: before,
airtime: airtime,
);
}
log('looking for $target from $base in the latest release');
final OtaReleaseMatch m;
@@ -566,15 +592,26 @@ class OtaTransfer {
} catch (e) {
throw OtaError('release: cannot download ($e)');
}
tag = m.tag;
if (m.current) {
log('the node already runs ${m.tag}');
return OtaResult(OtaState.current, airtime: airtime);
return OtaResult(
OtaState.current,
tag: tag,
versionBefore: before,
airtime: airtime,
);
}
if (m.package == null) {
log(
'${m.tag} has no delta from $base (too old: a full image over USB/BLE)',
);
return OtaResult(OtaState.noPackage, airtime: airtime);
return OtaResult(
OtaState.noPackage,
tag: tag,
versionBefore: before,
airtime: airtime,
);
}
log('${m.tag}: ${m.package!.name}, sha256 ok');
pkgs = [m.package!];
@@ -585,6 +622,8 @@ class OtaTransfer {
return OtaResult(
OtaState.current,
package: pick.package,
tag: tag,
versionBefore: before,
airtime: airtime,
);
}
@@ -592,11 +631,25 @@ class OtaTransfer {
log(
'no delta starts from $base (a full image does not go over the mesh)',
);
return OtaResult(OtaState.noPackage, airtime: airtime);
return OtaResult(
OtaState.noPackage,
tag: tag,
versionBefore: before,
airtime: airtime,
);
}
final pkg = pick.package!;
final data = pkg.data;
log('package ${pkg.name} (delta, ${data.length} B)');
if (checkOnly) {
return OtaResult(
OtaState.available,
package: pkg,
tag: tag,
versionBefore: before,
airtime: airtime,
);
}
if (side != null) await _enterSide();
final sid = 1 + math.Random().nextInt(0xFFFF);