fix(#999): offer the companion CLI console only on a 1.18 radio

The companion "CLI console" entry was gated only on the target being a
companion. A pre-1.18 radio, including Offband before the absorb, refuses a
type-3 send: companion-v1.17.1 CMD_SEND_TXT_MSG accepts only plain and
CLI_DATA and answers anything else with ERR_CODE_UNSUPPORTED_CMD
(companion-v1.18.0 adds CLI_COMMAND). The connector only logs error
frames, so the command waited out its mesh timeout and the console showed
the #891 row, which blames the target for a limit of the user's own radio.

- Gate: DeviceCliScreen.offersRemoteConsole requires a companion target
  AND a connected radio that speaks the 1.18 CLI (allowsCliFrame, the same
  check that gates the local Device CLI; type-3 send and frame 66 shipped
  together in 1.18). Disconnected or unclassified offers nothing. The chat
  menu uses it.
- Fail fast: RemoteCliTransport fails the command at once with
  CliConsoleUnsupported when the radio refuses the send. The window arms
  only when the text frame is written (the onAttempt hook, after the path
  update) and closes on the command's SENT, which on 1.18 carries an
  expected-ack of 0. So an unrelated unknown-command refusal before the
  write, or a DM's SENT, cannot be pinned on this command. Dispose
  releases a command still waiting.
- Console: a refused send shows "<command>: not sent. Your radio's
  firmware doesn't support remote CLI." (owner-approved), not the timeout
  row.

Tests: the gate (positive and negative across populations, roles, and
disconnected); fail-fast on the refusal, ignoring other codes, errors
after the radio accepted the send, a DM's SENT, an error before the write,
and dispose; the console row.

Reviewed by a one-off Sonnet adversarial pass (Gemini budget down). Its
Medium finding, that the window armed at run() before the write, is fixed
here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pull/1004/head
diffwireauto 1 month ago
parent 63c345e042
commit edf2798bdf

@ -223,6 +223,15 @@
}
}
},
"deviceCli_remoteUnsupported": "{command}: not sent. Your radio's firmware doesn't support remote CLI.",
"@deviceCli_remoteUnsupported": {
"description": "Console row when the connected radio refuses to send a remote-CLI command because its firmware predates TXT_TYPE_CLI_COMMAND (#999). Nothing was transmitted.",
"placeholders": {
"command": {
"type": "String"
}
}
},
"deviceCli_sendFailed": "Send failed: {error}",
"@deviceCli_sendFailed": {
"placeholders": {

@ -772,6 +772,12 @@ abstract class AppLocalizations {
/// **'{command}: no reply in {seconds} s. This radio may not allow remote CLI from you, or is unreachable. Not retried.'**
String deviceCli_remoteNoReply(String command, String seconds);
/// Console row when the connected radio refuses to send a remote-CLI command because its firmware predates TXT_TYPE_CLI_COMMAND (#999). Nothing was transmitted.
///
/// In en, this message translates to:
/// **'{command}: not sent. Your radio\'s firmware doesn\'t support remote CLI.'**
String deviceCli_remoteUnsupported(String command);
/// No description provided for @deviceCli_sendFailed.
///
/// In en, this message translates to:

@ -373,6 +373,11 @@ class AppLocalizationsBg extends AppLocalizations {
return '$command: no reply in $seconds s. This radio may not allow remote CLI from you, or is unreachable. Not retried.';
}
@override
String deviceCli_remoteUnsupported(String command) {
return '$command: not sent. Your radio\'s firmware doesn\'t support remote CLI.';
}
@override
String deviceCli_sendFailed(String error) {
return 'Send failed: $error';

@ -376,6 +376,11 @@ class AppLocalizationsDe extends AppLocalizations {
return '$command: no reply in $seconds s. This radio may not allow remote CLI from you, or is unreachable. Not retried.';
}
@override
String deviceCli_remoteUnsupported(String command) {
return '$command: not sent. Your radio\'s firmware doesn\'t support remote CLI.';
}
@override
String deviceCli_sendFailed(String error) {
return 'Send failed: $error';

@ -370,6 +370,11 @@ class AppLocalizationsEn extends AppLocalizations {
return '$command: no reply in $seconds s. This radio may not allow remote CLI from you, or is unreachable. Not retried.';
}
@override
String deviceCli_remoteUnsupported(String command) {
return '$command: not sent. Your radio\'s firmware doesn\'t support remote CLI.';
}
@override
String deviceCli_sendFailed(String error) {
return 'Send failed: $error';

@ -374,6 +374,11 @@ class AppLocalizationsEs extends AppLocalizations {
return '$command: no reply in $seconds s. This radio may not allow remote CLI from you, or is unreachable. Not retried.';
}
@override
String deviceCli_remoteUnsupported(String command) {
return '$command: not sent. Your radio\'s firmware doesn\'t support remote CLI.';
}
@override
String deviceCli_sendFailed(String error) {
return 'Send failed: $error';

@ -376,6 +376,11 @@ class AppLocalizationsFr extends AppLocalizations {
return '$command: no reply in $seconds s. This radio may not allow remote CLI from you, or is unreachable. Not retried.';
}
@override
String deviceCli_remoteUnsupported(String command) {
return '$command: not sent. Your radio\'s firmware doesn\'t support remote CLI.';
}
@override
String deviceCli_sendFailed(String error) {
return 'Send failed: $error';

@ -373,6 +373,11 @@ class AppLocalizationsHu extends AppLocalizations {
return '$command: no reply in $seconds s. This radio may not allow remote CLI from you, or is unreachable. Not retried.';
}
@override
String deviceCli_remoteUnsupported(String command) {
return '$command: not sent. Your radio\'s firmware doesn\'t support remote CLI.';
}
@override
String deviceCli_sendFailed(String error) {
return 'Send failed: $error';

@ -376,6 +376,11 @@ class AppLocalizationsIt extends AppLocalizations {
return '$command: no reply in $seconds s. This radio may not allow remote CLI from you, or is unreachable. Not retried.';
}
@override
String deviceCli_remoteUnsupported(String command) {
return '$command: not sent. Your radio\'s firmware doesn\'t support remote CLI.';
}
@override
String deviceCli_sendFailed(String error) {
return 'Send failed: $error';

@ -363,6 +363,11 @@ class AppLocalizationsJa extends AppLocalizations {
return '$command: no reply in $seconds s. This radio may not allow remote CLI from you, or is unreachable. Not retried.';
}
@override
String deviceCli_remoteUnsupported(String command) {
return '$command: not sent. Your radio\'s firmware doesn\'t support remote CLI.';
}
@override
String deviceCli_sendFailed(String error) {
return 'Send failed: $error';

@ -362,6 +362,11 @@ class AppLocalizationsKo extends AppLocalizations {
return '$command: no reply in $seconds s. This radio may not allow remote CLI from you, or is unreachable. Not retried.';
}
@override
String deviceCli_remoteUnsupported(String command) {
return '$command: not sent. Your radio\'s firmware doesn\'t support remote CLI.';
}
@override
String deviceCli_sendFailed(String error) {
return 'Send failed: $error';

@ -372,6 +372,11 @@ class AppLocalizationsNl extends AppLocalizations {
return '$command: no reply in $seconds s. This radio may not allow remote CLI from you, or is unreachable. Not retried.';
}
@override
String deviceCli_remoteUnsupported(String command) {
return '$command: not sent. Your radio\'s firmware doesn\'t support remote CLI.';
}
@override
String deviceCli_sendFailed(String error) {
return 'Send failed: $error';

@ -377,6 +377,11 @@ class AppLocalizationsPl extends AppLocalizations {
return '$command: no reply in $seconds s. This radio may not allow remote CLI from you, or is unreachable. Not retried.';
}
@override
String deviceCli_remoteUnsupported(String command) {
return '$command: not sent. Your radio\'s firmware doesn\'t support remote CLI.';
}
@override
String deviceCli_sendFailed(String error) {
return 'Send failed: $error';

@ -375,6 +375,11 @@ class AppLocalizationsPt extends AppLocalizations {
return '$command: no reply in $seconds s. This radio may not allow remote CLI from you, or is unreachable. Not retried.';
}
@override
String deviceCli_remoteUnsupported(String command) {
return '$command: not sent. Your radio\'s firmware doesn\'t support remote CLI.';
}
@override
String deviceCli_sendFailed(String error) {
return 'Send failed: $error';

@ -375,6 +375,11 @@ class AppLocalizationsRu extends AppLocalizations {
return '$command: no reply in $seconds s. This radio may not allow remote CLI from you, or is unreachable. Not retried.';
}
@override
String deviceCli_remoteUnsupported(String command) {
return '$command: not sent. Your radio\'s firmware doesn\'t support remote CLI.';
}
@override
String deviceCli_sendFailed(String error) {
return 'Send failed: $error';

@ -374,6 +374,11 @@ class AppLocalizationsSk extends AppLocalizations {
return '$command: no reply in $seconds s. This radio may not allow remote CLI from you, or is unreachable. Not retried.';
}
@override
String deviceCli_remoteUnsupported(String command) {
return '$command: not sent. Your radio\'s firmware doesn\'t support remote CLI.';
}
@override
String deviceCli_sendFailed(String error) {
return 'Send failed: $error';

@ -372,6 +372,11 @@ class AppLocalizationsSl extends AppLocalizations {
return '$command: no reply in $seconds s. This radio may not allow remote CLI from you, or is unreachable. Not retried.';
}
@override
String deviceCli_remoteUnsupported(String command) {
return '$command: not sent. Your radio\'s firmware doesn\'t support remote CLI.';
}
@override
String deviceCli_sendFailed(String error) {
return 'Send failed: $error';

@ -371,6 +371,11 @@ class AppLocalizationsSv extends AppLocalizations {
return '$command: no reply in $seconds s. This radio may not allow remote CLI from you, or is unreachable. Not retried.';
}
@override
String deviceCli_remoteUnsupported(String command) {
return '$command: not sent. Your radio\'s firmware doesn\'t support remote CLI.';
}
@override
String deviceCli_sendFailed(String error) {
return 'Send failed: $error';

@ -374,6 +374,11 @@ class AppLocalizationsUk extends AppLocalizations {
return '$command: no reply in $seconds s. This radio may not allow remote CLI from you, or is unreachable. Not retried.';
}
@override
String deviceCli_remoteUnsupported(String command) {
return '$command: not sent. Your radio\'s firmware doesn\'t support remote CLI.';
}
@override
String deviceCli_sendFailed(String error) {
return 'Send failed: $error';

@ -360,6 +360,11 @@ class AppLocalizationsZh extends AppLocalizations {
return '$command: no reply in $seconds s. This radio may not allow remote CLI from you, or is unreachable. Not retried.';
}
@override
String deviceCli_remoteUnsupported(String command) {
return '$command: not sent. Your radio\'s firmware doesn\'t support remote CLI.';
}
@override
String deviceCli_sendFailed(String error) {
return 'Send failed: $error';

@ -412,9 +412,12 @@ class _ChatScreenState extends State<ChatScreen> {
],
),
),
// Remote CLI is a companion feature (#999): repeaters and
// room servers have their own CLI via the repeater hub.
if (widget.contact.isCompanion)
// Remote CLI is a companion feature (#999), and the
// connected radio must speak the 1.18 CLI to send it.
if (DeviceCliScreen.offersRemoteConsole(
contact: widget.contact,
classification: connector.classification,
))
PopupMenuItem(
value: 'cliConsole',
child: Row(

@ -18,6 +18,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import '../connector/device_population.dart';
import '../connector/meshcore_connector.dart';
import '../helpers/device_name_validator.dart';
import '../helpers/snack_bar_builder.dart';
@ -92,6 +93,20 @@ class DeviceCliScreen extends StatefulWidget {
@visibleForTesting
final CliConsoleTransport? transportOverride;
/// Whether to offer the remote console for [contact]. Two conditions, both
/// required: the target is a companion (repeaters and room servers have
/// their own CLI via the repeater hub), and the CONNECTED radio speaks the
/// 1.18 CLI. A pre-1.18 radio refuses to send a type-3 command
/// (companion-v1.17.1 accepts only plain and CLI_DATA in CMD_SEND_TXT_MSG;
/// 1.18.0 adds CLI_COMMAND), so offering the console there would only
/// produce failures. Type-3 send and the local CLI frame shipped together
/// in 1.18, so this reuses the local console's gate. A null classification
/// (disconnected, or not yet classified) offers nothing.
static bool offersRemoteConsole({
required Contact contact,
required Classification? classification,
}) => contact.isCompanion && (classification?.allowsCliFrame ?? false);
@override
State<DeviceCliScreen> createState() => _DeviceCliScreenState();
}
@ -218,6 +233,14 @@ class _DeviceCliScreenState extends State<DeviceCliScreen> {
? context.l10n.deviceCli_remoteNoReply(command, e.secondsText)
: context.l10n.deviceCli_noReply(command, e.secondsText),
);
} on CliConsoleUnsupported {
if (!mounted) return;
// The connected radio refused the send itself (pre-1.18 firmware), so
// nothing went out: say so now instead of waiting out a timeout that
// would blame the target.
entry = _ConsoleEntry.sendFailed(
context.l10n.deviceCli_remoteUnsupported(command),
);
} catch (e) {
if (!mounted) return;
entry = _ConsoleEntry.sendFailed(

@ -37,6 +37,19 @@ class CliConsoleTimeout implements Exception {
String toString() => 'CLI command timed out after $secondsText s';
}
/// The connected radio refused to send a remote CLI command at all: its
/// firmware does not accept TXT_TYPE_CLI_COMMAND (pre-1.18 answers
/// ERR_CODE_UNSUPPORTED_CMD). Distinct from [CliConsoleTimeout], which means
/// the command went out and the target never answered.
class CliConsoleUnsupported implements Exception {
const CliConsoleUnsupported({required this.command});
final String command;
@override
String toString() => 'The connected radio does not support remote CLI';
}
/// One CLI transport for the console: the connected device, or a remote contact.
abstract class CliConsoleTransport {
/// Runs [command] and completes with the correlated reply, or throws
@ -92,8 +105,59 @@ class RemoteCliTransport implements CliConsoleTransport {
StreamSubscription<Uint8List>? _sub;
bool _disposed = false;
/// Rejection channel for the command in flight: completed with
/// [CliConsoleUnsupported] when the radio refuses the send outright.
///
/// It only listens while [_armed]: from the moment the text frame is written
/// (the `onAttempt` hook fires after the path update and runs straight into
/// the frame write, with no yield in between) until the radio answers that
/// write. The firmware answers each CMD_SEND_TXT_MSG at once, in order: a
/// pre-1.18 radio with ERR_CODE_UNSUPPORTED_CMD for type 3; a 1.18 radio with
/// RESP_CODE_SENT carrying an expected-ack of 0, since a CLI command expects
/// no ack (companion-v1.18.0 CMD_SEND_TXT_MSG). A plain DM's SENT carries a
/// real ack hash, so it never closes the window.
///
/// ERR_CODE_UNSUPPORTED_CMD is also the firmware's answer to any unknown
/// command. Arming at the write, rather than at [run], keeps an unrelated
/// refusal from failing a valid command. The residual exposure is one
/// landing inside our own send's round trip, on a radio where the connector
/// already withholds fork frames.
///
/// One command at a time: a new [run] replaces the channel, and the replaced
/// command falls back to its timeout rather than risk misattribution.
Completer<CliReply>? _sendWindow;
String? _sendWindowCommand;
bool _armed = false;
void _onFrame(Uint8List frame) {
if (_disposed || frame.isEmpty) return;
if (frame[0] == respCodeSent) {
// [RESP_CODE_SENT][is_flood][expected_ack x4][est_timeout x4]. Only a
// command send's SENT (ack 0) answers ours.
if (_armed &&
frame.length >= 6 &&
frame[2] == 0 &&
frame[3] == 0 &&
frame[4] == 0 &&
frame[5] == 0) {
_armed = false;
}
return;
}
if (frame[0] == respCodeErr) {
final code = frame.length > 1 ? frame[1] : -1;
final window = _sendWindow;
if (_armed &&
code == errCodeUnsupportedCmd &&
window != null &&
!window.isCompleted) {
_armed = false;
window.completeError(
CliConsoleUnsupported(command: _sendWindowCommand ?? ''),
);
}
return;
}
if (frame[0] != respCodeContactMsgRecv &&
frame[0] != respCodeContactMsgRecvV3) {
return;
@ -134,12 +198,35 @@ class RemoteCliTransport implements CliConsoleTransport {
@override
Future<CliReply> run(String command, {Duration? timeout}) async {
final window = Completer<CliReply>();
_sendWindow = window;
_sendWindowCommand = command;
_armed = false;
try {
// Whichever lands first: the reply (or its timeout), or the radio
// refusing the send. Future.any keeps handlers on the loser, so its later
// timeout is absorbed rather than surfacing as an unhandled error.
return await Future.any([_send(command, window), window.future]);
} finally {
if (identical(_sendWindow, window)) {
_sendWindow = null;
_armed = false;
}
}
}
Future<CliReply> _send(String command, Completer<CliReply> window) async {
// retries: 1 - one send, no auto-retry. See the file header.
try {
final text = await _service.sendCommand(
_resolveTarget(),
command,
retries: 1,
// Fires after the path update, immediately before the text frame is
// written: arm the rejection window here, not earlier.
onAttempt: (_) {
if (identical(_sendWindow, window)) _armed = true;
},
);
// payloadLength drives CliReply.atReplyBound (the local 165-byte device
// bound). A remote reply is a reassembled mesh message, so that bound is
@ -160,6 +247,13 @@ class RemoteCliTransport implements CliConsoleTransport {
_disposed = true;
_sub?.cancel();
_sub = null;
// Release a command still waiting, so its run() cannot hang.
final window = _sendWindow;
_sendWindow = null;
_armed = false;
if (window != null && !window.isCompleted) {
window.completeError(StateError('RemoteCliTransport disposed'));
}
_service.dispose();
}
}

@ -38,6 +38,17 @@ class _TimeoutTransport implements CliConsoleTransport {
void dispose() {}
}
/// The connected radio refuses the send outright (pre-1.18 firmware).
class _UnsupportedTransport implements CliConsoleTransport {
@override
Future<CliReply> run(String command, {Duration? timeout}) async {
throw CliConsoleUnsupported(command: command);
}
@override
void dispose() {}
}
void main() {
late OffbandDatabase db;
late MeshCoreConnector connector;
@ -354,5 +365,37 @@ void main() {
findsOneWidget,
);
});
testWidgets('a refused send says nothing went out, not a timeout (#999)', (
tester,
) async {
await tester.pumpWidget(
ChangeNotifierProvider<MeshCoreConnector>.value(
value: connector,
child: MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: DeviceCliScreen(
remoteContact: companion(),
transportOverride: _UnsupportedTransport(),
),
),
),
);
await tester.pumpAndSettle();
await send(tester, 'get radio');
await tester.pumpAndSettle();
expect(
find.text(
"get radio: not sent. Your radio's firmware doesn't support "
'remote CLI.',
),
findsOneWidget,
);
// Not the #891 row, which would blame the target.
expect(find.textContaining('may not allow remote CLI'), findsNothing);
});
});
}

@ -0,0 +1,75 @@
// #999 reopen: the companion "CLI console" entry is offered only when BOTH the
// target is a companion AND the connected radio speaks the 1.18 CLI. A
// pre-1.18 radio (stock 1.17, or Offband before the absorb) refuses a type-3
// send, so offering the console there only produces failures.
import 'dart:typed_data';
import 'package:flutter_test/flutter_test.dart';
import 'package:meshcore_open/connector/device_population.dart';
import 'package:meshcore_open/connector/meshcore_protocol.dart';
import 'package:meshcore_open/models/contact.dart';
import 'package:meshcore_open/screens/device_cli_screen.dart';
Contact _contact(int type) => Contact(
publicKey: Uint8List.fromList(List<int>.generate(32, (i) => i)),
receivedName: 'X',
type: type,
pathLength: 0,
path: Uint8List(0),
lastSeen: DateTime.fromMillisecondsSinceEpoch(0),
);
Classification _radio(DevicePopulation population) =>
Classification(population: population, conflict: false, evidence: 'test');
void main() {
test('a companion on a 1.18 radio is offered the console', () {
expect(
DeviceCliScreen.offersRemoteConsole(
contact: _contact(advTypeChat),
classification: _radio(DevicePopulation.stockModern),
),
isTrue,
);
});
test('no console when the connected radio is pre-1.18 or Offband', () {
for (final population in [
DevicePopulation.stockLegacy,
DevicePopulation.offband,
]) {
expect(
DeviceCliScreen.offersRemoteConsole(
contact: _contact(advTypeChat),
classification: _radio(population),
),
isFalse,
reason: '$population cannot send a type-3 command',
);
}
});
test('no console when the radio is not classified (disconnected)', () {
expect(
DeviceCliScreen.offersRemoteConsole(
contact: _contact(advTypeChat),
classification: null,
),
isFalse,
);
});
test('no console for a repeater or room server, even on a 1.18 radio', () {
for (final type in [advTypeRepeater, advTypeRoom, advTypeSensor]) {
expect(
DeviceCliScreen.offersRemoteConsole(
contact: _contact(type),
classification: _radio(DevicePopulation.stockModern),
),
isFalse,
reason: 'type $type has its own CLI via the repeater hub',
);
}
});
}

@ -239,6 +239,146 @@ void main() {
});
});
group('fail fast when the connected radio refuses the send (#999)', () {
// A pre-1.18 companion answers CMD_SEND_TXT_MSG carrying type 3 with
// ERR_CODE_UNSUPPORTED_CMD (companion-v1.17.1 MyMesh.cpp). The command
// never went out, so waiting out the mesh timeout would end in a row that
// blames the target.
final errUnsupported = Uint8List.fromList([
respCodeErr,
errCodeUnsupportedCmd,
]);
// [RESP_CODE_SENT][is_flood][expected_ack x4][est timeout x4]. 1.18 sends a
// CLI command with no ack expected, so OUR send's SENT carries ack 0; a
// plain DM's SENT carries a real ack hash.
Uint8List sent(List<int> ack) =>
Uint8List.fromList([respCodeSent, 0, ...ack, 0x10, 0x27, 0, 0]);
final commandSent = sent([0, 0, 0, 0]);
final dmSent = sent([0xDE, 0xAD, 0xBE, 0xEF]);
Future<
({
MeshCoreConnector connector,
Contact companion,
Future<CliReply> run,
String prefix,
RemoteCliTransport transport,
})
>
startRun() async {
final connector = MeshCoreConnector();
final companion = _companion();
final cliSent = Completer<Uint8List>();
connector.sendFrameOverrideForTest = (f) {
if (!cliSent.isCompleted && f.isNotEmpty && f[0] == cmdSendTxtMsg) {
cliSent.complete(f);
}
};
connector.setConnectedForTest();
connector.contactsForTest.add(companion);
final transport = RemoteCliTransport(connector, companion);
final run = transport.run('get radio');
final frame = await cliSent.future;
return (
connector: connector,
companion: companion,
run: run,
prefix: ascii.decode(frame.sublist(13, 16)),
transport: transport,
);
}
test('an unsupported-command error fails the command at once', () async {
final s = await startRun();
s.connector.handleFrameForTest(errUnsupported);
await expectLater(
s.run.timeout(const Duration(seconds: 1)),
throwsA(isA<CliConsoleUnsupported>()),
);
s.transport.dispose();
});
test('a different error code does not fail the command', () async {
final s = await startRun();
s.connector.handleFrameForTest(
Uint8List.fromList([respCodeErr, errCodeNotFound]),
);
s.connector.handleFrameForTest(
_replyFrame(
senderPrefix: s.companion.publicKey,
text: '${s.prefix}radio ok',
),
);
expect((await s.run).text, 'radio ok');
s.transport.dispose();
});
test('an error after the radio accepted the send is not ours', () async {
final s = await startRun();
s.connector.handleFrameForTest(commandSent);
s.connector.handleFrameForTest(errUnsupported);
s.connector.handleFrameForTest(
_replyFrame(
senderPrefix: s.companion.publicKey,
text: '${s.prefix}radio ok',
),
);
expect((await s.run).text, 'radio ok');
s.transport.dispose();
});
test('a DM\'s SENT does not close the window early', () async {
// An earlier in-flight DM's acknowledgement (real ack hash) must not be
// mistaken for ours, or a refusal after it would be missed.
final s = await startRun();
s.connector.handleFrameForTest(dmSent);
s.connector.handleFrameForTest(errUnsupported);
await expectLater(
s.run.timeout(const Duration(seconds: 1)),
throwsA(isA<CliConsoleUnsupported>()),
);
s.transport.dispose();
});
test('an error before the text frame is written is not ours', () async {
// The window arms only at the write. An unrelated refusal that lands
// while the path update is still in progress must not fail the command.
final connector = MeshCoreConnector();
final companion = _companion();
final cliSent = Completer<Uint8List>();
connector.sendFrameOverrideForTest = (f) {
if (!cliSent.isCompleted && f.isNotEmpty && f[0] == cmdSendTxtMsg) {
cliSent.complete(f);
}
};
connector.setConnectedForTest();
connector.contactsForTest.add(companion);
final transport = RemoteCliTransport(connector, companion);
final run = transport.run('get radio');
// run() has yielded inside the path update; nothing is armed yet.
connector.handleFrameForTest(errUnsupported);
final frame = await cliSent.future;
final prefix = ascii.decode(frame.sublist(13, 16));
connector.handleFrameForTest(
_replyFrame(
senderPrefix: companion.publicKey,
text: '${prefix}radio ok',
),
);
expect((await run).text, 'radio ok');
transport.dispose();
});
test('dispose with a command in flight does not hang its run()', () async {
final s = await startRun();
s.transport.dispose();
await expectLater(
s.run.timeout(const Duration(seconds: 1)),
throwsA(isA<StateError>()),
);
});
});
group('LocalCliTransport', () {
test('a local timeout surfaces as CliConsoleTimeout', () async {
final connector = MeshCoreConnector();

@ -17,6 +17,7 @@
"deviceCli_emptyHint",
"deviceCli_noReply",
"deviceCli_remoteNoReply",
"deviceCli_remoteUnsupported",
"deviceCli_sendFailed",
"deviceCli_truncatedByDevice",
"deviceCli_secretLongPressToCopy",
@ -352,6 +353,7 @@
"deviceCli_emptyHint",
"deviceCli_noReply",
"deviceCli_remoteNoReply",
"deviceCli_remoteUnsupported",
"deviceCli_sendFailed",
"deviceCli_truncatedByDevice",
"deviceCli_secretLongPressToCopy",
@ -687,6 +689,7 @@
"deviceCli_emptyHint",
"deviceCli_noReply",
"deviceCli_remoteNoReply",
"deviceCli_remoteUnsupported",
"deviceCli_sendFailed",
"deviceCli_truncatedByDevice",
"deviceCli_secretLongPressToCopy",
@ -1022,6 +1025,7 @@
"deviceCli_emptyHint",
"deviceCli_noReply",
"deviceCli_remoteNoReply",
"deviceCli_remoteUnsupported",
"deviceCli_sendFailed",
"deviceCli_truncatedByDevice",
"deviceCli_secretLongPressToCopy",
@ -1357,6 +1361,7 @@
"deviceCli_emptyHint",
"deviceCli_noReply",
"deviceCli_remoteNoReply",
"deviceCli_remoteUnsupported",
"deviceCli_sendFailed",
"deviceCli_truncatedByDevice",
"deviceCli_secretLongPressToCopy",
@ -1692,6 +1697,7 @@
"deviceCli_emptyHint",
"deviceCli_noReply",
"deviceCli_remoteNoReply",
"deviceCli_remoteUnsupported",
"deviceCli_sendFailed",
"deviceCli_truncatedByDevice",
"deviceCli_secretLongPressToCopy",
@ -2027,6 +2033,7 @@
"deviceCli_emptyHint",
"deviceCli_noReply",
"deviceCli_remoteNoReply",
"deviceCli_remoteUnsupported",
"deviceCli_sendFailed",
"deviceCli_truncatedByDevice",
"deviceCli_secretLongPressToCopy",
@ -2362,6 +2369,7 @@
"deviceCli_emptyHint",
"deviceCli_noReply",
"deviceCli_remoteNoReply",
"deviceCli_remoteUnsupported",
"deviceCli_sendFailed",
"deviceCli_truncatedByDevice",
"deviceCli_secretLongPressToCopy",
@ -2697,6 +2705,7 @@
"deviceCli_emptyHint",
"deviceCli_noReply",
"deviceCli_remoteNoReply",
"deviceCli_remoteUnsupported",
"deviceCli_sendFailed",
"deviceCli_truncatedByDevice",
"deviceCli_secretLongPressToCopy",
@ -3032,6 +3041,7 @@
"deviceCli_emptyHint",
"deviceCli_noReply",
"deviceCli_remoteNoReply",
"deviceCli_remoteUnsupported",
"deviceCli_sendFailed",
"deviceCli_truncatedByDevice",
"deviceCli_secretLongPressToCopy",
@ -3367,6 +3377,7 @@
"deviceCli_emptyHint",
"deviceCli_noReply",
"deviceCli_remoteNoReply",
"deviceCli_remoteUnsupported",
"deviceCli_sendFailed",
"deviceCli_truncatedByDevice",
"deviceCli_secretLongPressToCopy",
@ -3702,6 +3713,7 @@
"deviceCli_emptyHint",
"deviceCli_noReply",
"deviceCli_remoteNoReply",
"deviceCli_remoteUnsupported",
"deviceCli_sendFailed",
"deviceCli_truncatedByDevice",
"deviceCli_secretLongPressToCopy",
@ -4037,6 +4049,7 @@
"deviceCli_emptyHint",
"deviceCli_noReply",
"deviceCli_remoteNoReply",
"deviceCli_remoteUnsupported",
"deviceCli_sendFailed",
"deviceCli_truncatedByDevice",
"deviceCli_secretLongPressToCopy",
@ -4372,6 +4385,7 @@
"deviceCli_emptyHint",
"deviceCli_noReply",
"deviceCli_remoteNoReply",
"deviceCli_remoteUnsupported",
"deviceCli_sendFailed",
"deviceCli_truncatedByDevice",
"deviceCli_secretLongPressToCopy",
@ -4707,6 +4721,7 @@
"deviceCli_emptyHint",
"deviceCli_noReply",
"deviceCli_remoteNoReply",
"deviceCli_remoteUnsupported",
"deviceCli_sendFailed",
"deviceCli_truncatedByDevice",
"deviceCli_secretLongPressToCopy",
@ -5042,6 +5057,7 @@
"deviceCli_emptyHint",
"deviceCli_noReply",
"deviceCli_remoteNoReply",
"deviceCli_remoteUnsupported",
"deviceCli_sendFailed",
"deviceCli_truncatedByDevice",
"deviceCli_secretLongPressToCopy",
@ -5377,6 +5393,7 @@
"deviceCli_emptyHint",
"deviceCli_noReply",
"deviceCli_remoteNoReply",
"deviceCli_remoteUnsupported",
"deviceCli_sendFailed",
"deviceCli_truncatedByDevice",
"deviceCli_secretLongPressToCopy",

Loading…
Cancel
Save

Powered by TurnKey Linux.