mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-23 01:01:06 +10:00
Refactor timeout calculations for repeater and login frames to ensure minimum message size is respected; remove obsolete widget test file.
This commit is contained in:
@@ -261,9 +261,12 @@ class _RepeaterStatusScreenState extends State<RepeaterStatusScreen> {
|
|||||||
await connector.sendFrame(frame);
|
await connector.sendFrame(frame);
|
||||||
|
|
||||||
final pathLengthValue = selection.useFlood ? -1 : selection.hopCount;
|
final pathLengthValue = selection.useFlood ? -1 : selection.hopCount;
|
||||||
final messageBytes = frame.length >= _statusResponseBytes
|
var messageBytes = frame.length >= _statusResponseBytes
|
||||||
? frame.length
|
? frame.length
|
||||||
: _statusResponseBytes;
|
: _statusResponseBytes;
|
||||||
|
if (messageBytes < maxFrameSize) {
|
||||||
|
messageBytes = maxFrameSize;
|
||||||
|
}
|
||||||
final timeoutMs = connector.calculateTimeout(
|
final timeoutMs = connector.calculateTimeout(
|
||||||
pathLength: pathLengthValue,
|
pathLength: pathLengthValue,
|
||||||
messageBytes: messageBytes,
|
messageBytes: messageBytes,
|
||||||
|
|||||||
@@ -121,9 +121,12 @@ class _TelemetryScreenState extends State<TelemetryScreen> {
|
|||||||
await connector.sendFrame(frame);
|
await connector.sendFrame(frame);
|
||||||
|
|
||||||
final pathLengthValue = selection.useFlood ? -1 : selection.hopCount;
|
final pathLengthValue = selection.useFlood ? -1 : selection.hopCount;
|
||||||
final messageBytes = frame.length >= _statusResponseBytes
|
var messageBytes = frame.length >= _statusResponseBytes
|
||||||
? frame.length
|
? frame.length
|
||||||
: _statusResponseBytes;
|
: _statusResponseBytes;
|
||||||
|
if (messageBytes < maxFrameSize) {
|
||||||
|
messageBytes = maxFrameSize;
|
||||||
|
}
|
||||||
final timeoutMs = connector.calculateTimeout(
|
final timeoutMs = connector.calculateTimeout(
|
||||||
pathLength: pathLengthValue,
|
pathLength: pathLengthValue,
|
||||||
messageBytes: messageBytes,
|
messageBytes: messageBytes,
|
||||||
|
|||||||
@@ -70,11 +70,6 @@ class RepeaterCommandService {
|
|||||||
_pendingByPrefix[prefix] = commandId;
|
_pendingByPrefix[prefix] = commandId;
|
||||||
final framedCommand = '$prefix$command';
|
final framedCommand = '$prefix$command';
|
||||||
final pathLengthValue = selection.useFlood ? -1 : selection.hopCount;
|
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;
|
final timestampSeconds = DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
||||||
_connector.trackRepeaterAck(
|
_connector.trackRepeaterAck(
|
||||||
contact: repeater,
|
contact: repeater,
|
||||||
@@ -89,6 +84,12 @@ class RepeaterCommandService {
|
|||||||
attempt: attempt,
|
attempt: attempt,
|
||||||
timestampSeconds: timestampSeconds,
|
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);
|
await _connector.sendFrame(frame);
|
||||||
_commandTimeouts[commandId]?.cancel();
|
_commandTimeouts[commandId]?.cancel();
|
||||||
_commandTimeouts[commandId] = Timer(
|
_commandTimeouts[commandId] = Timer(
|
||||||
|
|||||||
@@ -91,9 +91,12 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
|
|||||||
final selection = await _connector.preparePathForContactSend(repeater);
|
final selection = await _connector.preparePathForContactSend(repeater);
|
||||||
final loginFrame = buildSendLoginFrame(repeater.publicKey, password);
|
final loginFrame = buildSendLoginFrame(repeater.publicKey, password);
|
||||||
final pathLengthValue = selection.useFlood ? -1 : selection.hopCount;
|
final pathLengthValue = selection.useFlood ? -1 : selection.hopCount;
|
||||||
|
final responseBytes = loginFrame.length > maxFrameSize
|
||||||
|
? loginFrame.length
|
||||||
|
: maxFrameSize;
|
||||||
final timeoutMs = _connector.calculateTimeout(
|
final timeoutMs = _connector.calculateTimeout(
|
||||||
pathLength: pathLengthValue,
|
pathLength: pathLengthValue,
|
||||||
messageBytes: loginFrame.length,
|
messageBytes: responseBytes,
|
||||||
);
|
);
|
||||||
final timeoutSeconds = (timeoutMs / 1000).ceil();
|
final timeoutSeconds = (timeoutMs / 1000).ceil();
|
||||||
final timeout = Duration(milliseconds: timeoutMs);
|
final timeout = Duration(milliseconds: timeoutMs);
|
||||||
|
|||||||
@@ -91,9 +91,12 @@ class _RoomLoginDialogState extends State<RoomLoginDialog> {
|
|||||||
final selection = await _connector.preparePathForContactSend(room);
|
final selection = await _connector.preparePathForContactSend(room);
|
||||||
final loginFrame = buildSendLoginFrame(room.publicKey, password);
|
final loginFrame = buildSendLoginFrame(room.publicKey, password);
|
||||||
final pathLengthValue = selection.useFlood ? -1 : selection.hopCount;
|
final pathLengthValue = selection.useFlood ? -1 : selection.hopCount;
|
||||||
|
final responseBytes = loginFrame.length > maxFrameSize
|
||||||
|
? loginFrame.length
|
||||||
|
: maxFrameSize;
|
||||||
final timeoutMs = _connector.calculateTimeout(
|
final timeoutMs = _connector.calculateTimeout(
|
||||||
pathLength: pathLengthValue,
|
pathLength: pathLengthValue,
|
||||||
messageBytes: loginFrame.length,
|
messageBytes: responseBytes,
|
||||||
);
|
);
|
||||||
final timeoutSeconds = (timeoutMs / 1000).ceil();
|
final timeoutSeconds = (timeoutMs / 1000).ceil();
|
||||||
final timeout = Duration(milliseconds: timeoutMs);
|
final timeout = Duration(milliseconds: timeoutMs);
|
||||||
|
|||||||
@@ -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);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user