Author SHA1 Message Date
tthandClaude Opus 5.5 3293254443 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>
2026-11-19 12:09:56 +01:00
3 changed files with 82 additions and 10 deletions

No files matched your search

+4 -1
View File
@@ -23,7 +23,10 @@ update stops with "not an -ota build".
(`fw ver`, `fw status`) and takes the matching delta from the **latest
release** on git.rfa.cz, checked against the release's `SHA256SUMS`.
*Choose .mcfw files* is for your own builds (signed with your own key).
4. **Update**. Keep the app open until the log ends with `applied`; about
4. **Check** (optional) only finds out: it shows the node's `ver` and either
"up to date … no update needed" or "update available" with the delta
size. A login and three or four CLI replies on air, no chunks.
5. **Update**. Keep the app open until the log ends with `applied`; about
2–3 minutes on a direct link, a minute of it waiting for the reboot.
A second run against an updated node ends with "the node already runs …".
+18 -2
View File
@@ -96,7 +96,7 @@ class _RepeaterOtaScreenState extends State<RepeaterOtaScreen> {
if (skipped.isNotEmpty) _addLog('not OTA packages: ${skipped.join(', ')}');
}
Future<void> _start() async {
Future<void> _start({bool checkOnly = false}) async {
if (!ensureRadioConnected(context)) return;
final duty = double.tryParse(_duty.text.replaceAll(',', '.'));
final gap = double.tryParse(_gap.text.replaceAll(',', '.'));
@@ -130,6 +130,7 @@ class _RepeaterOtaScreenState extends State<RepeaterOtaScreen> {
side: side,
window: window ?? 15,
apply: _apply,
checkOnly: checkOnly,
);
setState(() {
_transfer = transfer;
@@ -139,12 +140,19 @@ class _RepeaterOtaScreenState extends State<RepeaterOtaScreen> {
String outcome;
try {
final r = await transfer.run();
final release = r.tag ?? 'this release';
outcome = switch (r.state) {
OtaState.applied => 'applied: ${r.versionAfter ?? r.package?.version}',
OtaState.staged => 'staged ${r.package?.name} (not applied)',
OtaState.current => 'the node already runs this release',
OtaState.current =>
'up to date: the node already runs $release, no update needed',
OtaState.available =>
'update available: $release, delta ${r.package?.data.length} B',
OtaState.noPackage => 'no delta fits the node\'s image',
};
if (r.versionBefore != null) {
outcome = 'node: ${r.versionBefore}\n$outcome';
}
outcome += ', airtime ${r.airtime.toStringAsFixed(1)} s';
} on OtaCancelled {
outcome = 'cancelled (the node keeps what it got until the next begin)';
@@ -320,6 +328,14 @@ class _RepeaterOtaScreenState extends State<RepeaterOtaScreen> {
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
child: Row(
children: [
OutlinedButton.icon(
onPressed: _running
? null
: () => _start(checkOnly: true),
icon: const Icon(Icons.manage_search),
label: const Text('Check'),
),
const SizedBox(width: 12),
Expanded(
child: FilledButton.icon(
onPressed: _running ? null : _start,
+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);