diff --git a/lib/screens/repeater_status_screen.dart b/lib/screens/repeater_status_screen.dart index 5a3fa75..759a85e 100644 --- a/lib/screens/repeater_status_screen.dart +++ b/lib/screens/repeater_status_screen.dart @@ -261,9 +261,12 @@ class _RepeaterStatusScreenState extends State { await connector.sendFrame(frame); final pathLengthValue = selection.useFlood ? -1 : selection.hopCount; - final messageBytes = frame.length >= _statusResponseBytes + var messageBytes = frame.length >= _statusResponseBytes ? frame.length : _statusResponseBytes; + if (messageBytes < maxFrameSize) { + messageBytes = maxFrameSize; + } final timeoutMs = connector.calculateTimeout( pathLength: pathLengthValue, messageBytes: messageBytes, diff --git a/lib/screens/telemetry_screen.dart b/lib/screens/telemetry_screen.dart index f27410d..9210e3d 100644 --- a/lib/screens/telemetry_screen.dart +++ b/lib/screens/telemetry_screen.dart @@ -121,9 +121,12 @@ class _TelemetryScreenState extends State { await connector.sendFrame(frame); final pathLengthValue = selection.useFlood ? -1 : selection.hopCount; - final messageBytes = frame.length >= _statusResponseBytes + var messageBytes = frame.length >= _statusResponseBytes ? frame.length : _statusResponseBytes; + if (messageBytes < maxFrameSize) { + messageBytes = maxFrameSize; + } final timeoutMs = connector.calculateTimeout( pathLength: pathLengthValue, messageBytes: messageBytes, diff --git a/lib/services/repeater_command_service.dart b/lib/services/repeater_command_service.dart index 97a8a5a..d282bea 100644 --- a/lib/services/repeater_command_service.dart +++ b/lib/services/repeater_command_service.dart @@ -70,11 +70,6 @@ class RepeaterCommandService { _pendingByPrefix[prefix] = commandId; final framedCommand = '$prefix$command'; final pathLengthValue = selection.useFlood ? -1 : selection.hopCount; - final timeoutMs = _connector.calculateTimeout( - pathLength: pathLengthValue, - messageBytes: framedCommand.length, - ); - final timeoutSeconds = (timeoutMs / 1000).ceil(); final timestampSeconds = DateTime.now().millisecondsSinceEpoch ~/ 1000; _connector.trackRepeaterAck( contact: repeater, @@ -89,6 +84,12 @@ class RepeaterCommandService { attempt: attempt, timestampSeconds: timestampSeconds, ); + final responseBytes = frame.length > maxFrameSize ? frame.length : maxFrameSize; + final timeoutMs = _connector.calculateTimeout( + pathLength: pathLengthValue, + messageBytes: responseBytes, + ); + final timeoutSeconds = (timeoutMs / 1000).ceil(); await _connector.sendFrame(frame); _commandTimeouts[commandId]?.cancel(); _commandTimeouts[commandId] = Timer( diff --git a/lib/widgets/repeater_login_dialog.dart b/lib/widgets/repeater_login_dialog.dart index 50ff0e3..2865bce 100644 --- a/lib/widgets/repeater_login_dialog.dart +++ b/lib/widgets/repeater_login_dialog.dart @@ -91,9 +91,12 @@ class _RepeaterLoginDialogState extends State { final selection = await _connector.preparePathForContactSend(repeater); final loginFrame = buildSendLoginFrame(repeater.publicKey, password); final pathLengthValue = selection.useFlood ? -1 : selection.hopCount; + final responseBytes = loginFrame.length > maxFrameSize + ? loginFrame.length + : maxFrameSize; final timeoutMs = _connector.calculateTimeout( pathLength: pathLengthValue, - messageBytes: loginFrame.length, + messageBytes: responseBytes, ); final timeoutSeconds = (timeoutMs / 1000).ceil(); final timeout = Duration(milliseconds: timeoutMs); diff --git a/lib/widgets/room_login_dialog.dart b/lib/widgets/room_login_dialog.dart index dd179f8..838ecf8 100644 --- a/lib/widgets/room_login_dialog.dart +++ b/lib/widgets/room_login_dialog.dart @@ -91,9 +91,12 @@ class _RoomLoginDialogState extends State { final selection = await _connector.preparePathForContactSend(room); final loginFrame = buildSendLoginFrame(room.publicKey, password); final pathLengthValue = selection.useFlood ? -1 : selection.hopCount; + final responseBytes = loginFrame.length > maxFrameSize + ? loginFrame.length + : maxFrameSize; final timeoutMs = _connector.calculateTimeout( pathLength: pathLengthValue, - messageBytes: loginFrame.length, + messageBytes: responseBytes, ); final timeoutSeconds = (timeoutMs / 1000).ceil(); final timeout = Duration(milliseconds: timeoutMs); diff --git a/test/widget_test.dart b/test/widget_test.dart deleted file mode 100644 index ba020e6..0000000 --- a/test/widget_test.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; -import 'package:meshcore_open/main.dart'; - -void main() { - testWidgets('App loads successfully', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(const MeshCoreApp()); - - // Verify that the app title appears - expect(find.text('MeshCore Open'), findsOneWidget); - }); -}